| OLD | NEW |
| 1 // Copyright 2008 the V8 project authors. All rights reserved. | 1 // Copyright 2008 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | 27 |
| 28 #ifndef CCTEST_H_ | 28 #ifndef CCTEST_H_ |
| 29 #define CCTEST_H_ | 29 #define CCTEST_H_ |
| 30 | 30 |
| 31 #include "v8.h" | 31 #include "v8.h" |
| 32 | 32 |
| 33 #ifndef TEST | 33 #ifndef TEST |
| 34 #define TEST(Name) \ | 34 #define TEST(Name) \ |
| 35 static void Test##Name(); \ | 35 static void Test##Name(); \ |
| 36 CcTest register_test_##Name(Test##Name, __FILE__, #Name, NULL, true); \ | 36 CcTest register_test_##Name(Test##Name, __FILE__, #Name, NULL, true, true); \ |
| 37 static void Test##Name() |
| 38 #endif |
| 39 |
| 40 #ifndef UNINITIALIZED_TEST |
| 41 #define UNINITIALIZED_TEST(Name) \ |
| 42 static void Test##Name(); \ |
| 43 CcTest register_test_##Name(Test##Name, __FILE__, #Name, NULL, true, false); \ |
| 37 static void Test##Name() | 44 static void Test##Name() |
| 38 #endif | 45 #endif |
| 39 | 46 |
| 40 #ifndef DEPENDENT_TEST | 47 #ifndef DEPENDENT_TEST |
| 41 #define DEPENDENT_TEST(Name, Dep) \ | 48 #define DEPENDENT_TEST(Name, Dep) \ |
| 42 static void Test##Name(); \ | 49 static void Test##Name(); \ |
| 43 CcTest register_test_##Name(Test##Name, __FILE__, #Name, #Dep, true); \ | 50 CcTest register_test_##Name(Test##Name, __FILE__, #Name, #Dep, true, true); \ |
| 44 static void Test##Name() | 51 static void Test##Name() |
| 45 #endif | 52 #endif |
| 46 | 53 |
| 47 #ifndef DISABLED_TEST | 54 #ifndef DISABLED_TEST |
| 48 #define DISABLED_TEST(Name) \ | 55 #define DISABLED_TEST(Name) \ |
| 49 static void Test##Name(); \ | 56 static void Test##Name(); \ |
| 50 CcTest register_test_##Name(Test##Name, __FILE__, #Name, NULL, false); \ | 57 CcTest register_test_##Name(Test##Name, __FILE__, #Name, NULL, false, true); \ |
| 51 static void Test##Name() | 58 static void Test##Name() |
| 52 #endif | 59 #endif |
| 53 | 60 |
| 54 #define EXTENSION_LIST(V) \ | 61 #define EXTENSION_LIST(V) \ |
| 55 V(GC_EXTENSION, "v8/gc") \ | 62 V(GC_EXTENSION, "v8/gc") \ |
| 56 V(PRINT_EXTENSION, "v8/print") \ | 63 V(PRINT_EXTENSION, "v8/print") \ |
| 57 V(TRACE_EXTENSION, "v8/trace") | 64 V(TRACE_EXTENSION, "v8/trace") |
| 58 | 65 |
| 59 #define DEFINE_EXTENSION_ID(Name, Ident) Name##_ID, | 66 #define DEFINE_EXTENSION_ID(Name, Ident) Name##_ID, |
| 60 enum CcTestExtensionIds { | 67 enum CcTestExtensionIds { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 72 #undef DEFINE_EXTENSION_FLAG | 79 #undef DEFINE_EXTENSION_FLAG |
| 73 | 80 |
| 74 // Temporary macros for accessing current isolate and its subobjects. | 81 // Temporary macros for accessing current isolate and its subobjects. |
| 75 // They provide better readability, especially when used a lot in the code. | 82 // They provide better readability, especially when used a lot in the code. |
| 76 #define HEAP (v8::internal::Isolate::Current()->heap()) | 83 #define HEAP (v8::internal::Isolate::Current()->heap()) |
| 77 | 84 |
| 78 class CcTest { | 85 class CcTest { |
| 79 public: | 86 public: |
| 80 typedef void (TestFunction)(); | 87 typedef void (TestFunction)(); |
| 81 CcTest(TestFunction* callback, const char* file, const char* name, | 88 CcTest(TestFunction* callback, const char* file, const char* name, |
| 82 const char* dependency, bool enabled); | 89 const char* dependency, bool enabled, bool initialize); |
| 83 void Run() { callback_(); } | 90 void Run(); |
| 84 static CcTest* last() { return last_; } | 91 static CcTest* last() { return last_; } |
| 85 CcTest* prev() { return prev_; } | 92 CcTest* prev() { return prev_; } |
| 86 const char* file() { return file_; } | 93 const char* file() { return file_; } |
| 87 const char* name() { return name_; } | 94 const char* name() { return name_; } |
| 88 const char* dependency() { return dependency_; } | 95 const char* dependency() { return dependency_; } |
| 89 bool enabled() { return enabled_; } | 96 bool enabled() { return enabled_; } |
| 90 static v8::Isolate* default_isolate() { return default_isolate_; } | 97 static v8::Isolate* default_isolate() { return isolate(); } |
| 91 | 98 |
| 92 static v8::Handle<v8::Context> env() { | 99 static v8::Handle<v8::Context> env() { |
| 93 return v8::Local<v8::Context>::New(default_isolate_, context_); | 100 return v8::Local<v8::Context>::New(isolate(), context_); |
| 94 } | 101 } |
| 95 | 102 |
| 96 static v8::Isolate* isolate() { return default_isolate_; } | 103 static v8::Isolate* isolate() { |
| 104 return default_isolate_; |
| 105 } |
| 97 | 106 |
| 98 static i::Isolate* i_isolate() { | 107 static i::Isolate* i_isolate() { |
| 99 return reinterpret_cast<i::Isolate*>(default_isolate_); | 108 return reinterpret_cast<i::Isolate*>(isolate()); |
| 100 } | 109 } |
| 101 | 110 |
| 102 // Helper function to initialize the VM. | 111 // Helper function to initialize the VM. |
| 103 static void InitializeVM(CcTestExtensionFlags extensions = NO_EXTENSIONS); | 112 static void InitializeVM(CcTestExtensionFlags extensions = NO_EXTENSIONS); |
| 104 | 113 |
| 105 private: | 114 private: |
| 106 friend int main(int argc, char** argv); | 115 friend int main(int argc, char** argv); |
| 107 static void set_default_isolate(v8::Isolate* default_isolate) { | |
| 108 default_isolate_ = default_isolate; | |
| 109 } | |
| 110 TestFunction* callback_; | 116 TestFunction* callback_; |
| 111 const char* file_; | 117 const char* file_; |
| 112 const char* name_; | 118 const char* name_; |
| 113 const char* dependency_; | 119 const char* dependency_; |
| 114 bool enabled_; | 120 bool enabled_; |
| 121 bool initialize_; |
| 115 CcTest* prev_; | 122 CcTest* prev_; |
| 116 static CcTest* last_; | 123 static CcTest* last_; |
| 117 static v8::Isolate* default_isolate_; | 124 static v8::Isolate* default_isolate_; |
| 125 enum InitializationState {kUnset, kUnintialized, kInitialized}; |
| 126 static InitializationState initialization_state_; |
| 118 static v8::Persistent<v8::Context> context_; | 127 static v8::Persistent<v8::Context> context_; |
| 119 }; | 128 }; |
| 120 | 129 |
| 121 // Switches between all the Api tests using the threading support. | 130 // Switches between all the Api tests using the threading support. |
| 122 // In order to get a surprising but repeatable pattern of thread | 131 // In order to get a surprising but repeatable pattern of thread |
| 123 // switching it has extra semaphores to control the order in which | 132 // switching it has extra semaphores to control the order in which |
| 124 // the tests alternate, not relying solely on the big V8 lock. | 133 // the tests alternate, not relying solely on the big V8 lock. |
| 125 // | 134 // |
| 126 // A test is augmented with calls to ApiTestFuzzer::Fuzz() in its | 135 // A test is augmented with calls to ApiTestFuzzer::Fuzz() in its |
| 127 // callbacks. This will have no effect when we are not running the | 136 // callbacks. This will have no effect when we are not running the |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 302 static inline void SimulateFullSpace(v8::internal::PagedSpace* space) { | 311 static inline void SimulateFullSpace(v8::internal::PagedSpace* space) { |
| 303 int old_linear_size = static_cast<int>(space->limit() - space->top()); | 312 int old_linear_size = static_cast<int>(space->limit() - space->top()); |
| 304 space->Free(space->top(), old_linear_size); | 313 space->Free(space->top(), old_linear_size); |
| 305 space->SetTop(space->limit(), space->limit()); | 314 space->SetTop(space->limit(), space->limit()); |
| 306 space->ResetFreeList(); | 315 space->ResetFreeList(); |
| 307 space->ClearStats(); | 316 space->ClearStats(); |
| 308 } | 317 } |
| 309 | 318 |
| 310 | 319 |
| 311 #endif // ifndef CCTEST_H_ | 320 #endif // ifndef CCTEST_H_ |
| OLD | NEW |