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 c451fe452a2360cecfe53621116b973d95216a02..170cd7a015329af1960a3dcee7319d2eb6de9273 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 @@ -74,12 +74,20 @@ def show_compare_arrays(tc,a,b): tc.append_log(5, 'Result:\n%s' % compared) return (not False in compared) -def test_BG_to_DB(tc,io,cmd,use_pps=False): +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') + else: + use_pps=False + tc.append_log(1, '>>> NOT Using PPS') + + if use_pps==True: ppsh = pi_ppsh.PiPpsh(tc, io) tc.set_section_id('Read - ') @@ -143,10 +151,6 @@ def test_BG_to_DB(tc,io,cmd,use_pps=False): show_compare_arrays(tc,bg_ram,db_ram) Bg.write_disable() -def test_BG_to_DB_pps(tc,io,cmd): - return test_BG_to_DB(tc,io,cmd,use_pps=True) - - def test_tr_xaui(tc,io,cmd): tc.set_section_id('Read tr xaui status - ') @@ -264,6 +268,8 @@ def test_wdi(tc,io,cmd): Wdi = pi_wdi.PiWdi(tc, io) Wdi.write_wdi_override() tc.append_log(3, '') + tc.append_log(3, '>>> Booting...') + tc.sleep(5.0) @@ -285,6 +291,8 @@ def test_remu(tc,io,cmd): if dummy_tc.get_result() == 'FAILED': tc.append_log(1, 'Result=%s but ignoring this' % dummy_tc.get_result()) + tc.append_log(3, '>>> Booting...') + tc.sleep(5.0) tc.append_log(3, '') @@ -325,63 +333,55 @@ def test_flash(tc,io,cmd): def sleep(tc,io,cmd): - tc.set_section_id('%s - ' % cmd_text(cmd)) + tc.set_section_id('%s - ' % cmd) tc.append_log(1, '>>> %s' % help_text(tc,io,cmd)) - if cmd == 0: + if cmd == 'sleep1': tc.sleep(1.0) - elif cmd == 1: + elif cmd == 'sleep5': tc.sleep(5.0) def show_help(tc,io,cmd): - help_text(tc,io,100) - -def show_example(tc,io,cmd): + tc.set_section_id('%s - ' % cmd) tc.append_log(1, '>>> %s' % help_text(tc,io,cmd)) - help_text(tc,io,101) # Avaliable commands -Cmd = { - 0 : ('SLEEP1' , sleep, 'Sleep 1 second',''), - 1 : ('SLEEP5' , sleep, 'Sleep 5 seconds',''), - 2 : ('REGMAP' , read_regmap, 'using pi_system_info to read register info (access PIO_SYSTEM_INFO) and store REGMAPs',''), - 3 : ('INFO' , test_info, 'using pi_system_info to read system info (access PIO_SYSTEM_INFO)','(-s for expected design_name)'), - 4 : ('FLASH' , test_flash, 'using pi_epcs to program/verify flash','(-s for .rbf file)'), - 5 : ('SENSORS', test_sensors, 'using pi_unb_sens to readout sensors (access REG_UNB_SENS)',''), - 6 : ('PPSH' , test_ppsh, 'using pi_ppsh to read PPSH capture count (access PIO_PPS)',''), - 7 : ('ETH' , test_eth, 'using pi_eth to read eth status',''), - 8 : ('REMU' , test_remu, 'using pi_remu to load user image (access REG_REMU)',''), - 9 : ('WDI' , test_wdi, 'using pi_wdi to reset to image in bank 0 (access REG_WDI)',''), - 10 : ('XAUI' , test_tr_xaui, 'using pi_tr_xaui to read xaui status (access REG_TR_XAUI)',''), - 11 : ('10GBE' , test_tr_10GbE,'using pi_tr_10GbE to read 10GbE status (access REG_TR_10GBE)',''), - 12 : ('BSN' , test_bsn_mon, 'using pi_bsn_monitor to read BSN monitor (access REG_BSN_MONITOR)',''), - 13 : ('BGDB' , test_BG_to_DB,'using BG (pi_diag_block_gen.py) and DB (pi_diag_data_buffer.py)','(--sp for addressing streams)'), - 14 : ('BGDBpps', test_BG_to_DB_pps,'using BG (pi_diag_block_gen.py) and DB (pi_diag_data_buffer.py) using PPS','(--sp for addressing streams)'), - 15 : ('EXAMPLE', show_example, 'show several example commands',''), - 100 : ('HELP' , show_help, 'show help on commands','') -} - -def cmd_text(cmd): - return Cmd[cmd][0] +Cmd = dict() +Cmd['REGMAP'] = (read_regmap, 'using pi_system_info to read register info (access PIO_SYSTEM_INFO) and store REGMAPs','') +Cmd['INFO'] = (test_info, 'using pi_system_info to read system info (access PIO_SYSTEM_INFO)','(-s for expected design_name)') +Cmd['FLASH'] = (test_flash, 'using pi_epcs to program/verify flash','(-s for .rbf file)') +Cmd['SENSORS'] = (test_sensors, 'using pi_unb_sens to readout sensors (access REG_UNB_SENS)','') +Cmd['PPSH'] = (test_ppsh, 'using pi_ppsh to read PPSH capture count (access PIO_PPS)','') +Cmd['ETH'] = (test_eth, 'using pi_eth to read eth status','') +Cmd['REMU'] = (test_remu, 'using pi_remu to load user image (access REG_REMU)','') +Cmd['WDI'] = (test_wdi, 'using pi_wdi to reset to image in bank 0 (access REG_WDI)','') +Cmd['XAUI'] = (test_tr_xaui, 'using pi_tr_xaui to read xaui status (access REG_TR_XAUI)','') +Cmd['10GBE'] = (test_tr_10GbE,'using pi_tr_10GbE to read 10GbE status (access REG_TR_10GBE)','') +Cmd['BSN'] = (test_bsn_mon, 'using pi_bsn_monitor to read BSN monitor (access REG_BSN_MONITOR)','') +Cmd['BGDB'] = (test_BG_to_DB,'using BG (pi_diag_block_gen.py) and DB (pi_diag_data_buffer.py)','(--sp for addressing streams, -n1 for use pps)') +Cmd['sleep1'] = (sleep, 'Sleep 1 second','') +Cmd['sleep5'] = (sleep, 'Sleep 5 seconds','') +Cmd['example'] = (show_help, 'show several example commands','') +Cmd['help'] = (show_help, 'show help on commands','') + def help_text(tc,io,cmd): str='' - if cmd == 100: - tc.append_log(0, '>>> Usage [--cmd <command number or series of numbers>]:') + if cmd == 'help': + tc.append_log(0, '>>> Usage [--seq <command(s) separated by ",">]:') for cmd in sorted(Cmd): - tc.append_log(0, ' . %d : %s: %s : %s' % (cmd,Cmd[cmd][0],Cmd[cmd][2],Cmd[cmd][3])) - elif cmd == 101: # examples + tc.append_log(0, ' . %s\t%s %s' % (cmd,Cmd[cmd][1],Cmd[cmd][2])) + elif cmd == 'example': tc.append_log(0, '') - tc.append_log(0, '[reset, load user img] sequence: --cmd 2,9,1,2,9,1,2,8,1,2') - # ^fact ^fact ^user - tc.append_log(0, '[flash+start user img] sequence: --cmd 2,4,9,1,2,8,1,2 -s file.rbf') - # ^fact ^user - tc.append_log(0, '[re-read info,sensors] sequence: --cmd 3,5,6 --rep 10 -s expected_design_name') - tc.append_log(0, '[reset to factory] sequence: --cmd 2,9,1,2') - tc.append_log(0, '[program user image] sequence: --cmd 4 -s file.rbf') - tc.append_log(0, '[load user image] sequence: --cmd 8,1,2') + 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, '[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') + tc.append_log(0, '[modelsim BG-DB test] arguments: --unb 0 --fn 0 --seq BGDB --sim --sp 0:2') else: - str = Cmd[cmd][2] + str = Cmd[cmd][1] return str @@ -395,15 +395,13 @@ tc = test_case.Testcase('TB - ', '') tc.set_result('PASSED') dgnName = tc.gpString tc.append_log(3, '>>>') -tc.append_log(1, '>>> Title : Test bench for tc_unb1_test.py on nodes %s, %s' % (tc.unb_nodes_string(''),dgnName)) +tc.append_log(1, '>>> Title : Test bench (%s) on nodes %s, %s' % (sys.argv[0],tc.unb_nodes_string(''),dgnName)) tc.append_log(3, '>>>') # Create access object for nodes io = node_io.NodeIO(tc.nodeImages, tc.base_ip) - - ################################################################################################################## # Run tests rep = 0 @@ -412,15 +410,21 @@ while rep < tc.repeat: tc.append_log(3, '') tc.append_log(2, 'Rep = %d' % rep) - for cmd in tc.commands: - if cmd > len(Cmd): cmd = 100 # default to help_text - tc.append_log(3, 'Next command: %d : %s: %s' % (cmd,Cmd[cmd][0],Cmd[cmd][2])) - - if cmd == 2: # reload node_io: - io = Cmd[cmd][1](tc,io,cmd) - else: - Cmd[cmd][1](tc,io,cmd) - + try: + for cmd in tc.sequence: + tc.append_log(3, 'Next command: %s : %s: %s' % (cmd,Cmd[cmd][1],Cmd[cmd][2])) + + if cmd == 'INFO': # reload node_io: + io = Cmd[cmd][0](tc,io,cmd) + else: + Cmd[cmd][0](tc,io,cmd) + + except KeyError: + print 'Unknown command:',cmd + cmd='help' + Cmd[cmd][0](tc,io,cmd) + except: + print 'Catched error:',sys.exc_info()[0]