@@ -90,24 +90,17 @@ def __init__(self, path, clean=False, command=['sudo', '-E', 'python', 'test.py'
9090 else :
9191 self .name_ = name
9292
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-
93+ # Check if the tests is valid or not
94+ valid_status = check_valid (self .path_ )
95+ self .skip_ = valid_status ['skip' ]
96+ self .skip_reason_ = valid_status ['skip_reason' ]
10397
10498 print pretty .INFO ("Test" ), "starting" , self .name_
10599
106100 if clean :
107101 subprocess .check_output (["make" ,"clean" ])
108102 print pretty .C_GRAY + "\t Cleaned, now start... " , pretty .C_ENDC
109103
110-
111104 def __str__ (self ):
112105 """ Print output about the test object """
113106
@@ -122,7 +115,6 @@ def __str__(self):
122115 'skip_reason: {x[skip_reason_]} \n '
123116 ).format (x = self .__dict__ )
124117
125-
126118 def start (self ):
127119 os .chdir (startdir + "/" + self .path_ )
128120 self .proc_ = subprocess .Popen (self .command_ , shell = False ,
@@ -210,6 +202,7 @@ def unit_tests():
210202
211203 return max (build_status , unit_status )
212204
205+
213206def stress_test ():
214207 """Perform stresstest"""
215208 global test_count
@@ -230,6 +223,7 @@ def stress_test():
230223
231224 return 1 if stress .wait_status () else 0
232225
226+
233227def examples_working ():
234228 global test_count
235229 if ("examples" in args .skip ):
@@ -249,6 +243,7 @@ def examples_working():
249243 fail_count += 1 if build or run else 0
250244 return fail_count
251245
246+
252247def main ():
253248 global test_count
254249
@@ -292,14 +287,77 @@ def main():
292287 sys .exit (status )
293288
294289
295- def main2 ():
290+ def integration_tests2 ():
291+
296292 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
301293
294+ print pretty .HEADER ("Starting " + str (len (valid )) + " integration test(s)" )
295+ processes = []
296+
297+ fail_count = 0
298+ for path in valid :
299+ processes .append (Test (path , clean = args .clean ).start ())
300+
301+ # Collect test results
302+ print pretty .HEADER ("Collecting integration test results" )
303+
304+ for p in processes :
305+ fail_count += 1 if p .wait_status () else 0
306+
307+ # Exit early if any tests failed
308+ if fail_count and args .fail :
309+ print pretty .FAIL (str (fail_count ) + "integration tests failed" )
310+ sys .exit (fail_count )
311+
312+ return fail_count
313+
314+
315+ def check_valid (path ):
316+ """ Will check if a test is valid. The following points can declare a test valid:
317+ 1. Contains the files required
318+ 2. Not listed in the skipped_tests.json
319+ 3. Not listed in the args.skip cmd line argument
320+
321+ Arguments:
322+ path: Path of test to be checked
323+
324+ Returns:
325+ dict: Dictionary with skip status (bool) and skip reason (string)
326+ """
327+ # Test 1
328+ if not validate_test .validate_path (path , verb = False ):
329+ return {'skip' : True , 'skip_reason' : 'Failed validate_test, missing files' }
330+
331+ # Test 2
332+ # Figure out if the test should be skipped
333+ skip_json = json .loads (open ("skipped_tests.json" ).read ())
334+ for skip in skip_json :
335+ if path == skip ['name' ]:
336+ return {'skip' : True , 'skip_reason' : 'Defined in skipped_tests.json' }
337+
338+ # Test 3
339+ if path in args .skip :
340+ return {'skip' : True , 'skip_reason' : 'Defined by cmd line argument' }
341+
342+ return {'skip' : False , 'skip_reason' : None }
343+
344+
345+ def find_leaf_nodes ():
346+ """ Used to find all leaf nodes in the test directory,
347+ this is to help identify all possible test directories.
348+
349+ Returns:
350+ List: list of string with path to all leaf nodes
351+ """
352+
353+
354+
355+ def main2 ():
356+ # Populate test objects
357+ valid_test_objects = [ Test (x ) for x in validate_all .valid_tests () if not x in args .skip ]
302358
359+ for x in valid_test_objects :
360+ print x
303361
304362
305363
0 commit comments