test.sh: Make it more portable

This commit is contained in:
Albert S. 2022-12-20 10:50:37 +01:00
джерело 769f729dc5
коміт 01c5cbf701

22
test.sh

@ -8,41 +8,41 @@ COUNT_SUCCEEDED=0
COUNT_FAILED=0 COUNT_FAILED=0
COUNT_SKIPPED=0 COUNT_SKIPPED=0
function print_fail() print_fail()
{ {
echo -e "${RED}$@${NC}" 1>&2 printf "${RED}$@${NC}\n" 1>&2
} }
function print_success() print_success()
{ {
echo -e "${GREEN}$@${NC}" printf "${GREEN}$@${NC}\n"
} }
function print_skipped() print_skipped()
{ {
echo -e "${YELLOW}$@${NC}" printf "${YELLOW}$@${NC}\n"
} }
function runtest_fail() runtest_fail()
{ {
print_fail "failed" print_fail "failed"
COUNT_FAILED=$(($COUNT_FAILED+1)) COUNT_FAILED=$(($COUNT_FAILED+1))
} }
function runtest_success() runtest_success()
{ {
print_success "ok" print_success "ok"
COUNT_SUCCEEDED=$((COUNT_SUCCEEDED+1)) COUNT_SUCCEEDED=$((COUNT_SUCCEEDED+1))
} }
function runtest_skipped() runtest_skipped()
{ {
print_skipped "skipped" print_skipped "skipped"
COUNT_SKIPPED=$((COUNT_SKIPPED+1)) COUNT_SKIPPED=$((COUNT_SKIPPED+1))
} }
function runtest() runtest()
{ {
testbin="$1" testbin="$1"
testname="$2" testname="$2"
@ -52,7 +52,7 @@ function runtest()
echo -n "Running $testname... " echo -n "Running $testname... "
#exit $? to suppress shell message like "./test.sh: line 18: pid Bad system call" #exit $? to suppress shell message like "./test.sh: line 18: pid Bad system call"
(./$testbin "$testname" || exit $?) &>> "${test_log_file}" (./$testbin "$testname" || exit $?) 2>&1 | tee 1>/dev/null -a "${test_log_file}"
ret=$? ret=$?
SUCCESS="no" SUCCESS="no"
if [ $ret -eq 0 ] ; then if [ $ret -eq 0 ] ; then