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