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() { |