Skip to content

Commit

Permalink
Fix behavior test
Browse files Browse the repository at this point in the history
Signed-off-by: Ahmed, Daiyaan <[email protected]>
  • Loading branch information
daiyaan-ahmed6 committed Aug 2, 2023
1 parent c1f773c commit 7e5484c
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 27 deletions.
18 changes: 9 additions & 9 deletions behavior_tests/src/cmp_cmds_c_opt_test/compile_commands.json_ref
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
[
{
"command": "nvcc -O2 -DKERNEL_USE_PROFILE=1 -DRUN_ON_GPU=1 -o one -allow-unsupported-compiler -D__CUDACC__=1 one.cu",
"directory": "/export/users/dahmed/up/build/tools/clang/test/dpct/compile_commands_c_opt_test/Output/compile_commands_c_opt_test",
"file": "/export/users/dahmed/up/build/tools/clang/test/dpct/compile_commands_c_opt_test/Output/compile_commands_c_opt_test/one.cu"
"directory": "${TEST_DIRECTORY}",
"file": "${TEST_DIRECTORY}/one.cu"
},
{
"command": "nvcc -c -O2 -DKERNEL_USE_PROFILE=1 -DRUN_ON_GPU=1 -D__CUDACC__=1 two.cu",
"directory": "/export/users/dahmed/up/build/tools/clang/test/dpct/compile_commands_c_opt_test/Output/compile_commands_c_opt_test",
"file": "/export/users/dahmed/up/build/tools/clang/test/dpct/compile_commands_c_opt_test/Output/compile_commands_c_opt_test/two.cu"
"directory": "${TEST_DIRECTORY}",
"file": "${TEST_DIRECTORY}/two.cu"
},
{
"command": "nvcc -c -O2 -DKERNEL_USE_PROFILE=1 -DRUN_ON_GPU=1 -D__CUDACC__=1 three.cu",
"directory": "/export/users/dahmed/up/build/tools/clang/test/dpct/compile_commands_c_opt_test/Output/compile_commands_c_opt_test",
"file": "/export/users/dahmed/up/build/tools/clang/test/dpct/compile_commands_c_opt_test/Output/compile_commands_c_opt_test/three.cu"
"directory": "${TEST_DIRECTORY}",
"file": "${TEST_DIRECTORY}/three.cu"
},
{
"command": "nvcc -c -O2 -DKERNEL_USE_PROFILE=1 -DRUN_ON_GPU=1 -D__CUDACC__=1 four.cu",
"directory": "/export/users/dahmed/up/build/tools/clang/test/dpct/compile_commands_c_opt_test/Output/compile_commands_c_opt_test",
"file": "/export/users/dahmed/up/build/tools/clang/test/dpct/compile_commands_c_opt_test/Output/compile_commands_c_opt_test/four.cu"
"directory": "${TEST_DIRECTORY}",
"file": "${TEST_DIRECTORY}/four.cu"
}
]
]
47 changes: 29 additions & 18 deletions behavior_tests/src/cmp_cmds_c_opt_test/do_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#
#
# ===----------------------------------------------------------------------===#
import filecmp
import subprocess
import platform
import os
Expand All @@ -14,36 +15,46 @@

from test_utils import *


def setup_test():
change_dir(test_config.current_test)
return True


def parse_compilation_database(compilation_database_name):
if (not os.path.isfile(compilation_database_name)):
print("The compilation database is not existed, please double check\n")
if (not os.path.isfile(compilation_database_name)):
print("The compilation database is not existed, please double check\n")

with open(compilation_database_name) as compilation_database:
compilation_database_items = json.load(compilation_database)
database_source_files = []
for entry in compilation_database_items:
compilation_item = entry['file']
database_source_files.append(os.path.basename(compilation_item))
return database_source_files

with open(compilation_database_name) as compilation_database:
compilation_database_items = json.load(compilation_database)
database_source_files = []
for entry in compilation_database_items:
compilation_item = entry['file'];
database_source_files.append(os.path.basename(compilation_item))
return database_source_files

def migrate_test():
call_subprocess("intercept-build make -f Makefile CC=nvcc USE_SM=70 -B")
new_database = parse_compilation_database("compile_commands.json")
reference_database = parse_compilation_database("compile_commands.json_ref")
new_database = list(set(new_database))
reference_database = list(set(reference_database))
new_database.sort()
reference_database.sort()
if(new_database == reference_database):
return True
return False
test_dir = os.path.join(os.getcwd())
print(test_dir)
ref_cmp_db_file = open(test_dir+"/compile_commands.json_ref", "rt")
cmp_cmds = ref_cmp_db_file.read()
cmp_cmds = cmp_cmds.replace('${TEST_DIRECTORY}', test_dir)
ref_cmp_db_file.close()
ref_cmp_db_file = open(test_dir+"/compile_commands.json_ref", "wt")
ref_cmp_db_file.write(cmp_cmds)
ref_cmp_db_file.close()

result = filecmp.cmp(test_dir+"/compile_commands.json",
test_dir+"/compile_commands.json_ref", shallow=False)

return result


def build_test():
return True


def run_test():
return True

0 comments on commit 7e5484c

Please sign in to comment.