Skip to content

Commit

Permalink
fix output and command record
Browse files Browse the repository at this point in the history
Signed-off-by: Ni, Wenhui <[email protected]>
  • Loading branch information
wenhuiNi committed Jul 3, 2023
1 parent 999916c commit 61e86bd
Show file tree
Hide file tree
Showing 122 changed files with 203 additions and 190 deletions.
2 changes: 1 addition & 1 deletion behavior_tests/src/bad_input_1/do_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ 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"), single_case_text)
return is_sub_string("unknown type name", single_case_text.command_text)
return is_sub_string("unknown type name", single_case_text.print_text)
def build_test(single_case_text):
return True
def run_test(single_case_text):
Expand Down
2 changes: 1 addition & 1 deletion behavior_tests/src/bt-analysis-scope-path2/do_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def migrate_test(single_case_text):
os.path.join("cuda", ".."), single_case_text)
return is_sub_string(
f"use the same option set as in previous migration: \"--analysis-scope-path=",
single_case_text.command_text)
single_case_text.print_text)


def build_test(single_case_text):
Expand Down
44 changes: 22 additions & 22 deletions behavior_tests/src/bt-autocomplete/do_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,93 +21,93 @@ def migrate_test(single_case_text):

call_subprocess(test_config.CT_TOOL + " --autocomplete=--gen-build", single_case_text)
reference = '--gen-build-script\n'
res = res and (reference == single_case_text.command_text)
res = res and (reference == single_case_text.print_text)

call_subprocess(test_config.CT_TOOL + " --autocomplete=-gen-build", single_case_text)
reference = '-gen-build-script\n'
res = res and (reference == single_case_text.command_text)
res = res and (reference == single_case_text.print_text)

call_subprocess(test_config.CT_TOOL + " --autocomplete=foo")
reference = '\n'
res = res and (reference == single_case_text.command_text)
res = res and (reference == single_case_text.print_text)

call_subprocess(test_config.CT_TOOL + " --autocomplete=--output-verbosity=#d", single_case_text)
reference = 'detailed\n' + \
'diagnostics\n'
res = res and (reference == single_case_text.command_text)
res = res and (reference == single_case_text.print_text)

call_subprocess(test_config.CT_TOOL + " --autocomplete=-output-verbosity=#d", single_case_text)
reference = 'detailed\n' + \
'diagnostics\n'
res = res and (reference == single_case_text.command_text)
res = res and (reference == single_case_text.print_text)

call_subprocess(test_config.CT_TOOL + " --autocomplete=--output-verbosity=", single_case_text)
reference = 'detailed\n' + \
'diagnostics\n' + \
'normal\n' + \
'silent\n'
res = res and (reference == single_case_text.command_text)
res = res and (reference == single_case_text.print_text)

call_subprocess(test_config.CT_TOOL + " --autocomplete=-output-verbosity=", single_case_text)
reference = 'detailed\n' + \
'diagnostics\n' + \
'normal\n' + \
'silent\n'
res = res and (reference == single_case_text.command_text)
res = res and (reference == single_case_text.print_text)

call_subprocess(test_config.CT_TOOL + " --autocomplete=foo#bar##--enable-c", single_case_text)
reference = '--enable-ctad\n'
res = res and (reference == single_case_text.command_text)
res = res and (reference == single_case_text.print_text)

call_subprocess(test_config.CT_TOOL + " --autocomplete=foo#bar###--format-range=#a", single_case_text)
reference = 'all\n'
res = res and (reference == single_case_text.command_text)
res = res and (reference == single_case_text.print_text)

call_subprocess(test_config.CT_TOOL + " --autocomplete=--rule-file=", single_case_text)
reference = '\n'
res = res and (reference == single_case_text.command_text)
res = res and (reference == single_case_text.print_text)

call_subprocess(test_config.CT_TOOL + " --autocomplete=--rule-file", single_case_text)
reference = '--rule-file\n'
res = res and (reference == single_case_text.command_text)
res = res and (reference == single_case_text.print_text)

call_subprocess(test_config.CT_TOOL + " --autocomplete=-p=", single_case_text)
reference = '\n'
res = res and (reference == single_case_text.command_text)
res = res and (reference == single_case_text.print_text)

call_subprocess(test_config.CT_TOOL + " --autocomplete=-p", single_case_text)
reference = '-p\n' + \
'-process-all\n'
res = res and (reference == single_case_text.command_text)
res = res and (reference == single_case_text.print_text)

call_subprocess(test_config.CT_TOOL + " --autocomplete=--usm-level=#none,restricted#--use-explicit-namespace=#cl,sycl,", single_case_text)
reference = 'cl,sycl,cl\n' + \
'cl,sycl,dpct\n' + \
'cl,sycl,none\n' + \
'cl,sycl,sycl\n' + \
'cl,sycl,sycl-math\n'
res = res and (reference == single_case_text.command_text)
res = res and (reference == single_case_text.print_text)

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

call_subprocess(test_config.CT_TOOL + " --autocomplete=", single_case_text)
reference = '\n'
res = res and (reference == single_case_text.command_text)
res = res and (reference == single_case_text.print_text)

call_subprocess(test_config.CT_TOOL + " --autocomplete=,", single_case_text)
reference = '\n'
res = res and (reference == single_case_text.command_text)
res = res and (reference == single_case_text.print_text)

call_subprocess(test_config.CT_TOOL + " --autocomplete==", single_case_text)
reference = '\n'
res = res and (reference == single_case_text.command_text)
res = res and (reference == single_case_text.print_text)

call_subprocess(test_config.CT_TOOL + " --autocomplete=,,", single_case_text)
reference = '\n'
res = res and (reference == single_case_text.command_text)
res = res and (reference == single_case_text.print_text)

call_subprocess(test_config.CT_TOOL + " --autocomplete=-", single_case_text)
opts = ['--always-use-async-handler\n',
Expand Down Expand Up @@ -152,15 +152,15 @@ def migrate_test(single_case_text):
'--version\n',
'-p\n']
for opt in opts:
res = res and (opt in single_case_text.command_text)
res = res and (opt in single_case_text.print_text)

call_subprocess(test_config.CT_TOOL + " --autocomplete=##", single_case_text)
reference = '\n'
res = res and (reference == single_case_text.command_text)
res = res and (reference == single_case_text.print_text)

call_subprocess(test_config.CT_TOOL + " --autocomplete=#", single_case_text)
reference = '\n'
res = res and (reference == single_case_text.command_text)
res = res and (reference == single_case_text.print_text)

return res

Expand Down
2 changes: 1 addition & 1 deletion behavior_tests/src/bt-check-unexpected-message/do_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def setup_test(single_case_text):

def migrate_test(single_case_text):
call_subprocess(test_config.CT_TOOL + " test.cu --out-root=out --cuda-include-path=" + test_config.include_path + " --extra-arg=-xc++", single_case_text)
return not is_sub_string("warning: '-x c' after last input file has no effect [-Wunused-command-line-argument]", single_case_text.command_text)
return not is_sub_string("warning: '-x c' after last input file has no effect [-Wunused-command-line-argument]", single_case_text.print_text)

def build_test(single_case_text):
return call_subprocess("icpx -fsycl out/test.dp.cpp", single_case_text)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def setup_test(single_case_text):

def migrate_test(single_case_text):
call_subprocess(test_config.CT_TOOL + " -p=./ --cuda-include-path=" + test_config.include_path, single_case_text)
return is_sub_string("Migration not necessary; no CUDA code detected", single_case_text.command_text)
return is_sub_string("Migration not necessary; no CUDA code detected", single_case_text.print_text)
def build_test(single_case_text):
return True
def run_test(single_case_text):
Expand Down
6 changes: 3 additions & 3 deletions behavior_tests/src/bt-extra-arg/do_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ def setup_test(single_case_text):

def migrate_test(single_case_text):
return (call_subprocess(test_config.CT_TOOL + " --extra-arg=\"--cuda-path=" + test_config.include_path + "\" vector_add.cu", single_case_text)
and is_sub_string("Parsing", single_case_text.command_text)
and is_sub_string("Analyzing", single_case_text.command_text)
and is_sub_string("Migrating", single_case_text.command_text))
and is_sub_string("Parsing", single_case_text.print_text)
and is_sub_string("Analyzing", single_case_text.print_text)
and is_sub_string("Migrating", single_case_text.print_text))

def build_test(single_case_text):
return True
Expand Down
2 changes: 1 addition & 1 deletion behavior_tests/src/bt-help/do_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def setup_test(single_case_text):
def migrate_test(single_case_text):

call_subprocess(test_config.CT_TOOL +" --help", single_case_text)
return is_sub_string("USAGE", single_case_text.command_text)
return is_sub_string("USAGE", single_case_text.print_text)

def build_test(single_case_text):
return True
Expand Down
2 changes: 1 addition & 1 deletion behavior_tests/src/bt-in-root-empty-process-all/do_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def setup_test(single_case_text):
def migrate_test(single_case_text):

call_subprocess(test_config.CT_TOOL + " --process-all --cuda-include-path=" + test_config.include_path + " --in-root=", single_case_text)
return is_sub_string("Error: The option --process-all requires that the --in-root be specified explicitly", single_case_text.command_text)
return is_sub_string("Error: The option --process-all requires that the --in-root be specified explicitly", single_case_text.print_text)

def build_test(single_case_text):
return True
Expand Down
2 changes: 1 addition & 1 deletion behavior_tests/src/bt-invalid-cuda-version/do_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def migrate_test(single_case_text):
in_root = os.getcwd()
test_case_path = os.path.join(in_root, "vector_add.cu")
call_subprocess(test_config.CT_TOOL + " " + test_case_path + " --out-root=out --in-root=" + in_root + " --cuda-include-path=" + include_path, single_case_text)
return is_sub_string("Error: The version of CUDA header files specified by --cuda-include-path is not supported. See Release Notes for supported versions.", single_case_text.command_text)
return is_sub_string("Error: The version of CUDA header files specified by --cuda-include-path is not supported. See Release Notes for supported versions.", single_case_text.print_text)

def build_test(single_case_text):
return True
Expand Down
4 changes: 2 additions & 2 deletions behavior_tests/src/bt-kernel-function-limitation/do_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ def migrate_test(single_case_text):

call_subprocess(test_config.CT_TOOL + " --optimize-migration --out-root=./out kernel-func.cu --cuda-include-path=" + test_config.include_path, single_case_text)

ret = is_sub_string("Recursive functions cannot be called in SYCL device code", single_case_text.command_text)
ret = is_sub_string("Virtual functions cannot be called in SYCL device code", single_case_text.command_text) and ret
ret = is_sub_string("Recursive functions cannot be called in SYCL device code", single_case_text.print_text)
ret = is_sub_string("Virtual functions cannot be called in SYCL device code", single_case_text.print_text) and ret
return ret
def build_test(single_case_text):
return True
Expand Down
2 changes: 1 addition & 1 deletion behavior_tests/src/bt-language-warning/do_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def setup_test(single_case_text):

def migrate_test(single_case_text):
call_subprocess(test_config.CT_TOOL + " test.cpp --out-root=out --cuda-include-path=" + test_config.include_path, single_case_text)
return is_sub_string("NOTE: test.cpp is treated as a CUDA file by default. Use the --extra-arg=-xc++ option to treat test.cpp as a C++ file if needed.", single_case_text.command_text)
return is_sub_string("NOTE: test.cpp is treated as a CUDA file by default. Use the --extra-arg=-xc++ option to treat test.cpp as a C++ file if needed.", single_case_text.print_text)

def build_test(single_case_text):
return True
Expand Down
2 changes: 1 addition & 1 deletion behavior_tests/src/bt-suppress-warnings-all/do_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def setup_test(single_case_text):

def migrate_test(single_case_text):
call_subprocess(test_config.CT_TOOL + " --suppress-warnings-all vector_add.cu --cuda-include-path=" + test_config.include_path, single_case_text)
return not is_sub_string("DPCT1015", single_case_text.command_text)
return not is_sub_string("DPCT1015", single_case_text.print_text)
def build_test(single_case_text):
return True

Expand Down
2 changes: 1 addition & 1 deletion behavior_tests/src/bt-suppress-warnings/do_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def setup_test(single_case_text):

def migrate_test(single_case_text):
call_subprocess(test_config.CT_TOOL + " hello.cu --suppress-warnings=1000-1003,1008 --cuda-include-path=" + test_config.include_path, single_case_text)
return not is_sub_string("warning: DPCT10", single_case_text.command_text)
return not is_sub_string("warning: DPCT10", single_case_text.print_text)
def build_test(single_case_text):
return True

Expand Down
4 changes: 2 additions & 2 deletions behavior_tests/src/bt-version/do_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ def migrate_test(single_case_text):
ct_clang_version = get_ct_clang_version()
expected_output = "dpct version {0}".format(ct_clang_version)
print("expected dpct version output: {0}".format(expected_output))
print("\n'dpct --version' outputs {0}".format(single_case_text.command_text))
return is_sub_string(expected_output, single_case_text.command_text)
print("\n'dpct --version' outputs {0}".format(single_case_text.print_text))
return is_sub_string(expected_output, single_case_text.print_text)

def build_test(single_case_text):
return True
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def setup_test(single_case_text):

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)
return is_sub_string("Incremental migration requires the same version of dpct. Migration continues with incremental migration disabled", single_case_text.command_text)
return is_sub_string("Incremental migration requires the same version of dpct. Migration continues with incremental migration disabled", single_case_text.print_text)

def build_test(single_case_text):
return True
Expand Down
6 changes: 3 additions & 3 deletions behavior_tests/src/bt-yaml-with-different-options1/do_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ def setup_test(single_case_text):
def migrate_test(single_case_text):
call_subprocess(test_config.CT_TOOL + " test.cu --in-root . --out-root out --always-use-async-handler --assume-nd-range-dim=1 --comments --enable-ctad --no-dpcpp-extensions=enqueued_barriers --no-dry-pattern --process-all -p . --sycl-named-lambda --use-experimental-features=free-function-queries,nd_range_barrier --use-explicit-namespace=cl,dpct --usm-level=none --cuda-include-path=" + test_config.include_path, single_case_text)
call_subprocess(test_config.CT_TOOL + " test.cu --out-root out --cuda-include-path=" + test_config.include_path, single_case_text)
return is_sub_string("\"--analysis-scope-path=\"", single_case_text.command_text) and \
is_sub_string("--always-use-async-handler --comments --compilation-database=\"", single_case_text.command_text) and \
is_sub_string("--enable-ctad --use-experimental-features=free-function-queries,nd_range_barrier --use-explicit-namespace=cl,dpct --no-dpcpp-extensions=enqueued_barriers --assume-nd-range-dim=1 --no-dry-pattern --process-all --sycl-named-lambda --usm-level=none\".", single_case_text.command_text)
return is_sub_string("\"--analysis-scope-path=\"", single_case_text.print_text) and \
is_sub_string("--always-use-async-handler --comments --compilation-database=\"", single_case_text.print_text) and \
is_sub_string("--enable-ctad --use-experimental-features=free-function-queries,nd_range_barrier --use-explicit-namespace=cl,dpct --no-dpcpp-extensions=enqueued_barriers --assume-nd-range-dim=1 --no-dry-pattern --process-all --sycl-named-lambda --usm-level=none\".", single_case_text.print_text)

def build_test(single_case_text):
return True
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def setup_test(single_case_text):
def migrate_test(single_case_text):
call_subprocess(test_config.CT_TOOL + " test.cu --out-root out --no-cl-namespace-inline --cuda-include-path=" + test_config.include_path, single_case_text)
call_subprocess(test_config.CT_TOOL + " test.cu --out-root out --cuda-include-path=" + test_config.include_path, single_case_text)
return is_sub_string("--no-cl-namespace-inline\".", single_case_text.command_text)
return is_sub_string("--no-cl-namespace-inline\".", single_case_text.print_text)

def build_test(single_case_text):
return True
Expand Down
4 changes: 2 additions & 2 deletions behavior_tests/src/bt-yaml-without-ct-version/do_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ def setup_test(single_case_text):
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)
return is_sub_string("Failed to load", single_case_text.command_text) and \
is_sub_string("Migration continues with incremental migration disabled", single_case_text.command_text)
return is_sub_string("Failed to load", single_case_text.print_text) and \
is_sub_string("Migration continues with incremental migration disabled", single_case_text.print_text)

def build_test(single_case_text):
return True
Expand Down
2 changes: 1 addition & 1 deletion behavior_tests/src/cannot-acc-dir-in-db/do_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def migrate_test(single_case_text):
call_subprocess(test_config.CT_TOOL + ' -p ./helloworld_tst/compile_commands.json --cuda-include-path=' + \
os.environ['CUDA_INCLUDE_PATH'], single_case_text)

if 'check if the directory exists and can be accessed by the tool' in single_case_text.command_text:
if 'check if the directory exists and can be accessed by the tool' in single_case_text.print_text:
return True
print("could not get expected message: check if the directory exists and can be accessed by the tool")
return False
Expand Down
10 changes: 5 additions & 5 deletions behavior_tests/src/change-filename-extension/do_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,30 +22,30 @@ def setup_test(single_case_text):
def migrate_test(single_case_text):
call_subprocess(
test_config.CT_TOOL + " -p=. --change-cuda-files-extension-only --out-root=out --cuda-include-path=" + test_config.include_path, single_case_text)
print(single_case_text.command_text)
print(single_case_text.print_text)

reference = 'main.dp.cpp'
call_subprocess("ls out | grep " + reference, single_case_text)
res = True
if reference not in single_case_text.command_text:
if reference not in single_case_text.print_text:
res = False
print("there should be a file: " + reference)

reference = 'test.cpp'
call_subprocess("ls out | grep " + reference, single_case_text)
if reference not in single_case_text.command_text:
if reference not in single_case_text.print_text:
res = False
print("there should be a file: " + reference)

reference = 'test.dp.hpp'
call_subprocess("ls out | grep " + reference, single_case_text)
if reference not in single_case_text.command_text:
if reference not in single_case_text.print_text:
res = False
print("there should be a file: " + reference)

reference = 'test.h'
call_subprocess("ls out | grep " + reference, single_case_text)
if reference not in single_case_text.command_text:
if reference not in single_case_text.print_text:
res = False
print("there should be a file: " + reference)

Expand Down
4 changes: 2 additions & 2 deletions behavior_tests/src/check-device-unsupport-aspect/do_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def run_test(single_case_text):
res += 1
print("double.run run pass")
print("double.run output:")
print(single_case_text.command_text)
print(single_case_text.print_text)
if res != 1:
print("case 'double' failed")
return False
Expand All @@ -79,7 +79,7 @@ def run_test(single_case_text):
res += 1
print("half.run run pass")
print("half.run output:")
print(single_case_text.command_text)
print(single_case_text.print_text)
if res != 2:
print("case 'half' failed")
return False
Expand Down
2 changes: 1 addition & 1 deletion behavior_tests/src/check-windows-version/do_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def setup_test(single_case_text):

def get_windows_version(arg1, arg2):
call_subprocess("powershell \"(Get-Item -path " + arg1 + ").VersionInfo." + arg2 + "\"", single_case_text)
return single_case_text.command_text
return single_case_text.print_text

def migrate_test(single_case_text):
ct_path = get_ct_path()
Expand Down
Loading

0 comments on commit 61e86bd

Please sign in to comment.