From c2bc38d7e953a7a818bbeff2d56eb2d1765368a5 Mon Sep 17 00:00:00 2001 From: Leon Hiemstra <hiemstra@astron.nl> Date: Mon, 17 Nov 2014 15:01:40 +0000 Subject: [PATCH] enhanced --- .../unb1_test/tb/python/tc_unb1_test.py | 44 ++++++++++++------- 1 file changed, 27 insertions(+), 17 deletions(-) diff --git a/boards/uniboard1/designs/unb1_test/tb/python/tc_unb1_test.py b/boards/uniboard1/designs/unb1_test/tb/python/tc_unb1_test.py index 0a37c5ac14..49229880b8 100644 --- a/boards/uniboard1/designs/unb1_test/tb/python/tc_unb1_test.py +++ b/boards/uniboard1/designs/unb1_test/tb/python/tc_unb1_test.py @@ -48,6 +48,7 @@ Description: ############################################################################### # System imports import sys +import signal import test_case import node_io import pi_system_info @@ -75,17 +76,17 @@ def show_compare_arrays(tc,a,b): return (not False in compared) def test_BG_to_DB(tc,io,cmd): - tc.set_section_id('Test BG - ') - tc.append_log(3, '>>>') - tc.append_log(1, '>>> %s' % help_text(tc,io,cmd)) - tc.append_log(3, '>>>') - if tc.number == 1: use_pps=True - tc.append_log(1, '>>> Using PPS') + tc.set_section_id('Test BG-DB (pps) - ') else: use_pps=False - tc.append_log(1, '>>> NOT Using PPS') + tc.set_section_id('Test BG-DB (nopps) - ') + + tc.append_log(3, '>>>') + tc.append_log(1, '>>> %s' % help_text(tc,io,cmd)) + tc.append_log(3, '>>>') + if use_pps==True: ppsh = pi_ppsh.PiPpsh(tc, io) @@ -377,7 +378,7 @@ def help_text(tc,io,cmd): tc.append_log(0, '') tc.append_log(0, '[reset, load user img] sequence: --seq REGMAP,WDI,REGMAP,REMU,REGMAP,INFO') tc.append_log(0, '[flash+start user img] sequence: --seq FLASH,WDI,REGMAP,REMU,REGMAP,INFO -s file.rbf') - tc.append_log(0, '[re-read info,sensors] sequence: --seq INFO,PPSH,SENSORS --rep 10 -s expected_design_name') + tc.append_log(0, '[re-read info,sensors] sequence: --seq INFO,PPSH,SENSORS --rep -1 -s expected_design_name') tc.append_log(0, '[reset to factory] sequence: --seq WDI,REGMAP') tc.append_log(0, '[program user image] sequence: --seq FLASH -s file.rbf') tc.append_log(0, '[load user image] sequence: --seq REMU,REGMAP') @@ -387,6 +388,9 @@ def help_text(tc,io,cmd): return str +def signal_handler(signal, frame): + print('You pressed Ctrl+C!') + tc.repeat=0 ################################################################################################################## @@ -398,37 +402,41 @@ tc.set_result('PASSED') dgnName = tc.gpString tc.append_log(3, '>>>') tc.append_log(1, '>>> Title : Test bench (%s) on nodes %s, %s' % (sys.argv[0],tc.unb_nodes_string(''),dgnName)) +tc.append_log(1, '>>> Commandline : %s' % " ".join(sys.argv)) tc.append_log(3, '>>>') - + # Create access object for nodes io = node_io.NodeIO(tc.nodeImages, tc.base_ip) +signal.signal(signal.SIGINT, signal_handler) + ################################################################################################################## # Run tests nof_errors = 0 -rep = 0 -while rep < tc.repeat: - rep += 1 +run = 0 +while tc.repeat != 0: # -1 for non-stop + tc.repeat -= 1 + run += 1 tc.append_log(3, '') - tc.append_log(2, 'Rep = %d' % rep) + tc.append_log(2, 'Run = %d' % run) try: for cmd in tc.sequence: - tc.append_log(3, 'Next command: %s : %s: %s' % (cmd,Cmd[cmd][1],Cmd[cmd][2])) + tc.append_log(3, 'Next command: %s' % cmd) - subtc = test_case.Testcase('SUBTB - ', '') + subtc = test_case.Testcase('TB %d (%.02fs) - ' % (run,tc.get_run_time()), '') subtc.set_result('PASSED') - if cmd == 'INFO': # reload node_io: + if cmd == 'REGMAP': # reload node_io: io = Cmd[cmd][0](subtc,io,cmd) else: Cmd[cmd][0](subtc,io,cmd) if subtc.get_result() == 'FAILED': nof_errors+=1 - tc.append_log(3, 'This test FAILED') + tc.append_log(3, 'Testcase FAILED') tc.append_log(3, '>>>') tc.set_result('FAILED') @@ -448,7 +456,9 @@ tc.set_section_id('') tc.append_log(3, '') tc.append_log(3, '>>>') tc.append_log(0, '>>> Test bench result: %s' % tc.get_result()) +tc.append_log(0, '>>> Number of runs=%d' % run) tc.append_log(0, '>>> Number of errors=%d' % nof_errors) +tc.append_log(0, '>>> Runtime=%f seconds (%f hours)' % (tc.get_run_time(),tc.get_run_time()/3600)) tc.append_log(3, '>>>') sys.exit(tc.get_result()) -- GitLab