Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(329)

Unified Diff: runtime/vm/unit_test.h

Issue 2666133002: Added new type of unit test, RAW_UNIT_TEST_CASE, which is used for tests that can be flaky if run w… (Closed)
Patch Set: Fixed name of UNIT_TEST_CASE macro Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/thread_test.cc ('k') | runtime/vm/unit_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/unit_test.h
diff --git a/runtime/vm/unit_test.h b/runtime/vm/unit_test.h
index 945fd6e8378b88ed8045a6672439cfc73e770a68..40b8adad5e25c664285803710256bdc0c7c02ccb 100644
--- a/runtime/vm/unit_test.h
+++ b/runtime/vm/unit_test.h
@@ -21,21 +21,29 @@
#include "vm/simulator.h"
#include "vm/zone.h"
-// The UNIT_TEST_CASE macro is used for tests that do not need any
+// The VM_UNIT_TEST_CASE macro is used for tests that do not need any
// default isolate or zone functionality.
-#define UNIT_TEST_CASE(name) \
+#define VM_UNIT_TEST_CASE(name) \
void Dart_Test##name(); \
static const dart::TestCase kRegister##name(Dart_Test##name, #name); \
void Dart_Test##name()
-// The VM_TEST_CASE macro is used for tests that need an isolate and zone
-// in order to test its functionality. This macro is used for tests that
+// The UNIT_TEST_CASE macro is used for tests that do not require any
+// functionality provided by the VM. Tests declared using this macro will be run
+// after the VM is cleaned up.
+#define UNIT_TEST_CASE(name) \
+ void Dart_Test##name(); \
+ static const dart::RawTestCase kRegister##name(Dart_Test##name, #name); \
+ void Dart_Test##name()
+
+// The ISOLATE_UNIT_TEST_CASE macro is used for tests that need an isolate and
+// zone in order to test its functionality. This macro is used for tests that
// are implemented using the VM code directly and do not use the Dart API
// for calling into the VM. The safepoint execution state of threads using
// this macro is transitioned from kThreadInNative to kThreadInVM.
-#define VM_TEST_CASE(name) \
+#define ISOLATE_UNIT_TEST_CASE(name) \
static void Dart_TestHelper##name(Thread* thread); \
- UNIT_TEST_CASE(name) { \
+ VM_UNIT_TEST_CASE(name) { \
TestIsolateScope __test_isolate__; \
Thread* __thread__ = Thread::Current(); \
ASSERT(__thread__->isolate() == __test_isolate__.isolate()); \
@@ -52,7 +60,7 @@
// execution state of threads using this macro remains kThreadNative.
#define TEST_CASE(name) \
static void Dart_TestHelper##name(Thread* thread); \
- UNIT_TEST_CASE(name) { \
+ VM_UNIT_TEST_CASE(name) { \
TestIsolateScope __test_isolate__; \
Thread* __thread__ = Thread::Current(); \
ASSERT(__thread__->isolate() == __test_isolate__.isolate()); \
@@ -77,7 +85,7 @@
// C++ callee-saved registers are not preserved. Arguments may be passed in.
#define ASSEMBLER_TEST_RUN(name, test) \
static void AssemblerTestRun##name(AssemblerTest* test); \
- VM_TEST_CASE(name) { \
+ ISOLATE_UNIT_TEST_CASE(name) { \
Assembler __assembler__; \
AssemblerTest test("" #name, &__assembler__); \
AssemblerTestGenerate##name(test.assembler()); \
@@ -100,7 +108,7 @@
// Pass the name of test and the expected results as RawObject.
#define CODEGEN_TEST_RUN(name, expected) \
static void CodeGenTestRun##name(const Function& function); \
- VM_TEST_CASE(name) { \
+ ISOLATE_UNIT_TEST_CASE(name) { \
CodeGenTest __test__("" #name); \
CodeGenTestGenerate##name(&__test__); \
__test__.Compile(); \
@@ -120,7 +128,7 @@
// and evaluate its result.
#define CODEGEN_TEST_RAW_RUN(name, function) \
static void CodeGenTestRun##name(const Function& function); \
- VM_TEST_CASE(name) { \
+ ISOLATE_UNIT_TEST_CASE(name) { \
CodeGenTest __test__("" #name); \
CodeGenTestGenerate##name(&__test__); \
__test__.Compile(); \
@@ -133,7 +141,7 @@
// The first one may reference the Function object generated by the second one.
#define CODEGEN_TEST2_RUN(name1, name2, expected) \
static void CodeGenTestRun##name1(const Function& function); \
- VM_TEST_CASE(name1) { \
+ ISOLATE_UNIT_TEST_CASE(name1) { \
/* Generate code for name2 */ \
CodeGenTest __test2__("" #name2); \
CodeGenTestGenerate##name2(&__test2__); \
@@ -261,6 +269,10 @@ class TestCaseBase {
void RunTest();
static void RunAll();
+ static void RunAllRaw();
+
+ protected:
+ bool raw_test_;
private:
static TestCaseBase* first_;
@@ -323,6 +335,20 @@ class TestCase : TestCaseBase {
};
+class RawTestCase : TestCaseBase {
+ public:
+ typedef void(RunEntry)();
+
+ RawTestCase(RunEntry* run, const char* name) : TestCaseBase(name), run_(run) {
+ raw_test_ = true;
+ }
+ virtual void Run();
+
+ private:
+ RunEntry* const run_;
+};
+
+
class TestIsolateScope {
public:
TestIsolateScope() {
« no previous file with comments | « runtime/vm/thread_test.cc ('k') | runtime/vm/unit_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698