Skip to content

Commit ef265a1

Browse files
committed
Use multiprocess to parallel run test case
Signed-off-by: Ni, Wenhui <[email protected]>
1 parent f9d8629 commit ef265a1

File tree

171 files changed

+1288
-1222
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

171 files changed

+1288
-1222
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,10 +113,10 @@ For example, for test suite: internal_samples, there is a test driver configure
113113

114114
The test driver implementation file test_samples.py needs to implement the following 4 interfaces:
115115

116-
1. setup_test(): Setup the execution environment. eg. setup CPATH or LD_LIBRARY_PATH in Linux to contain library required for the test case.
117-
2. migrate_test(): Migration command for each test case.
118-
3. build_test(): Compile and link command for each test case.
119-
4. run_test(): Run the test cases in the test suite.
116+
1. setup_test(single_case_text): Setup the execution environment. eg. setup CPATH or LD_LIBRARY_PATH in Linux to contain library required for the test case.
117+
2. migrate_test(single_case_text): Migration command for each test case.
118+
3. build_test(single_case_text): Compile and link command for each test case.
119+
4. run_test(single_case_text): Run the test cases in the test suite.
120120

121121

122122
# Add or modify test case

api_coverage/test_api_coverage.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,37 +15,37 @@
1515

1616
from test_utils import *
1717

18-
def setup_test():
18+
def setup_test(single_case_text):
1919
return True
2020

21-
def migrate_test():
21+
def migrate_test(single_case_text):
2222
src = []
2323
extra_args = []
24-
in_root = os.path.join(os.getcwd(), test_config.current_test)
25-
test_config.out_root = os.path.join(in_root, 'out_root')
24+
in_root = os.path.join(os.getcwd(), single_case_text.name)
25+
single_case_text.out_root = os.path.join(in_root, 'out_root')
2626

2727
for dirpath, dirnames, filenames in os.walk(in_root):
2828
for filename in [f for f in filenames if re.match('.*(cu|cpp|c)$', f)]:
2929
src.append(os.path.abspath(os.path.join(dirpath, filename)))
3030

3131

32-
return do_migrate(src, in_root, test_config.out_root, extra_args)
32+
return do_migrate(src, in_root, single_case_text.out_root, single_case_text, extra_args)
3333

34-
def build_test():
35-
if (os.path.exists(test_config.current_test)):
36-
os.chdir(test_config.current_test)
34+
def build_test(single_case_text):
35+
if (os.path.exists(single_case_text.name)):
36+
os.chdir(single_case_text.name)
3737
srcs = []
3838
cmp_opts = ''
3939
link_opts = ''
4040
objects = ''
4141

42-
for dirpath, dirnames, filenames in os.walk(test_config.out_root):
42+
for dirpath, dirnames, filenames in os.walk(single_case_text.out_root):
4343
for filename in [f for f in filenames if re.match('.*(cpp|c)$', f)]:
4444
srcs.append(os.path.abspath(os.path.join(dirpath, filename)))
4545
ret = False
46-
ret = compile_files(srcs, cmp_opts)
46+
ret = compile_files(srcs, single_case_text, cmp_opts)
4747
return ret
4848

4949

50-
def run_test():
50+
def run_test(single_case_text):
5151
return True

behavior_tests/src/array_size_fold/do_test.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@
1414
from test_utils import *
1515

1616

17-
def setup_test():
18-
change_dir(test_config.current_test)
17+
def setup_test(single_case_text):
18+
change_dir(single_case_text.name, single_case_text)
1919
return True
2020

2121

22-
def migrate_test():
22+
def migrate_test(single_case_text):
2323
call_subprocess(
2424
test_config.CT_TOOL + " test.cu --out-root=out --cuda-include-path=" + test_config.include_path)
2525

@@ -37,9 +37,9 @@ def migrate_test():
3737
return res
3838

3939

40-
def build_test():
40+
def build_test(single_case_text):
4141
return True
4242

4343

44-
def run_test():
44+
def run_test(single_case_text):
4545
return True

behavior_tests/src/bad_input_1/do_test.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,16 @@
1313

1414
from test_utils import *
1515

16-
def setup_test():
17-
change_dir(test_config.current_test)
16+
def setup_test(single_case_text):
17+
change_dir(single_case_text.name, single_case_text)
1818
return True
1919

20-
def migrate_test():
20+
def migrate_test(single_case_text):
2121

2222
call_subprocess(test_config.CT_TOOL + " --cuda-include-path=" + test_config.include_path + " " +
2323
os.path.join("cuda", "migrate_nonbuilding_code.cu"))
24-
return is_sub_string("unknown type name", test_config.command_output)
25-
def build_test():
24+
return is_sub_string("unknown type name", single_case_text.command_text)
25+
def build_test(single_case_text):
2626
return True
27-
def run_test():
27+
def run_test(single_case_text):
2828
return True

behavior_tests/src/bt-analysis-scope-path1/do_test.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@
1515
from test_utils import *
1616

1717

18-
def setup_test():
19-
change_dir(test_config.current_test)
18+
def setup_test(single_case_text):
19+
change_dir(single_case_text.name, single_case_text)
2020
return True
2121

2222

23-
def migrate_test():
23+
def migrate_test(single_case_text):
2424
# clean previous migration output
2525
if (os.path.exists("out")):
2626
shutil.rmtree("out")
@@ -50,9 +50,9 @@ def migrate_test():
5050
return True
5151

5252

53-
def build_test():
53+
def build_test(single_case_text):
5454
return True
5555

5656

57-
def run_test():
57+
def run_test(single_case_text):
5858
return True

behavior_tests/src/bt-analysis-scope-path2/do_test.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,18 @@
1515
from test_utils import *
1616

1717

18-
def setup_test():
19-
cur_dir = os.path.join(os.getcwd(), test_config.current_test)
18+
def setup_test(single_case_text):
19+
cur_dir = os.path.join(os.getcwd(), single_case_text.name)
2020
if platform.system() == 'Windows':
2121
# windows current working directory might start with lowercased drive(e.g., "d:\path") in some cases
2222
# so make the drive symbol in cwd to be upper explicitly to avoid inconsistent paths.
2323
if cur_dir[1] == ":" and cur_dir[0].islower():
2424
cur_dir = cur_dir[0].upper() + cur_dir[1:]
25-
change_dir(cur_dir)
25+
change_dir(cur_dir, single_case_text)
2626
return True
2727

2828

29-
def migrate_test():
29+
def migrate_test(single_case_text):
3030
# clean previous migration output
3131
if (os.path.exists("out")):
3232
shutil.rmtree("out")
@@ -50,12 +50,12 @@ def migrate_test():
5050
os.path.join("cuda", ".."))
5151
return is_sub_string(
5252
f"use the same option set as in previous migration: \"--analysis-scope-path=",
53-
test_config.command_output)
53+
single_case_text.command_text)
5454

5555

56-
def build_test():
56+
def build_test(single_case_text):
5757
return True
5858

5959

60-
def run_test():
60+
def run_test(single_case_text):
6161
return True

behavior_tests/src/bt-analysis-scope-path3/do_test.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@
1616
from test_utils import *
1717

1818

19-
def setup_test():
20-
change_dir(test_config.current_test)
19+
def setup_test(single_case_text):
20+
change_dir(single_case_text.name, single_case_text)
2121
return True
2222

2323

24-
def migrate_test():
24+
def migrate_test(single_case_text):
2525
# clean previous migration output
2626
if (os.path.exists("out")):
2727
shutil.rmtree("out")
@@ -54,9 +54,9 @@ def migrate_test():
5454
return True
5555

5656

57-
def build_test():
57+
def build_test(single_case_text):
5858
return True
5959

6060

61-
def run_test():
61+
def run_test(single_case_text):
6262
return True

behavior_tests/src/bt-analysis-scope-path4/do_test.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,15 @@
1616
from test_utils import *
1717

1818

19-
def setup_test():
20-
change_dir(test_config.current_test)
19+
def setup_test(single_case_text):
20+
change_dir(single_case_text.name, single_case_text)
2121
if os.path.exists("cuda_symlink"):
2222
os.unlink("cuda_symlink")
2323
os.symlink("cuda", "cuda_symlink")
2424
return True
2525

2626

27-
def migrate_test():
27+
def migrate_test(single_case_text):
2828
# clean previous migration output
2929
if (os.path.exists("out")):
3030
shutil.rmtree("out")
@@ -40,9 +40,9 @@ def migrate_test():
4040
return True
4141

4242

43-
def build_test():
43+
def build_test(single_case_text):
4444
return True
4545

4646

47-
def run_test():
47+
def run_test(single_case_text):
4848
return True

behavior_tests/src/bt-autocomplete/do_test.py

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -12,102 +12,102 @@
1212

1313
from test_utils import *
1414

15-
def setup_test():
16-
change_dir(test_config.current_test)
15+
def setup_test(single_case_text):
16+
change_dir(single_case_text.name, single_case_text)
1717
return True
1818

19-
def migrate_test():
19+
def migrate_test(single_case_text):
2020
res = True
2121

2222
call_subprocess(test_config.CT_TOOL + " --autocomplete=--gen-build")
2323
reference = '--gen-build-script\n'
24-
res = res and (reference == test_config.command_output)
24+
res = res and (reference == single_case_text.command_text)
2525

2626
call_subprocess(test_config.CT_TOOL + " --autocomplete=-gen-build")
2727
reference = '-gen-build-script\n'
28-
res = res and (reference == test_config.command_output)
28+
res = res and (reference == single_case_text.command_text)
2929

3030
call_subprocess(test_config.CT_TOOL + " --autocomplete=foo")
3131
reference = '\n'
32-
res = res and (reference == test_config.command_output)
32+
res = res and (reference == single_case_text.command_text)
3333

3434
call_subprocess(test_config.CT_TOOL + " --autocomplete=--output-verbosity=#d")
3535
reference = 'detailed\n' + \
3636
'diagnostics\n'
37-
res = res and (reference == test_config.command_output)
37+
res = res and (reference == single_case_text.command_text)
3838

3939
call_subprocess(test_config.CT_TOOL + " --autocomplete=-output-verbosity=#d")
4040
reference = 'detailed\n' + \
4141
'diagnostics\n'
42-
res = res and (reference == test_config.command_output)
42+
res = res and (reference == single_case_text.command_text)
4343

4444
call_subprocess(test_config.CT_TOOL + " --autocomplete=--output-verbosity=")
4545
reference = 'detailed\n' + \
4646
'diagnostics\n' + \
4747
'normal\n' + \
4848
'silent\n'
49-
res = res and (reference == test_config.command_output)
49+
res = res and (reference == single_case_text.command_text)
5050

5151
call_subprocess(test_config.CT_TOOL + " --autocomplete=-output-verbosity=")
5252
reference = 'detailed\n' + \
5353
'diagnostics\n' + \
5454
'normal\n' + \
5555
'silent\n'
56-
res = res and (reference == test_config.command_output)
56+
res = res and (reference == single_case_text.command_text)
5757

5858
call_subprocess(test_config.CT_TOOL + " --autocomplete=foo#bar##--enable-c")
5959
reference = '--enable-ctad\n'
60-
res = res and (reference == test_config.command_output)
60+
res = res and (reference == single_case_text.command_text)
6161

6262
call_subprocess(test_config.CT_TOOL + " --autocomplete=foo#bar###--format-range=#a")
6363
reference = 'all\n'
64-
res = res and (reference == test_config.command_output)
64+
res = res and (reference == single_case_text.command_text)
6565

6666
call_subprocess(test_config.CT_TOOL + " --autocomplete=--rule-file=")
6767
reference = '\n'
68-
res = res and (reference == test_config.command_output)
68+
res = res and (reference == single_case_text.command_text)
6969

7070
call_subprocess(test_config.CT_TOOL + " --autocomplete=--rule-file")
7171
reference = '--rule-file\n'
72-
res = res and (reference == test_config.command_output)
72+
res = res and (reference == single_case_text.command_text)
7373

7474
call_subprocess(test_config.CT_TOOL + " --autocomplete=-p=")
7575
reference = '\n'
76-
res = res and (reference == test_config.command_output)
76+
res = res and (reference == single_case_text.command_text)
7777

7878
call_subprocess(test_config.CT_TOOL + " --autocomplete=-p")
7979
reference = '-p\n' + \
8080
'-process-all\n'
81-
res = res and (reference == test_config.command_output)
81+
res = res and (reference == single_case_text.command_text)
8282

8383
call_subprocess(test_config.CT_TOOL + " --autocomplete=--usm-level=#none,restricted#--use-explicit-namespace=#cl,sycl,")
8484
reference = 'cl,sycl,cl\n' + \
8585
'cl,sycl,dpct\n' + \
8686
'cl,sycl,none\n' + \
8787
'cl,sycl,sycl\n' + \
8888
'cl,sycl,sycl-math\n'
89-
res = res and (reference == test_config.command_output)
89+
res = res and (reference == single_case_text.command_text)
9090

9191
call_subprocess(test_config.CT_TOOL + " --autocomplete=--usm-level=#none,restricted#--use-explicit-namespace=#cl,sycl,s")
9292
reference = 'cl,sycl,sycl\n' + \
9393
'cl,sycl,sycl-math\n'
94-
res = res and (reference == test_config.command_output)
94+
res = res and (reference == single_case_text.command_text)
9595

9696
call_subprocess(test_config.CT_TOOL + " --autocomplete=")
9797
reference = '\n'
98-
res = res and (reference == test_config.command_output)
98+
res = res and (reference == single_case_text.command_text)
9999

100100
call_subprocess(test_config.CT_TOOL + " --autocomplete=,")
101101
reference = '\n'
102-
res = res and (reference == test_config.command_output)
102+
res = res and (reference == single_case_text.command_text)
103103

104104
call_subprocess(test_config.CT_TOOL + " --autocomplete==")
105105
reference = '\n'
106-
res = res and (reference == test_config.command_output)
106+
res = res and (reference == single_case_text.command_text)
107107

108108
call_subprocess(test_config.CT_TOOL + " --autocomplete=,,")
109109
reference = '\n'
110-
res = res and (reference == test_config.command_output)
110+
res = res and (reference == single_case_text.command_text)
111111

112112
call_subprocess(test_config.CT_TOOL + " --autocomplete=-")
113113
opts = ['--always-use-async-handler\n',
@@ -152,20 +152,20 @@ def migrate_test():
152152
'--version\n',
153153
'-p\n']
154154
for opt in opts:
155-
res = res and (opt in test_config.command_output)
155+
res = res and (opt in single_case_text.command_text)
156156

157157
call_subprocess(test_config.CT_TOOL + " --autocomplete=##")
158158
reference = '\n'
159-
res = res and (reference == test_config.command_output)
159+
res = res and (reference == single_case_text.command_text)
160160

161161
call_subprocess(test_config.CT_TOOL + " --autocomplete=#")
162162
reference = '\n'
163-
res = res and (reference == test_config.command_output)
163+
res = res and (reference == single_case_text.command_text)
164164

165165
return res
166166

167-
def build_test():
167+
def build_test(single_case_text):
168168
return True
169169

170-
def run_test():
170+
def run_test(single_case_text):
171171
return True

0 commit comments

Comments
 (0)