xref: /kvm-unit-tests/scripts/common.bash (revision fd149358c4910a68ba81aa0a7aa157a77205a43c)
1
2function for_each_unittest()
3{
4	local unittests="$1"
5	local cmd="$2"
6	local testname
7	local smp
8	local kernel
9	local opts
10	local groups
11	local arch
12	local check
13	local accel
14	local timeout
15
16	exec {fd}<"$unittests"
17
18	while read -u $fd line; do
19		if [[ "$line" =~ ^\[(.*)\]$ ]]; then
20			"$cmd" "$testname" "$groups" "$smp" "$kernel" "$opts" "$arch" "$check" "$accel" "$timeout"
21			testname=${BASH_REMATCH[1]}
22			smp=1
23			kernel=""
24			opts=""
25			groups=""
26			arch=""
27			check=""
28			accel=""
29			timeout=""
30		elif [[ $line =~ ^file\ *=\ *(.*)$ ]]; then
31			kernel=$TEST_DIR/${BASH_REMATCH[1]}
32		elif [[ $line =~ ^smp\ *=\ *(.*)$ ]]; then
33			smp=${BASH_REMATCH[1]}
34		elif [[ $line =~ ^extra_params\ *=\ *(.*)$ ]]; then
35			opts=${BASH_REMATCH[1]}
36		elif [[ $line =~ ^groups\ *=\ *(.*)$ ]]; then
37			groups=${BASH_REMATCH[1]}
38		elif [[ $line =~ ^arch\ *=\ *(.*)$ ]]; then
39			arch=${BASH_REMATCH[1]}
40		elif [[ $line =~ ^check\ *=\ *(.*)$ ]]; then
41			check=${BASH_REMATCH[1]}
42		elif [[ $line =~ ^accel\ *=\ *(.*)$ ]]; then
43			accel=${BASH_REMATCH[1]}
44		elif [[ $line =~ ^timeout\ *=\ *(.*)$ ]]; then
45			timeout=${BASH_REMATCH[1]}
46		fi
47	done
48	"$cmd" "$testname" "$groups" "$smp" "$kernel" "$opts" "$arch" "$check" "$accel" "$timeout"
49	exec {fd}<&-
50}
51