Skip to content

Commit fde3004

Browse files
committed
Use valgrind's macro instead of LLVM's interface
1 parent fa7ab10 commit fde3004

File tree

7 files changed

+27
-19
lines changed

7 files changed

+27
-19
lines changed

.github/workflows/ci.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -744,7 +744,7 @@ jobs:
744744
run: |
745745
# Install deps
746746
sudo apt-get update
747-
sudo apt-get install git g++ debhelper devscripts gnupg python3
747+
sudo apt-get install git g++ debhelper devscripts gnupg python3 valgrind
748748
sudo apt-get install -y libc6-dbg
749749
sudo snap install valgrind --classic
750750
sudo apt autoremove

unittests/CppInterOp/FunctionReflectionTest.cpp

+6-7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#include "Utils.h"
22

3-
#include "llvm/Support/Valgrind.h"
43
#include "clang/AST/ASTContext.h"
54
#include "clang/Interpreter/CppInterOp.h"
65
#include "clang/Frontend/CompilerInstance.h"
@@ -532,7 +531,7 @@ TEST(FunctionReflectionTest, ExistsFunctionTemplate) {
532531
}
533532

534533
TEST(FunctionReflectionTest, InstantiateTemplateFunctionFromString) {
535-
if (llvm::sys::RunningOnValgrind())
534+
if (RUNNING_ON_VALGRIND)
536535
GTEST_SKIP() << "XFAIL due to Valgrind report";
537536
Cpp::CreateInterpreter();
538537
std::string code = R"(#include <memory>)";
@@ -735,7 +734,7 @@ TEST(FunctionReflectionTest, IsStaticMethod) {
735734
}
736735

737736
TEST(FunctionReflectionTest, GetFunctionAddress) {
738-
if (llvm::sys::RunningOnValgrind())
737+
if (RUNNING_ON_VALGRIND)
739738
GTEST_SKIP() << "XFAIL due to Valgrind report";
740739
std::vector<Decl*> Decls, SubDecls;
741740
std::string code = "int f1(int i) { return i * i; }";
@@ -776,7 +775,7 @@ TEST(FunctionReflectionTest, IsVirtualMethod) {
776775
}
777776

778777
TEST(FunctionReflectionTest, JitCallAdvanced) {
779-
if (llvm::sys::RunningOnValgrind())
778+
if (RUNNING_ON_VALGRIND)
780779
GTEST_SKIP() << "XFAIL due to Valgrind report";
781780
std::vector<Decl*> Decls;
782781
std::string code = R"(
@@ -800,7 +799,7 @@ TEST(FunctionReflectionTest, JitCallAdvanced) {
800799

801800

802801
TEST(FunctionReflectionTest, GetFunctionCallWrapper) {
803-
if (llvm::sys::RunningOnValgrind())
802+
if (RUNNING_ON_VALGRIND)
804803
GTEST_SKIP() << "XFAIL due to Valgrind report";
805804
std::vector<Decl*> Decls;
806805
std::string code = R"(
@@ -1011,7 +1010,7 @@ TEST(FunctionReflectionTest, GetFunctionArgDefault) {
10111010
}
10121011

10131012
TEST(FunctionReflectionTest, Construct) {
1014-
if (llvm::sys::RunningOnValgrind())
1013+
if (RUNNING_ON_VALGRIND)
10151014
GTEST_SKIP() << "XFAIL due to Valgrind report";
10161015
Cpp::CreateInterpreter();
10171016

@@ -1047,7 +1046,7 @@ TEST(FunctionReflectionTest, Construct) {
10471046
}
10481047

10491048
TEST(FunctionReflectionTest, Destruct) {
1050-
if (llvm::sys::RunningOnValgrind())
1049+
if (RUNNING_ON_VALGRIND)
10511050
GTEST_SKIP() << "XFAIL due to Valgrind report";
10521051
Cpp::CreateInterpreter();
10531052

unittests/CppInterOp/InterpreterTest.cpp

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
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"
67
#include "llvm/Support/Path.h"
7-
#include "llvm/Support/Valgrind.h"
8+
89
#include <gmock/gmock.h>
910
#include "gtest/gtest.h"
1011

@@ -44,7 +45,7 @@ TEST(InterpreterTest, DebugFlag) {
4445
}
4546

4647
TEST(InterpreterTest, Evaluate) {
47-
if (llvm::sys::RunningOnValgrind())
48+
if (RUNNING_ON_VALGRIND)
4849
GTEST_SKIP() << "XFAIL due to Valgrind report";
4950
// EXPECT_TRUE(Cpp::Evaluate(I, "") == 0);
5051
//EXPECT_TRUE(Cpp::Evaluate(I, "__cplusplus;") == 201402);
@@ -60,7 +61,7 @@ TEST(InterpreterTest, Evaluate) {
6061
}
6162

6263
TEST(InterpreterTest, Process) {
63-
if (llvm::sys::RunningOnValgrind())
64+
if (RUNNING_ON_VALGRIND)
6465
GTEST_SKIP() << "XFAIL due to Valgrind report";
6566
Cpp::CreateInterpreter();
6667
EXPECT_TRUE(Cpp::Process("") == 0);

unittests/CppInterOp/JitTest.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#include "Utils.h"
22

33
#include "clang/Interpreter/CppInterOp.h"
4-
#include "llvm/Support/Valgrind.h"
54

65
#include "gtest/gtest.h"
76

@@ -13,7 +12,7 @@ static int printf_jit(const char* format, ...) {
1312
}
1413

1514
TEST(JitTest, InsertOrReplaceJitSymbol) {
16-
if (llvm::sys::RunningOnValgrind())
15+
if (RUNNING_ON_VALGRIND)
1716
GTEST_SKIP() << "XFAIL due to Valgrind report";
1817
std::vector<Decl*> Decls;
1918
std::string code = R"(

unittests/CppInterOp/ScopeReflectionTest.cpp

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#include "Utils.h"
2-
#include "llvm/Support/Valgrind.h"
2+
33
#include "clang/Interpreter/CppInterOp.h"
44

55
#include "clang/AST/ASTContext.h"
@@ -800,7 +800,7 @@ template<typename T> T TrivialFnTemplate() { return T(); }
800800
}
801801

802802
TEST(ScopeReflectionTest, InstantiateTemplateFunctionFromString) {
803-
if (llvm::sys::RunningOnValgrind())
803+
if (RUNNING_ON_VALGRIND)
804804
GTEST_SKIP() << "XFAIL due to Valgrind report";
805805
Cpp::CreateInterpreter();
806806
std::string code = R"(#include <memory>)";
@@ -940,7 +940,8 @@ TEST(ScopeReflectionTest, GetClassTemplateInstantiationArgs) {
940940

941941

942942
TEST(ScopeReflectionTest, IncludeVector) {
943-
GTEST_SKIP() << "XFAIL due to Valgrind report";
943+
if (RUNNING_ON_VALGRIND)
944+
GTEST_SKIP() << "XFAIL due to Valgrind report";
944945
std::string code = R"(
945946
#include <vector>
946947
#include <iostream>

unittests/CppInterOp/TypeReflectionTest.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#include "Utils.h"
22

3-
#include "llvm/Support/Valgrind.h"
43
#include "clang/AST/ASTContext.h"
54
#include "clang/Interpreter/CppInterOp.h"
65
#include "clang/Frontend/CompilerInstance.h"
@@ -524,7 +523,7 @@ TEST(TypeReflectionTest, IsPODType) {
524523
}
525524

526525
TEST(TypeReflectionTest, IsSmartPtrType) {
527-
if (llvm::sys::RunningOnValgrind())
526+
if (RUNNING_ON_VALGRIND)
528527
GTEST_SKIP() << "XFAIL due to Valgrind report";
529528
Cpp::CreateInterpreter();
530529

unittests/CppInterOp/Utils.h

+9
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,15 @@
66
#include <memory>
77
#include <vector>
88

9+
// Include this to access the RUNNING_ON_VALGRIND directive to conditionally skip tests reporting memory issues
10+
11+
#ifndef __APPLE__
12+
#include <valgrind/valgrind.h>
13+
#endif //__APPLE__
14+
#ifdef __APPLE__
15+
#define RUNNING_ON_VALGRIND 0
16+
#endif //__APPLE__
17+
918
using namespace clang;
1019
using namespace llvm;
1120

0 commit comments

Comments
 (0)