-
Notifications
You must be signed in to change notification settings - Fork 43
Expand file tree
/
Copy pathruntests.sh
More file actions
executable file
·84 lines (74 loc) · 1.86 KB
/
runtests.sh
File metadata and controls
executable file
·84 lines (74 loc) · 1.86 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
#!/bin/sh
set -e
# Set ROOT_DIR to GITHUB_WORKSPACE or the top-level Git directory if GITHUB_WORKSPACE is not set
ROOT_DIR=${GITHUB_WORKSPACE:-$(git rev-parse --show-toplevel)}
RTLIB_DIR="${ROOT_DIR}/rtlib"
UNIT_TEST_DIR="${ROOT_DIR}/build/test/unit"
SYSTEM_TEST_DIR="${ROOT_DIR}/test/system"
usage() {
echo "usage: $0 [-h] [-s] [-u]" 1>&2
echo "run the complete unit and system test suite"
echo
echo "-h display help"
echo "-s runs system tests only"
echo "-u runs unit tests only"
}
run_unit_tests() {
find "${ROOT_DIR}" -name '*gcda' -delete
echo "running the unit test suite"
find "${UNIT_TEST_DIR}" -name '*_unit_tests' | xargs -n1 sh -c
echo "unit test run complete"
}
assert_unit_test_dir() {
if [ ! -d "${UNIT_TEST_DIR}" ]; then
echo "${UNIT_TEST_DIR} was not found. Please make sure you build the project before running tests."
exit 1
fi
}
run_system_tests() {
# Change to RTLIB_DIR directory
cd "${RTLIB_DIR}" || exit 1
if ! ./build.sh; then
echo "error: could not build the runtime library"
exit 1
fi
echo "running the system test suite"
# Change to SYSTEM_TEST_DIR directory
cd "${SYSTEM_TEST_DIR}" || exit 1
if ! python3 run_system_tests.py; then
echo "error while running system tests"
exit 1
fi
echo "system test suite complete"
}
run_system_tests="true"
run_unit_tests="true"
while getopts ":hsu" opt; do
case "${opt}" in
h)
usage
exit 0
;;
s)
echo "Preparing to run only the system tests suite"
run_unit_tests=""
;;
u)
echo "Preparing to run only the unit tests suite"
run_system_tests=""
;;
*)
echo "$0 illegal option"
usage
exit 1
;;
esac
done
shift $((OPTIND - 1))
if [ -n "${run_unit_tests}" ]; then
assert_unit_test_dir
run_unit_tests
fi
if [ -n "${run_system_tests}" ]; then
run_system_tests
fi