*.bak
bindtests.tmp
capitests/test-command
+capitests/test-config
+capitests/test-create-handle
capitests/test*.img
capitests/tests
capitests/tests.c
# libguestfs
-# Copyright (C) 2009 Red Hat Inc.
+# Copyright (C) 2009-2010 Red Hat Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
EXTRA_DIST = $(BUILT_SOURCES)
-# Tests. These are auto-generated from the test descriptions
-# in the generator.
+check_PROGRAMS = \
+ tests \
+ test-command \
+ test-create-handle \
+ test-config
-check_PROGRAMS = tests test-command
-
-tests_SOURCES = tests.c
-tests_CFLAGS = -I$(top_srcdir)/src -I$(top_builddir)/src \
- $(WARN_CFLAGS) $(WERROR_CFLAGS)
-tests_LDADD = $(top_builddir)/src/libguestfs.la
-
-TESTS = tests
+TESTS = \
+ tests \
+ test-create-handle \
+ test-config
TESTS_ENVIRONMENT = \
SKIP_TEST_COMMAND=$(shell ldd test-command | grep -sq 'not a dynamic executable' || echo 1) \
SKIP_TEST_COMMAND_LINES=$(shell ldd test-command | grep -sq 'not a dynamic executable' || echo 1) \
LIBGUESTFS_PATH=$(top_builddir)/appliance \
$(VG)
-# Run the tests under valgrind.
-
-valgrind:
- $(MAKE) check VG="valgrind --quiet --leak-check=full"
+tests_SOURCES = tests.c
+tests_CFLAGS = -I$(top_srcdir)/src -I$(top_builddir)/src \
+ $(WARN_CFLAGS) $(WERROR_CFLAGS)
+tests_LDADD = $(top_builddir)/src/libguestfs.la
# This binary must be statically linked. It is used for testing
# the "guestfs_command" and "guestfs_command_lines" functions.
test_command_SOURCES = test-command.c
test_command_LDFLAGS = -all-static
+
+# Hand-written C API tests.
+
+test_create_handle_SOURCES = test-create-handle.c
+test_create_handle_CFLAGS = \
+ -I$(top_srcdir)/src -I$(top_builddir)/src \
+ $(WARN_CFLAGS) $(WERROR_CFLAGS)
+test_create_handle_LDADD = \
+ $(top_builddir)/src/libguestfs.la
+
+test_config_SOURCES = test-config.c
+test_config_CFLAGS = \
+ -I$(top_srcdir)/src -I$(top_builddir)/src \
+ $(WARN_CFLAGS) $(WERROR_CFLAGS)
+test_config_LDADD = \
+ $(top_builddir)/src/libguestfs.la
+
+# Run the tests under valgrind.
+
+valgrind:
+ $(MAKE) check VG="valgrind --quiet --leak-check=full"
--- /dev/null
+/* libguestfs
+ * Copyright (C) 2010 Red Hat Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include <config.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#include "guestfs.h"
+
+int
+main (int argc, char *argv[])
+{
+ guestfs_h *g;
+ int r;
+
+ g = guestfs_create ();
+ if (g == NULL) {
+ fprintf (stderr, "failed to create handle\n");
+ exit (EXIT_FAILURE);
+ }
+
+ /* If these fail, the default error handler will print an error
+ * message to stderr, so we don't need to print anything. This code
+ * is very pedantic, but after all we are testing the details of the
+ * C API.
+ */
+
+ if (guestfs_set_verbose (g, 1) == -1)
+ exit (EXIT_FAILURE);
+ r = guestfs_get_verbose (g);
+ if (r == -1)
+ exit (EXIT_FAILURE);
+ if (!r) {
+ fprintf (stderr, "set_verbose not true\n");
+ exit (EXIT_FAILURE);
+ }
+ if (guestfs_set_verbose (g, 0) == -1)
+ exit (EXIT_FAILURE);
+ r = guestfs_get_verbose (g);
+ if (r == -1)
+ exit (EXIT_FAILURE);
+ if (r) {
+ fprintf (stderr, "set_verbose not false\n");
+ exit (EXIT_FAILURE);
+ }
+
+ guestfs_close (g);
+
+ exit (EXIT_SUCCESS);
+}
--- /dev/null
+/* libguestfs
+ * Copyright (C) 2010 Red Hat Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include <config.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#include "guestfs.h"
+
+int
+main (int argc, char *argv[])
+{
+ guestfs_h *g;
+
+ g = guestfs_create ();
+ if (g == NULL) {
+ fprintf (stderr, "failed to create handle\n");
+ exit (EXIT_FAILURE);
+ }
+
+ guestfs_close (g);
+
+ exit (EXIT_SUCCESS);
+}