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 16 matching lines...) Expand all Loading... |
27 | 27 |
28 #ifndef CCTEST_H_ | 28 #ifndef CCTEST_H_ |
29 #define CCTEST_H_ | 29 #define CCTEST_H_ |
30 | 30 |
31 #include "include/libplatform/libplatform.h" | 31 #include "include/libplatform/libplatform.h" |
32 #include "src/isolate-inl.h" // TODO(everyone): Make cctest IWYU. | 32 #include "src/isolate-inl.h" // TODO(everyone): Make cctest IWYU. |
33 #include "src/objects-inl.h" // TODO(everyone): Make cctest IWYU. | 33 #include "src/objects-inl.h" // TODO(everyone): Make cctest IWYU. |
34 #include "src/v8.h" | 34 #include "src/v8.h" |
35 | 35 |
36 #ifndef TEST | 36 #ifndef TEST |
37 #define TEST(Name) \ | 37 #define TEST(Name) \ |
38 static void Test##Name(); \ | 38 static void Test##Name(); \ |
39 CcTest register_test_##Name(Test##Name, __FILE__, #Name, NULL, true, true); \ | 39 CcTest register_test_##Name(Test##Name, __FILE__, #Name, true, true); \ |
40 static void Test##Name() | 40 static void Test##Name() |
41 #endif | 41 #endif |
42 | 42 |
43 #ifndef UNINITIALIZED_TEST | 43 #ifndef UNINITIALIZED_TEST |
44 #define UNINITIALIZED_TEST(Name) \ | 44 #define UNINITIALIZED_TEST(Name) \ |
45 static void Test##Name(); \ | 45 static void Test##Name(); \ |
46 CcTest register_test_##Name(Test##Name, __FILE__, #Name, NULL, true, false); \ | 46 CcTest register_test_##Name(Test##Name, __FILE__, #Name, true, false); \ |
47 static void Test##Name() | |
48 #endif | |
49 | |
50 #ifndef DEPENDENT_TEST | |
51 #define DEPENDENT_TEST(Name, Dep) \ | |
52 static void Test##Name(); \ | |
53 CcTest register_test_##Name(Test##Name, __FILE__, #Name, #Dep, true, true); \ | |
54 static void Test##Name() | |
55 #endif | |
56 | |
57 #ifndef UNINITIALIZED_DEPENDENT_TEST | |
58 #define UNINITIALIZED_DEPENDENT_TEST(Name, Dep) \ | |
59 static void Test##Name(); \ | |
60 CcTest register_test_##Name(Test##Name, __FILE__, #Name, #Dep, true, false); \ | |
61 static void Test##Name() | 47 static void Test##Name() |
62 #endif | 48 #endif |
63 | 49 |
64 #ifndef DISABLED_TEST | 50 #ifndef DISABLED_TEST |
65 #define DISABLED_TEST(Name) \ | 51 #define DISABLED_TEST(Name) \ |
66 static void Test##Name(); \ | 52 static void Test##Name(); \ |
67 CcTest register_test_##Name(Test##Name, __FILE__, #Name, NULL, false, true); \ | 53 CcTest register_test_##Name(Test##Name, __FILE__, #Name, false, true); \ |
68 static void Test##Name() | 54 static void Test##Name() |
69 #endif | 55 #endif |
70 | 56 |
71 #define EXTENSION_LIST(V) \ | 57 #define EXTENSION_LIST(V) \ |
72 V(GC_EXTENSION, "v8/gc") \ | 58 V(GC_EXTENSION, "v8/gc") \ |
73 V(PRINT_EXTENSION, "v8/print") \ | 59 V(PRINT_EXTENSION, "v8/print") \ |
74 V(PROFILER_EXTENSION, "v8/profiler") \ | 60 V(PROFILER_EXTENSION, "v8/profiler") \ |
75 V(TRACE_EXTENSION, "v8/trace") | 61 V(TRACE_EXTENSION, "v8/trace") |
76 | 62 |
77 #define DEFINE_EXTENSION_ID(Name, Ident) Name##_ID, | 63 #define DEFINE_EXTENSION_ID(Name, Ident) Name##_ID, |
78 enum CcTestExtensionIds { | 64 enum CcTestExtensionIds { |
79 EXTENSION_LIST(DEFINE_EXTENSION_ID) | 65 EXTENSION_LIST(DEFINE_EXTENSION_ID) |
80 kMaxExtensions | 66 kMaxExtensions |
81 }; | 67 }; |
82 #undef DEFINE_EXTENSION_ID | 68 #undef DEFINE_EXTENSION_ID |
83 | 69 |
84 typedef v8::internal::EnumSet<CcTestExtensionIds> CcTestExtensionFlags; | 70 typedef v8::internal::EnumSet<CcTestExtensionIds> CcTestExtensionFlags; |
85 #define DEFINE_EXTENSION_FLAG(Name, Ident) \ | 71 #define DEFINE_EXTENSION_FLAG(Name, Ident) \ |
86 static const CcTestExtensionFlags Name(1 << Name##_ID); | 72 static const CcTestExtensionFlags Name(1 << Name##_ID); |
87 static const CcTestExtensionFlags NO_EXTENSIONS(0); | 73 static const CcTestExtensionFlags NO_EXTENSIONS(0); |
88 static const CcTestExtensionFlags ALL_EXTENSIONS((1 << kMaxExtensions) - 1); | 74 static const CcTestExtensionFlags ALL_EXTENSIONS((1 << kMaxExtensions) - 1); |
89 EXTENSION_LIST(DEFINE_EXTENSION_FLAG) | 75 EXTENSION_LIST(DEFINE_EXTENSION_FLAG) |
90 #undef DEFINE_EXTENSION_FLAG | 76 #undef DEFINE_EXTENSION_FLAG |
91 | 77 |
92 | 78 |
93 class CcTest { | 79 class CcTest { |
94 public: | 80 public: |
95 typedef void (TestFunction)(); | 81 typedef void (TestFunction)(); |
96 CcTest(TestFunction* callback, const char* file, const char* name, | 82 CcTest(TestFunction* callback, const char* file, const char* name, |
97 const char* dependency, bool enabled, bool initialize); | 83 bool enabled, bool initialize); |
98 ~CcTest() { i::DeleteArray(file_); } | 84 ~CcTest() { i::DeleteArray(file_); } |
99 void Run(); | 85 void Run(); |
100 static CcTest* last() { return last_; } | 86 static CcTest* last() { return last_; } |
101 CcTest* prev() { return prev_; } | 87 CcTest* prev() { return prev_; } |
102 const char* file() { return file_; } | 88 const char* file() { return file_; } |
103 const char* name() { return name_; } | 89 const char* name() { return name_; } |
104 const char* dependency() { return dependency_; } | |
105 bool enabled() { return enabled_; } | 90 bool enabled() { return enabled_; } |
106 | 91 |
107 static v8::Isolate* isolate() { | 92 static v8::Isolate* isolate() { |
108 CHECK(isolate_ != NULL); | 93 CHECK(isolate_ != NULL); |
109 v8::base::NoBarrier_Store(&isolate_used_, 1); | 94 v8::base::NoBarrier_Store(&isolate_used_, 1); |
110 return isolate_; | 95 return isolate_; |
111 } | 96 } |
112 | 97 |
113 static i::Isolate* InitIsolateOnce() { | 98 static i::Isolate* InitIsolateOnce() { |
114 if (!initialize_called_) InitializeVM(); | 99 if (!initialize_called_) InitializeVM(); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 | 146 |
162 static void TearDown() { | 147 static void TearDown() { |
163 if (isolate_ != NULL) isolate_->Dispose(); | 148 if (isolate_ != NULL) isolate_->Dispose(); |
164 } | 149 } |
165 | 150 |
166 private: | 151 private: |
167 friend int main(int argc, char** argv); | 152 friend int main(int argc, char** argv); |
168 TestFunction* callback_; | 153 TestFunction* callback_; |
169 const char* file_; | 154 const char* file_; |
170 const char* name_; | 155 const char* name_; |
171 const char* dependency_; | |
172 bool enabled_; | 156 bool enabled_; |
173 bool initialize_; | 157 bool initialize_; |
174 CcTest* prev_; | 158 CcTest* prev_; |
175 static CcTest* last_; | 159 static CcTest* last_; |
176 static v8::ArrayBuffer::Allocator* allocator_; | 160 static v8::ArrayBuffer::Allocator* allocator_; |
177 static v8::Isolate* isolate_; | 161 static v8::Isolate* isolate_; |
178 static bool initialize_called_; | 162 static bool initialize_called_; |
179 static v8::base::Atomic32 isolate_used_; | 163 static v8::base::Atomic32 isolate_used_; |
180 }; | 164 }; |
181 | 165 |
(...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
604 HandleAndZoneScope() {} | 588 HandleAndZoneScope() {} |
605 | 589 |
606 // Prefixing the below with main_ reduces a lot of naming clashes. | 590 // Prefixing the below with main_ reduces a lot of naming clashes. |
607 i::Zone* main_zone() { return &main_zone_; } | 591 i::Zone* main_zone() { return &main_zone_; } |
608 | 592 |
609 private: | 593 private: |
610 i::Zone main_zone_; | 594 i::Zone main_zone_; |
611 }; | 595 }; |
612 | 596 |
613 #endif // ifndef CCTEST_H_ | 597 #endif // ifndef CCTEST_H_ |
OLD | NEW |