-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathexecute.sh
More file actions
executable file
·150 lines (130 loc) · 4.44 KB
/
execute.sh
File metadata and controls
executable file
·150 lines (130 loc) · 4.44 KB
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
#!/bin/bash
# Usage Function
Usage()
{
echo "Usage: $(basename ${BASH_SOURCE[0]}) [OPTIONS]"
echo " Optional Options:"
# Just do a simple grep of this file so we can keep the command with the comment together
grep ". )\ #" ${BASH_SOURCE[0]} | sed 's/# //' | awk -F ")" '{ printf "%-30s %s\n", $1, $2 }'
exit 0
}
# Initialise the options
OPTS=$(getopt -o vhxt:d: --long directory:,verbose,help,xml,test: -n "$(basename "$0")" -- "$@")
if [ $? != 0 ]; then echo; Usage; fi
eval set -- "$OPTS"
REDIRECT_OUTPUT="> /dev/null 2>&1"
GENERATE_XML=
TEST_TO_EXECUTE=
export DALI_DISABLE_PARTIAL_UPDATE=1
dir=""
# Go through all the options
if [[ $* > 1 ]] ; then
while true;
do
case "$1" in
-d|--directory ) # Outputs captured images to this directory
dir="--directory $2"
shift 2
;;
-v|--verbose ) # Verbose output for every test case
REDIRECT_OUTPUT=
shift
;;
-h|--help ) # Help
shift
Usage
;;
-x|--xml ) # Outputs visual-tests-results.xml with the test re
GENERATE_XML=1
shift
;;
-t|--test ) # Executes a single test
TEST_TO_EXECUTE="$2"
shift 2
;;
-- )
shift
;;
* )
break
;;
esac
done
fi
# Formatting Codes
Bold="\e[1m"
Green='\e[0;32m'
Red='\e[0;31m'
Clear='\e[0m'
# Retrieve all the installed tests
scriptLocation=$(dirname ${BASH_SOURCE[0]})
tests=$(ls $scriptLocation/visual-tests)
num_tests=$(echo $tests | wc -w)
num_passes=0
num_fails=0
testOutput=""
DEBUG=""
#DEBUG=gdb --args
if [[ "$TEST_TO_EXECUTE" != "" ]] ; then
tests=$TEST_TO_EXECUTE
num_tests=1
fi
# Execute each test executable in turn
for i in $tests ; do
test=$(basename $i).test
dimensions=$($test --get-dimensions 2>/dev/null)
command="timeout 3m xvfb-run -s \"-screen 0 $dimensions -fbdir /var/tmp\" $DEBUG $test --fb $dir ${REDIRECT_OUTPUT}"
echo -e "${Bold}Executing: $command"
# Run a second time if failed the first as it seems to fail incorrectly from time to time
eval $command || eval $command
percent=$?
# Check the test result
if [ "$percent" != "0" ]; then
echo "$test Failed ($percent % match)"
testOutput="$testOutput $test,Failed"
((num_fails++))
else
echo "$test Passed"
testOutput="$testOutput $test,Passed"
((num_passes++))
fi
#read -p "Waiting..>" aline
done
# Output the summary of test result
TestOutputColor=${Green}
if [[ ! "$num_passes" = "$num_tests" ]] ; then TestOutputColor=${Red}; fi
percent_passing=$(printf %.2f\\n "$((10000 * $num_passes / $num_tests ))e-2")
percent_failing=$(printf %.2f\\n "$((10000 * $num_fails / $num_tests ))e-2")
echo
echo -e "${Bold}Test Summary:${Clear}"
echo -e " Total tests: $num_tests"
echo -e " Number of test passes: ${Bold}$num_passes ($percent_passing%)${Clear}"
echo -e " ${TestOutputColor}Number of test failures: ${Bold}$num_fails ${Clear}"
# Create an XML file with all the output
if [[ "$GENERATE_XML" = "1" ]]
then
xmlOutputFile=visual-tests-results.xml
echo -e "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" > $xmlOutputFile
echo -e "<visual_tests>" >> $xmlOutputFile
echo -e "\t<summary>" >> $xmlOutputFile
echo -e "\t\t<total_tests>$num_tests</total_tests>" >> $xmlOutputFile
echo -e "\t\t<pass_tests>$num_passes</pass_tests>" >> $xmlOutputFile
echo -e "\t\t<pass_rate>$percent_passing</pass_rate>" >> $xmlOutputFile
echo -e "\t\t<fail_tests>$num_fails</fail_tests>" >> $xmlOutputFile
echo -e "\t\t<fail_rate>$percent_failing</fail_rate>" >> $xmlOutputFile
echo -e "\t</summary>" >> $xmlOutputFile
echo -e "\t<tests>" >> $xmlOutputFile
for test in $testOutput
do
testName=$(echo $test | cut -d, -f 1)
testResult=$(echo $test | cut -d, -f 2)
echo -e "\t\t<test>" >> $xmlOutputFile
echo -e "\t\t\t<name>$testName</name>" >> $xmlOutputFile
echo -e "\t\t\t<result>$testResult</result>" >> $xmlOutputFile
echo -e "\t\t</test>" >> $xmlOutputFile
done
echo -e "\t</tests>" >> $xmlOutputFile
echo -e "</visual_tests>" >> $xmlOutputFile
fi
# If we have failures, this will exit this script with 1 otherwise it'll be 0 (success)
[[ $num_fails -eq 0 ]]