Skip to content

Commit

Permalink
[SYCLomatic #1311]Add behavior test for incorrect compilation databas…
Browse files Browse the repository at this point in the history
…e generation when source file builds with "-optf" of intercept-build tool (#474)

Signed-off-by: chenwei.sun <[email protected]>
  • Loading branch information
tomflinda authored Oct 11, 2023
1 parent 319c955 commit bf529b7
Show file tree
Hide file tree
Showing 13 changed files with 104 additions and 0 deletions.
1 change: 1 addition & 0 deletions behavior_tests/behavior_tests.xml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
<test testName="ngt-invalid-cuda-include-path" configFile="config/TEMPLATE_behavior_tests.xml" />
<test testName="bt-empty-cdb-default-out-folder" configFile="config/TEMPLATE_behavior_tests.xml" />
<test testName="cannot-acc-dir-in-db" configFile="config/TEMPLATE_behavior_tests_lin.xml" />
<test testName="process_optf_option" configFile="config/TEMPLATE_behavior_tests_lin.xml" />
<test testName="ngt-invalid-yaml-for-format1" configFile="config/TEMPLATE_behavior_tests.xml" />
<test testName="ngt-invalid-yaml-for-format2" configFile="config/TEMPLATE_behavior_tests.xml" />
<test testName="ngt-invalid-yaml-for-format3" configFile="config/TEMPLATE_behavior_tests.xml" />
Expand Down
40 changes: 40 additions & 0 deletions behavior_tests/src/process_optf_option/do_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# ====------ do_test.py---------- *- Python -* ----===##
#
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
# See https://llvm.org/LICENSE.txt for license information.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#
#
# ===----------------------------------------------------------------------===#
import subprocess
import platform
import os
import sys

from test_utils import *

def setup_test():
return True

def migrate_test():
change_dir('process_optf_option/use_optf_option_case')
call_subprocess('intercept-build /usr/bin/make')
call_subprocess(test_config.CT_TOOL + ' -in-root ./ -out-root out -gen-build-script -p ./compile_commands.json --cuda-include-path=' + \
os.environ['CUDA_INCLUDE_PATH'])
change_dir("./out")
call_subprocess("make -f Makefile.dpct -B")


if os.path.isfile("./test1.dp.o") and os.path.isfile("./test1.dp.o"):
print("process_optf_option migrate pass")
return True
else:
print("process_optf_option migrate failed")
return False


def build_test():
return True

def run_test():
return True
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
all:test

test:test1.o test2.o

test1.o:test1.cu
nvcc -c test1.cu --options-file=./includes1.rsp -optf=./includes2.rsp --options-file ./includes3.rsp -optf ./includes4.rsp

test2.o:test2.cu
cd inner && nvcc -c ../test2.cu



clean:
-rm inner/test2.o test1.o
Empty file.
Empty file.
Empty file.
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-D__FOO1__ -I"./inc/inc1"
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-D__FOO2__ -I"./inc/inc2"
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-D__FOO3__ -I"./inc/inc3"
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-D__FOO4__ -I"./inc/inc4"
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// ====------ test1.cu---------------------------------- *- CUDA -* ----===////
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//
// ===----------------------------------------------------------------------===//

#include <cuda.h>

#ifdef __FOO1__
__global__ void foo1() {}
#endif

#ifdef __FOO2__
__global__ void foo2() {}
#endif

#ifdef __FOO3__
__global__ void foo3() {}
#endif

#ifdef __FOO4__
__global__ void foo4() {}
#endif

#include "foo1.h"
#include "foo2.h"
#include "foo3.h"
#include "foo4.h"

int main() { return 0; }
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// ====------ test2.cu---------------------------------- *- CUDA -* ----===////
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//
// ===----------------------------------------------------------------------===//

#ifdef __FOO__
__global__ void foo() {}
#endif

0 comments on commit bf529b7

Please sign in to comment.