Commit 91dfdb8f authored by Grzegorz Daniluk's avatar Grzegorz Daniluk

pts.py: adding MAC support

parent 0367f677
......@@ -68,8 +68,8 @@ def run_test(testname, logname, test_path, yes=False):
class Suite(object):
def __init__(self, cfgfilename=default_config_file):
self.required = [ 'board', 'serial', 'extra_serial', 'test_path',
'log_path', 'sequence' ]
self.required = [ 'board', 'serial', 'extra_serial', 'mac_addr',
'test_path', 'log_path', 'sequence' ]
for fieldname in self.required:
self.__setattr__(fieldname, None)
self.config = default_config_file
......@@ -100,6 +100,7 @@ class Suite(object):
self.board = config.get('global', 'board')
self.serial = config.get('global', 'serial')
self.extra_serial = config.get('global', 'extra_serial')
self.mac_addr = config.get('global', 'mac_addr')
self.test_path = config.get('global', 'test_path')
self.log_path = config.get('global', 'log_path')
self.sequence = config.get('global', 'sequence')
......@@ -115,6 +116,7 @@ class Suite(object):
config.set('global', 'board', self.board)
config.set('global', 'serial', self.serial)
config.set('global', 'extra_serial', self.extra_serial)
config.set('global', 'mac_addr', self.mac_addr)
config.set('global', 'test_path', self.test_path)
config.set('global', 'log_path', self.log_path)
config.set('global', 'sequence', self.sequence)
......@@ -232,10 +234,11 @@ class Suite(object):
' board = {0}\n'
' 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))
' MAC address = {3}\n'
' comment = {4}\n'
' timestamp = {5}\n'
' runid = {6}\n'.format(
self.board, self.serial, self.extra_serial, self.mac_addr, self.comment, ts, runid))
failures = []
for test in sequence:
try:
......@@ -402,6 +405,7 @@ class Cli(cmd.Cmd, Suite):
'board',
'serial',
'extra_serial',
'mac_addr',
'test_path',
'log_path',
'repeat',
......@@ -428,6 +432,12 @@ def validate_args(args):
if not re.match(default_test_syntax, arg) ]
return valid_args, invalid_args
def store_mac(path, mac):
filepath = os.path.join(path, 'mac.tmp')
mac_file = open(filepath, 'w')
mac_file.write(mac)
mac_file.close()
def main():
usage = ( '%prog: [options] test ...\n'
......@@ -444,6 +454,8 @@ def main():
help="board serial number", metavar="SERIAL")
parser.add_option("-e", "--extra_serial", dest="extra_serial",
help="another board serial number [Optional]", metavar="SERIAL")
parser.add_option("-m", "--mac", dest="mac_addr",
help="MAC address of the SFP port")
parser.add_option("-t", "--test-path", dest="test_path",
help="path to test files", metavar="PATH")
parser.add_option("-l", "--log-path", dest="log_path",
......@@ -481,6 +493,10 @@ def main():
print 'bad parameters:', e
return
# store MAC address if needed
if options.mac_addr:
store_mac(options.test_path, options.mac_addr)
# decide what to do
if options.write_config:
s.save()
......
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