From e0b2ada62fdae1a066987e3bc71d932992f0da49 Mon Sep 17 00:00:00 2001 From: "brice.boisson" Date: Thu, 30 Nov 2023 14:43:01 +0900 Subject: [PATCH] Add: error message when the number of ran test is lower than the number of test present is the assmbly file (the number of ran test can be superior, and in few time lower that's why it's only a warning --- scripts/gen_test.py | 5 +++++ scripts/run_test.sh | 9 ++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/scripts/gen_test.py b/scripts/gen_test.py index 5ff5905..af25177 100644 --- a/scripts/gen_test.py +++ b/scripts/gen_test.py @@ -8,6 +8,7 @@ if len(sys.argv) != 2: source_code = open(sys.argv[1], 'r') Lines = source_code.readlines() test_file = [] +nb_test = 0 def get_test(test, instr_addr, final = False): result = "" @@ -48,6 +49,7 @@ for line in Lines: new_test = get_test(test, instr_addr) if new_test != "": test_file.append(new_test) + nb_test += 1 instr_addr += 4 @@ -67,6 +69,7 @@ for line in reversed(Lines): new_test = get_test(test, instr_addr, True) if new_test != "": final_test_file.append(new_test) + nb_test += 1 else: break @@ -74,3 +77,5 @@ for line in reversed(Lines): with open('final_test.tmp', 'w') as f: for item in final_test_file: f.write("%s\n" % item) + +print(f"Generated {nb_test} tests") diff --git a/scripts/run_test.sh b/scripts/run_test.sh index ca60b9a..30bac29 100755 --- a/scripts/run_test.sh +++ b/scripts/run_test.sh @@ -32,8 +32,7 @@ run_test () fi ./${SCRIPT_FOLDER}/get_bin.sh $TEST_FILE_PATH - python3 ./${SCRIPT_FOLDER}/gen_test.py $TEST_FILE_PATH - + NB_TEST=$(python3 ./${SCRIPT_FOLDER}/gen_test.py $TEST_FILE_PATH | sed -n 's/^Generated \([[:digit:]]*\) tests$/\1/p') if [ -z $2 ]; then vsim -c -do "do simu.do; quit -f" >& /dev/null @@ -41,7 +40,7 @@ run_test () vsim -do "do simu.do" fi - print_result "$TEST_BENCH-$(basename $TEST_FILE_PATH .S)" + print_result "$TEST_BENCH-$(basename $TEST_FILE_PATH .S)" "$NB_TEST" } print_result () @@ -71,6 +70,10 @@ print_result () fi done < ./transcript + if [ ! -z $2 ] && [ $2 -ne 0 ] && [ $nb_test -lt $2 ]; then + echo -e "\033[0;31m$BOLD"Warning:"$NORMAL\033[0m Only $BOLD$nb_test$NORMAL tests were executed, at least $BOLD$2$NORMAL were expected." + fi + echo -e "[\033[0;34m$BOLD$1$NORMAL\033[0m]$BOLD Test: $nb_test | Passed: $NORMAL\033[0;32m$BOLD$nb_pass$NORMAL\033[0m$BOLD | Failed: $NORMAL\033[0;31m$BOLD$nb_fail$NORMAL\033[0m" } -- 2.30.2