summaryrefslogtreecommitdiffstats
path: root/tests/extra/Makefile.am
blob: e54584781dfe0301c3fc76b6837fb1cd9c9d7e25 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
# libguestfs
# Copyright (C) 2009-2012 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.

# Extra tests.
#
# Requires:
#   - some local libvirt guests are available
#   - the disks of these guests are accessible by the current user
#     (tip: add yourself to the 'disk' group)
#   - valgrind
#   - libtool
# Optional:
#   - upstream qemu in $QEMUDIR
#   - upstream libvirt in $LIBVIRTDIR
#
# These tests may fail for reasons which aren't necessarily real problems.
#
# XXX Not tested:
#
# ../edit/virt-edit
#
# Perl bindings
# ../edit/virt-edit -e
# ../tools/virt-win-reg (Perl)
# ../tools/virt-make-fs (Perl)
#   - hard because Perl doesn't cooperate by freeing memory
#
# Python bindings
#   - as for Perl
#
# Ruby bindings
#   - these look feasible to test using valgrind
#
# Java bindings
#
# ../fuse/guestmount
#   - hard to test because guestmount forks into the background, and
#     if valgrind reports errors it doesn't stop the test shell script

# Old RHEL 5 autoconf doesn't have abs_srcdir.
abs_srcdir ?= $(shell cd $(top_srcdir)/tests/extra && pwd)

# Old RHEL 5 autoconf doesn't have abs_builddir.
abs_builddir ?= $(shell pwd)

EXTRA_DIST = \
	pick-guests.pl \
	test-with-launch-appliance.sh \
	test-with-upstream-libvirt.sh \
	test-with-upstream-qemu.sh

VG = @VG@
RUN_VG = $(abs_top_builddir)/run $(VG)

libvirt_uri = qemu+unix:///system?socket=/var/run/libvirt/libvirt-sock-ro

# Choose guests at random on each run.
random_guests := \
	$(shell \
	  LIBVIRT_DEFAULT_URI="$(libvirt_uri)" \
	    $(abs_top_builddir)/run $(srcdir)/pick-guests.pl 5)

extra-tests-non-recursive: \
	test-guests \
	test-prerequisites \
	test-c-api \
	test-tools-null \
	test-tools-internal \
	test-df-real \
	test-filesystems-real \
	test-inspector-real \
	test-sysprep-real \
	test-ocaml \
	test-resize \
	test-sparsify \
	test-mount-local

extra-tests: \
	extra-tests-non-recursive \
	extra-tests-with-upstream-qemu \
	extra-tests-with-upstream-libvirt \
	extra-tests-with-launch-appliance

test-guests:
	$(MAKE) -C ../guests check

test-prerequisites:
	@libtool --help >/dev/null 2>&1 || { \
	  echo "extra-tests: libtool is not installed"; \
	  exit 1; \
	}
	@valgrind --help >/dev/null 2>&1 || { \
	  echo "extra-tests: valgrind is not installed"; \
	  exit 1; \
	}

# Null invocations of the basic tools shouldn't leak memory.
test-tools-null:
	$(RUN_VG) ../../fish/guestfish -N part exit
	$(RUN_VG) ../../align/virt-alignment-scan -a test1.img >/dev/null
	$(RUN_VG) ../../format/virt-format -a test1.img >/dev/null
	rm test1.img
	$(RUN_VG) ../../cat/virt-filesystems -a /dev/null >/dev/null
	$(RUN_VG) ../../cat/virt-filesystems -a /dev/null --all --long -h --uuid >/dev/null
	$(RUN_VG) ../../df/virt-df -a /dev/null >/dev/null
	$(RUN_VG) ../../fish/guestfish -a /dev/null run
	$(RUN_VG) ../../inspector/virt-inspector -a /dev/null >/dev/null
	$(RUN_VG) ../../test-tool/libguestfs-test-tool >/dev/null 2>&1

# Invocations of tools on internal images shouldn't leak memory.
test-tools-internal:
	$(RUN_VG) ../../cat/virt-cat -a ../guests/fedora.img /etc/fstab >/dev/null
	$(RUN_VG) ../../cat/virt-filesystems -a ../guests/fedora.img >/dev/null
	$(RUN_VG) ../../cat/virt-filesystems -a ../guests/fedora.img --all --long -h --uuid >/dev/null
	$(RUN_VG) ../../cat/virt-ls -a ../guests/fedora.img / >/dev/null
	$(RUN_VG) ../../cat/virt-ls -a ../guests/fedora.img -l / >/dev/null
	$(RUN_VG) ../../cat/virt-ls -a ../guests/fedora.img -R / >/dev/null
	$(RUN_VG) ../../cat/virt-ls -a ../guests/fedora.img -lR / >/dev/null
	$(RUN_VG) ../../df/virt-df -a ../guests/fedora.img >/dev/null
	$(RUN_VG) ../../df/virt-df -a ../guests/fedora.img -h >/dev/null
	$(RUN_VG) ../../fish/guestfish -a ../guests/fedora.img run
	$(RUN_VG) ../../fish/guestfish -a ../guests/fedora.img -i exit
	$(RUN_VG) ../../inspector/virt-inspector -a ../guests/debian.img >/dev/null
	$(RUN_VG) ../../inspector/virt-inspector -a ../guests/fedora.img >/dev/null
	$(RUN_VG) ../../inspector/virt-inspector -a ../guests/fedora-md1.img -a ../guests/fedora-md2.img >/dev/null
	$(RUN_VG) ../../inspector/virt-inspector -a ../guests/ubuntu.img >/dev/null
	$(RUN_VG) ../../inspector/virt-inspector -a ../guests/windows.img >/dev/null
	$(RUN_VG) ../../sysprep/virt-sysprep -n -a ../guests/debian.img
	$(RUN_VG) ../../sysprep/virt-sysprep -n -a ../guests/fedora.img
	$(RUN_VG) ../../sysprep/virt-sysprep -n -a ../guests/fedora-md1.img -a ../guests/fedora-md2.img
	$(RUN_VG) ../../sysprep/virt-sysprep -n -a ../guests/ubuntu.img
	$(RUN_VG) ../../sysprep/virt-sysprep -n -a ../guests/windows.img

# Invocations of tools on real images shouldn't leak memory.
test-df-real:
	$(RUN_VG) ../../df/virt-df -c "$(libvirt_uri)" >/dev/null
	$(RUN_VG) ../../df/virt-df -c "$(libvirt_uri)" -h >/dev/null

test-filesystems-real:
	@for g in $(random_guests); do \
	  echo $(RUN_VG) ../../cat/virt-filesystems -c "$(libvirt_uri)" -d $$g --all --long -h --uuid; \
	  $(RUN_VG) ../../cat/virt-filesystems -c "$(libvirt_uri)" -d $$g --all --long -h --uuid > /dev/null; \
	  r=$$?; \
	  if [ $$r -ne 0 ]; then exit $$r; fi; \
	done

test-inspector-real:
	@for g in $(random_guests); do \
	  echo $(RUN_VG) ../../inspector/virt-inspector -c "$(libvirt_uri)" -d $$g; \
	  $(RUN_VG) ../../inspector/virt-inspector -c "$(libvirt_uri)" -d $$g > /dev/null; \
	  r=$$?; \
	  if [ $$r -ne 0 ]; then exit $$r; fi; \
	done

test-sysprep-real:
	@for g in $(random_guests); do \
	  echo $(RUN_VG) ../../sysprep/virt-sysprep -n -c "$(libvirt_uri)" -d $$g; \
	  $(RUN_VG) ../../sysprep/virt-sysprep -n -c "$(libvirt_uri)" -d $$g > /dev/null; \
	  r=$$?; \
	  if [ $$r -ne 0 ]; then exit $$r; fi; \
	done

# Run virt-resize tests under valgrind.
test-resize:
	$(MAKE) -C ../../resize VG="$(VG)" check

# Run virt-sparsify tests under valgrind.
test-sparsify:
	$(MAKE) -C ../../sparsify VG="$(VG)" check

# Run c-api tests under valgrind.
test-c-api:
	$(MAKE) -C ../c-api VG="$(RUN_VG)" check

# Run parallel mount-local test under valgrind.
test-mount-local:
	$(MAKE) -C ../mount-local VG="$(VG)" check

# Test OCaml bindings under valgrind.
test-ocaml:
	$(MAKE) -C ../../ocaml VG="$(VG)" check

# When running the extra tests, if directory $QEMUDIR exists then we
# will rerun all the extra-tests using the version of qemu from that
# directory.  eg. That might be qemu from git.
#
# The directory name can be overridden using:
#   make extra-tests QEMUDIR=/path/to/other/qemu

QEMUDIR = $(HOME)/d/qemu
export QEMUDIR
export abs_srcdir
export MAKE

extra-tests-with-upstream-qemu:
	./test-with-upstream-qemu.sh

# When running the extra tests and ./configure
# --with-default-attach-method=libvirt, if directory $LIBVIRTDIR
# exists, we will rerun all the extra-tests using the version of
# libvirt in that directory.  eg. That might be upstream libvirt from
# git.
#
# The directory name can be overridden using:
#   make extra-tests LIBVIRTDIR=/path/to/other/libvirt

LIBVIRTDIR = $(HOME)/d/libvirt
export LIBVIRTDIR

extra-tests-with-upstream-libvirt:
	./test-with-upstream-libvirt.sh

# If libvirt is being used as the backend, rerun all the extra-tests
# again using the regular appliance backend.

extra-tests-with-launch-appliance:
	./test-with-launch-appliance.sh