aboutsummaryrefslogtreecommitdiffstats
path: root/meta/recipes-support/ptest-runner/files/ptest-runner
blob: 204cbdfc7622cb3785a2fb6855444806496e2db6 (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
#!/bin/sh

determine_ptests_to_run()
{
    for libdir in /usr/lib*
    do
	[ ! -d "$libdir" ] && continue

	for x in `ls -d $libdir/*/ptest 2>/dev/null`
	do
	    [ ! -f $x/run-ptest ] && continue
            [ -h `dirname $x` ] && continue

	    #found a ptest in the system
	    PTEST_FOUND=$(basename $(dirname $x))

	    # when no pkg-names were specified, by default run each one
	    if [[ -z $@ ]]; then
		printf " $x"
	    else
		#check if this ptest has been asked for and add it
		if [[ $@ =~ $PTEST_FOUND ]]; then
			printf " $x"
		fi
	    fi
	done
    done
}

run_ptests()
{
    ANYFAILED=no

    #the paths were sanity-checked in determine_ptests_to_run()
    for ptst_path in $PTESTS_TO_RUN
    do
        date "+%Y-%m-%dT%H:%M"
        echo "BEGIN: $ptst_path"
        cd "$ptst_path"
        ./run-ptest || ANYFAILED=yes
        echo "END: $ptest_path"
        date "+%Y-%m-%dT%H:%M"
    done
}

echo "START: $0"
PTESTS_TO_RUN=$(determine_ptests_to_run $@)
run_ptests
echo "STOP: $0"

if [ "$ANYFAILED" = "yes"  ]; then
    exit 1
fi
exit 0