Fix stray "no" in configure output
[zfs.git] / .github / workflows / scripts / qemu-6-tests.sh
blob2f023198bbf6f2b1febe2696ef84e95d039009a3
1 #!/usr/bin/env bash
3 ######################################################################
4 # 6) load openzfs module and run the tests
6 # called on runner: qemu-6-tests.sh
7 # called on qemu-vm: qemu-6-tests.sh $OS $2/$3
8 ######################################################################
10 set -eu
12 function prefix() {
13 ID="$1"
14 LINE="$2"
15 CURRENT=$(date +%s)
16 TSSTART=$(cat /tmp/tsstart)
17 DIFF=$((CURRENT-TSSTART))
18 H=$((DIFF/3600))
19 DIFF=$((DIFF-(H*3600)))
20 M=$((DIFF/60))
21 S=$((DIFF-(M*60)))
23 CTR=$(cat /tmp/ctr)
24 echo $LINE| grep -q "^Test[: ]" && CTR=$((CTR+1)) && echo $CTR > /tmp/ctr
26 BASE="$HOME/work/zfs/zfs"
27 COLOR="$BASE/scripts/zfs-tests-color.sh"
28 CLINE=$(echo $LINE| grep "^Test[ :]" | sed -e 's|/usr/local|/usr|g' \
29 | sed -e 's| /usr/share/zfs/zfs-tests/tests/| |g' | $COLOR)
30 if [ -z "$CLINE" ]; then
31 printf "vm${ID}: %s\n" "$LINE"
32 else
33 # [vm2: 00:15:54 256] Test: functional/checksum/setup (run as root) [00:00] [PASS]
34 printf "[vm${ID}: %02d:%02d:%02d %4d] %s\n" \
35 "$H" "$M" "$S" "$CTR" "$CLINE"
39 # called directly on the runner
40 if [ -z ${1:-} ]; then
41 cd "/var/tmp"
42 source env.txt
43 SSH=$(which ssh)
44 TESTS='$HOME/zfs/.github/workflows/scripts/qemu-6-tests.sh'
45 echo 0 > /tmp/ctr
46 date "+%s" > /tmp/tsstart
48 for i in $(seq 1 $VMs); do
49 IP="192.168.122.1$i"
50 daemonize -c /var/tmp -p vm${i}.pid -o vm${i}log.txt -- \
51 $SSH zfs@$IP $TESTS $OS $i $VMs $CI_TYPE
52 # handly line by line and add info prefix
53 stdbuf -oL tail -fq vm${i}log.txt \
54 | while read -r line; do prefix "$i" "$line"; done &
55 echo $! > vm${i}log.pid
56 # don't mix up the initial --- Configuration --- part
57 sleep 0.13
58 done
60 # wait for all vm's to finish
61 for i in $(seq 1 $VMs); do
62 tail --pid=$(cat vm${i}.pid) -f /dev/null
63 pid=$(cat vm${i}log.pid)
64 rm -f vm${i}log.pid
65 kill $pid
66 done
68 exit 0
71 # this part runs inside qemu vm
72 export PATH="$PATH:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/sbin:/usr/local/bin"
73 case "$1" in
74 freebsd*)
75 sudo kldstat -n zfs 2>/dev/null && sudo kldunload zfs
76 sudo -E ./zfs/scripts/zfs.sh
77 TDIR="/usr/local/share/zfs"
80 # use xfs @ /var/tmp for all distros
81 sudo mv -f /var/tmp/*.txt /tmp
82 sudo mkfs.xfs -fq /dev/vdb
83 sudo mount -o noatime /dev/vdb /var/tmp
84 sudo chmod 1777 /var/tmp
85 sudo mv -f /tmp/*.txt /var/tmp
86 sudo -E modprobe zfs
87 TDIR="/usr/share/zfs"
89 esac
91 # run functional testings and save exitcode
92 cd /var/tmp
93 TAGS=$2/$3
94 if [ "$4" == "quick" ]; then
95 export RUNFILES="sanity.run"
97 sudo dmesg -c > dmesg-prerun.txt
98 mount > mount.txt
99 df -h > df-prerun.txt
100 $TDIR/zfs-tests.sh -vK -s 3GB -T $TAGS
101 RV=$?
102 df -h > df-postrun.txt
103 echo $RV > tests-exitcode.txt
104 sync
105 exit 0