@@ -204,70 +204,59 @@ def test_suite(
204204 xip_flag = False ,
205205 clean_up_flag = True ,
206206 verbose_flag = True ,
207+ parl_flag = False ,
207208):
208209 suite_path = pathlib .Path (SPEC_TEST_DIR ).resolve ()
209210 if not suite_path .exists ():
210211 print (f"can not find spec test cases at { suite_path } " )
211212 return False
212213
213- case_list = sorted (suite_path .glob ("**/*.wast" ))
214+ case_list = sorted (suite_path .glob ("*.wast" ))
215+ if simd_flag :
216+ simd_case_list = sorted (suite_path .glob ("simd/*.wast" ))
217+ case_list .extend (simd_case_list )
218+
214219 case_count = len (case_list )
215220 failed_case = 0
216221 successful_case = 0
217- for case_path in case_list :
218- try :
219- test_case (
220- str (case_path ),
221- target ,
222- aot_flag ,
223- sgx_flag ,
224- multi_module_flag ,
225- multi_thread_flag ,
226- simd_flag ,
227- xip_flag ,
228- clean_up_flag ,
229- verbose_flag ,
230- )
231- successful_case += 1
232- except Exception :
233- failed_case += 1
234- break
235-
236- print (
237- f"IN ALL { case_count } cases: { successful_case } PASS, { failed_case } FAIL, { case_count - successful_case - failed_case } SKIP"
238- )
239-
240- return 0 == failed_case
241222
223+ if parl_flag :
224+ print (f"----- Run the whole spec test suite on { mp .cpu_count ()} cores -----" )
225+ with mp .Pool () as pool :
226+ results = {}
227+ for case_path in case_list :
228+ results [case_path .stem ] = pool .apply_async (
229+ test_case ,
230+ [
231+ str (case_path ),
232+ target ,
233+ aot_flag ,
234+ sgx_flag ,
235+ multi_module_flag ,
236+ multi_thread_flag ,
237+ simd_flag ,
238+ xip_flag ,
239+ clean_up_flag ,
240+ verbose_flag ,
241+ ],
242+ )
242243
243- def test_suite_parallelly (
244- target ,
245- aot_flag = False ,
246- sgx_flag = False ,
247- multi_module_flag = False ,
248- multi_thread_flag = False ,
249- simd_flag = False ,
250- xip_flag = False ,
251- clean_up_flag = False ,
252- verbose_flag = False ,
253- ):
254-
255- suite_path = pathlib .Path (SPEC_TEST_DIR ).resolve ()
256- if not suite_path .exists ():
257- print (f"can not find spec test cases at { suite_path } " )
258- return False
259-
260- case_list = sorted (suite_path .glob ("**/*.wast" ))
261- case_count = len (case_list )
262- failed_case = 0
263- successful_case = 0
264- print (f"----- Run the whole spec test suite on { mp .cpu_count ()} cores -----" )
265- with mp .Pool () as pool :
266- results = {}
244+ for case_name , result in results .items ():
245+ try :
246+ # 5 min / case
247+ result .wait (300 )
248+ if not result .successful ():
249+ failed_case += 1
250+ else :
251+ successful_case += 1
252+ except mp .TimeoutError :
253+ print (f"{ case_name } meets TimeoutError" )
254+ failed_case += 1
255+ else :
256+ print (f"----- Run the whole spec test suite -----" )
267257 for case_path in case_list :
268- results [case_path .stem ] = pool .apply_async (
269- test_case ,
270- [
258+ try :
259+ test_case (
271260 str (case_path ),
272261 target ,
273262 aot_flag ,
@@ -278,20 +267,11 @@ def test_suite_parallelly(
278267 xip_flag ,
279268 clean_up_flag ,
280269 verbose_flag ,
281- ],
282- )
283-
284- for case_name , result in results .items ():
285- try :
286- # 5 min / case
287- result .wait (300 )
288- if not result .successful ():
289- failed_case += 1
290- else :
291- successful_case += 1
292- except mp .TimeoutError :
293- print (f"{ case_name } meets TimeoutError" )
270+ )
271+ successful_case += 1
272+ except Exception :
294273 failed_case += 1
274+ break
295275
296276 print (
297277 f"IN ALL { case_count } cases: { successful_case } PASS, { failed_case } FAIL, { case_count - successful_case - failed_case } SKIP"
@@ -396,37 +376,23 @@ def main():
396376 options .clean_up_flag = False
397377 options .verbose_flag = False
398378
399- start = time .time_ns ()
400- ret = test_suite_parallelly (
401- options .target ,
402- options .aot_flag ,
403- options .sgx_flag ,
404- options .multi_module_flag ,
405- options .multi_thread_flag ,
406- options .simd_flag ,
407- options .xip_flag ,
408- options .clean_up_flag ,
409- options .verbose_flag ,
410- )
411- end = time .time_ns ()
412- print (
413- f"It takes { ((end - start ) / 1000000 ):,} ms to run test_suite_parallelly"
414- )
415- else :
416- start = time .time_ns ()
417- ret = test_suite (
418- options .target ,
419- options .aot_flag ,
420- options .sgx_flag ,
421- options .multi_module_flag ,
422- options .multi_thread_flag ,
423- options .simd_flag ,
424- options .xip_flag ,
425- options .clean_up_flag ,
426- options .verbose_flag ,
427- )
428- end = time .time_ns ()
429- print (f"It takes { ((end - start ) / 1000000 ):,} ms to run test_suite" )
379+ start = time .time_ns ()
380+ ret = test_suite (
381+ options .target ,
382+ options .aot_flag ,
383+ options .sgx_flag ,
384+ options .multi_module_flag ,
385+ options .multi_thread_flag ,
386+ options .simd_flag ,
387+ options .xip_flag ,
388+ options .clean_up_flag ,
389+ options .verbose_flag ,
390+ options .parl_flag ,
391+ )
392+ end = time .time_ns ()
393+ print (
394+ f"It takes { ((end - start ) / 1000000 ):,} ms to run test_suite { 'parallelly' if options .parl_flag else '' } "
395+ )
430396 else :
431397 try :
432398 for case in options .cases :
0 commit comments