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