Commit f5d13a54 authored by Dimitris Lampridis's avatar Dimitris Lampridis

Repository cleanup, restructuring, addition of READMEs, source headers and…

Repository cleanup, restructuring, addition of READMEs, source headers and modification of test02 to run over SSH.
parent f83537f6
# CONV-RS485-OPT-RTM Production Test System (PTS)
This is the repository for the the CONV-RS485-OPT-RTM.
Currently it contains the [software for the Production Test System software (PTS)](pts/), under the
`pts` directory.
#!/bin/bash
source ./set_env.sh
#######################################################################
####################### Make sure that run as root ####################
#######################################################################
#if [ "$EUID" -ne 0 ]
# then echo "Please run as root"
# exit
#fi
#######################################################################
###################### Setting project paths ##########################
#######################################################################
topdirname="opt-pts"
projectpath="."
LOGDIR="${HOME}/Desktop/opt-pts-log/"
#######################################################################
############# Getting absolute path for project #######################
#######################################################################
# if [ -n "$1" ]
# then
# top="$1"
# else
# prg=$0
# if [ ! -e "$prg" ]; then
# case $prg in
# (*/*) exit 1;;
# (*) prg=$(command -v -- "$prg") || exit;;
# esac
# fi
# dir=$(
# cd -P -- "$(dirname -- "$prg")" && pwd -P
# ) || exit
# prg=$dir/$(basename -- "$prg") || exit
# top=$prg
# while true
# do
# if [ `basename "$top"` == "$topdirname" ]
# then
# break;
# else
# top=`dirname "$top"`
# fi
# done
# fi
#######################################################################
####################### Drivers management ############################
#######################################################################
#######################################################################
############################## Logging ################################
#######################################################################
# create log directories
mkdir -p "$LOGDIR"
# get board serial
serial=0000
extra_serial=0000
serial=$1
if [ x$1 = x"" ]; then
echo -n "Please scan CERN serial number bar-code, then press [ENTER]: "
read serial
fi
if [ x$serial = x"" ]; then
serial=0000
fi
extra_serial=$2
if [ x$2 = x"" ]; then
echo -n "If needed input extra serial number and press [ENTER] OR just press [ENTER]: "
read extra_serial
fi
if [ x$extra_serial = x"" ]; then
extra_serial=0000
fi
echo " "
board_plugged=$3
echo -n "---> Now please plug in the board and then press [ENTER]"
read board_plugged
nb_test_limit=2
nb_test=1
#######################################################################
############################## Testing ###############################
#######################################################################
while [ "$nb_test" -le "$nb_test_limit" ]
do
echo "--------------------------------------------------------------"
echo "Test series run $nb_test out of $nb_test_limit"
echo " "
# run tests
#sudo ${top}/pts/pts-opt.py -b pts-opt -s $serial -e $extra_serial "-t${top}/python" -l $LOGDIR 00 01
sudo ./pts.py -b OptRtm -s $serial -e $extra_serial -t./python -l $LOGDIR 00 01 02
# repeat test?
if [ "$nb_test" != "$nb_test_limit" ]
then
echo " "
echo -n "Do you want to run the test series again [y,n]? "
read reply
if [ "$reply" != "y" ]
then
break
fi
fi
nb_test=$(($nb_test+1))
done
echo "--------------------------------------------------------------"
echo " "
echo -n "End of the test, do you want to switch the computer OFF? [y,n]"
read reply
if [ "$reply" = "y" ]
then
sudo poweroff
fi
[DUT.FEC]
MgtHostName = cfvm-774-opt-pts2
MgtPort = 23
MgtUserName = admin
MgtPassword = Gr@nBr@st0
Slot = 5
[CTR.FEC]
MgtHostName = cfvm-774-opt-pts1
MgtPort = 23
MgtUserName = admin
MgtPassword = Gr@nBr@st0
CpuHostName = cfv-774-opt-pts1
CpuPort = 22
# Please set CpuUserName to an account name you have access to on the CTR.FEC
CpuUserName = nobody
# CONV-RS485-OPT-RTM Production Test System (PTS)
This is the software for the the CONV-RS485-OPT-RTM PTS.
To configure it, please edit directly the file `CONFIG.ini`. In particular, please make sure that
you have set `CpuUserName` to an account name you have access to on the Front-End Computer (FEC)
that is hosting the Central Timing Receiver (CTR) cards.
To run it, simply run the `run-pts.sh` script.
**Dependencies:**
- snmp
- python configparser
#!/usr/bin/env python
# Copyright CERN, 2011
# Author: Juan David Gonzalez Cobas <dcobas@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: pts.py
##
## description: Generic PTS framework used for running the various tests and
## logging their outputs.
##
################################################################################
## Copyright CERN 2011-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 cmd
......@@ -21,14 +46,12 @@ import fnmatch
from ConfigParser import ConfigParser, NoOptionError
from optparse import OptionParser
#from sha import sha as sha160
import hashlib
from ptsexcept import *
default_config_file = 'ptsdefault.cfg'
default_log_pattern = '{timestamp}_pts_tst_{runid}_{board}_{serial}_{number}.txt'
default_log_name = '{timestamp}_pts_run_{runid}_{board}_{serial}.txt'
default_zip_name = '{timestamp}_zip_run_{runid}_{board}_{serial}.zip'
default_log_pattern = '{timestamp}_pts_tst_{board}_{serial}_{number}.txt'
default_log_name = '{timestamp}_pts_run_{board}_{serial}.txt'
default_zip_name = '{timestamp}_zip_run_{board}_{serial}.zip'
default_test_pattern = r'test[0-9][0-9]'
default_test_syntax = r'(test)?(\d\d)'
......@@ -77,14 +100,14 @@ def run_test(testname, logname, card, test_path, serial, yes=False):
if yes:
sys.stdin = tmpin
raw_input = original_raw_input
return card
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
......@@ -206,7 +229,7 @@ class Suite(object):
def search_prev_logs(self) :
"""Search for previous logs and ask the operator why repeat the test"""
for filename in os.listdir(self.log_path):
if string.find(filename, "run") == -1 :
continue;
......@@ -217,7 +240,7 @@ class Suite(object):
self.comment = raw_input('Previous logs for this board have been recorded.\nWhy do you want to repeat the test? (press ENTER to finish) : \n')
break;
except AttributeError:
pass
pass
def run(self):
self.comment = ""
......@@ -226,18 +249,14 @@ class Suite(object):
card = None
sequence = self.validate_and_compute_run()
ts = timestamp()
#runid = hashlib.sha(self.board + ':' + self.serial + ':' + ts)
runid = hashlib.sha256(self.board + ':' + self.serial + ':' + ts)
logfilename = self.log_name.format(board=self.board,
serial=self.serial,
timestamp=ts,
runid=runid)
timestamp=ts)
logfilename = os.path.join(self.log_path, logfilename)
log = file(logfilename, 'wb')
zipfilename = self.zip_name.format(board=self.board,
serial=self.serial,
timestamp=ts,
runid=runid)
timestamp=ts)
zipfilename = os.path.join(self.log_path, zipfilename)
ziplist = [ logfilename ]
......@@ -249,9 +268,8 @@ class Suite(object):
' serial = {1}\n'
' optional serial = {2}\n'
' comment = {3}\n'
' timestamp = {4}\n'
' runid = {5}\n'.format(
self.board, self.serial, self.extra_serial, self.comment, ts, runid))
' timestamp = {4}\n'.format(
self.board, self.serial, self.extra_serial, self.comment, ts))
failures = []
for test in sequence:
try:
......@@ -259,8 +277,7 @@ class Suite(object):
shortname= re.match('test(\d\d)', testname).group(1)
logname = self.log_pattern.format(board=self.board,
serial=self.serial,
timestamp=timestamp(),
runid = runid,
timestamp=ts,
number=shortname)
logname = os.path.join(self.log_path, logname)
ziplist.append(logname)
......@@ -322,10 +339,6 @@ class Suite(object):
log.write(msg)
log.close()
# adc_data_files=get_files("/tmp","mfdata*")
# adc_read_script=os.path.abspath("../python/read_samples.py")
# ziplist = ziplist + adc_data_files + [ adc_read_script ]
make_zip(zipfilename, ziplist)
def get_serial():
......@@ -343,19 +356,6 @@ def timestamp():
"""
return datetime.datetime.now().strftime('%Y%m%d.%H%M%S.%f')
def sha(blob, len=7):
"""create a sha-160 hash of a binary object
len is the number of hex digits to take from the hex digest,
defaulting to 7 just as in git
"""
#hash = sha160(blob)
hash = hashlib.sha256(blob)
ret = hash.hexdigest()
if len:
return ret[:len]
class Cli(cmd.Cmd, Suite):
def __init__(self, cfgfilename=default_config_file):
cmd.Cmd.__init__(self)
......@@ -452,33 +452,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
# coding: utf8
#!/usr/bin/env python
################################################################################
## CERN BE-CO-HT
## CONV-RS485-OPT-RTM
## https://www.ohwr.org/projects/conv-rs485-opt-rtm
################################################################################
##
## unit name: ptsexcept.py
##
## description: Generic PTS framework used for running the various tests and
## logging their outputs: common exceptions and handling
##
################################################################################
## Copyright CERN 2011-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
################################################################################
class PtsException(Exception):
pass
......
#!/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 os
import sys
import time
import os, errno, re, sys, struct
import os.path
import traceback
import configparser
# Import common modules
sys.path.append('..')
import ptsexcept
import utilities as util
import vv_skt
from ptsdefine import *
##-------------------------------------------------------------------------------------------------
## main --
##-------------------------------------------------------------------------------------------------
def main (card=None, default_directory='.',suite=None, serial=""):
......@@ -35,24 +51,40 @@ 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']
# Turn on VME crate
os.popen("snmpset -v2c -c %s %s 1.3.6.1.4.1.37968.1.1.7.2.1.3.1 i 0" % (pwrd, ip))
time.sleep(10)
dut = vv_skt.SKT(lun, ip, port, user, pwrd)
###############################################################################
############################ actual test ######################################
###############################################################################
rtm = (dut.vv_read(CSR) >> CSR_RTM_OFS) & 0x3f
rtm = (dut.vv_read(4) >> 16) & 0x3f
if (rtm == 0x05):
test_results['DUT identification']= 1
util.info_msg("DUT identified; detection lines read correctly: 0x%02X" % rtm)
else:
test_results['DUT identification']= 0
util.err_msg("Identified wrong DUT; expected RTM ID 0x05 and received 0x%02X" % rtm)
###############################################################################
########################## result processing ##################################
###############################################################################
###############################################################################
errors = util.summarise_test_results(testname, test_results)
sys.stdout.flush()
return 0;
if __name__ == '__main__' :
main()
#!/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
###TODO: add switching ON of the vme crate
################################################################################
## CERN BE-CO-HT
## CONV-RS485-OPT-RTM
## https://www.ohwr.org/projects/conv-rs485-opt-rtm
################################################################################
##
## unit name: test01.py
##
## description: Test LEDs
##
################################################################################
## 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 sys
import os
......@@ -18,7 +40,7 @@ import ptsexcept
def test_led_all():
util.section_msg("Testing LEDs OFF state")
if not util.ask_user("Are all LEDs OFF now?"):
......@@ -27,29 +49,28 @@ def test_led_all():
util.section_msg("Testing LEDs ON state")
util.user_msg("---> Now make all the front panel connections and press [ENTER]")
ret = raw_input("")
ret = raw_input("")
# switch ON VME crate now..
# loop vv_read of BIDR reg to check when initialization is completed
# loop vv_read of BIDR reg to check when initialization is completed
if not util.ask_user("Are all LEDs ON now?"):
util.err_msg("Some LEDs or other board components might be broken")
return 0
util.info_msg("All LEDs verified successfully!")
return 1
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"] )
###############################################################################
############################ initialization ###################################
###############################################################################
test_results={}
###############################################################################
############################ actual test ######################################
......@@ -63,6 +84,6 @@ def main (card=None, default_directory='.',suite=None, serial=""):
sys.stdout.flush()
return 0;
if __name__ == '__main__' :
main()
\ No newline at end of file
main()
#!/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: test02.py
##
## description: Test all transmitters and receivers by feeding them with a GMT
## signal and verifying that there are no errors on the CTRs.
##
################################################################################
## 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
################################################################################
###TODO: it seems the test passes when there is no CTR in the crate:-o
......@@ -11,17 +36,18 @@ import os
import string
import time
import sys
import configparser
sys.path.append('..')
import utilities as util
import ptsexcept
def get_ctrtest_err(module):
def get_ctrtest_err(user, host, port, module):
cmd = 'echo "mo {0} rst" | /usr/local/bin/ctrtest-timdt | grep -A 7 -e MsMissedErrs | xargs'.format(module)
output = os.popen(cmd).read()
output = os.popen("ssh -p %d %s@%s '%s'" % (port, user, host, cmd)).read()
items = string.split(output)
mserr = '{0} {1} {2}'.format(items[1][1:], items[3][1:], items[4])
......@@ -36,65 +62,72 @@ def main (card=None, default_directory='.',suite=None, serial=""):
testname= "Test02: GMT transmission/ recetion"
util.header_msg( testname, [ "GMT transmission/ reception"] )
###############################################################################
############################ initialization ###################################
###############################################################################
test_results={}
result={}
config = configparser.ConfigParser()
config.read(default_directory + "/../../CONFIG.ini")
host = config['CTR.FEC']['CpuHostName']
port = int(config['CTR.FEC']['CpuPort'])
user = config['CTR.FEC']['CpuUserName']
mgt_ip = config['DUT.FEC']['MgtHostName']
mgt_pwrd = config['DUT.FEC']['MgtPassword']
ms1 = [0, 0, 0, 0]
pll1 = [0, 0, 0, 0]
miss1 = [0, 0, 0, 0]
ms2 = [0, 0, 0, 0]
pll2 = [0, 0, 0, 0]
miss2 = [0, 0, 0, 0]
errors = False
test_results={}
test_results['Ms errors'] = 1
test_results['PLL errors'] = 1
test_results['Missed errors'] = 1
###############################################################################
############################ actual test ######################################