Skip to content

Commit

Permalink
debug_prirnt() statements were not correctly turned on/off. fatal_pri…
Browse files Browse the repository at this point in the history
…nt() did not exit as expected.
  • Loading branch information
billmcspadden-riscv committed Apr 30, 2024
1 parent 2c74f81 commit 72f5984
Showing 1 changed file with 16 additions and 22 deletions.
38 changes: 16 additions & 22 deletions bin/run_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,12 @@
# TRACE() For bringup debug only. TRACE() instances should be removed.

def debug_print (text = "") :
cf = currentframe()
of = cf.f_back
fi = getframeinfo(of)
filename = os.path.basename(fi.filename)
print("debug: file: " + filename + " line: " + str(of.f_lineno) + " : " + text)
if debug :
cf = currentframe()
of = cf.f_back
fi = getframeinfo(of)
filename = os.path.basename(fi.filename)
print("debug: file: " + filename + " line: " + str(of.f_lineno) + " : " + text)
return

def error_print (text = "") :
Expand All @@ -139,7 +140,8 @@ def fatal_print (text = "") :
fi = getframeinfo(of)
filename = os.path.basename(fi.filename)
print("fatal error: file: " + filename + " line: " + str(of.f_lineno) + " : " + text)
return
sys.exit(1)
return # never taken

def TRACE(text = "") :
cf = currentframe()
Expand Down Expand Up @@ -406,7 +408,7 @@ def is_riscv_elf_64(filename) :

def ignore_test(testname) :
for t in my_ignore_test_tuple :
print("ignore_test function: testname: " + os.path.basename(testname) + " t: " + t)
debug_print("ignore testname: " + os.path.basename(testname) + " t: " + t)
if t == os.path.basename(testname) :
return True
else :
Expand Down Expand Up @@ -490,7 +492,7 @@ def ignore_test(testname) :
# Do 'make clean' to avoid cross-arch pollution.

if clean_build :
cmd = "make clean"
cmd = "make ARCH=RV32 clean"
ret_val = os.system(cmd)
if ret_val != 0 :
fatal_print("non-zero exit value from command: '" + cmd + "'")
Expand All @@ -510,9 +512,7 @@ def ignore_test(testname) :
debug_print("non-zero exit value from command: '" + cmd + "'")
red("Building 32-bit RISCV OCaml emulator","fail")

TRACE("run_32bit_tests and run_ocamlsim : " + str(run_32bit_tests and run_ocamlsim))
if run_32bit_tests and run_ocamlsim :
TRACE()
for test in glob.glob(DIR + '/' + TESTDIR + '/' + "*") :
debug_print("test: " + test)
if not is_riscv_elf_32(test) :
Expand Down Expand Up @@ -549,10 +549,10 @@ def ignore_test(testname) :
finish_suite("32-bit RISCV OCaml-simulator tests")

if clean_build :
cmd = "make clean"
cmd = "make ARCH=RV32 clean"
ret_val = os.system(cmd)
if ret_val != 0 :
print("error: non-zero exit value from command: '" + cmd + "'")
fatal_print("non-zero exit value from command: '" + cmd + "'")
sys.exit(1)
else :
pass
Expand All @@ -568,12 +568,10 @@ def ignore_test(testname) :
if ret_val == 0 :
green("Building 32-bit RISCV C emulator", "ok")
else :
error_print("non-zero exit value from command: '" + cmd + "'")
red("Building 32-bit RISCV C emulator","fail")
error_print("non-zero exit value from command: '" + cmd + "'")

TRACE("run_32bit_tests and run_csim : " + str(run_32bit_tests and run_csim))
if run_32bit_tests and run_csim :
TRACE()
for test in glob.glob(DIR + '/' + TESTDIR + '/' + "*") :
if not is_riscv_elf_32(test) :
continue
Expand Down Expand Up @@ -607,7 +605,7 @@ def ignore_test(testname) :
finish_suite("32-bit RISCV C-simulator tests")

if clean_build :
cmd = "make clean"
cmd = "make ARCH=RV64 clean"
ret_val = os.system(cmd)
if ret_val != 0 :
fatal_print("non-zero exit value from command: '" + cmd + "'")
Expand All @@ -627,9 +625,7 @@ def ignore_test(testname) :
error_print("non-zero exit value from command: '" + cmd + "'")
red("Building 64-bit RISCV OCaml emulator","fail")

TRACE("run_64bit_tests and run_ocamlsim : " + str(run_64bit_tests and run_ocamlsim))
if run_64bit_tests and run_ocamlsim :
TRACE()
for test in glob.glob(DIR + '/' + TESTDIR + '/' + "*") :
debug_print("test: " + test)
if not is_riscv_elf_64(test) :
Expand Down Expand Up @@ -667,7 +663,7 @@ def ignore_test(testname) :


if clean_build :
cmd = "make clean"
cmd = "make ARCH=RV64 clean"
ret_val = os.system(cmd)
if ret_val != 0 :
fatal_print("non-zero exit value from command: '" + cmd + "'")
Expand All @@ -684,12 +680,10 @@ def ignore_test(testname) :
if ret_val == 0 :
green("Building 64-bit RISCV C emulator", "ok")
else :
print("error: non-zero exit value from command: '" + cmd + "'")
red("Building 64-bit RISCV C emulator","fail")
error_print("non-zero exit value from command: '" + cmd + "'")

TRACE("run_64bit_tests and run_csim : " + str(run_64bit_tests and run_csim))
if run_64bit_tests and run_csim :
TRACE()
for test in glob.glob(DIR + '/' + TESTDIR + '/' + "*") :
debug_print("test: " + test)
if not is_riscv_elf_64(test) :
Expand Down

0 comments on commit 72f5984

Please sign in to comment.