daemon: debug segv correct use of dereferencing NULL.
[libguestfs.git] / tests / extra / Makefile.am
1 # libguestfs
2 # Copyright (C) 2009-2011 Red Hat Inc.
3 #
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 2 of the License, or
7 # (at your option) any later version.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 # GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17
18 # Extra tests.
19 #
20 # Requires:
21 #   - some local libvirt guests are available
22 #   - the disks of these guests are accessible by the current user
23 #     (tip: add yourself to the 'disk' group)
24 #   - valgrind
25 #   - libtool
26 #
27 # These tests may fail for reasons which aren't necessarily real problems.
28 #
29 # XXX Not tested:
30 #
31 # ../clone/virt-sysprep
32 #   - hard to test because it's a shell script
33 #
34 # ../edit/virt-edit
35 #
36 # Perl bindings
37 # ../edit/virt-edit -e
38 # ../tools/virt-win-reg (Perl)
39 # ../tools/virt-make-fs (Perl)
40 #   - hard because Perl doesn't cooperate by freeing memory
41 #
42 # Python bindings
43 #   - as for Perl
44 #
45 # Ruby bindings
46 #   - these look feasible to test using valgrind
47 #
48 # Java bindings
49 #
50 # ../fuse/guestmount
51 #   - hard to test because guestmount forks into the background, and
52 #     if valgrind reports errors it doesn't stop the test shell script
53
54 EXTRA_DIST = suppressions
55
56 VG = valgrind \
57         --log-file=$(abs_builddir)/valgrind.log \
58         --leak-check=full \
59         --error-exitcode=119 \
60         --suppressions=$(abs_srcdir)/suppressions
61 RUN_VG = $(abs_top_builddir)/run $(VG)
62
63 export LIBVIRT_DEFAULT_URI = \
64         qemu+unix:///system?socket=/var/run/libvirt/libvirt-sock-ro
65
66 GUESTS = $(shell virsh -c $(LIBVIRT_DEFAULT_URI) list --all | \
67                  head -n -1 | \
68                  tail -n +3 | \
69                  awk '{print $$2}')
70
71 extra-tests: \
72         test-guests \
73         test-prerequisites \
74         test-c-api \
75         test-tools-null \
76         test-tools-internal \
77         test-df-real \
78         test-filesystems-real \
79         test-inspector-real \
80         test-ocaml \
81         test-resize \
82         test-sparsify
83
84 test-guests:
85         $(MAKE) -C ../guests check
86
87 test-prerequisites:
88         @libtool --help >/dev/null 2>&1 || { \
89           echo "extra-tests: libtool is not installed"; \
90           exit 1; \
91         }
92         @valgrind --help >/dev/null 2>&1 || { \
93           echo "extra-tests: valgrind is not installed"; \
94           exit 1; \
95         }
96
97 # Null invocations of the basic tools shouldn't leak memory.
98 test-tools-null:
99         $(RUN_VG) ../../fish/guestfish -N part exit
100         $(RUN_VG) ../../align/virt-alignment-scan -a test1.img >/dev/null
101         rm test1.img
102         $(RUN_VG) ../../cat/virt-filesystems -a /dev/null >/dev/null
103         $(RUN_VG) ../../cat/virt-filesystems -a /dev/null --all --long -h --uuid >/dev/null
104         $(RUN_VG) ../../df/virt-df -a /dev/null >/dev/null
105         $(RUN_VG) ../../fish/guestfish -a /dev/null run
106         $(RUN_VG) ../../inspector/virt-inspector -a /dev/null >/dev/null
107         $(RUN_VG) ../../test-tool/libguestfs-test-tool >/dev/null 2>&1
108
109 # Invocations of tools on internal images shouldn't leak memory.
110 test-tools-internal:
111         $(RUN_VG) ../../cat/virt-cat -a ../guests/fedora.img /etc/fstab >/dev/null
112         $(RUN_VG) ../../cat/virt-filesystems -a ../guests/fedora.img >/dev/null
113         $(RUN_VG) ../../cat/virt-filesystems -a ../guests/fedora.img --all --long -h --uuid >/dev/null
114         $(RUN_VG) ../../cat/virt-ls -a ../guests/fedora.img / >/dev/null
115         $(RUN_VG) ../../cat/virt-ls -a ../guests/fedora.img -l / >/dev/null
116         $(RUN_VG) ../../cat/virt-ls -a ../guests/fedora.img -R / >/dev/null
117         $(RUN_VG) ../../cat/virt-ls -a ../guests/fedora.img -lR / >/dev/null
118         $(RUN_VG) ../../df/virt-df -a ../guests/fedora.img >/dev/null
119         $(RUN_VG) ../../df/virt-df -a ../guests/fedora.img -h >/dev/null
120         $(RUN_VG) ../../fish/guestfish -a ../guests/fedora.img run
121         $(RUN_VG) ../../fish/guestfish -a ../guests/fedora.img -i exit
122         $(RUN_VG) ../../inspector/virt-inspector -a ../guests/debian.img >/dev/null
123         $(RUN_VG) ../../inspector/virt-inspector -a ../guests/fedora.img >/dev/null
124         $(RUN_VG) ../../inspector/virt-inspector -a ../guests/fedora-md1.img -a ../guests/fedora-md2.img >/dev/null
125         $(RUN_VG) ../../inspector/virt-inspector -a ../guests/ubuntu.img >/dev/null
126         $(RUN_VG) ../../inspector/virt-inspector -a ../guests/windows.img >/dev/null
127
128 # Invocations of tools on real images shouldn't leak memory.
129 test-df-real:
130         $(RUN_VG) ../../df/virt-df >/dev/null
131         $(RUN_VG) ../../df/virt-df -h >/dev/null
132
133 test-filesystems-real:
134         @for g in $(GUESTS); do \
135           echo $(RUN_VG) ../../cat/virt-filesystems -d $$g --all --long -h --uuid; \
136           $(RUN_VG) ../../cat/virt-filesystems -d $$g --all --long -h --uuid > /dev/null; \
137           r=$$?; \
138           if [ $$r -ne 0 ]; then exit $$r; fi; \
139         done
140
141 test-inspector-real:
142         @for g in $(GUESTS); do \
143           echo $(RUN_VG) ../../inspector/virt-inspector -d $$g; \
144           $(RUN_VG) ../../inspector/virt-inspector -d $$g > /dev/null; \
145           r=$$?; \
146           if [ $$r -ne 0 ]; then exit $$r; fi; \
147         done
148
149 # Run virt-resize tests under valgrind.
150 test-resize:
151         $(MAKE) -C ../../resize VG="$(VG)" check
152
153 # Run virt-sparsify tests under valgrind.
154 test-sparsify:
155         $(MAKE) -C ../../sparsify VG="$(VG)" check
156
157 # Run c-api tests under valgrind.
158 test-c-api:
159         $(MAKE) -C ../c-api VG="$(RUN_VG)" check
160
161 # Test OCaml bindings under valgrind.
162 test-ocaml:
163         $(MAKE) -C ../../ocaml VG="$(VG)" check