tps: change tps for pts (Production Test Suite). Added license

parent 214b6c87
Production Test Suite, automatized tests for OHWR boards.
Copyright (C) 2011 CERN
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 2 of the License, or
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/>.
This is the infamous Test Production Suite facility, This is Production Test Suite project.
aka TPS of "Office Space" fame.
Supporting automated hardware testing at BE/CO/HT Supporting automated hardware testing at BE/CO/HT
since 2011 or even less since 2011 or even less
License: GPL v2 or later
...@@ -21,18 +21,18 @@ import string ...@@ -21,18 +21,18 @@ import string
from ConfigParser import ConfigParser, NoOptionError from ConfigParser import ConfigParser, NoOptionError
from optparse import OptionParser from optparse import OptionParser
from sha import sha as sha160 from sha import sha as sha160
from tpsexcept import * from ptsexcept import *
default_config_file = 'tpsdefault.cfg' default_config_file = 'ptsdefault.cfg'
default_log_pattern = 'tps_tst_{runid}_{timestamp}_{board}_{serial}_{number}.txt' default_log_pattern = 'pts_tst_{runid}_{timestamp}_{board}_{serial}_{number}.txt'
default_log_name = 'tps_run_{runid}_{timestamp}_{board}_{serial}.txt' default_log_name = 'pts_run_{runid}_{timestamp}_{board}_{serial}.txt'
default_zip_name = 'zip_run_{runid}_{timestamp}_{board}_{serial}.zip' default_zip_name = 'zip_run_{runid}_{timestamp}_{board}_{serial}.zip'
default_test_pattern = r'test[0-9][0-9]' default_test_pattern = r'test[0-9][0-9]'
default_test_syntax = r'(test)?(\d\d)' default_test_syntax = r'(test)?(\d\d)'
original_raw_input = raw_input original_raw_input = raw_input
def tps_raw_input(msg, default='y'): def pts_raw_input(msg, default='y'):
try: try:
ret = original_raw_input(msg) ret = original_raw_input(msg)
except EOFError: except EOFError:
...@@ -55,7 +55,7 @@ def run_test(testname, logname, yes=False): ...@@ -55,7 +55,7 @@ def run_test(testname, logname, yes=False):
if yes: if yes:
tmpin = sys.stdin tmpin = sys.stdin
sys.stdin = open('/dev/null') sys.stdin = open('/dev/null')
__builtins__.raw_input = tps_raw_input __builtins__.raw_input = pts_raw_input
mod = __import__(testname, globals(), locals(), []) mod = __import__(testname, globals(), locals(), [])
mod.main(default_directory='./test/spec/python') mod.main(default_directory='./test/spec/python')
finally: finally:
...@@ -93,7 +93,7 @@ class Suite(object): ...@@ -93,7 +93,7 @@ class Suite(object):
except IOError: except IOError:
errmsg = 'could not read configuration file {0}' errmsg = 'could not read configuration file {0}'
errmsg = errmsg.format(self.config) errmsg = errmsg.format(self.config)
raise TpsCritical(errmsg) raise PtsCritical(errmsg)
config = ConfigParser(cfg) config = ConfigParser(cfg)
try: try:
...@@ -131,10 +131,10 @@ class Suite(object): ...@@ -131,10 +131,10 @@ class Suite(object):
if not self.board: if not self.board:
msg = 'invalid board name [{0}]'.format(self.board) msg = 'invalid board name [{0}]'.format(self.board)
raise TpsInvalid(msg) raise PtsInvalid(msg)
if not self.serial: if not self.serial:
msg = 'invalid serial number [{0}]'.format(self.serial) msg = 'invalid serial number [{0}]'.format(self.serial)
raise TpsInvalid(msg) raise PtsInvalid(msg)
# self.serial = self.serial.strip(',') # self.serial = self.serial.strip(',')
if not self.extra_serial: if not self.extra_serial:
self.extra_serial = '0000' self.extra_serial = '0000'
...@@ -150,7 +150,7 @@ class Suite(object): ...@@ -150,7 +150,7 @@ class Suite(object):
pass pass
except IOError: except IOError:
msg = 'invalid test path [{0}]'.format(self.test_path) msg = 'invalid test path [{0}]'.format(self.test_path)
raise TpsInvalid(msg) raise PtsInvalid(msg)
try: try:
tmp = os.tempnam(self.log_path) tmp = os.tempnam(self.log_path)
...@@ -160,7 +160,7 @@ class Suite(object): ...@@ -160,7 +160,7 @@ class Suite(object):
pass pass
except: except:
msg = 'invalid log path [{0}]'.format(self.log_path) msg = 'invalid log path [{0}]'.format(self.log_path)
raise TpsInvalid(msg) raise PtsInvalid(msg)
if not self.repeat: if not self.repeat:
self.repeat = 1 self.repeat = 1
...@@ -169,17 +169,17 @@ class Suite(object): ...@@ -169,17 +169,17 @@ class Suite(object):
self.repeat = int(self.repeat) self.repeat = int(self.repeat)
except ValueError: except ValueError:
msg = 'invalid repeat factor [{0}]'.format(self.repeat) msg = 'invalid repeat factor [{0}]'.format(self.repeat)
raise TpsInvalid(msg) raise PtsInvalid(msg)
if not self.sequence: if not self.sequence:
raise TpsNoBatch('null test sequence') raise PtsNoBatch('null test sequence')
run = [] run = []
for testno in self.sequence: for testno in self.sequence:
test_glob = os.path.join(self.test_path, 'test' + testno + '.py') test_glob = os.path.join(self.test_path, 'test' + testno + '.py')
files = glob.glob(test_glob) files = glob.glob(test_glob)
if not files: if not files:
print files, test_glob print files, test_glob
raise TpsBadTestNo('no test number [%s], aborting' % testno) raise PtsBadTestNo('no test number [%s], aborting' % testno)
run.append(files[0]) run.append(files[0])
if self.randomize: if self.randomize:
...@@ -252,17 +252,17 @@ class Suite(object): ...@@ -252,17 +252,17 @@ class Suite(object):
log.write('running test {0} = {1}\n'.format(shortname, test)) log.write('running test {0} = {1}\n'.format(shortname, test))
print 'running test ' + shortname print 'running test ' + shortname
run_test(testname, logname, yes=self.yes) run_test(testname, logname, yes=self.yes)
except TpsCritical, e: except PtsCritical, e:
print 'test [%s]: critical error, aborting: [%s]' % (shortname, e) print 'test [%s]: critical error, aborting: [%s]' % (shortname, e)
log.write(' critical error in test {0}, exception [{1}]\n'.format(shortname, e)) log.write(' critical error in test {0}, exception [{1}]\n'.format(shortname, e))
log.write(' cannot continue, aborting test suite') log.write(' cannot continue, aborting test suite')
failures.append((shortname, e, )) failures.append((shortname, e, ))
break break
except TpsError, e: except PtsError, e:
print 'test [%s]: error, continuing: [%s]' % (shortname, e) print 'test [%s]: error, continuing: [%s]' % (shortname, e)
log.write(' error in test {0}, exception [{1}]\n'.format(shortname, e)) log.write(' error in test {0}, exception [{1}]\n'.format(shortname, e))
failures.append((shortname, e, )) failures.append((shortname, e, ))
except TpsUser, e: except PtsUser, e:
print 'test [%s]: user error, user intervention required: [%s]' % (shortname, e) print 'test [%s]: user error, user intervention required: [%s]' % (shortname, e)
log.write(' error in test {0}, exception [{1}]\n'.format(shortname, e)) log.write(' error in test {0}, exception [{1}]\n'.format(shortname, e))
failures.append((shortname, e, )) failures.append((shortname, e, ))
...@@ -280,7 +280,7 @@ class Suite(object): ...@@ -280,7 +280,7 @@ class Suite(object):
elif ans == 'c': elif ans == 'c':
log.write(' user intervention: continue\n') log.write(' user intervention: continue\n')
continue continue
except TpsWarning, e: except PtsWarning, e:
print 'test [%s]: warning: [%s]' % (shortname, e) print 'test [%s]: warning: [%s]' % (shortname, e)
log.write(' warning in test {0}, exception [{1}]\n'.format(shortname, e)) log.write(' warning in test {0}, exception [{1}]\n'.format(shortname, e))
failures.append((shortname, e, )) failures.append((shortname, e, ))
...@@ -477,7 +477,7 @@ def main(): ...@@ -477,7 +477,7 @@ def main():
s.sequence = valid s.sequence = valid
try: try:
s.validate_and_compute_run() s.validate_and_compute_run()
except TpsInvalid, e: except PtsInvalid, e:
print 'bad parameters:', e print 'bad parameters:', e
return return
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
LOGDIR=./log LOGDIR=./log
mkdir -p $LOGDIR mkdir -p $LOGDIR
sudo rm -fr $LOGDIR/tps* sudo rm -fr $LOGDIR/pts*
serial=$1 serial=$1
if [ x$1 = x"" ]; then if [ x$1 = x"" ]; then
...@@ -28,7 +28,7 @@ echo -n "Press enter to continue...\n" ...@@ -28,7 +28,7 @@ echo -n "Press enter to continue...\n"
read tmp read tmp
echo -n "--------------------------------------------------------------\n" echo -n "--------------------------------------------------------------\n"
sudo ./tps.py -b SPEC -s $serial -e $extra_serial -t./test/spec/python -l $LOGDIR 00 01 02 03 04 05 06 07 08 09 10 12 sudo ./pts.py -b SPEC -s $serial -e $extra_serial -t./test/spec/python -l $LOGDIR 00 01 02 03 04 05 06 07 08 09 10 12
echo -n "Press enter to exit... " echo -n "Press enter to exit... "
......
#! /usr/bin/env python #! /usr/bin/env python
# coding: utf8 # coding: utf8
class TpsException(Exception): class PtsException(Exception):
pass pass
class TpsCritical(TpsException): class PtsCritical(PtsException):
"""critical error, abort the whole test suite""" """critical error, abort the whole test suite"""
pass pass
class TpsError(TpsException): class PtsError(PtsException):
"""error, continue remaining tests in test suite""" """error, continue remaining tests in test suite"""
pass pass
class TpsUser(TpsException): class PtsUser(PtsException):
"""error, user intervention required""" """error, user intervention required"""
pass pass
class TpsWarning(TpsException): class PtsWarning(PtsException):
"""warning, a cautionary message should be displayed""" """warning, a cautionary message should be displayed"""
pass pass
class TpsInvalid(TpsException): class PtsInvalid(PtsException):
"""reserved: invalid parameters""" """reserved: invalid parameters"""
class TpsNoBatch(TpsInvalid): class PtsNoBatch(PtsInvalid):
"""reserved: a suite was created without batch of tests to run""" """reserved: a suite was created without batch of tests to run"""
pass pass
class TpsBadTestNo(TpsInvalid): class PtsBadTestNo(PtsInvalid):
"""reserved: a bad test number was given""" """reserved: a bad test number was given"""
pass pass
......
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