Skip to content

Commit ec4be66

Browse files
restore to original
1 parent 0ab2965 commit ec4be66

File tree

2 files changed

+21
-21
lines changed

2 files changed

+21
-21
lines changed

libc/test/UnitTest/LibcTest.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,17 @@ char **envp = nullptr;
116116

117117
using internal::RunContext;
118118

119+
void Test::addTest(Test *T) {
120+
if (End == nullptr) {
121+
Start = T;
122+
End = T;
123+
return;
124+
}
125+
126+
End->Next = T;
127+
End = T;
128+
}
129+
119130
int Test::getNumTests() {
120131
int N = 0;
121132
for (Test *T = Start; T; T = T->Next, ++N)

libc/test/UnitTest/LibcTest.h

Lines changed: 10 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -120,25 +120,14 @@ class Test {
120120
static int getNumTests();
121121

122122
public:
123-
constexpr Test() = default;
123+
virtual ~Test() {}
124124
virtual void SetUp() {}
125125
virtual void TearDown() {}
126126

127127
static int runTests(const TestOptions &Options);
128128

129129
protected:
130-
constexpr static void *addTest(Test *T) {
131-
if (End == nullptr) {
132-
Start = T;
133-
End = T;
134-
// read of constexpr
135-
return nullptr;
136-
}
137-
138-
End->Next = T;
139-
End = T;
140-
return nullptr;
141-
}
130+
static void addTest(Test *T);
142131

143132
// We make use of a template function, with |LHS| and |RHS| as explicit
144133
// parameters, for enhanced type checking. Other gtest like unittest
@@ -354,15 +343,15 @@ CString libc_make_test_file_path_func(const char *file_name);
354343
public: \
355344
using ParamType = T; \
356345
char name[256]; \
357-
constexpr SuiteName##_##TestName() { \
346+
SuiteName##_##TestName() { \
358347
addTest(this); \
359348
LIBC_NAMESPACE::testing::internal::GenerateName<T>( \
360349
name, sizeof(name), #SuiteName "." #TestName); \
361350
} \
362351
void Run() override; \
363352
const char *getName() const override { return name; } \
364353
}; \
365-
constexpr TypeList::Tests<SuiteName##_##TestName>::type \
354+
TypeList::Tests<SuiteName##_##TestName>::type \
366355
SuiteName##_##TestName##_Instance; \
367356
template <typename T> void SuiteName##_##TestName<T>::Run()
368357

@@ -374,15 +363,15 @@ CString libc_make_test_file_path_func(const char *file_name);
374363
public: \
375364
using ParamType = T; \
376365
char name[256]; \
377-
constexpr SuiteClass##_##TestName() { \
366+
SuiteClass##_##TestName() { \
378367
SuiteClass<T>::addTest(this); \
379368
LIBC_NAMESPACE::testing::internal::GenerateName<T>( \
380369
name, sizeof(name), #SuiteClass "." #TestName); \
381370
} \
382371
void Run() override; \
383372
const char *getName() const override { return name; } \
384373
}; \
385-
static constexpr TypeList::Tests<SuiteClass##_##TestName>::type \
374+
TypeList::Tests<SuiteClass##_##TestName>::type \
386375
SuiteClass##_##TestName##_Instance; \
387376
template <typename T> void SuiteClass##_##TestName<T>::Run()
388377

@@ -391,11 +380,11 @@ CString libc_make_test_file_path_func(const char *file_name);
391380
"All LLVM-libc TEST suite names must start with 'LlvmLibc'."); \
392381
class SuiteName##_##TestName : public LIBC_NAMESPACE::testing::Test { \
393382
public: \
394-
constexpr SuiteName##_##TestName() { addTest(this); } \
383+
SuiteName##_##TestName() { addTest(this); } \
395384
void Run() override; \
396385
const char *getName() const override { return #SuiteName "." #TestName; } \
397386
}; \
398-
static constexpr SuiteName##_##TestName SuiteName##_##TestName##_Instance; \
387+
SuiteName##_##TestName SuiteName##_##TestName##_Instance; \
399388
void SuiteName##_##TestName::Run()
400389

401390
#define TEST_F(SuiteClass, TestName) \
@@ -404,11 +393,11 @@ CString libc_make_test_file_path_func(const char *file_name);
404393
"All LLVM-libc TEST_F suite class names must start with 'LlvmLibc'."); \
405394
class SuiteClass##_##TestName : public SuiteClass { \
406395
public: \
407-
constexpr SuiteClass##_##TestName() { addTest(this); } \
396+
SuiteClass##_##TestName() { addTest(this); } \
408397
void Run() override; \
409398
const char *getName() const override { return #SuiteClass "." #TestName; } \
410399
}; \
411-
static constexpr SuiteClass##_##TestName SuiteClass##_##TestName##_Instance; \
400+
SuiteClass##_##TestName SuiteClass##_##TestName##_Instance; \
412401
void SuiteClass##_##TestName::Run()
413402

414403
// Helper to trick the compiler into ignoring lack of braces on the else

0 commit comments

Comments
 (0)