You need to sign in or sign up before continuing.
virt-aa-helper-test 17.5 KB
Newer Older
J
Jamie Strandboge 已提交
1
#!/bin/sh
2 3 4 5 6 7
#
# virt-aa-helper needs a working locale system. If testing this in a chroot
# system, need to make sure these are setup properly. On Debian-based systems
# this can be done with something like (as root):
#  locale-gen en_US.UTF-8

J
Jamie Strandboge 已提交
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
set -e

test_hostdev="no"
if [ "$1" = "test_hostdev" ]; then
    test_hostdev="yes"
    shift
fi

output="/dev/null"
use_valgrind=""
ld_library_path="../src/.libs/"
if [ ! -z "$1" ] && [ "$1" = "-d" ]; then
    output="/dev/stdout"
    shift
fi

exe="../src/virt-aa-helper"
if [ ! -z "$1" ]; then
    if [ "$1" = "-v" ]; then
        use_valgrind="yes"
        shift
    fi
    if [ -n "$1" ]; then
        exe="$1"
        shift
    fi
fi

if [ ! -x "$exe" ]; then
    echo "Could not find '$exe'"
    exit 1
fi

echo "testing `basename $exe`" >$output
if [ "$use_valgrind" = "yes" ]; then
    exe="valgrind --error-exitcode=2 --track-origins=yes $exe"
fi

extra_args="--dryrun"
errors=0

tmpdir=`mktemp -d`
trap "rm -rf $tmpdir" EXIT HUP INT QUIT TERM

template_xml="$tmpdir/template.xml"
test_xml="$tmpdir/test.xml"

uuid="00000000-0000-0000-0000-0123456789ab"
disk1="$tmpdir/1.img"
disk2="$tmpdir/2.img"
relative_disk1="$tmpdir/./../`basename $tmpdir`//./1.img"
N
Nehal J Wani 已提交
59
nonexistent="$tmpdir/nonexistent.img"
J
Jamie Strandboge 已提交
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
bad_disk="/etc/passwd"
valid_uuid="libvirt-$uuid"
nonexistent_uuid="libvirt-00000000-0000-0000-0000-000000000001"

cat > "$template_xml" <<EOM
<domain type='kvm'>
  <name>virt-aa-helper-test</name>
  <uuid>###UUID###</uuid>
  <memory>524288</memory>
  <currentMemory>524288</currentMemory>
  <vcpu>1</vcpu>
  <os>
    <type arch='x86_64' machine='pc'>hvm</type>
    <boot dev='hd'/>
  </os>
  <features>
    <acpi/>
  </features>
  <clock offset='utc'/>
  <on_poweroff>destroy</on_poweroff>
  <on_reboot>restart</on_reboot>
  <on_crash>destroy</on_crash>
  <devices>
83
    <emulator>/usr/bin/qemu-system-x86_64</emulator>
J
Jamie Strandboge 已提交
84
    <disk type='file' device='disk'>
85
      <driver name='qemu' type='raw'/>
J
Jamie Strandboge 已提交
86 87 88 89 90 91 92 93 94 95 96 97
      <source file='###DISK###'/>
      <target dev='hda' bus='ide'/>
    </disk>
    <interface type='network'>
      <mac address='52:54:00:50:4b:26'/>
      <source network='default'/>
      <model type='virtio'/>
    </interface>
    <input type='tablet' bus='usb'/>
    <input type='mouse' bus='ps2'/>
    <graphics type='vnc' port='-1' autoport='yes' listen='127.0.0.1'/>
    <video>
98
      <model type='cirrus' vram='16384' heads='1'/>
J
Jamie Strandboge 已提交
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121
    </video>
  </devices>
</domain>
EOM

touch "$disk1" "$disk2"

testme() {
    expected="$1"
    outstr="$2"
    args="$3"
    input=""

    if [ -n "$4" ]; then
        input="$4"
        if [ ! -e "$input" ]; then
            echo "FAIL: could not find $input" >$output
            echo "FAIL: could not find $input"
            echo " '$extra_args $args': "
            errors=$(($errors + 1))
        fi
    fi

122 123
    printf %s "  $outstr: " >$output
    printf %s " '$extra_args $args" >$output
J
Jamie Strandboge 已提交
124
    if [ -n "$input" ]; then
125
        printf %s " < $input" >$output
J
Jamie Strandboge 已提交
126 127 128 129 130 131 132 133 134 135 136 137 138 139 140
    fi
    echo "': " >$output
    set +e
    if [ -n "$input" ]; then
        LD_LIBRARY_PATH="$ld_library_path" $exe $extra_args $args < $input >$output 2>&1
    else
        LD_LIBRARY_PATH="$ld_library_path" $exe $extra_args $args >$output 2>&1
    fi
    rc="$?"
    set -e
    if [ "$rc" = "$expected" ]; then
        echo "pass" >$output
    else
        echo "FAIL: exited with '$rc'" >$output
        echo "FAIL: exited with '$rc'"
141
        printf %s "  $outstr: "
J
Jamie Strandboge 已提交
142 143 144 145 146 147
        echo " '$extra_args $args': "
        errors=$(($errors + 1))
        #exit $rc
    fi
}

148 149 150 151 152 153 154 155 156 157 158 159 160 161
testfw() {
    title="$1"
    fwpath="$2"

    if [ -f "$fwpath" ]; then
        sed -e "s,###UUID###,$uuid,g"  \
            -e "s,###DISK###,$disk1,g" \
            -e "s,</os>,<loader readonly='yes' type='pflash'>$fwpath</loader></os>,g" "$template_xml" > "$test_xml"
        testme "0" "$title" "-r -u $valid_uuid" "$test_xml"
    else
        echo "Skipping FW $title test. Could not find $fwpath"
    fi
}

J
Jamie Strandboge 已提交
162 163 164 165 166
# Expected failures
echo "Expected failures:" >$output
testme "1" "invalid arg" "-z"
testme "1" "invalid case" "-A"
testme "1" "not enough args" "-c"
167
testme "1" "not enough args" "-p"
J
Jamie Strandboge 已提交
168

J
Jamie Strandboge 已提交
169
sed -e "s,###UUID###,$uuid,g" -e "s,###DISK###,$disk1,g" "$template_xml" > "$test_xml"
J
Jamie Strandboge 已提交
170 171 172 173 174 175 176 177 178 179 180
testme "1" "no -u with -c" "-c" "$test_xml"
testme "1" "bad uuid (bad digit)" "-c -u libvirt-00000000-0000-0000-0000-00000000000g" "$test_xml"
testme "1" "bad uuid (too long)" "-c -u ${valid_uuid}abcdef" "$test_xml"
testme "1" "bad uuid (too short)" "-c -u libvirt-00000000-0000-0000-0000-0123456789a" "$test_xml"
testme "1" "non-matching uuid" "-c -u libvirt-00000000-0000-0000-0000-00000000000a" "$test_xml"
testme "1" "missing uuid" "-c -u" "$test_xml"
testme "1" "no -u with -R" "-R"
testme "1" "non-existent uuid" "-R -u $nonexistent_uuid"
testme "1" "no -u with -r" "-r"
testme "1" "old '-n' option" "-c -n foo -u $valid_uuid" "$test_xml"

J
Jamie Strandboge 已提交
181
sed -e "s,###UUID###,$uuid,g" -e "s,###DISK###,$bad_disk,g" "$template_xml" > "$test_xml"
J
Jamie Strandboge 已提交
182 183
testme "1" "bad disk" "-c -u $valid_uuid" "$test_xml"

J
Jamie Strandboge 已提交
184
sed -e "s,###UUID###,$uuid,g" -e "s,###DISK###,$bad_disk,g" -e "s,</devices>,<disk type='file' device='disk'><driver name='qemu' type='raw'/><source file='$disk2'/><target dev='hda' bus='ide'/></disk></devices>,g" "$template_xml" > "$test_xml"
J
Jamie Strandboge 已提交
185 186
testme "1" "bad disk2" "-c -u $valid_uuid" "$test_xml"

J
Jamie Strandboge 已提交
187
sed -e "s,###UUID###,$uuid,g" -e "s,###DISK###,$disk1,g" -e "s,</devices>,<devices>,g" "$template_xml" > "$test_xml"
J
Jamie Strandboge 已提交
188 189
testme "1" "malformed xml" "-c -u $valid_uuid" "$test_xml"

190 191 192 193
initrd=`ls -1 /boot/initrd* | head -1`
if [ -z "$initrd" ]; then
    echo "Skipping /boot/initrd* tests. Could not find /boot/initrd*"
else
J
Jamie Strandboge 已提交
194
    sed -e "s,###UUID###,$uuid,g" -e "s,###DISK###,$initrd,g" "$template_xml" > "$test_xml"
195 196 197
    testme "1" "disk in /boot without probing" "-p 0 -r -u $valid_uuid" "$test_xml"
    testme "1" "disk in /boot with probing" "-p 1 -r -u $valid_uuid" "$test_xml"

J
Jamie Strandboge 已提交
198
    sed -e "s,###UUID###,$uuid,g" -e "s,###DISK###,/boot/initrd,g" "$template_xml" > "$test_xml"
199 200
    testme "1" "-r with invalid -f with probing" "-p 1 -r -u $valid_uuid -f $bad_disk" "$test_xml"
    testme "1" "-r with invalid -f without probing" "-p 0 -r -u $valid_uuid -f $bad_disk" "$test_xml"
201 202
    testme "1" "-r with invalid -F with probing" "-p 1 -r -u $valid_uuid -F $bad_disk" "$test_xml"
    testme "1" "-r with invalid -F without probing" "-p 0 -r -u $valid_uuid -F $bad_disk" "$test_xml"
203
fi
J
Jamie Strandboge 已提交
204

J
Jamie Strandboge 已提交
205
sed -e "s,###UUID###,$uuid,g" -e "s,###DISK###,$disk1</disk>,g" "$template_xml" > "$test_xml"
206 207
testme "1" "-c with malformed xml" "-c -u $valid_uuid" "$test_xml"

J
Jamie Strandboge 已提交
208
sed -e "s,###UUID###,$uuid,g" -e "s,###DISK###,$disk1,g" -e "s,<type arch='x86_64' machine='pc'>hvm</type>,,g" "$template_xml" > "$test_xml"
209 210
testme "1" "-c with no os.type" "-c -u $valid_uuid" "$test_xml"

J
Jamie Strandboge 已提交
211
sed -e "s,###UUID###,$uuid,g" -e "s,###DISK###,$disk1,g" -e "s,hvm</type>,hvm_invalid</type>,g" "$template_xml" > "$test_xml"
212 213
testme "1" "-c with invalid hvm" "-c -u $valid_uuid" "$test_xml"

214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233
sed -e "s,###UUID###,$uuid,g" -e "s,###DISK###,$disk1,g" -e "s,virt-aa-helper-test,virt-aa-helper-test-/,g" "$template_xml" > "$test_xml"
testme "1" "-c with invalid domain name char /" "-c -u $valid_uuid" "$test_xml"
sed -e "s,###UUID###,$uuid,g" -e "s,###DISK###,$disk1,g" -e "s,virt-aa-helper-test,virt-aa-helper-test-[,g" "$template_xml" > "$test_xml"
testme "1" "-c with invalid domain name char [" "-c -u $valid_uuid" "$test_xml"
sed -e "s,###UUID###,$uuid,g" -e "s,###DISK###,$disk1,g" -e "s,virt-aa-helper-test,virt-aa-helper-test-],g" "$template_xml" > "$test_xml"
testme "1" "-c with invalid domain name char ]" "-c -u $valid_uuid" "$test_xml"
sed -e "s,###UUID###,$uuid,g" -e "s,###DISK###,$disk1,g" -e "s,virt-aa-helper-test,virt-aa-helper-test-{,g" "$template_xml" > "$test_xml"
testme "1" "-c with invalid domain name char {" "-c -u $valid_uuid" "$test_xml"
sed -e "s,###UUID###,$uuid,g" -e "s,###DISK###,$disk1,g" -e "s,virt-aa-helper-test,virt-aa-helper-test-},g" "$template_xml" > "$test_xml"
testme "1" "-c with invalid domain name char }" "-c -u $valid_uuid" "$test_xml"
sed -e "s,###UUID###,$uuid,g" -e "s,###DISK###,$disk1,g" -e "s,virt-aa-helper-test,virt-aa-helper-test-?,g" "$template_xml" > "$test_xml"
testme "1" "-c with invalid domain name char ?" "-c -u $valid_uuid" "$test_xml"
sed -e "s,###UUID###,$uuid,g" -e "s,###DISK###,$disk1,g" -e "s,virt-aa-helper-test,virt-aa-helper-test-^,g" "$template_xml" > "$test_xml"
testme "1" "-c with invalid domain name char ^" "-c -u $valid_uuid" "$test_xml"
sed -e "s,###UUID###,$uuid,g" -e "s,###DISK###,$disk1,g" -e "s,virt-aa-helper-test,virt-aa-helper-test-\,,g" "$template_xml" > "$test_xml"
testme "1" "-c with invalid domain name char ," "-c -u $valid_uuid" "$test_xml"
sed -e "s,###UUID###,$uuid,g" -e "s,###DISK###,$disk1,g" -e "s,virt-aa-helper-test,virt-aa-helper-test-\",g" "$template_xml" > "$test_xml"
testme "1" "-c with invalid domain name char \"" "-c -u $valid_uuid" "$test_xml"
sed -e "s,###UUID###,$uuid,g" -e "s,###DISK###,$disk1,g" -e "s,virt-aa-helper-test,virt-aa-helper-test-*,g" "$template_xml" > "$test_xml"
testme "1" "-c with invalid domain name char *" "-c -u $valid_uuid" "$test_xml"
J
Jamie Strandboge 已提交
234 235

echo "Expected pass:" >$output
J
Jamie Strandboge 已提交
236
sed -e "s,###UUID###,$uuid,g" -e "s,###DISK###,$disk1,g" "$template_xml" > "$test_xml"
237 238
testme "0" "create (x86_64)" "-c -u $valid_uuid" "$test_xml"

J
Jamie Strandboge 已提交
239
sed -e "s,###UUID###,$uuid,g" -e "s,###DISK###,$disk1,g" -e "s,arch='x86_64',arch='i686',g" "$template_xml" > "$test_xml"
240 241
testme "0" "create (i686)" "-c -u $valid_uuid" "$test_xml"

J
Jamie Strandboge 已提交
242
sed -e "s,###UUID###,$uuid,g" -e "s,###DISK###,$disk1,g" -e "s,arch='x86_64',arch='ppc',g" "$template_xml" > "$test_xml"
243
testme "0" "create (ppc)" "-c -u $valid_uuid" "$test_xml"
J
Jamie Strandboge 已提交
244

J
Jamie Strandboge 已提交
245
sed -e "s,###UUID###,$uuid,g" -e "s,###DISK###,$disk1,g" -e "s,</disk>,</disk><disk type='file' device='disk'><driver name='qemu' type='raw'/><source file='$disk2'/><target dev='hdb' bus='ide'/></disk>,g" "$template_xml" > "$test_xml"
246
testme "0" "create multiple disks" "-c -u $valid_uuid" "$test_xml"
J
Jamie Strandboge 已提交
247

J
Jamie Strandboge 已提交
248
sed -e "s,###UUID###,$uuid,g" -e "s,###DISK###',${disk1}'/><readonly,g" "$template_xml" > "$test_xml"
J
Jamie Strandboge 已提交
249 250 251
testme "0" "create (readonly)" "-c -u $valid_uuid" "$test_xml"

if [ "$test_hostdev" = "yes" ]; then
J
Jamie Strandboge 已提交
252
    sed -e "s,###UUID###,$uuid,g" -e "s,###DISK###,$disk1,g" -e "s,</disk>,</disk><hostdev mode='subsystem' type='usb'><source><address bus='002' device='004'/></source></hostdev>,g" "$template_xml" > "$test_xml"
J
Jamie Strandboge 已提交
253 254
    testme "0" "create hostdev (USB)" "-c -u $valid_uuid" "$test_xml"

J
Jamie Strandboge 已提交
255
    sed -e "s,###UUID###,$uuid,g" -e "s,###DISK###,$disk1,g" -e "s,</disk>,</disk><hostdev mode='subsystem' type='pci'><source><address bus='0x00' slot='0x19' function='0x0'/></source></hostdev>,g" "$template_xml" > "$test_xml"
J
Jamie Strandboge 已提交
256 257 258
    testme "0" "create hostdev (PCI)" "-c -u $valid_uuid" "$test_xml"
fi

J
Jamie Strandboge 已提交
259
sed -e "s,###UUID###,$uuid,g" -e "s,###DISK###,$nonexistent,g" "$template_xml" > "$test_xml"
J
Jamie Strandboge 已提交
260 261
testme "0" "create (non-existent disk)" "-c -u $valid_uuid" "$test_xml"

J
Jamie Strandboge 已提交
262
sed -e "s,###UUID###,$uuid,g" -e "s,###DISK###,$relative_disk1,g" "$template_xml" > "$test_xml"
J
Jamie Strandboge 已提交
263 264
testme "0" "create (relative path)" "-c -u $valid_uuid" "$test_xml"

J
Jamie Strandboge 已提交
265
sed -e "s,###UUID###,$uuid,g" -e "s,###DISK###,$disk2,g" "$template_xml" > "$test_xml"
J
Jamie Strandboge 已提交
266 267
testme "0" "replace" "-r -u $valid_uuid" "$test_xml"

J
Jamie Strandboge 已提交
268
sed -e "s,###UUID###,$uuid,g" -e "s,###DISK###,$nonexistent,g" "$template_xml" > "$test_xml"
J
Jamie Strandboge 已提交
269 270
testme "0" "replace (non-existent disk)" "-r -u $valid_uuid" "$test_xml"

J
Jamie Strandboge 已提交
271
sed -e "s,###UUID###,$uuid,g" -e "s,###DISK###,$disk1,g" "$template_xml" > "$test_xml"
J
Jamie Strandboge 已提交
272 273
testme "0" "replace (adding disk)" "-r -u $valid_uuid -f $disk2" "$test_xml"

J
Jamie Strandboge 已提交
274
sed -e "s,###UUID###,$uuid,g" -e "s,###DISK###,$disk1,g" "$template_xml" > "$test_xml"
J
Jamie Strandboge 已提交
275 276
testme "0" "replace (adding non-existent disk)" "-r -u $valid_uuid -f $nonexistent" "$test_xml"

J
Jamie Strandboge 已提交
277
sed -e "s,###UUID###,$uuid,g" -e "s,###DISK###,$disk1,g" "$template_xml" > "$test_xml"
278 279
testme "0" "replace (appending disk)" "-r -u $valid_uuid -F $disk2" "$test_xml"

J
Jamie Strandboge 已提交
280
sed -e "s,###UUID###,$uuid,g" -e "s,###DISK###,$disk1,g" "$template_xml" > "$test_xml"
281 282
testme "0" "replace (appending non-existent disk)" "-r -u $valid_uuid -F $nonexistent" "$test_xml"

J
Jamie Strandboge 已提交
283
sed -e "s,###UUID###,$uuid,g" -e "s,###DISK###,$disk1,g" -e "s,</devices>,<disk type='block' device='cdrom'><target dev='hdc' bus='ide'/><readonly/></disk></devices>,g" "$template_xml" > "$test_xml"
J
Jamie Strandboge 已提交
284 285
testme "0" "disk (empty cdrom)" "-r -u $valid_uuid" "$test_xml"

J
Jamie Strandboge 已提交
286
sed -e "s,###UUID###,$uuid,g" -e "s,###DISK###,$disk1,g" -e "s,</devices>,<serial type='file'><source path='$tmpdir/serial.log'/><target port='0'/></serial></devices>,g" "$template_xml" > "$test_xml"
J
Jamie Strandboge 已提交
287 288
testme "0" "serial" "-r -u $valid_uuid" "$test_xml"

J
Jamie Strandboge 已提交
289
sed -e "s,###UUID###,$uuid,g" -e "s,###DISK###,$disk1,g" -e "s,</devices>,<serial type='pty'><target port='0'/></serial></devices>,g" "$template_xml" > "$test_xml"
J
Jamie Strandboge 已提交
290 291
testme "0" "serial (pty)" "-r -u $valid_uuid" "$test_xml"

J
Jamie Strandboge 已提交
292
sed -e "s,###UUID###,$uuid,g" -e "s,###DISK###,$disk1,g" -e "s,</devices>,<serial type='dev'><source path='/dev/ttyS0'/><target port='0'/></serial></devices>,g" "$template_xml" > "$test_xml"
293 294
testme "0" "serial (dev)" "-r -u $valid_uuid" "$test_xml"

295 296 297 298
sed -e "s,###UUID###,$uuid,g" -e "s,###DISK###,$disk1,g" -e "s,</devices>,<serial type='pipe'><source path='$tmpdir/serial.pipe'/><target port='0'/></serial></devices>,g" "$template_xml" > "$test_xml"
mkfifo "$tmpdir/serial.pipe.in" "$tmpdir/serial.pipe.out"
testme "0" "serial (pipe)" "-r -u $valid_uuid" "$test_xml"

J
Jamie Strandboge 已提交
299
sed -e "s,###UUID###,$uuid,g" -e "s,###DISK###,$disk1,g" -e "s,</devices>,<console type='file'><source path='$tmpdir/console.log'/><target port='0'/></console></devices>,g" "$template_xml" > "$test_xml"
J
Jamie Strandboge 已提交
300 301 302
touch "$tmpdir/console.log"
testme "0" "console" "-r -u $valid_uuid" "$test_xml"

J
Jamie Strandboge 已提交
303
sed -e "s,###UUID###,$uuid,g" -e "s,###DISK###,$disk1,g" -e "s,</devices>,<console type='pty'><target port='0'/></console></devices>,g" "$template_xml" > "$test_xml"
J
Jamie Strandboge 已提交
304 305
testme "0" "console (pty)" "-r -u $valid_uuid" "$test_xml"

306 307 308 309
sed -e "s,###UUID###,$uuid,g" -e "s,###DISK###,$disk1,g" -e "s,</devices>,<console type='pipe'><source path='$tmpdir/console.pipe'/><target port='0'/></console></devices>,g" "$template_xml" > "$test_xml"
mkfifo "$tmpdir/console.pipe.in" "$tmpdir/console.pipe.out"
testme "0" "console (pipe)" "-r -u $valid_uuid" "$test_xml"

J
Jamie Strandboge 已提交
310
sed -e "s,###UUID###,$uuid,g" -e "s,###DISK###,$disk1,g" -e "s,</devices>,<parallel type='pty'><source path='/dev/pts/0'/><target port='0'/></parallel></devices>,g" "$template_xml" > "$test_xml"
311 312
testme "0" "parallel (pty)" "-r -u $valid_uuid" "$test_xml"

313 314 315 316
sed -e "s,###UUID###,$uuid,g" -e "s,###DISK###,$disk1,g" -e "s,</devices>,<parallel type='pipe'><source path='$tmpdir/parallel.pipe'/><target port='0'/></parallel></devices>,g" "$template_xml" > "$test_xml"
mkfifo "$tmpdir/parallel.pipe.in" "$tmpdir/parallel.pipe.out"
testme "0" "parallel (pipe)" "-r -u $valid_uuid" "$test_xml"

J
Jamie Strandboge 已提交
317
sed -e "s,###UUID###,$uuid,g" -e "s,###DISK###,$disk1,g" -e "s,</devices>,<channel type='unix'><source mode='bind' path='$tmpdir/guestfwd'/><target type='guestfwd' address='10.0.2.1' port='4600'/></channel></devices>,g" "$template_xml" > "$test_xml"
318 319 320
touch "$tmpdir/guestfwd"
testme "0" "channel (unix)" "-r -u $valid_uuid" "$test_xml"

J
Jamie Strandboge 已提交
321
sed -e "s,###UUID###,$uuid,g" -e "s,###DISK###,$disk1,g" -e "s,</devices>,<channel type='pty'><target type='virtio'/></channel></devices>,g" "$template_xml" > "$test_xml"
322 323
testme "0" "channel (pty)" "-r -u $valid_uuid" "$test_xml"

J
Jamie Strandboge 已提交
324
sed -e "s,###UUID###,$uuid,g" -e "s,###DISK###,$disk1,g" -e "s,</os>,<kernel>$tmpdir/kernel</kernel></os>,g" "$template_xml" > "$test_xml"
J
Jamie Strandboge 已提交
325 326 327
touch "$tmpdir/kernel"
testme "0" "kernel" "-r -u $valid_uuid" "$test_xml"

328 329
testfw "ovmf (old path)" "/usr/share/ovmf/OVMF.fd"
testfw "OVMF (new path)" "/usr/share/OVMF/OVMF_CODE.fd"
330
testfw "AAVMF" "/usr/share/AAVMF/AAVMF_CODE.fd"
331
testfw "AAVMF32" "/usr/share/AAVMF/AAVMF32_CODE.fd"
332
testfw "qemu-efi" "/usr/share/qemu-efi/QEMU_EFI.fd"
333

J
Jamie Strandboge 已提交
334
sed -e "s,###UUID###,$uuid,g" -e "s,###DISK###,$disk1,g" -e "s,</os>,<initrd>$tmpdir/initrd</initrd></os>,g" "$template_xml" > "$test_xml"
J
Jamie Strandboge 已提交
335 336 337
touch "$tmpdir/initrd"
testme "0" "initrd" "-r -u $valid_uuid" "$test_xml"

J
Jamie Strandboge 已提交
338
sed -e "s,###UUID###,$uuid,g" -e "s,###DISK###,$disk1,g" -e "s,</os>,<kernel>/boot/kernel</kernel></os>,g" "$template_xml" > "$test_xml"
J
Jamie Strandboge 已提交
339 340
testme "0" "kernel in /boot" "-r -u $valid_uuid" "$test_xml"

J
Jamie Strandboge 已提交
341
sed -e "s,###UUID###,$uuid,g" -e "s,###DISK###,$disk1,g" -e "s,</os>,<initrd>/boot/initrd</initrd></os>,g" "$template_xml" > "$test_xml"
J
Jamie Strandboge 已提交
342 343
testme "0" "initrd in /boot" "-r -u $valid_uuid" "$test_xml"

J
Jamie Strandboge 已提交
344
sed -e "s,###UUID###,$uuid,g" -e "s,###DISK###,$disk1,g" -e "s,</os>,<kernel>/vmlinuz</kernel></os>,g" "$template_xml" > "$test_xml"
J
Jamie Strandboge 已提交
345 346
testme "0" "kernel is /vmlinuz" "-r -u $valid_uuid" "$test_xml"

J
Jamie Strandboge 已提交
347
sed -e "s,###UUID###,$uuid,g" -e "s,###DISK###,$disk1,g" -e "s,</os>,<initrd>/initrd/ramdisk</initrd></os>,g" "$template_xml" > "$test_xml"
J
Jamie Strandboge 已提交
348 349
testme "0" "initrd is /initrd/ramdisk" "-r -u $valid_uuid" "$test_xml"

J
Jamie Strandboge 已提交
350
sed -e "s,###UUID###,$uuid,g" -e "s,###DISK###,$disk1,g" -e "s,</os>,<initrd>/initrd.img</initrd></os>,g" "$template_xml" > "$test_xml"
J
Jamie Strandboge 已提交
351 352
testme "0" "initrd is /initrd.img" "-r -u $valid_uuid" "$test_xml"

J
Jamie Strandboge 已提交
353
sed -e "s,###UUID###,$uuid,g" -e "s,###DISK###,$disk1,g" -e "s,<graphics*,<graphics type='sdl' display=':0.0' xauth='/home/myself/.Xauthority'/>,g" "$template_xml" > "$test_xml"
354 355
testme "0" "sdl Xauthority" "-r -u $valid_uuid" "$test_xml"

356 357 358
sed -e "s,###UUID###,$uuid,g" -e "s,###DISK###,$disk1,g" "$template_xml" > "$test_xml"
testme "0" "hugepages" "-r -u $valid_uuid -F /run/hugepages/kvm/\*\*" "$test_xml"

359 360 361
sed -e "s,###UUID###,$uuid,g" -e "s,###DISK###,$disk1,g" -e "s,<graphics.*>,<graphics type='vnc' socket='/var/lib/libvirt/qemu/myself.vnc'><listen type='address' address='0.0.0.0'/></graphics>,g" "$template_xml" > "$test_xml"
testme "0" "vnc socket" "-r -u $valid_uuid" "$test_xml"

J
Jamie Strandboge 已提交
362 363 364 365 366 367 368 369
testme "0" "help" "-h"

echo "" >$output
if [ "$errors" != "0" ]; then
    echo "FAIL: $errors error(s)" >$output
    exit 1
fi
echo PASS >$output