]> git.proxmox.com Git - mirror_qemu.git/blob - tests/check-block.sh
88e02453d294bd9e766204cd8ce4852e8cf6f535
[mirror_qemu.git] / tests / check-block.sh
1 #!/bin/sh
2
3 if [ "$#" -eq 0 ]; then
4 echo "Usage: $0 fmt..." >&2
5 exit 99
6 fi
7
8 # Honor the SPEED environment variable, just like we do it for "meson test"
9 format_list="$@"
10 if [ "$SPEED" = "slow" ] || [ "$SPEED" = "thorough" ]; then
11 group=
12 else
13 group="-g auto"
14 fi
15
16 skip() {
17 echo "$*"
18 exit 77
19 }
20
21 if grep -q "CONFIG_GPROF=y" config-host.mak 2>/dev/null ; then
22 skip "GPROF is enabled ==> Not running the qemu-iotests."
23 fi
24
25 # Disable tests with any sanitizer except for specific ones
26 SANITIZE_FLAGS=$( grep "CFLAGS.*-fsanitize" config-host.mak 2>/dev/null )
27 ALLOWED_SANITIZE_FLAGS="safe-stack cfi-icall"
28 #Remove all occurrencies of allowed Sanitize flags
29 for j in ${ALLOWED_SANITIZE_FLAGS}; do
30 TMP_FLAGS=${SANITIZE_FLAGS}
31 SANITIZE_FLAGS=""
32 for i in ${TMP_FLAGS}; do
33 if ! echo ${i} | grep -q "${j}" 2>/dev/null; then
34 SANITIZE_FLAGS="${SANITIZE_FLAGS} ${i}"
35 fi
36 done
37 done
38 if echo ${SANITIZE_FLAGS} | grep -q "\-fsanitize" 2>/dev/null; then
39 # Have a sanitize flag that is not allowed, stop
40 skip "Sanitizers are enabled ==> Not running the qemu-iotests."
41 fi
42
43 if [ -z "$(find . -name 'qemu-system-*' -print)" ]; then
44 skip "No qemu-system binary available ==> Not running the qemu-iotests."
45 fi
46
47 if ! command -v bash >/dev/null 2>&1 ; then
48 skip "bash not available ==> Not running the qemu-iotests."
49 fi
50
51 if LANG=C bash --version | grep -q 'GNU bash, version [123]' ; then
52 skip "bash version too old ==> Not running the qemu-iotests."
53 fi
54
55 if ! (sed --version | grep 'GNU sed') > /dev/null 2>&1 ; then
56 if ! command -v gsed >/dev/null 2>&1; then
57 skip "GNU sed not available ==> Not running the qemu-iotests."
58 fi
59 else
60 # Double-check that we're not using BusyBox' sed which says
61 # that "This is not GNU sed version 4.0" ...
62 if sed --version | grep -q 'not GNU sed' ; then
63 skip "BusyBox sed not supported ==> Not running the qemu-iotests."
64 fi
65 fi
66
67 cd tests/qemu-iotests
68
69 # QEMU_CHECK_BLOCK_AUTO is used to disable some unstable sub-tests
70 export QEMU_CHECK_BLOCK_AUTO=1
71 export PYTHONUTF8=1
72 # If make was called with -jN we want to call ./check with -j N. Extract the
73 # flag from MAKEFLAGS, so that if it absent (or MAKEFLAGS is not defined), JOBS
74 # would be an empty line otherwise JOBS is prepared string of flag with value:
75 # "-j N"
76 # Note, that the following works even if make was called with "-j N" or even
77 # "--jobs N", as all these variants becomes simply "-jN" in MAKEFLAGS variable.
78 JOBS=$(echo "$MAKEFLAGS" | sed -n 's/\(^\|.* \)-j\([0-9]\+\)\( .*\|$\)/-j \2/p')
79
80 ret=0
81 for fmt in $format_list ; do
82 ${PYTHON} ./check $JOBS -makecheck -$fmt $group || ret=1
83 done
84
85 exit $ret