qemu-test: add support for named choices
[qemu-test.git] / tests / finger-print.sh
1 #!/bin/sh
2
3 in_host() {
4 machine=`choose pc-0.13 pc-0.14 pc-0.15 pc-1.0`
5
6 tmpdisk=$tmpdir/disk-$$.img
7 qemu-img create -f raw $tmpdisk 10G
8
9 # N.B. If you change this invocation line, please update all of the files
10 # stored in fingerprints/
11 echo "Using machine: $machine"
12 if test "$QEMU_TEST_GEN_FINGERPRINT" = "yes"; then
13 machine="pc"
14 fi
15 qemu -nographic -enable-kvm -hda $tmpdisk -M $machine \
16 -drive file=$tmpdisk,if=virtio,snapshot=on \
17 -device virtio-balloon-pci \
18 -device virtio-serial \
19 -net nic,model=virtio -net user
20 rc=$?
21
22 if test $rc = 0; then
23 # this should create one file named fingerprint.txt
24 tar xf $tmpdisk
25 if test -e fingerprint.txt -a \
26 "$QEMU_TEST_GEN_FINGERPRINT" != "yes"; then
27 diff -u fingerprints/$machine.x86_64 fingerprint.txt
28 rc=$?
29 if test $rc != 0; then
30 echo "Guest fingerprint changed for $machine!"
31 fi
32 else
33 rc=1
34 fi
35 fi
36
37 rm -f $tmpdisk
38 if test "$QEMU_TEST_GEN_FINGERPRINT" != "yes"; then
39 rm -f fingerprint.txt
40 fi
41
42 return $rc
43 }
44
45 in_guest() {
46 fingerprint > fingerprint.txt
47 tar cf /dev/sda fingerprint.txt
48 }
49
50 if test $QEMU_TEST; then
51 in_host
52 else
53 in_guest
54 fi