forked from temmihoo/plushie-badname
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathintegration_test.sh
More file actions
executable file
·81 lines (70 loc) · 1.5 KB
/
integration_test.sh
File metadata and controls
executable file
·81 lines (70 loc) · 1.5 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
#!/bin/sh
if [ -z $1 ]
then
sleep_period=0
else
sleep_period=$1
fi
if [ -n "${DEBUG}" ]
then
client="false"
else
client="node client.js"
fi
failures=0
light_test () {
colour=$(printf "%03d %03d %03d\n" $1 $2 $3)
testname=$4
send_coap_colour ${colour} ${testname}
ask_user_success_status ${colour} ${testname}
sleep ${sleep_period}
}
send_coap_colour () {
echo ${colour}
echo ${colour} | ${client}
if [ $? -eq 0 ]
then
eval ${testname}_test_exec="OK"
else
eval ${testname}_test_exec=$?
failures=$((${failures} + 1))
fi
}
ask_user_success_status () {
cat <<EOT
Test ${testname}:
The light should be coloured $1 $2 $3
if it is, please press enter
In case of any failure, type anything and press enter
EOT
read string
if [ -z ${string} ]
then
eval ${testname}_test_human="OK"
else
eval ${testname}_test_human=$string
failures=$((${failures} + 1))
fi
}
report () {
tests=$@
for testname in ${tests}
do
test_exec=${testname}_test_exec
test_human=${testname}_test_human
cat <<EOT
Test ${testname}
return code: ${!test_exec}
human evaluation: ${!test_human}
EOT
done
echo "Total number of failures: ${failures}"
}
light_test 255 255 255 White
light_test 255 050 100 Panther
light_test 255 000 000 Red
light_test 000 255 000 Green
light_test 000 000 255 Blue
light_test 000 000 000 Black
report White Panther Red Green Blue Black
exit ${failures}