-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest_dual.sh
executable file
·59 lines (47 loc) · 998 Bytes
/
test_dual.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
#!/bin/bash
#The list of serial ports need to be tested.
SERIAL_LIST=(ttyS0 ttyS1 ttyS2 ttyS3)
#if arguments specified, get the serial port list from arguments
if [ $# -gt 0 ];then
SERIAL_LIST=( $@ )
fi
BAUDRATE=115200
LOOP_COUNT=100
if [ -f "./dualport" ] ;then
DUALPORT=./dualport
else
DUALPORT=dualport
fi
term_exit()
{
echo "Test aborted"
pkill $DUALPORT
exit 1
}
trap term_exit TERM INT
#Result of test, 0: PASS, 1: FAIL
result=0
count=${#SERIAL_LIST[@]}
n=0
while [ $n -lt $count ] ;do
sport1=${SERIAL_LIST[$n]}
let n=n+1
if [ $n -ge $count ] ;then
echo "skip $sport1"
break;
fi
sport2=${SERIAL_LIST[$n]}
let n=n+1
echo "Run test on $sport1 and $sport2 ..."
$DUALPORT $sport1 $sport2 -b $BAUDRATE -l $LOOP_COUNT
if [ $? -ne 0 ];then
result=1
echo "ERROR on testing $sport1 and $sport2"
fi
done
if [ $result -eq 0 ] ;then
echo "Test PASS"
else
echo "Test FAIL"
fi
exit $result