summaryrefslogtreecommitdiff
path: root/scripts/vsp-tests.sh
blob: 1ed81713e5c5848ebb072447c3d443be6bdc80c3 (plain)
1
2
3
4
5
6
7
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
59
60
61
#!/bin/sh

##
## VSP Tests runner
##
## Automatically execute all vsp-unit tests
## Move test failure results to a specific folder for
## the running kernel version
##
## An argument can be provided to specify the number of
## iterations to perform
##
## usage:
##  ./vsp-tests.sh <n>
##
##   n: Number of iterations to execute test suite
##

KERNEL_VERSION=`uname -r`

run_test() {
	local script=$1
	local iteration=$2
	local IFS="$(printf '\n\t')"

	echo "- $script"

	local output=$(./$script 2>&1 | tee /proc/self/fd/2)
	for line in $output ; do
		(echo "$line" | grep -q 'fail$') && num_fail=$((num_fail+1))
		(echo "$line" | grep -q 'pass$') && num_pass=$((num_pass+1))
		(echo "$line" | grep -q 'skipped$') && num_skip=$((num_skip+1))
		num_test=$((num_test+1))
	done

	if [ $(ls *.bin 2>/dev/null | wc -l) != 0 ] ; then
		local dir=$KERNEL_VERSION/test-$script/$iteration/

		mkdir -p $dir
		mv *.bin $dir
	fi
}

run_suite() {
	echo "--- Test loop $1 ---"

	num_fail=0
	num_pass=0
	num_skip=0
	num_test=0

	for test in vsp-unit-test*.sh; do
		run_test $test $1
	done;

	echo "$num_test tests: $num_pass passed, $num_fail failed, $num_skip skipped"
}

for loop in `seq 1 1 $1`; do
	run_suite $loop
done;