-
Notifications
You must be signed in to change notification settings - Fork 78
/
test.sh
executable file
·143 lines (118 loc) · 5.11 KB
/
test.sh
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
#!/bin/sh
#
# For pylint-related info, see:
# https://jeffknupp.com/blog/2016/12/09/how-python-linters-will-save-your-large-python-project/
BOARD=bbb
if [ -n "$1" ] ; then
if [ "$1" = "-h" ] ; then
echo "Usage: test.sh [options]"
echo " -h Show this usage help"
echo " -f Do 'flake8' test of grabserial syntax"
echo " -l Do 'pylint' test of grabserial source"
echo " -b <board> Do tests on board <board> (default is 'bbb')"
echo ""
echo "By default (with no arguments), test.sh will run 2 tests on"
echo "the board 'bbb' (using the ttc command) using the default"
echo "python interpreter, and then 2 more test using the python3"
echo "interpreter"
echo ""
echo "On the second test of each set you should log in to the"
echo "board when the login prompt appears. This tests interactive"
echo "input to the board during grabserial operation."
exit 0
fi
if [ "$1" = "-f" ] ; then
echo "Running flake8 to analyze grabserial source"
flake8 --count grabserial
exit $?
fi
if [ "$1" = "-l" ] ; then
echo "Running pylint to analyze grabserial source"
# C0325 is unnecessary-parens (in python 2.0, parens for prints
# is encouraged to make them forward-compatible with python 3.0)
# R0914 is "too many branches" (for the grab() function)
# R0914 is "too many local variables" (for the grab() function)
# R0915 is "too many statements" (for the grab() function)
pylint --disable=C0325,R0912,R0914,R0915, --good-names=dt,sd,x grabserial
exit $?
fi
if [ "$1" = "-b" ] ; then
shift
BOARD=$1
shift
fi
fi
if [ -n "$1" ] ; then
echo "Unrecognized option '$1'"
echo "Use -h for help"
exit 0
fi
echo "Running grabserial on target '$BOARD'"
# get the console device for target board
console_dev="$(ttc info $BOARD -n console_dev)"
# Also, use ttc to reboot board
# use ttc to reboot the requested board
echo "==================================="
echo "Testing with python 2"
echo " 60 second grab, stopping when 'login' is seen"
echo " resetting time at "Starting kernel"
echo " reporting when 'FAQ' was seen"
echo "==================================="
# do the reboot after grabserial is started
(sleep 1 ; ttc reboot $BOARD) &
# grab data from from that console device (-d ${console_dev},
# skipping the serial port sanity check (-S)
# end either in 60 seconds (-e 60) or when "login" is seen (-q "login")
# report the time when "FAQ" was seen (-i "FAQ")
# send data to graboutput.log (-o graboutput.log)
# reset the running timer when the string "Starting kernel" is seen (-m ...)
# show verbose messages (-v)
./grabserial -v -S -d ${console_dev} -e 60 -t -m "Starting kernel" -i "FAQ" -q "login" -o graboutput.log
# use ttc to reboot the requested board
echo "==================================="
echo "Testing with python 2"
echo " 60 second grab, using both -t and -T, stopping when 'login' is seen"
echo "==================================="
# do the reboot after grabserial is started
(sleep 1 ; ttc reboot $BOARD) &
# grab data from from that console device (-d ${console_dev},
# skipping the serial port sanity check (-S)
# end either in 60 seconds (-e 60) or when "login" is seen (-q "login")
# report the time when "FAQ" was seen (-i "FAQ")
# send data to graboutput.log (-o graboutput.log)
# reset the running timer when the string "Starting kernel" is seen (-m ...)
# show verbose messages (-v)
# show both time (-t) and systime (-T)
./grabserial -v -S -d ${console_dev} -e 60 -t -T -m "Starting kernel" -i "FAQ" -q "login" -o graboutput.log
echo
echo "==================================="
echo "Testing with python 2"
echo " 120 second grab, try logging in (test user input to serial port)"
echo "==================================="
(sleep 1 ; ttc reboot $BOARD) &
# run for two minutes, allowing user to login (using threaded input)
./grabserial -v -S -d ${console_dev} -e 120 -t -o graboutput2.log
echo
echo "==================================="
echo "Testing with python 3"
echo " 60 second grab, stopping when 'login' is seen"
echo "==================================="
(sleep 1 ; ttc reboot $BOARD) &
python3 ./grabserial -v -S -d ${console_dev} -e 60 -t -m "Starting kernel" -i "FAQ" -q "login" -o graboutput3.log
echo
echo "==================================="
echo "Testing with python 3"
echo " 120 second grab, try logging in (test user input to serial port)"
echo "==================================="
(sleep 1 ; ttc reboot $BOARD) &
python3 ./grabserial -v -S -d ${console_dev} -e 120 -t -o graboutput4.log
echo
echo "==================================="
echo "Testing with python 2"
echo " 60 second grab, stopping when 'login' is seen, with hex output"
echo "==================================="
# do the reboot after grabserial is started
(sleep 1 ; ttc reboot $BOARD) &
# same as first test, but this time with --hex-output
./grabserial -v -S -d ${console_dev} -e 60 -t -m "Starting kernel" -i "FAQ" -q "login" --hex-output -o graboutput.log
echo "Done in test.sh"