]> git.proxmox.com Git - mirror_qemu.git/blobdiff - tests/qemu-iotests/142
iotests: Specify explicit backing format where sensible
[mirror_qemu.git] / tests / qemu-iotests / 142
index 9a5b713256773027928e64c603c11dd1c25dfc98..69fd10ef5103803159cf948cf955a851ba809fab 100755 (executable)
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
 #
 # Test for configuring cache modes of arbitrary nodes (requires O_DIRECT)
 #
@@ -24,13 +24,12 @@ owner=kwolf@redhat.com
 seq=`basename $0`
 echo "QA output created by $seq"
 
-here=`pwd`
 status=1       # failure is the default!
 
 _cleanup()
 {
     _cleanup_test_img
-    rm -f $TEST_IMG.snap
+    _rm_test_img "$TEST_IMG.snap"
 }
 trap "_cleanup; exit \$status" 0 1 2 3 15
 
@@ -40,13 +39,12 @@ trap "_cleanup; exit \$status" 0 1 2 3 15
 
 _supported_fmt qcow2
 _supported_proto file
-_supported_os Linux
 
 # We test all cache modes anyway, but O_DIRECT needs to be supported
 _default_cache_mode none
 _supported_cache_modes none directsync
 
-function do_run_qemu()
+do_run_qemu()
 {
     echo Testing: "$@"
     (
@@ -60,7 +58,7 @@ function do_run_qemu()
     echo
 }
 
-function run_qemu()
+run_qemu()
 {
     do_run_qemu "$@" 2>&1 | _filter_testdir | _filter_qemu | _filter_hmp
 }
@@ -69,7 +67,7 @@ size=128M
 
 TEST_IMG="$TEST_IMG.base" _make_test_img $size
 TEST_IMG="$TEST_IMG.snap" _make_test_img $size
-_make_test_img -b "$TEST_IMG.base" $size
+_make_test_img -b "$TEST_IMG.base" $size -F $IMGFMT
 
 echo
 echo === Simple test for all cache modes ===
@@ -89,41 +87,41 @@ echo
 files="if=none,file=$TEST_IMG,backing.file.filename=$TEST_IMG.base"
 ids="node-name=image,backing.node-name=backing,backing.file.node-name=backing-file,file.node-name=file"
 
-function check_cache_all()
+check_cache_all()
 {
     # cache.direct is supposed to be inherited by both bs->file and
     # bs->backing
 
-    echo -e "cache.direct=on on none0"
+    printf "cache.direct=on on none0\n"
     echo "$hmp_cmds" | run_qemu -drive "$files","$ids",cache.direct=on | grep -e "Cache" -e "[Cc]annot|[Cc]ould not|[Cc]an't"
-    echo -e "\ncache.direct=on on file"
+    printf "\ncache.direct=on on file\n"
     echo "$hmp_cmds" | run_qemu -drive "$files","$ids",file.cache.direct=on | grep -e "Cache" -e "[Cc]annot|[Cc]ould not|[Cc]an't"
-    echo -e "\ncache.direct=on on backing"
+    printf "\ncache.direct=on on backing\n"
     echo "$hmp_cmds" | run_qemu -drive "$files","$ids",backing.cache.direct=on | grep -e "Cache" -e "[Cc]annot|[Cc]ould not|[Cc]an't"
-    echo -e "\ncache.direct=on on backing-file"
+    printf "\ncache.direct=on on backing-file\n"
     echo "$hmp_cmds" | run_qemu -drive "$files","$ids",backing.file.cache.direct=on | grep -e "Cache" -e "[Cc]annot|[Cc]ould not|[Cc]an't"
 
     # cache.writeback is supposed to be inherited by bs->backing; bs->file
     # always gets cache.writeback=on
 
-    echo -e "\n\ncache.writeback=off on none0"
+    printf "\n\ncache.writeback=off on none0\n"
     echo "$hmp_cmds" | run_qemu -drive "$files","$ids",cache.writeback=off | grep -e "Cache" -e "[Cc]annot\|[Cc]ould not\|[Cc]an't"
-    echo -e "\ncache.writeback=off on file"
+    printf "\ncache.writeback=off on file\n"
     echo "$hmp_cmds" | run_qemu -drive "$files","$ids",file.cache.writeback=off | grep -e "doesn't" -e "does not"
-    echo -e "\ncache.writeback=off on backing"
+    printf "\ncache.writeback=off on backing\n"
     echo "$hmp_cmds" | run_qemu -drive "$files","$ids",backing.cache.writeback=off | grep -e "doesn't" -e "does not"
-    echo -e "\ncache.writeback=off on backing-file"
+    printf "\ncache.writeback=off on backing-file\n"
     echo "$hmp_cmds" | run_qemu -drive "$files","$ids",backing.file.cache.writeback=off | grep -e "doesn't" -e "does not"
 
     # cache.no-flush is supposed to be inherited by both bs->file and bs->backing
 
-    echo -e "\n\ncache.no-flush=on on none0"
+    printf "\n\ncache.no-flush=on on none0\n"
     echo "$hmp_cmds" | run_qemu -drive "$files","$ids",cache.no-flush=on | grep -e "Cache" -e "[Cc]annot\|[Cc]ould not\|[Cc]an't"
-    echo -e "\ncache.no-flush=on on file"
+    printf "\ncache.no-flush=on on file\n"
     echo "$hmp_cmds" | run_qemu -drive "$files","$ids",file.cache.no-flush=on | grep -e "Cache" -e "[Cc]annot\|[Cc]ould not\|[Cc]an't"
-    echo -e "\ncache.no-flush=on on backing"
+    printf "\ncache.no-flush=on on backing\n"
     echo "$hmp_cmds" | run_qemu -drive "$files","$ids",backing.cache.no-flush=on | grep -e "Cache" -e "[Cc]annot\|[Cc]ould not\|[Cc]an't"
-    echo -e "\ncache.no-flush=on on backing-file"
+    printf "\ncache.no-flush=on on backing-file\n"
     echo "$hmp_cmds" | run_qemu -drive "$files","$ids",backing.file.cache.no-flush=on | grep -e "Cache" -e "[Cc]annot\|[Cc]ould not\|[Cc]an't"
 }
 
@@ -232,39 +230,39 @@ drv_bk="if=none,file=json:{'driver':'$IMGFMT',,'file':'backing-file',,'node-name
 drv_file="if=none,driver=file,filename=$TEST_IMG,node-name=file"
 drv_img="if=none,id=blk,file=json:{'driver':'$IMGFMT',,'file':'file',,'backing':'backing',,'node-name':'image'}"
 
-function check_cache_all_separate()
+check_cache_all_separate()
 {
     # Check cache.direct
 
-    echo -e "cache.direct=on on blk"
+    printf "cache.direct=on on blk\n"
     echo "$hmp_cmds" | run_qemu -drive "$drv_bkfile" -drive "$drv_bk" -drive "$drv_file" -drive "$drv_img",cache.direct=on | grep -e "Cache" -e "[Cc]annot\|[Cc]ould not\|[Cc]an't"
-    echo -e "\ncache.direct=on on file"
+    printf "\ncache.direct=on on file\n"
     echo "$hmp_cmds" | run_qemu -drive "$drv_bkfile" -drive "$drv_bk" -drive "$drv_file",cache.direct=on -drive "$drv_img" | grep -e "Cache" -e "[Cc]annot\|[Cc]ould not\|[Cc]an't"
-    echo -e "\ncache.direct=on on backing"
+    printf "\ncache.direct=on on backing\n"
     echo "$hmp_cmds" | run_qemu -drive "$drv_bkfile" -drive "$drv_bk",cache.direct=on -drive "$drv_file" -drive "$drv_img" | grep -e "Cache" -e "[Cc]annot\|[Cc]ould not\|[Cc]an't"
-    echo -e "\ncache.direct=on on backing-file"
+    printf "\ncache.direct=on on backing-file\n"
     echo "$hmp_cmds" | run_qemu -drive "$drv_bkfile",cache.direct=on -drive "$drv_bk" -drive "$drv_file" -drive "$drv_img" | grep -e "Cache" -e "[Cc]annot\|[Cc]ould not\|[Cc]an't"
 
     # Check cache.writeback
 
-    echo -e "\n\ncache.writeback=off on blk"
+    printf "\n\ncache.writeback=off on blk\n"
     echo "$hmp_cmds" | run_qemu -drive "$drv_bkfile" -drive "$drv_bk" -drive "$drv_file" -drive "$drv_img",cache.writeback=off | grep -e "Cache" -e "[Cc]annot\|[Cc]ould not\|[Cc]an't"
-    echo -e "\ncache.writeback=off on file"
+    printf "\ncache.writeback=off on file\n"
     echo "$hmp_cmds" | run_qemu -drive "$drv_bkfile" -drive "$drv_bk" -drive "$drv_file",cache.writeback=off -drive "$drv_img" | grep -e "Cache" -e "[Cc]annot\|[Cc]ould not\|[Cc]an't"
-    echo -e "\ncache.writeback=off on backing"
+    printf "\ncache.writeback=off on backing\n"
     echo "$hmp_cmds" | run_qemu -drive "$drv_bkfile" -drive "$drv_bk",cache.writeback=off -drive "$drv_file" -drive "$drv_img" | grep -e "Cache" -e "[Cc]annot\|[Cc]ould not\|[Cc]an't"
-    echo -e "\ncache.writeback=off on backing-file"
+    printf "\ncache.writeback=off on backing-file\n"
     echo "$hmp_cmds" | run_qemu -drive "$drv_bkfile",cache.writeback=off -drive "$drv_bk" -drive "$drv_file" -drive "$drv_img" | grep -e "Cache" -e "[Cc]annot\|[Cc]ould not\|[Cc]an't"
 
     # Check cache.no-flush
 
-    echo -e "\n\ncache.no-flush=on on blk"
+    printf "\n\ncache.no-flush=on on blk\n"
     echo "$hmp_cmds" | run_qemu -drive "$drv_bkfile" -drive "$drv_bk" -drive "$drv_file" -drive "$drv_img",cache.no-flush=on | grep -e "Cache" -e "[Cc]annot\|[Cc]ould not\|[Cc]an't"
-    echo -e "\ncache.no-flush=on on file"
+    printf "\ncache.no-flush=on on file\n"
     echo "$hmp_cmds" | run_qemu -drive "$drv_bkfile" -drive "$drv_bk" -drive "$drv_file",cache.no-flush=on -drive "$drv_img" | grep -e "Cache" -e "[Cc]annot\|[Cc]ould not\|[Cc]an't"
-    echo -e "\ncache.no-flush=on on backing"
+    printf "\ncache.no-flush=on on backing\n"
     echo "$hmp_cmds" | run_qemu -drive "$drv_bkfile" -drive "$drv_bk",cache.no-flush=on -drive "$drv_file" -drive "$drv_img" | grep -e "Cache" -e "[Cc]annot\|[Cc]ould not\|[Cc]an't"
-    echo -e "\ncache.no-flush=on on backing-file"
+    printf "\ncache.no-flush=on on backing-file\n"
     echo "$hmp_cmds" | run_qemu -drive "$drv_bkfile",cache.no-flush=on -drive "$drv_bk" -drive "$drv_file" -drive "$drv_img" | grep -e "Cache" -e "[Cc]annot\|[Cc]ould not\|[Cc]an't"
 }