Skip to content

Commit 2030fe0

Browse files
authored
[SYCLomatic #1443] Add behavior test for analysis mode (#597)
Signed-off-by: Ziran Zhang <[email protected]>
1 parent 47da2c8 commit 2030fe0

File tree

3 files changed

+85
-0
lines changed

3 files changed

+85
-0
lines changed

behavior_tests/behavior_tests.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@
167167
<test testName="bt-no-dpct-helper-function" configFile="config/TEMPLATE_behavior_tests.xml" />
168168
<test testName="cmp-cmds-linker-entry-src-files" configFile="config/TEMPLATE_behavior_tests_lin.xml" />
169169
<test testName="cmake_dpct_helper_compile_sycl_code" configFile="config/TEMPLATE_behavior_tests.xml" />
170+
<test testName="analysis-mode" configFile="config/TEMPLATE_behavior_tests.xml" />
170171
</tests>
171172

172173
</suite>
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# ====------ do_test.py---------- *- Python -* ----===##
2+
#
3+
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
# See https://llvm.org/LICENSE.txt for license information.
5+
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
#
7+
#
8+
# ===----------------------------------------------------------------------===#
9+
import subprocess
10+
import platform
11+
import os
12+
import sys
13+
14+
from test_utils import *
15+
16+
17+
def setup_test():
18+
change_dir(test_config.current_test)
19+
return True
20+
21+
22+
def migrate_test():
23+
call_subprocess(
24+
test_config.CT_TOOL + " test.cu -analysis-mode --cuda-include-path=" + test_config.include_path)
25+
26+
27+
reference_lines = [
28+
["test.cu:"],
29+
["lines of code", "will be automatically migrated."],
30+
["APIs/Types - No manual effort."],
31+
["APIs/Types - Low manual effort for checking and code fixing."],
32+
["APIs/Types - Medium manual effort for code fixing."],
33+
["lines of code", "will not be automatically migrated."],
34+
["APIs/Types - High manual effort for code fixing."],
35+
["Total Project:"],
36+
["lines of code", "will be automatically migrated."],
37+
["APIs/Types - No manual effort."],
38+
["APIs/Types - Low manual effort for checking and code fixing."],
39+
["APIs/Types - Medium manual effort for code fixing."],
40+
["lines of code", "will not be automatically migrated."],
41+
["APIs/Types - High manual effort for code fixing."]]
42+
43+
ret_lines = test_config.command_output.splitlines()
44+
res = True
45+
idx = 5
46+
for refs in reference_lines:
47+
ret = ret_lines[idx]
48+
for ref in refs:
49+
if ref not in ret:
50+
res = False
51+
print("there should be a '" + ref + "' in output.")
52+
idx = idx + 1
53+
54+
return res
55+
56+
57+
def build_test():
58+
return True
59+
60+
61+
def run_test():
62+
return True
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// ====------ test.cu---------- *- CUDA -* ----===////
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//
8+
// ===----------------------------------------------------------------------===//
9+
10+
__global__ void kernel(int *a) {
11+
*a = clock64();
12+
__syncthreads();
13+
int b = *a;
14+
}
15+
16+
void foo() {
17+
int *a;
18+
size_t b, c;
19+
cudaMemGetInfo(&b, &c);
20+
cudaMalloc(&a, sizeof(int));
21+
cudaFree(a);
22+
}

0 commit comments

Comments
 (0)