From e2206733d1287f5809dbde954f3eb64420471b0d Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Thu, 28 May 2009 13:15:34 +0100 Subject: [PATCH] Move C API tests out of root build dir into 'capitests' subdir. --- .gitignore | 8 ++-- HACKING | 3 ++ Makefile.am | 35 +--------------- capitests/Makefile.am | 49 ++++++++++++++++++++++ .../test-bootbootboot.sh | 0 test-cleanup.sh => capitests/test-cleanup.sh | 0 test-command.c => capitests/test-command.c | 0 tests.c => capitests/tests.c | 5 +-- configure.ac | 1 + src/generator.ml | 7 +--- 10 files changed, 62 insertions(+), 46 deletions(-) create mode 100644 capitests/Makefile.am rename test-bootbootboot.sh => capitests/test-bootbootboot.sh (100%) rename test-cleanup.sh => capitests/test-cleanup.sh (100%) rename test-command.c => capitests/test-command.c (100%) rename tests.c => capitests/tests.c (99%) diff --git a/.gitignore b/.gitignore index a002cab..0d52da3 100644 --- a/.gitignore +++ b/.gitignore @@ -25,6 +25,10 @@ appliance/make-initramfs.sh.in.old appliance/update-initramfs.sh appliance/vmlinuz.* autom4te.cache +capitests/test-command +capitests/test*.img +capitests/test*.tmp +capitests/tests compile config.h config.h.in @@ -91,7 +95,3 @@ ruby/Rakefile ruby/ext/guestfs/extconf.h ruby/ext/guestfs/mkmf.log stamp-h1 -test-command -test*.img -test*.tmp -tests diff --git a/HACKING b/HACKING index 4f88e88..390e4a4 100644 --- a/HACKING +++ b/HACKING @@ -34,6 +34,9 @@ Directories appliance/ The qemu appliance, build scripts and so on. +capitests/ + Automated tests of the C API. + contrib/ Outside contributions, experimental parts. diff --git a/Makefile.am b/Makefile.am index 17adf1c..55b20ba 100644 --- a/Makefile.am +++ b/Makefile.am @@ -17,7 +17,7 @@ ACLOCAL_AMFLAGS = -I m4 -SUBDIRS = src daemon appliance fish po examples images +SUBDIRS = src daemon appliance fish po examples images capitests if HAVE_OCAML SUBDIRS += ocaml @@ -47,7 +47,6 @@ EXTRA_DIST = \ guestfish.pod guestfish-actions.pod \ html/pod.css \ HACKING TODO \ - tests.c \ libguestfs.pc libguestfs.pc.in \ gitlog-to-changelog \ recipes/LICENSE \ @@ -57,40 +56,10 @@ EXTRA_DIST = \ recipes/*.example \ html/recipes.css \ make-recipes.sh \ - test-cleanup.sh \ contrib/README \ contrib/febootstrap/install.title \ contrib/febootstrap/install.html \ - contrib/febootstrap/install.sh \ - test-bootbootboot.sh - -# Tests. These are auto-generated from the test descriptions -# in the generator. - -check_PROGRAMS = tests test-command - -tests_SOURCES = tests.c -tests_CFLAGS = \ - -I$(top_builddir)/src -Wall -tests_LDADD = $(top_builddir)/src/libguestfs.la - -TESTS = tests test-bootbootboot.sh -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) \ - SKIP_TEST_ZEROFREE=$(shell test -x initramfs/usr/sbin/zerofree || echo 1) \ - $(VG) - -# Run the tests under valgrind. - -valgrind: - $(MAKE) check VG="valgrind --quiet --leak-check=full" - -# 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 + contrib/febootstrap/install.sh # Manual pages. # guestfs-actions.pod and guestfs-structs are autogenerated. There is diff --git a/capitests/Makefile.am b/capitests/Makefile.am new file mode 100644 index 0000000..f061243 --- /dev/null +++ b/capitests/Makefile.am @@ -0,0 +1,49 @@ +# libguestfs +# Copyright (C) 2009 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., 675 Mass Ave, Cambridge, MA 02139, USA. + +EXTRA_DIST = \ + tests.c \ + test-cleanup.sh \ + test-bootbootboot.sh + +# Tests. These are auto-generated from the test descriptions +# in the generator. + +check_PROGRAMS = tests test-command + +tests_SOURCES = tests.c +tests_CFLAGS = \ + -I$(top_builddir)/src -Wall +tests_LDADD = $(top_builddir)/src/libguestfs.la + +TESTS = tests test-bootbootboot.sh +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) \ + SKIP_TEST_ZEROFREE=$(shell test -x ../initramfs/usr/sbin/zerofree || echo 1) \ + $(VG) + +# Run the tests under valgrind. + +valgrind: + $(MAKE) check VG="valgrind --quiet --leak-check=full" + +# 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 diff --git a/test-bootbootboot.sh b/capitests/test-bootbootboot.sh similarity index 100% rename from test-bootbootboot.sh rename to capitests/test-bootbootboot.sh diff --git a/test-cleanup.sh b/capitests/test-cleanup.sh similarity index 100% rename from test-cleanup.sh rename to capitests/test-cleanup.sh diff --git a/test-command.c b/capitests/test-command.c similarity index 100% rename from test-command.c rename to capitests/test-command.c diff --git a/tests.c b/capitests/tests.c similarity index 99% rename from tests.c rename to capitests/tests.c index 11bd2a5..5d94598 100644 --- a/tests.c +++ b/capitests/tests.c @@ -15699,10 +15699,7 @@ int main (int argc, char *argv[]) guestfs_set_error_handler (g, print_error, NULL); - srcdir = getenv ("srcdir"); - if (!srcdir) srcdir = "."; - chdir (srcdir); - guestfs_set_path (g, "appliance"); + guestfs_set_path (g, "../appliance"); filename = "test1.img"; fd = open (filename, O_WRONLY|O_CREAT|O_NOCTTY|O_NONBLOCK|O_TRUNC, 0666); diff --git a/configure.ac b/configure.ac index d40464d..2d91872 100644 --- a/configure.ac +++ b/configure.ac @@ -449,6 +449,7 @@ AC_CONFIG_FILES([Makefile appliance/Makefile appliance/make-initramfs.sh appliance/update-initramfs.sh images/Makefile + capitests/Makefile ocaml/Makefile ocaml/examples/Makefile perl/Makefile python/Makefile diff --git a/src/generator.ml b/src/generator.ml index 03439aa..6741541 100755 --- a/src/generator.ml +++ b/src/generator.ml @@ -3717,10 +3717,7 @@ int main (int argc, char *argv[]) guestfs_set_error_handler (g, print_error, NULL); - srcdir = getenv (\"srcdir\"); - if (!srcdir) srcdir = \".\"; - chdir (srcdir); - guestfs_set_path (g, \"appliance\"); + guestfs_set_path (g, \"../appliance\"); filename = \"test1.img\"; fd = open (filename, O_WRONLY|O_CREAT|O_NOCTTY|O_NONBLOCK|O_TRUNC, 0666); @@ -7182,7 +7179,7 @@ Run it from the top source directory using the command generate_daemon_actions (); close (); - let close = output_to "tests.c" in + let close = output_to "capitests/tests.c" in generate_tests (); close (); -- 1.8.3.1