@@ -70,24 +70,59 @@ def valid_tests(subfolder=None):
7070
7171class Test :
7272 """ A class to start a test as a subprocess and pretty-print status """
73- def __init__ (self , path , clean = False , command = ['sudo' , '-E' , 'python' , 'test.py' ], name = None ):
73+ def __init__ (self , path , clean = False , command = ['sudo' , '-E' , 'python' , 'test.py' ], name = None , category = None , test_type = None ):
7474
7575 self .command_ = command
7676 self .proc_ = None
7777 self .path_ = path
7878 self .output_ = None
7979
80- if (name == None ):
80+ # Extract category and type from the path variable
81+ # Category is linked to the top level folder e.g. net, fs, hw
82+ # Type is linked to the type of test e.g. integration, unit, stress
83+ if not category :
84+ self .category_ = self .path_ .split ('/' )[- 3 ]
85+ if not test_type :
86+ self .type_ = self .path_ .split ('/' )[- 2 ]
87+
88+ if not name :
8189 self .name_ = path
8290 else :
8391 self .name_ = name
8492
93+ # Figure out if the test should be skipped
94+ skip_json = json .loads (open ("skipped_tests.json" ).read ())
95+ for skip in skip_json :
96+ if self .name_ == skip ['name' ]:
97+ self .skip_ = True
98+ self .skip_reason_ = skip ['reason' ]
99+ else :
100+ self .skip_ = False
101+ self .skip_reason_ = None
102+
103+
85104 print pretty .INFO ("Test" ), "starting" , self .name_
86105
87106 if clean :
88107 subprocess .check_output (["make" ,"clean" ])
89108 print pretty .C_GRAY + "\t Cleaned, now start... " , pretty .C_ENDC
90109
110+
111+ def __str__ (self ):
112+ """ Print output about the test object """
113+
114+ return ('name_: {x[name_]} \n '
115+ 'path_: {x[path_]} \n '
116+ 'command_: {x[command_]} \n '
117+ 'proc_: {x[proc_]} \n '
118+ 'output_: {x[output_]} \n '
119+ 'category_: {x[category_]} \n '
120+ 'type_: {x[type_]} \n '
121+ 'skip: {x[skip_]} \n '
122+ 'skip_reason: {x[skip_reason_]} \n '
123+ ).format (x = self .__dict__ )
124+
125+
91126 def start (self ):
92127 os .chdir (startdir + "/" + self .path_ )
93128 self .proc_ = subprocess .Popen (self .command_ , shell = False ,
@@ -137,6 +172,9 @@ def integration_tests(subfolder=None):
137172 print pretty .HEADER ("Starting " + str (len (valid )) + " integration test(s)" )
138173 processes = []
139174
175+ print valid
176+ sys .exit (0 )
177+
140178 fail_count = 0
141179 for path in valid :
142180 processes .append (Test (path , clean = args .clean ).start ())
@@ -253,5 +291,17 @@ def main():
253291
254292 sys .exit (status )
255293
294+
295+ def main2 ():
296+ valid = valid_tests ()
297+ test_objects = [ Test (x ) for x in valid ]
298+ net_tests = [ x for x in test_objects if x .category_ == 'net' ]
299+ for test in net_tests :
300+ print test
301+
302+
303+
304+
305+
256306if __name__ == '__main__' :
257- main ()
307+ main2 ()
0 commit comments