Skip to content
This repository was archived by the owner on Dec 26, 2022. It is now read-only.

Commit 35fa8e8

Browse files
authored
Merge pull request #690 from splasky/test_endpoint_unit-sh
test(endpoint): Provide unit-test script for endpoint
2 parents fe1fb22 + e013a81 commit 35fa8e8

File tree

1 file changed

+52
-0
lines changed

1 file changed

+52
-0
lines changed

endpoint/unit-test/driver.sh

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
#!/usr/bin/env bash
2+
3+
set -uo pipefail
4+
RED='\033[0;31m'
5+
GREEN='\033[0;32m'
6+
NC='\033[0m' # No Color
7+
EP_TEST_CONFIG=(asan tsan ubsan)
8+
9+
function cleanup(){
10+
kill -9 "${TA}"
11+
}
12+
13+
function success(){
14+
cleanup
15+
echo -e "${GREEN}ALL test passed${NC}"
16+
exit 0
17+
}
18+
19+
function failed(){
20+
cleanup
21+
echo -e "${RED}Unit-test: ${TEST_CASE} not passed${NC}"
22+
exit 1
23+
}
24+
25+
function run_test_suite(){
26+
bazel test -c dbg --config "$1" //endpoint/unit-test/...
27+
ret=$?
28+
if [[ ret -ne 0 ]]
29+
then
30+
TEST_CASE="$1"
31+
failed
32+
fi
33+
}
34+
35+
function start_ta(){
36+
# Create tangle-accelerator for unit-test
37+
bazel run accelerator &
38+
TA=$!
39+
# Wait for tangle-acclerator build finish
40+
sleep 20
41+
}
42+
43+
echo "Start unit-test for endpoint"
44+
start_ta
45+
46+
# Run endpoint unit-test
47+
for i in ${EP_TEST_CONFIG[*]}; do
48+
run_test_suite "$i"
49+
done
50+
51+
# Finish
52+
success

0 commit comments

Comments
 (0)