2626import binascii
2727from shutil import copyfile
2828
29- from lib .logger import logger_init
3029from lib import helper
3130
3231BASE_PATH = os .path .dirname (os .path .abspath (__file__ ))
4746TEST_DIR = "%s/tests" % BASE_PATH
4847DATA_DIR = "%s/data" % BASE_PATH
4948LOG_DIR = "%s/results" % BASE_PATH
50- logger = logger_init (filepath = BASE_PATH ).getlogger ()
5149prescript_dir = CONFIGFILE .get ('script-dir' , 'prescriptdir' )
5250postscipt_dir = CONFIGFILE .get ('script-dir' , 'postscriptdir' )
5351
@@ -97,9 +95,8 @@ def config(self):
9795 os .system (cmd )
9896 self .conf = cfg
9997 elif self .type == 'host' :
100- local_cfg = "%s/%s/%s.cfg" % (TEST_CONF_PATH ,
101- self .type ,
102- self .shortname )
98+ local_cfg = "%s/%s.cfg" % (TEST_CONF_PATH ,
99+ self .conf .replace ('_' , '/' , 1 ))
103100 if not os .path .isfile (local_cfg ):
104101 return self .conf
105102 self .conf = local_cfg
@@ -403,6 +400,26 @@ def run_test(testsuite, avocado_bin):
403400 return
404401
405402
403+ def log_files (test_list , log_dir ):
404+ """
405+ Log the test config files, input file, norun config files, command line.
406+ """
407+ with open (os .path .join (log_dir , "command.txt" ), "w" ) as fp :
408+ fp .write (" " .join (sys .argv ))
409+ fp .write ("\n " )
410+
411+ no_run_tests = os .path .join (log_dir , "no_run_tests" )
412+ helper .copy_file (NORUNTEST_PATH , no_run_tests )
413+
414+ config_path = os .path .join (log_dir , "test_configs" )
415+ for test in test_list :
416+ helper .copy_file (Testsuites [test ].config (), config_path )
417+
418+ if args .inputfile :
419+ input_file = os .path .join (log_dir , "input_file" )
420+ helper .copy_file (args .inputfile , input_file )
421+
422+
406423def env_clean ():
407424 """
408425 Clean/uninstall avocado and autotest
@@ -610,6 +627,21 @@ def parse_test_config(test_config_file, avocado_bin, enable_kvm):
610627 default = False , help = 'enable bootstrap kvm tests' )
611628
612629 args = parser .parse_args ()
630+
631+ if args .outputdir :
632+ # Check if it is valid path
633+ if not os .path .isdir (os .path .abspath (args .outputdir )):
634+ raise ValueError ("No output dir" )
635+ outputdir = args .outputdir
636+ else :
637+ outputdir = BASE_PATH
638+ outputdir = os .path .join (log_dir , "results" )
639+ timeObj = time .localtime (time .time ())
640+ log_dir = os .path .join (outputdir , "%d-%d-%d_%d_%d_%d" % (timeObj .tm_mday , timeObj .tm_mon , timeObj .tm_year ,
641+ timeObj .tm_hour , timeObj .tm_min , timeObj .tm_sec ))
642+ os .makedirs (log_dir )
643+ logger = helper .get_logger (log_dir )
644+
613645 if helper .get_machine_type () == 'pHyp' :
614646 args .enable_kvm = False
615647 if args .run_suite :
@@ -627,13 +659,6 @@ def parse_test_config(test_config_file, avocado_bin, enable_kvm):
627659 additional_args = args .add_args
628660 if args .verbose :
629661 additional_args += ' --show-job-log'
630- if args .outputdir :
631- # Check if it valid path
632- if not os .path .isdir (os .path .abspath (args .outputdir )):
633- raise ValueError ("No output dir" )
634- outputdir = os .path .join (args .outputdir , 'results' )
635- else :
636- outputdir = os .path .join (BASE_PATH , 'results' )
637662
638663 additional_args += ' --job-results-dir %s' % outputdir
639664 bootstraped = False
@@ -708,6 +733,7 @@ def parse_test_config(test_config_file, avocado_bin, enable_kvm):
708733 outputdir , args .vt_type ,
709734 test ['test' ], test ['mux' ],
710735 test ['args' ])
736+ Testsuites [test_suite_name ].conf = test_suite
711737 Testsuites_list .append (test_suite_name )
712738
713739 if 'guest' in test_suite :
@@ -719,6 +745,10 @@ def parse_test_config(test_config_file, avocado_bin, enable_kvm):
719745 Testsuites [test_suite ].runstatus ("Cant_Run" ,
720746 "Config file not present" )
721747 continue
748+
749+ # Log config files
750+ log_files (Testsuites_list , log_dir )
751+
722752 # Run Tests
723753 for test_suite in Testsuites_list :
724754 if not Testsuites [test_suite ].run == "Cant_Run" :
@@ -743,7 +773,9 @@ def parse_test_config(test_config_file, avocado_bin, enable_kvm):
743773 Testsuites [test_suite ].run .ljust (10 ),
744774 Testsuites [test_suite ].runsummary ))
745775 summary_output .append (Testsuites [test_suite ].runlink )
776+ summary_output .append ("" )
746777 logger .info ("\n " .join (summary_output ))
778+ logger .info ("Results and Configs logged at: %s" % log_dir )
747779
748780 if os .path .isdir ("/tmp/mux/" ):
749781 logger .info ("Removing temporary mux dir" )
0 commit comments