Commit e2b9cd63 authored by Dimitris Lampridis's avatar Dimitris Lampridis

wip cleanup

parent 5179da72
[GENERAL]
BoardName = "opt-rtm"
[DUT-FEC]
MgtHostName = "cfvm-774-opt-pts2"
MgtUserName = "admin"
MgtPassword = "Gr@nBr@st0"
[DUT.FEC]
MgtHostName = cfvm-774-opt-pts2
MgtPort = 23
MgtUserName = admin
MgtPassword = Gr@nBr@st0
Slot = 5
[CTR-FEC]
MgtHostName = "cfvm-774-opt-pts1"
MgtUserName = "admin"
MgtPassword = "Gr@nBr@st0"
CpuHostName = "cfv-774-opt-pts1"
[CTR.FEC]
MgtHostName = cfvm-774-opt-pts1
MgtPort = 23
MgtUserName = admin
MgtPassword = Gr@nBr@st0
CpuHostName = cfv-774-opt-pts1
CpuPort = 22
......@@ -90,18 +90,16 @@ def run_test(testname, logname, card, test_path, serial, yes=False):
try:
tmpout = sys.stdout
sys.stdout = open(logname, 'w')
if yes:
tmpin = sys.stdin
sys.stdin = open('/dev/null')
__builtins__.raw_input = pts_raw_input
tmpin = sys.stdin
sys.stdin = open('/dev/null')
__builtins__.raw_input = pts_raw_input
mod = __import__(testname, globals(), locals(), [])
card = mod.main(card, default_directory=test_path, serial=serial)
finally:
# sys.stdout.close()
sys.stdout = tmpout
if yes:
sys.stdin = tmpin
raw_input = original_raw_input
sys.stdin = tmpin
raw_input = original_raw_input
return card
......@@ -109,7 +107,7 @@ class Suite(object):
def __init__(self, cfgfilename=default_config_file):
self.required = [ 'board', 'serial', 'extra_serial', 'test_path',
'log_path', 'sequence' ]
'log_path', 'sequence' ]
for fieldname in self.required:
self.__setattr__(fieldname, None)
self.config = default_config_file
......@@ -276,7 +274,7 @@ class Suite(object):
' comment = {3}\n'
' timestamp = {4}\n'
' runid = {5}\n'.format(
self.board, self.serial, self.extra_serial, self.comment, ts, runid))
self.board, self.serial, self.extra_serial, self.comment, ts, runid))
failures = []
for test in sequence:
try:
......@@ -473,33 +471,34 @@ def validate_args(args):
def main():
usage = ( '%prog: [options] test ...\n'
'run %prog with option -h or --help for more help' )
'run %prog with option -h or --help for more help' )
parser = OptionParser(usage)
parser.add_option("-c", "--config", dest="config",
default=default_config_file,
help="config file name")
default=default_config_file,
help="config file name")
parser.add_option("-C", "--cli", dest="cli", action="store_true",
help="enter command-line interpreter")
help="enter command-line interpreter")
parser.add_option("-b", "--board", dest="board",
help="board name (e.g. -b SPEC)", metavar="NAME")
help="board name (e.g. -b SPEC)", metavar="NAME")
parser.add_option("-s", "--serial", dest="serial",
help="board serial number", metavar="SERIAL")
help="board serial number", metavar="SERIAL")
parser.add_option("-e", "--extra_serial", dest="extra_serial",
help="another board serial number [Optional]", metavar="SERIAL")
help="another board serial number [Optional]", metavar="SERIAL")
parser.add_option("-t", "--test-path", dest="test_path",
help="path to test files", metavar="PATH")
help="path to test files", metavar="PATH",
default=os.getcwd()+"/tests")
parser.add_option("-l", "--log-path", dest="log_path",
help="path to log files", metavar="PATH")
help="path to log files", metavar="PATH")
parser.add_option("-n", "--ntimes", dest="repeat",
help="number of times to repeat the batch of tests",
metavar="NUMBER")
help="number of times to repeat the batch of tests",
metavar="NUMBER")
parser.add_option("-r", "--randomize", action="store_true",
default=False,
help="run the batch in random order", )
default=False,
help="run the batch in random order", )
parser.add_option("-w", "--write-config", action="store_true",
help="write configuration data to config file", )
help="write configuration data to config file", )
parser.add_option("-y", "--yes", action="store_true",
help="assume all user interventions are affirmative", )
help="assume all user interventions are affirmative", )
(options, args) = parser.parse_args()
......
#!/usr/bin/env python
# Copyright CERN, 2019
# Author: <Dimitris.Lampridis@cern.ch>, <Evangelia.Gousiou@cern.ch>
# Licence: GPL v2 or later.
# Website: http://www.ohwr.org
################################################################################
## CERN BE-CO-HT
## CONV-RS485-OPT-RTM
## https://www.ohwr.org/projects/conv-rs485-opt-rtm
################################################################################
##
## unit name: test00.py
##
## description: Test for reading out the RTM ID over I2C
##
################################################################################
## Copyright CERN 2019
################################################################################
##
## 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 <https://www.gnu.org/licenses/>.
##
## SPDX-License-Identifier: GPL-3.0-or-later
################################################################################
# Import system modules
import sys
......@@ -11,6 +35,7 @@ import time
import os, errno, re, sys, struct
import os.path
import traceback
import configparser
# Import common modules
sys.path.append('..')
......@@ -19,11 +44,6 @@ import utilities as util
import vv_skt
from ptsdefine import *
##-------------------------------------------------------------------------------------------------
## main --
##-------------------------------------------------------------------------------------------------
def main (card=None, default_directory='.',suite=None, serial=""):
testname= "Test00: DUT identification"
......@@ -35,7 +55,17 @@ def main (card=None, default_directory='.',suite=None, serial=""):
util.section_msg("I2C to read RTM ID")
test_results={}
dut = vv_skt.SKT()
config = configparser.ConfigParser()
config.read(default_directory + "/../../CONFIG.ini")
lun = int(config['DUT.FEC']['Slot'])
ip = config['DUT.FEC']['MgtHostName']
port = int(config['DUT.FEC']['MgtPort'])
user = config['DUT.FEC']['MgtUserName']
pwrd = config['DUT.FEC']['MgtPassword']
dut = vv_skt.SKT(lun, ip, port, user, pwrd)
###############################################################################
############################ actual test ######################################
......
......@@ -42,7 +42,7 @@ def test_led_all():
def main (card=None, default_directory='.',suite=None, serial=""):
testname= "Test00: LEDs and basic connectivity"
testname= "Test01: LEDs and basic connectivity"
util.header_msg( testname, [ "LED connectivity"] )
###############################################################################
......
#! /usr/bin/python
# coding: utf8
# Copyright CERN, 2014
# Author: Julian Lewis <julian.lewis@cern.ch>
# Theodor Stana <t.stana@cern.ch>
# Licence: GPL v2 or later.
# Website: http://www.ohwr.org
#!/usr/bin/env python
################################################################################
## CERN BE-CO-HT
## CONV-RS485-OPT-RTM
## https://www.ohwr.org/projects/conv-rs485-opt-rtm
################################################################################
##
## unit name: vv_skt.py
##
## description: A simple python class to handle Telnet communication with an
## ELMA crate.
##
################################################################################
## Copyright CERN 2014-2019
################################################################################
##
## 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 <https://www.gnu.org/licenses/>.
##
## SPDX-License-Identifier: GPL-3.0-or-later
################################################################################
import sys
import time
......@@ -22,24 +45,21 @@ import utilities as util
class SKT:
def __init__(self, lun=None):
def __init__(self, lun, ip, port, user, pwrd):
""" Telnet access over a socket to ELMA I2C bus
"""
slot = int(os.environ['ELMASLOT'])
if type(lun) == type(slot):
self.lun = lun
else:
self.lun = slot
#raise PtsWarning("Warning: SKT __init__: Bad lun=(slot), default to %s" % slot)
self.base = 0;
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((os.environ['ELMAIP'], 23))
self.lun = lun
self.ip = ip
self.port = port
self.user = user
self.pwrd = pwrd
addr = (self.ip, self.port)
s = socket.create_connection(addr)
s.recv(256)
s.send("admin\r\n")
s.send("%s\r\n" % self.user)
s.recv(256)
s.send(os.environ['ELMAPWD'] + "\r\n")
s.send("%s\r\n" % self.pwrd)
s.recv(256)
self.handle = s
......@@ -48,14 +68,11 @@ class SKT:
ver = self.handle.recv(256)
pos = ver.find("Software version")
if (pos == -1):
util.crit_msg("Crate %s not responding as expected" % os.environ['ELMAIP'])
#print("Unexpected response from \"version\" command, exiting...")
#self.close()
util.crit_msg("Crate %s not responding as expected" % self.addr)
sys.exit(2)
ver = float(ver[pos+17:pos+21])
self.ver = ver
def vv_read(self, byte_offset):
""" Read from the application FPGA via ELMA telnet
The byte offset will be aligned to D32
......
#!/bin/bash
#!/bin/sh
################################################################################
## CERN BE-CO-HT
## CONV-RS485-OPT-RTM
......@@ -29,7 +29,9 @@
## SPDX-License-Identifier: GPL-3.0-or-later
################################################################################
LOGDIR="log/"
BOARD="OptRtm"
LOGDIR=`pwd`"/log/"
mkdir -p "$LOGDIR"
......@@ -64,7 +66,9 @@ echo -n "---> Now please plug in the board and then press [ENTER]"
read board_plugged
# run tests
./pts.py -b OptRtm -s $serial -e $extra_serial -t./tests -l $LOGDIR 00 01 02
cd python
python pts.py -b $BOARD -s $serial -e $extra_serial -l $LOGDIR 00 01 02
cd ..
echo
echo "---------------"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment