-
Notifications
You must be signed in to change notification settings - Fork 1
/
run-test.sh
executable file
·81 lines (72 loc) · 1.82 KB
/
run-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
#!/bin/bash
# define testScripts (need to edit when test case was added)
testScripts=()
testScripts+=(simple_pubsub/rclcpp_to_rclcpp.sh)
testScripts+=(simple_pubsub/rclcpp_to_rclex.sh)
testScripts+=(simple_pubsub/rclex_to_rclcpp.sh)
testScripts+=(simple_pubsub/rclex_to_rclex.sh)
if [ $# -ne 0 ];
then
testScripts=()
for arg in ${@};
do
echo "INFO: adding ${arg} as test script"
if [ -e ${arg} ];
then
testScripts+=(${arg})
else
echo "ERROR: test script ${arg} does not exists"
exit 1
fi
done
fi
testRoot=`pwd`
rclcppRoot=${testRoot}/rclcpp_node
rclexRoot=${testRoot}/rclex_node
if [ ! -d ${rclcppRoot}/build ];
then
echo "ERROR: ${rclcppRoot} has not been built"
echo "ERROR: please do ./run-rebuild.sh before this"
exit 1
else
source ${rclcppRoot}/install/setup.bash
fi
if [ ! -d ${rclexRoot}/_build ];
then
echo "ERROR: ${rclexRoot} has not been built"
echo "ERROR: please do ./run-rebuild.sh before this"
exit 1
fi
failedTestNames=""
testCount=0
passedTestCount=0
for testScript in ${testScripts[@]};
do
cd $testRoot
if [ $testScript = '*.sh' ];
then
continue
fi
testCount=$(($testCount + 1))
echo "INFO: running test scrpit: $testScript"
./$testScript $rclexRoot
result=$?
if [ $result -eq 0 ];
then
echo -e "INFO: $testScript passed!\n"
passedTestCount=$(($passedTestCount + 1))
else
echo -e "WARN: $testScript failed!\n"
failedTestNames+=" $testScript\n"
fi
done
echo "INFO: Complete all tests"
echo "INFO: number of passed tests: $passedTestCount / $testCount"
if [ $testCount -ne $passedTestCount ];
then
echo -e "ERROR: Failed tests: \n$failedTestNames"
exit $testCount
else
echo "INFO: All Tests passed."
exit 0
fi