Skip to content

Commit

Permalink
runtests: add test all client and all server test function
Browse files Browse the repository at this point in the history
Add test all client and all server test function:
./runtests -f tests-client
./runtests -f tests-server

Signed-off-by: Pengfei Xu <[email protected]>
  • Loading branch information
xupengfe committed Jul 7, 2023
1 parent 8844c6c commit 0545f56
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions runtests
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ source .env

START_TIME=""
SUMMRY_LOG=""
TESTS_CLIENT="tests-client"
TESTS_SERVER="tests-server"
TEST_FILES=""
SUB_FOLDERS=""

usage() {
cat << _EOF
Expand All @@ -17,6 +21,8 @@ Usage: ${0##*/} [-f CMDFILES] [-c CMDLINE] [-o LOGFILE]
Examples:
./runtests -f cet/tests
./runtests -f cet/tests -o cet_tests.log
./runtests -f tests-client // exeucte tests-client or tests in all subfolders
./runtests -f tests-server // exeucte tests-server or tests in all subfolders
./runtests -c ./cet/quick_test -o cet_quick_test.log
_EOF
}
Expand Down Expand Up @@ -110,6 +116,48 @@ runcmdfile() {
done < "$cmdfile"
}

prepare_files_list() {
local test_file_type=$1
local sub_folder=""

for sub_folder in $SUB_FOLDERS; do
# Remov the / in the end
sub_folder="${sub_folder%/}"
[[ "$sub_folder" == "common" ]] && continue

if [[ -e "${sub_folder}/${test_file_type}" ]]; then
if [[ -z "$TEST_FILES" ]]; then
TEST_FILES="${sub_folder}/${test_file_type}"
else
TEST_FILES="${TEST_FILES},${sub_folder}/${test_file_type}"
fi
elif [[ -e "${sub_folder}/tests" ]]; then
if [[ -z "$TEST_FILES" ]]; then
TEST_FILES="${sub_folder}/tests"
else
TEST_FILES="${TEST_FILES},${sub_folder}/tests"
fi
else
echo "WARNING: No $test_file_type or tests file under $sub_folder folder."
fi
done
}

test_all() {
local test_file_type=$1

# Don't quote */, otherwise it could not list all folders.
SUB_FOLDERS=$(ls -1 -d */)

prepare_files_list "$test_file_type"
CMDFILES="$TEST_FILES"
if [[ -z "$LOGFILE" ]]; then
echo "Test files: $CMDFILES"
else
echo "Test files: $CMDFILES" | tee "$LOGFILE"
fi
}

: LOGFILE=""
: CMDFILES=""
: CMDLINE=""
Expand All @@ -121,6 +169,8 @@ while getopts ":o:f:c:h" opt; do
;;
f)
CMDFILES=$OPTARG
[[ "$CMDFILES" == "$TESTS_CLIENT" ]] && test_all "$TESTS_CLIENT"
[[ "$CMDFILES" == "$TESTS_SERVER" ]] && test_all "$TESTS_SERVER"
;;
c)
CMDLINE=$OPTARG
Expand Down

0 comments on commit 0545f56

Please sign in to comment.