Skip to content
Snippets Groups Projects
Commit 0cc264aa authored by Kenneth Hiemstra's avatar Kenneth Hiemstra
Browse files

move testcase to design tb/python

parent c1e89143
Branches
No related tags found
No related merge requests found
#! /usr/bin/env python
###############################################################################
#
# Copyright (C) 2014
# ASTRON (Netherlands Institute for Radio Astronomy) <http://www.astron.nl/>
# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
###############################################################################
"""Test case for unb1_minimal
Usage:
--rep = number of intervals that diagnostics results are verified
--sim targets a running simulation.
Description:
This test case tests:
- system info
- read sensors
- read ppsh
- read status 1GbE
- write to wdi to force reload from bank 0
- flash access: write image to bank 1
- remote update: start image in bank 1
"""
###############################################################################
# System imports
import sys
import test_case
import node_io
import pi_system_info
import pi_unb_sens
import pi_ppsh
import pi_wdi
import pi_epcs
import pi_remu
import pi_eth
from tools import *
from common import *
def test_info(tc, io):
tc.set_section_id('Read System Info - ')
tc.append_log(3, '>>>')
tc.append_log(1, '>>> Access the PIO_SYSTEM_INFO peripheral (pi_system_info.py)')
tc.append_log(3, '>>>')
info = pi_system_info.PiSystemInfo(tc, io)
info.make_register_info()
tc.append_log(3, '')
info.read_reg_map()
tc.append_log(3, '')
info.read_system_info()
tc.append_log(3, '')
info.read_use_phy()
tc.append_log(3, '')
info.read_design_name()
tc.append_log(3, '')
info.read_stamps()
tc.append_log(3, '')
info.read_design_note()
def test_sensors(tc, io):
tc.set_section_id('Read sensors - ')
tc.append_log(3, '>>>')
tc.append_log(1, '>>> Access the REG_UNB_SENS peripheral (pi_unb_sens.py)')
tc.append_log(3, '>>>')
sens = pi_unb_sens.PiUnbSens(tc, io)
sens.read_unb_sensors()
tc.append_log(3, '')
sens.read_fpga_temperature()
tc.append_log(3, '')
sens.read_eth_temperature()
tc.append_log(3, '')
sens.read_unb_current()
sens.read_unb_voltage()
sens.read_unb_power()
def test_ppsh(tc,io):
tc.set_section_id('Read PPSH capture count - ')
tc.append_log(3, '>>>')
tc.append_log(1, '>>> Access the PIO_PPS peripheral (pi_ppsh.py)')
tc.append_log(3, '>>>')
Ppsh = pi_ppsh.PiPpsh(tc, io)
Ppsh.read_ppsh_capture_cnt()
tc.append_log(3, '')
def test_wdi(tc,io):
tc.set_section_id('Reset to image in bank 0 using WDI - ')
tc.append_log(3, '>>>')
tc.append_log(1, '>>> Access the REG_WDI peripheral (pi_wdi.py)')
tc.append_log(3, '>>>')
Wdi = pi_wdi.PiWdi(tc, io)
Wdi.write_wdi_override()
tc.append_log(3, '')
def test_remu(tc,io):
tc.set_section_id('REMU start image in bank 1 - ')
tc.append_log(3, '>>>')
tc.append_log(1, '>>> REMU (pi_remu.py)')
tc.append_log(3, '>>>')
Remu = pi_remu.PiRemu(tc, io)
try:
Remu.write_user_reconfigure()
except:
pass # ignoring FAILED
tc.append_log(3, '')
def test_eth(tc,io):
tc.set_section_id('ETH status - ')
tc.append_log(3, '>>>')
tc.append_log(1, '>>> ETH (pi_eth.py)')
tc.append_log(3, '>>>')
eth = pi_eth.PiEth(tc, io)
hdr=eth.read_hdr(0)
eth.disassemble_hdr(hdr)
tc.append_log(3, '')
def test_flash(tc,io):
tc.set_section_id('Flash write to bank 1 - ')
tc.append_log(3, '>>>')
tc.append_log(1, '>>> Write to flash (pi_epcs.py)')
tc.append_log(3, '>>>')
Epcs = pi_epcs.PiEpcs(tc, io)
path_to_rbf = instanceName = tc.gpString
Epcs.write_raw_binary_file("user", path_to_rbf)
tc.append_log(3, '')
tc.set_section_id('Flash read/verify bank 1 - ')
tc.append_log(3, '>>>')
tc.append_log(1, '>>> Read from flash (pi_epcs.py)')
tc.append_log(3, '>>>')
path_to_rbf = instanceName = tc.gpString
Epcs.read_and_verify_raw_binary_file("user", path_to_rbf)
tc.append_log(3, '')
def sleep(tc,io):
tc.append_log(3, 'sleeping 1 second')
tc.sleep(1.0)
def show_help(tc,io):
help_text(tc,io)
# Avaliable commands
Cmd = {
0 : ('SLEEP' , sleep, 'Sleep 1 second'),
1 : ('INFO' , test_info, 'using pi_system_info to read system info'),
2 : ('SENSORS', test_sensors, 'using pi_unb_sens to readout sensors'),
3 : ('PPSH' , test_ppsh, 'using pi_ppsh to read PPSH capture count'),
4 : ('WDI' , test_wdi, 'using pi_wdi to reset to image in bank 0'),
5 : ('FLASH' , test_flash, 'using pi_epcs to program/verify flash'),
6 : ('REMU' , test_remu, 'using pi_remu to load user image'),
7 : ('ETH' , test_eth, 'using pi_eth to read eth status'),
100 : ('HELP' , show_help, 'show help on commands')
}
def help_text(tc,io):
tc.append_log(0, '>>> Usage [--cmd <command number or series of numbers>]:')
for cmd in sorted(Cmd):
tc.append_log(0, ' . %d : %s: %s' % (cmd,Cmd[cmd][0],Cmd[cmd][2]))
tc.append_log(0, '')
tc.append_log(0, '[full test] sequence: --cmd 1,4,0,0,0,0,1,5,6,0,0,0,1,2,3 -s file.rbf')
tc.append_log(0, '[image start and test] sequence: --cmd 1,4,0,0,0,0,1,6,0,0,0,1,2,3')
tc.append_log(0, '[read info,sensors] sequence: --cmd 1,2,3 --rep 10')
###############################################################################
# Setup
# Create a test case object
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_minimal.py on nodes %s, %s' % (tc.unb_nodes_string(''),dgnName))
tc.append_log(3, '>>>')
# Create access object for nodes
io = node_io.NodeIO(tc.nodeImages, tc.base_ip)
rep = 0
while rep < tc.repeat:
rep += 1
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]))
Cmd[cmd][1](tc,io)
###############################################################################
###############################################################################
# End
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(3, '>>>')
sys.exit(tc.get_result())
#! /usr/bin/env python
###############################################################################
#
# Copyright (C) 2014
# ASTRON (Netherlands Institute for Radio Astronomy) <http://www.astron.nl/>
# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
###############################################################################
"""Test case for unb1_test
Usage:
--rep = number of intervals that diagnostics results are verified
--sim targets a running simulation.
Description:
This test case tests:
- system info
- read sensors
- read ppsh
- write to wdi to force reload from bank 0
- flash access: write image to bank 1
- remote update: start image in bank 1
- read status MAC 10GbE
- read status PHY XAUI
- BG - DB tests for 1 port on 1 FPGA
- BG - DB tests for all ports on all FPGAs
- link test between ports on the same FPGA (same XO)
- link test between ports on different Uniboards (XO drift)
- stable link after image restart
"""
###############################################################################
# System imports
import sys
import test_case
import node_io
import pi_system_info
import pi_unb_sens
import pi_ppsh
import pi_wdi
import pi_epcs
import pi_remu
import pi_eth
from tools import *
from common import *
def test_info(tc, io):
tc.set_section_id('Read System Info - ')
tc.append_log(3, '>>>')
tc.append_log(1, '>>> Access the PIO_SYSTEM_INFO peripheral (pi_system_info.py)')
tc.append_log(3, '>>>')
info = pi_system_info.PiSystemInfo(tc, io)
info.make_register_info()
tc.append_log(3, '')
info.read_reg_map()
tc.append_log(3, '')
info.read_system_info()
tc.append_log(3, '')
info.read_use_phy()
tc.append_log(3, '')
info.read_design_name()
tc.append_log(3, '')
info.read_stamps()
tc.append_log(3, '')
info.read_design_note()
def test_sensors(tc, io):
tc.set_section_id('Read sensors - ')
tc.append_log(3, '>>>')
tc.append_log(1, '>>> Access the REG_UNB_SENS peripheral (pi_unb_sens.py)')
tc.append_log(3, '>>>')
sens = pi_unb_sens.PiUnbSens(tc, io)
sens.read_unb_sensors()
tc.append_log(3, '')
sens.read_fpga_temperature()
tc.append_log(3, '')
sens.read_eth_temperature()
tc.append_log(3, '')
sens.read_unb_current()
sens.read_unb_voltage()
sens.read_unb_power()
def test_ppsh(tc,io):
tc.set_section_id('Read PPSH capture count - ')
tc.append_log(3, '>>>')
tc.append_log(1, '>>> Access the PIO_PPS peripheral (pi_ppsh.py)')
tc.append_log(3, '>>>')
Ppsh = pi_ppsh.PiPpsh(tc, io)
Ppsh.read_ppsh_capture_cnt()
tc.append_log(3, '')
def test_wdi(tc,io):
tc.set_section_id('Reset to image in bank 0 using WDI - ')
tc.append_log(3, '>>>')
tc.append_log(1, '>>> Access the REG_WDI peripheral (pi_wdi.py)')
tc.append_log(3, '>>>')
Wdi = pi_wdi.PiWdi(tc, io)
Wdi.write_wdi_override()
tc.append_log(3, '')
def test_remu(tc,io):
tc.set_section_id('REMU start image in bank 1 - ')
tc.append_log(3, '>>>')
tc.append_log(1, '>>> REMU (pi_remu.py)')
tc.append_log(3, '>>>')
Remu = pi_remu.PiRemu(tc, io)
try:
Remu.write_user_reconfigure()
except:
pass # ignoring FAILED
tc.append_log(3, '')
def test_eth(tc,io):
tc.set_section_id('ETH status - ')
tc.append_log(3, '>>>')
tc.append_log(1, '>>> ETH (pi_eth.py)')
tc.append_log(3, '>>>')
eth = pi_eth.PiEth(tc, io)
hdr=eth.read_hdr(0)
eth.disassemble_hdr(hdr)
tc.append_log(3, '')
def test_flash(tc,io):
tc.set_section_id('Flash write to bank 1 - ')
tc.append_log(3, '>>>')
tc.append_log(1, '>>> Write to flash (pi_epcs.py)')
tc.append_log(3, '>>>')
Epcs = pi_epcs.PiEpcs(tc, io)
path_to_rbf = instanceName = tc.gpString
Epcs.write_raw_binary_file("user", path_to_rbf)
tc.append_log(3, '')
tc.set_section_id('Flash read/verify bank 1 - ')
tc.append_log(3, '>>>')
tc.append_log(1, '>>> Read from flash (pi_epcs.py)')
tc.append_log(3, '>>>')
path_to_rbf = instanceName = tc.gpString
Epcs.read_and_verify_raw_binary_file("user", path_to_rbf)
tc.append_log(3, '')
def sleep(tc,io):
tc.append_log(3, 'sleeping 1 second')
tc.sleep(1.0)
def show_help(tc,io):
help_text(tc,io)
# Avaliable commands
Cmd = {
0 : ('SLEEP' , sleep, 'Sleep 1 second'),
1 : ('INFO' , test_info, 'using pi_system_info to read system info'),
2 : ('SENSORS', test_sensors, 'using pi_unb_sens to readout sensors'),
3 : ('PPSH' , test_ppsh, 'using pi_ppsh to read PPSH capture count'),
4 : ('WDI' , test_wdi, 'using pi_wdi to reset to image in bank 0'),
5 : ('FLASH' , test_flash, 'using pi_epcs to program/verify flash'),
6 : ('REMU' , test_remu, 'using pi_remu to load user image'),
7 : ('ETH' , test_eth, 'using pi_eth to read eth status'),
100 : ('HELP' , show_help, 'show help on commands')
}
def help_text(tc,io):
tc.append_log(0, '>>> Usage [--cmd <command number or series of numbers>]:')
for cmd in sorted(Cmd):
tc.append_log(0, ' . %d : %s: %s' % (cmd,Cmd[cmd][0],Cmd[cmd][2]))
tc.append_log(0, '')
tc.append_log(0, '[full test] sequence: --cmd 1,4,0,0,0,0,1,5,6,0,0,0,1,2,3 -s file.rbf')
tc.append_log(0, '[image start and test] sequence: --cmd 1,4,0,0,0,0,1,6,0,0,0,1,2,3')
tc.append_log(0, '[read info,sensors] sequence: --cmd 1,2,3 --rep 10')
###############################################################################
# Setup
# Create a test case object
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(3, '>>>')
# Create access object for nodes
io = node_io.NodeIO(tc.nodeImages, tc.base_ip)
rep = 0
while rep < tc.repeat:
rep += 1
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]))
Cmd[cmd][1](tc,io)
###############################################################################
###############################################################################
# End
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(3, '>>>')
sys.exit(tc.get_result())
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment