Skip to content

Commit a9705ff

Browse files
committed
add test
1 parent b48efc6 commit a9705ff

File tree

2 files changed

+34
-8
lines changed

2 files changed

+34
-8
lines changed

unittests/CppInterOp/CUDATest.cpp

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,3 +75,37 @@ TEST(CUDATest, CUDARuntime) {
7575

7676
EXPECT_TRUE(HasCudaRuntime());
7777
}
78+
79+
#ifndef CPPINTEROP_USE_CLING
80+
static bool HasCudaSDK_CAPI() {
81+
auto supportsCudaSDK = []() {
82+
#if CLANG_VERSION_MAJOR < 16
83+
return false;
84+
#endif // CLANG_VERSION_MAJOR < 16
85+
86+
const char* argv[] = {"--cuda"};
87+
CXInterpreter CXI = clang_createInterpreter(argv, 1);
88+
if (!CXI)
89+
return false;
90+
91+
// Clean up the interpreter since we just needed to test creation
92+
clang_Interpreter_dispose(CXI);
93+
return true;
94+
};
95+
static bool hasCuda = supportsCudaSDK();
96+
return hasCuda;
97+
}
98+
99+
TEST(CUDATest, SanityCAPI) {
100+
#ifdef _WIN32
101+
GTEST_SKIP() << "Disabled on Windows. Needs fixing.";
102+
#endif
103+
if (!HasCudaSDK_CAPI())
104+
GTEST_SKIP() << "Skipping CUDA CAPI test; CUDA not available.";
105+
106+
const char* argv[] = {"--cuda"};
107+
CXInterpreter CXI = clang_createInterpreter(argv, 1);
108+
EXPECT_NE(CXI, nullptr);
109+
clang_Interpreter_dispose(CXI);
110+
}
111+
#endif

unittests/CppInterOp/InterpreterTest.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -177,14 +177,6 @@ TEST(InterpreterTest, CreateInterpreterCAPI) {
177177

178178
clang_Interpreter_dispose(CXI);
179179
}
180-
181-
TEST(InterpreterTest, CreateInterpreterCAPIFailure) {
182-
const char* argv[] = {
183-
"--this-flag-should-not-exist"
184-
};
185-
CXInterpreter CXI = clang_createInterpreter(argv, 1);
186-
EXPECT_EQ(CXI, nullptr);
187-
}
188180
#endif
189181

190182
#ifdef LLVM_BINARY_DIR

0 commit comments

Comments
 (0)