Skip to content

Commit ecb1b33

Browse files
authored
[tests] Conditionally skip valgrind xfails using llvm::sys (#281)
1 parent 01b5bc3 commit ecb1b33

File tree

8 files changed

+31
-15
lines changed

8 files changed

+31
-15
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,7 @@ jobs:
294294
run: |
295295
# Install deps
296296
sudo apt-get update
297+
sudo apt-get install valgrind
297298
sudo apt-get autoremove
298299
sudo apt-get clean
299300

unittests/CppInterOp/CUDATest.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ TEST(CUDATest, CUDAH) {
6161
}
6262

6363
TEST(CUDATest, CUDARuntime) {
64-
if (!HasCudaSDK())
65-
GTEST_SKIP() << "Skipping CUDA tests as CUDA SDK not found";
64+
if (!HasCudaRuntime())
65+
GTEST_SKIP() << "Skipping CUDA tests as CUDA runtime not found";
6666

6767
EXPECT_TRUE(HasCudaRuntime());
6868
}

unittests/CppInterOp/FunctionReflectionTest.cpp

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -531,7 +531,8 @@ TEST(FunctionReflectionTest, ExistsFunctionTemplate) {
531531
}
532532

533533
TEST(FunctionReflectionTest, InstantiateTemplateFunctionFromString) {
534-
GTEST_SKIP() << "XFAIL due to Valgrind report";
534+
if (llvm::sys::RunningOnValgrind())
535+
GTEST_SKIP() << "XFAIL due to Valgrind report";
535536
Cpp::CreateInterpreter();
536537
std::string code = R"(#include <memory>)";
537538
Interp->process(code);
@@ -733,7 +734,8 @@ TEST(FunctionReflectionTest, IsStaticMethod) {
733734
}
734735

735736
TEST(FunctionReflectionTest, GetFunctionAddress) {
736-
GTEST_SKIP() << "XFAIL due to Valgrind report";
737+
if (llvm::sys::RunningOnValgrind())
738+
GTEST_SKIP() << "XFAIL due to Valgrind report";
737739
std::vector<Decl*> Decls, SubDecls;
738740
std::string code = "int f1(int i) { return i * i; }";
739741

@@ -773,7 +775,8 @@ TEST(FunctionReflectionTest, IsVirtualMethod) {
773775
}
774776

775777
TEST(FunctionReflectionTest, JitCallAdvanced) {
776-
GTEST_SKIP() << "XFAIL due to Valgrind report";
778+
if (llvm::sys::RunningOnValgrind())
779+
GTEST_SKIP() << "XFAIL due to Valgrind report";
777780
std::vector<Decl*> Decls;
778781
std::string code = R"(
779782
typedef struct _name {
@@ -796,7 +799,8 @@ TEST(FunctionReflectionTest, JitCallAdvanced) {
796799

797800

798801
TEST(FunctionReflectionTest, GetFunctionCallWrapper) {
799-
GTEST_SKIP() << "XFAIL due to Valgrind report";
802+
if (llvm::sys::RunningOnValgrind())
803+
GTEST_SKIP() << "XFAIL due to Valgrind report";
800804
std::vector<Decl*> Decls;
801805
std::string code = R"(
802806
int f1(int i) { return i * i; }
@@ -1006,7 +1010,8 @@ TEST(FunctionReflectionTest, GetFunctionArgDefault) {
10061010
}
10071011

10081012
TEST(FunctionReflectionTest, Construct) {
1009-
GTEST_SKIP() << "XFAIL due to Valgrind report";
1013+
if (llvm::sys::RunningOnValgrind())
1014+
GTEST_SKIP() << "XFAIL due to Valgrind report";
10101015
Cpp::CreateInterpreter();
10111016

10121017
Interp->declare(R"(
@@ -1041,7 +1046,8 @@ TEST(FunctionReflectionTest, Construct) {
10411046
}
10421047

10431048
TEST(FunctionReflectionTest, Destruct) {
1044-
GTEST_SKIP() << "XFAIL due to Valgrind report";
1049+
if (llvm::sys::RunningOnValgrind())
1050+
GTEST_SKIP() << "XFAIL due to Valgrind report";
10451051
Cpp::CreateInterpreter();
10461052

10471053
Interp->declare(R"(

unittests/CppInterOp/InterpreterTest.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
#include "clang/Interpreter/CppInterOp.h"
1+
#include "Utils.h"
22

3+
#include "clang/Interpreter/CppInterOp.h"
34
#include "clang/Basic/Version.h"
45

56
#include "llvm/ADT/SmallString.h"
@@ -44,7 +45,8 @@ TEST(InterpreterTest, DebugFlag) {
4445
}
4546

4647
TEST(InterpreterTest, Evaluate) {
47-
GTEST_SKIP() << "XFAIL due to Valgrind report";
48+
if (llvm::sys::RunningOnValgrind())
49+
GTEST_SKIP() << "XFAIL due to Valgrind report";
4850
// EXPECT_TRUE(Cpp::Evaluate(I, "") == 0);
4951
//EXPECT_TRUE(Cpp::Evaluate(I, "__cplusplus;") == 201402);
5052
// Due to a deficiency in the clang-repl implementation to get the value we
@@ -59,7 +61,8 @@ TEST(InterpreterTest, Evaluate) {
5961
}
6062

6163
TEST(InterpreterTest, Process) {
62-
GTEST_SKIP() << "XFAIL due to Valgrind report";
64+
if (llvm::sys::RunningOnValgrind())
65+
GTEST_SKIP() << "XFAIL due to Valgrind report";
6366
Cpp::CreateInterpreter();
6467
EXPECT_TRUE(Cpp::Process("") == 0);
6568
EXPECT_TRUE(Cpp::Process("int a = 12;") == 0);

unittests/CppInterOp/JitTest.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ static int printf_jit(const char* format, ...) {
1212
}
1313

1414
TEST(JitTest, InsertOrReplaceJitSymbol) {
15-
GTEST_SKIP() << "XFAIL due to Valgrind report";
15+
if (llvm::sys::RunningOnValgrind())
16+
GTEST_SKIP() << "XFAIL due to Valgrind report";
1617
std::vector<Decl*> Decls;
1718
std::string code = R"(
1819
extern "C" int printf(const char*,...);

unittests/CppInterOp/ScopeReflectionTest.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include "Utils.h"
2+
23
#include "clang/Interpreter/CppInterOp.h"
34

45
#include "clang/AST/ASTContext.h"
@@ -799,7 +800,8 @@ template<typename T> T TrivialFnTemplate() { return T(); }
799800
}
800801

801802
TEST(ScopeReflectionTest, InstantiateTemplateFunctionFromString) {
802-
GTEST_SKIP() << "XFAIL due to Valgrind report";
803+
if (llvm::sys::RunningOnValgrind())
804+
GTEST_SKIP() << "XFAIL due to Valgrind report";
803805
Cpp::CreateInterpreter();
804806
std::string code = R"(#include <memory>)";
805807
Interp->process(code);
@@ -938,7 +940,8 @@ TEST(ScopeReflectionTest, GetClassTemplateInstantiationArgs) {
938940

939941

940942
TEST(ScopeReflectionTest, IncludeVector) {
941-
GTEST_SKIP() << "XFAIL due to Valgrind report";
943+
if (llvm::sys::RunningOnValgrind())
944+
GTEST_SKIP() << "XFAIL due to Valgrind report";
942945
std::string code = R"(
943946
#include <vector>
944947
#include <iostream>

unittests/CppInterOp/TypeReflectionTest.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,8 @@ TEST(TypeReflectionTest, IsPODType) {
523523
}
524524

525525
TEST(TypeReflectionTest, IsSmartPtrType) {
526-
GTEST_SKIP() << "XFAIL due to Valgrind report";
526+
if (llvm::sys::RunningOnValgrind())
527+
GTEST_SKIP() << "XFAIL due to Valgrind report";
527528
Cpp::CreateInterpreter();
528529

529530
Interp->declare(R"(

unittests/CppInterOp/Utils.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
#include <memory>
77
#include <vector>
8+
#include "llvm/Support/Valgrind.h"
89

910
using namespace clang;
1011
using namespace llvm;

0 commit comments

Comments
 (0)