4949
5050
5151# config file should be in the same directory of this script
52- LH_CFG = "lh_test_cfg .yaml"
52+ LH_CFG = "lh_unittest_cfg .yaml"
5353# lockhammer.c has these parameters
5454LH_ARGU_LIST = ['t' , 'a' , 'c' , 'p' , 'i' , 'o' ]
55-
55+ # sh _timeout in seconds, default half an hour
56+ LH_TMOUT = 1800
5657
5758# python unittest framework container class
5859@unittest .skipUnless (sys .platform .startswith ('linux' ), "require Linux" )
@@ -75,7 +76,7 @@ def write_output(stdOut, logFile, paramList):
7576def construct_func (fullCmd , fullArg , logFile ):
7677 def test (self ):
7778 cmdObj = sh .Command (fullCmd )
78- stdOut = str (cmdObj (fullArg ))
79+ stdOut = str (cmdObj (fullArg , _timeout = LH_TMOUT ))
7980 write_output (stdOut , logFile , [str (datetime .datetime .now ()), socket .getfqdn (), fullCmd ] + fullArg )
8081 regEx = "[0-9]*, [0-9]*\.?[0-9]*, [0-9]*\.?[0-9]*, [0-9]*\.?[0-9]*, [0-9]*\.?[0-9]*"
8182 self .assertRegex (stdOut , regEx , "This program has not run to completion." )
@@ -144,9 +145,9 @@ def parse_lstopo():
144145 for line in out .splitlines ():
145146 match = re .search ("P#(\d+)" , line .strip ())
146147 if match :
147- result += (match .group (1 ) + ', ' )
148+ result += (match .group (1 ) + ': ' )
148149 finally :
149- if result [- 1 ] == ', ' :
150+ if result [- 1 ] == ': ' :
150151 result = result [:- 1 ]
151152
152153 # sample output for single-socket EPYC 7601 server:
@@ -272,7 +273,9 @@ def generate_unittest(className, lhCfg, testCfg):
272273 logFile = default_value (globalCfg , 'logfile' , None )
273274 safeMode = default_value (unitCfg , 'safemode' , True )
274275
275- prepare_logfile (logFile )
276+ if logFile :
277+ logFile = socket .gethostname () + '_' + logFile
278+ prepare_logfile (logFile )
276279
277280 allCmd = []
278281 if isinstance (testCfg ['cmd' ], list ):
@@ -326,7 +329,10 @@ def generate_sweeptest(className, lhCfg):
326329 lhCommand = default_value (sweepCfg , 'cmd' , [])
327330 lhArgument = default_value (sweepCfg , 'argulist' , [{}])
328331
329- prepare_logfile (logFile )
332+ if logFile :
333+ logFile = socket .gethostname () + '_' + logFile
334+ prepare_logfile (logFile )
335+
330336 sweepList = calc_sweep_list (arguMax , skipSince , skipStep )
331337 append_arch_cmd (sweepCfg , lhCommand )
332338
@@ -357,10 +363,14 @@ def build_sweep_test(lhCfg):
357363 sys .exit (2 )
358364
359365
360- # main function
366+ # test_lockhammer.py [local_yaml_config_filename]
361367if __name__ == "__main__" :
362- lhConfig = read_config (os .path .join (os .path .dirname (os .path .abspath (__file__ )), LH_CFG ))
368+ if len (sys .argv ) == 2 :
369+ lhConfigFullPath = os .path .join (os .path .dirname (os .path .abspath (__file__ )), sys .argv [1 ])
370+ else :
371+ lhConfigFullPath = os .path .join (os .path .dirname (os .path .abspath (__file__ )), LH_CFG )
372+ lhConfig = read_config (lhConfigFullPath )
363373 pprint .pprint (lhConfig )
364374 build_unit_test (lhConfig )
365375 build_sweep_test (lhConfig )
366- unittest .main (verbosity = 2 )
376+ unittest .main (argv = [ 'first-arg-is-ignored' ], verbosity = 2 )
0 commit comments