Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use multiprocess to parallel run test case #384

Open
wants to merge 10 commits into
base: SYCLomatic
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,10 @@ For example, for test suite: internal_samples, there is a test driver configure

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

1. setup_test(): Setup the execution environment. eg. setup CPATH or LD_LIBRARY_PATH in Linux to contain library required for the test case.
2. migrate_test(): Migration command for each test case.
3. build_test(): Compile and link command for each test case.
4. run_test(): Run the test cases in the test suite.
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.
2. migrate_test(single_case_text): Migration command for each test case.
3. build_test(single_case_text): Compile and link command for each test case.
4. run_test(single_case_text): Run the test cases in the test suite.


# Add or modify test case
Expand Down
22 changes: 11 additions & 11 deletions api_coverage/test_api_coverage.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,37 +15,37 @@

from test_utils import *

def setup_test():
def setup_test(single_case_text):
return True

def migrate_test():
def migrate_test(single_case_text):
src = []
extra_args = []
in_root = os.path.join(os.getcwd(), test_config.current_test)
test_config.out_root = os.path.join(in_root, 'out_root')
in_root = os.path.join(os.getcwd(), single_case_text.name)
single_case_text.out_root = os.path.join(in_root, 'out_root')

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


return do_migrate(src, in_root, test_config.out_root, extra_args)
return do_migrate(src, in_root, single_case_text.out_root, single_case_text, extra_args)

def build_test():
if (os.path.exists(test_config.current_test)):
os.chdir(test_config.current_test)
def build_test(single_case_text):
if (os.path.exists(single_case_text.name)):
os.chdir(single_case_text.name)
srcs = []
cmp_opts = ''
link_opts = ''
objects = ''

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


def run_test():
def run_test(single_case_text):
return True
12 changes: 6 additions & 6 deletions behavior_tests/src/array_size_fold/do_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@
from test_utils import *


def setup_test():
change_dir(test_config.current_test)
def setup_test(single_case_text):
change_dir(single_case_text.name, single_case_text)
return True


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

with open(os.path.join("out", "test.dp.cpp"), 'r') as f:
ret_str = f.read()
Expand All @@ -37,9 +37,9 @@ def migrate_test():
return res


def build_test():
def build_test(single_case_text):
return True


def run_test():
def run_test(single_case_text):
return True
16 changes: 8 additions & 8 deletions behavior_tests/src/bad_input_1/do_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@

from test_utils import *

def setup_test():
change_dir(test_config.current_test)
def setup_test(single_case_text):
change_dir(single_case_text.name, single_case_text)
return True

def migrate_test():
def migrate_test(single_case_text):

call_subprocess(test_config.CT_TOOL + " --cuda-include-path=" + test_config.include_path + " " +
os.path.join("cuda", "migrate_nonbuilding_code.cu"))
return is_sub_string("unknown type name", test_config.command_output)
def build_test():
call_subprocess(single_case_text.CT_TOOL + " --cuda-include-path=" + single_case_text.include_path + " " +
os.path.join("cuda", "migrate_nonbuilding_code.cu"), single_case_text)
return is_sub_string("unknown type name", single_case_text.print_text)
def build_test(single_case_text):
return True
def run_test():
def run_test(single_case_text):
return True
18 changes: 9 additions & 9 deletions behavior_tests/src/bt-analysis-scope-path1/do_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,44 +15,44 @@
from test_utils import *


def setup_test():
change_dir(test_config.current_test)
def setup_test(single_case_text):
change_dir(single_case_text.name, single_case_text)
return True


def migrate_test():
def migrate_test(single_case_text):
# clean previous migration output
if (os.path.exists("out")):
shutil.rmtree("out")
migrate_cmd = test_config.CT_TOOL + " --cuda-include-path=" + test_config.include_path + " " + os.path.join(
migrate_cmd = single_case_text.CT_TOOL + " --cuda-include-path=" + single_case_text.include_path + " " + os.path.join(
"cuda",
"call_device_func_outside.cu") + " --in-root=cuda" + " --out-root=out"
# migrate with implicit --analysis-scope-path which defaults to --in-root
call_subprocess(migrate_cmd)
call_subprocess(migrate_cmd, single_case_text)
if (not os.path.exists(
os.path.join("out", "call_device_func_outside.dp.cpp"))):
return False
shutil.rmtree("out")

# migrate with specified --analysis-scope-path which equals --in-root
call_subprocess(migrate_cmd + " --analysis-scope-path=cuda")
call_subprocess(migrate_cmd + " --analysis-scope-path=cuda", single_case_text)
if (not os.path.exists(
os.path.join("out", "call_device_func_outside.dp.cpp"))):
return False
shutil.rmtree("out")

# migrate with specified --analysis-scope-path which is the parent of --in-root
call_subprocess(migrate_cmd + " --analysis-scope-path=" +
os.path.join("cuda", ".."))
os.path.join("cuda", ".."), single_case_text)
if (not os.path.exists(
os.path.join("out", "call_device_func_outside.dp.cpp"))):
return False
return True


def build_test():
def build_test(single_case_text):
return True


def run_test():
def run_test(single_case_text):
return True
22 changes: 11 additions & 11 deletions behavior_tests/src/bt-analysis-scope-path2/do_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,47 +15,47 @@
from test_utils import *


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


def migrate_test():
def migrate_test(single_case_text):
# clean previous migration output
if (os.path.exists("out")):
shutil.rmtree("out")
migrate_cmd = test_config.CT_TOOL + " --cuda-include-path=" + test_config.include_path + " " + os.path.join(
migrate_cmd = single_case_text.CT_TOOL + " --cuda-include-path=" + single_case_text.include_path + " " + os.path.join(
"cuda",
"call_device_func_outside.cu") + " --in-root=cuda" + " --out-root=out"
# migrate with implicit --analysis-scope-path which defaults to --in-root
call_subprocess(migrate_cmd)
call_subprocess(migrate_cmd, single_case_text)
if (not os.path.exists(
os.path.join("out", "call_device_func_outside.dp.cpp"))):
return False

# expect incremental migration with specified --analysis-scope-path which equals --in-root
call_subprocess(migrate_cmd + " --analysis-scope-path=cuda")
call_subprocess(migrate_cmd + " --analysis-scope-path=cuda", single_case_text)
if (not os.path.exists(
os.path.join("out", "call_device_func_outside.dp.cpp"))):
return False

# not expect incremental migration with specified --analysis-scope-path which is the parent of --in-root
call_subprocess(migrate_cmd + " --analysis-scope-path=" +
os.path.join("cuda", ".."))
os.path.join("cuda", ".."), single_case_text)
return is_sub_string(
f"use the same option set as in previous migration: \"--analysis-scope-path=",
test_config.command_output)
single_case_text.print_text)


def build_test():
def build_test(single_case_text):
return True


def run_test():
def run_test(single_case_text):
return True
14 changes: 7 additions & 7 deletions behavior_tests/src/bt-analysis-scope-path3/do_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,21 @@
from test_utils import *


def setup_test():
change_dir(test_config.current_test)
def setup_test(single_case_text):
change_dir(single_case_text.name, single_case_text)
return True


def migrate_test():
def migrate_test(single_case_text):
# clean previous migration output
if (os.path.exists("out")):
shutil.rmtree("out")
migrate_cmd = test_config.CT_TOOL + " --cuda-include-path=" + test_config.include_path + " " + os.path.join(
migrate_cmd = single_case_text.CT_TOOL + " --cuda-include-path=" + single_case_text.include_path + " " + os.path.join(
"cuda",
"call_device_func_outside.cu") + " --in-root=cuda" + " --out-root=out"

call_subprocess(migrate_cmd + " --analysis-scope-path=" +
os.path.join("cuda", ".."))
os.path.join("cuda", ".."), single_case_text)
expected_files = [
os.path.join("out", "call_device_func_outside.dp.cpp"),
]
Expand All @@ -54,9 +54,9 @@ def migrate_test():
return True


def build_test():
def build_test(single_case_text):
return True


def run_test():
def run_test(single_case_text):
return True
14 changes: 7 additions & 7 deletions behavior_tests/src/bt-analysis-scope-path4/do_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,33 +16,33 @@
from test_utils import *


def setup_test():
change_dir(test_config.current_test)
def setup_test(single_case_text):
change_dir(single_case_text.name, single_case_text)
if os.path.exists("cuda_symlink"):
os.unlink("cuda_symlink")
os.symlink("cuda", "cuda_symlink")
return True


def migrate_test():
def migrate_test(single_case_text):
# clean previous migration output
if (os.path.exists("out")):
shutil.rmtree("out")

migrate_cmd = test_config.CT_TOOL + " --cuda-include-path=" + test_config.include_path + " " + os.path.join(
migrate_cmd = single_case_text.CT_TOOL + " --cuda-include-path=" + single_case_text.include_path + " " + os.path.join(
"cuda",
"call_device_func_outside.cu") + " --in-root=cuda" + " --out-root=out"

call_subprocess(migrate_cmd + " --analysis-scope-path=cuda_symlink")
call_subprocess(migrate_cmd + " --analysis-scope-path=cuda_symlink", single_case_text)
if (not os.path.exists(
os.path.join("out", "call_device_func_outside.dp.cpp"))):
return False
return True


def build_test():
def build_test(single_case_text):
return True


def run_test():
def run_test(single_case_text):
return True
Loading