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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
44 static void Test##Name() | 44 static void Test##Name() |
45 #endif | 45 #endif |
46 | 46 |
47 #ifndef DISABLED_TEST | 47 #ifndef DISABLED_TEST |
48 #define DISABLED_TEST(Name) \ | 48 #define DISABLED_TEST(Name) \ |
49 static void Test##Name(); \ | 49 static void Test##Name(); \ |
50 CcTest register_test_##Name(Test##Name, __FILE__, #Name, NULL, false); \ | 50 CcTest register_test_##Name(Test##Name, __FILE__, #Name, NULL, false); \ |
51 static void Test##Name() | 51 static void Test##Name() |
52 #endif | 52 #endif |
53 | 53 |
54 #define EXTENSION_LIST(V) \ | |
55 V(GC_EXTENSION, "v8/gc") \ | |
56 V(PRINT_EXTENSION, "v8/print") \ | |
57 V(TRACE_EXTENSION, "v8/trace") | |
58 | |
59 #define DEFINE_EXTENSION_ID(Name, Ident) Name##_ID, | |
60 enum CcTestExtensionIds { | |
61 EXTENSION_LIST(DEFINE_EXTENSION_ID) | |
62 kMaxExtensions | |
63 }; | |
64 #undef DEFINE_EXTENSION_ID | |
65 | |
66 #define DEFINE_EXTENSION_FLAG(Name, Ident) Name = 1 << Name##_ID, | |
67 enum CcTestExtensionFlags { | |
Sven Panne
2013/04/09 07:26:28
Using EnumSet here would be simpler and actually m
Michael Starzinger
2013/04/09 09:04:00
Done.
| |
68 NO_EXTENSIONS = 0, | |
69 EXTENSION_LIST(DEFINE_EXTENSION_FLAG) | |
70 ALL_EXTENSIONS = (1 << kMaxExtensions) - 1 | |
71 }; | |
72 #undef DEFINE_EXTENSION_FLAG | |
73 | |
54 class CcTest { | 74 class CcTest { |
55 public: | 75 public: |
56 typedef void (TestFunction)(); | 76 typedef void (TestFunction)(); |
57 CcTest(TestFunction* callback, const char* file, const char* name, | 77 CcTest(TestFunction* callback, const char* file, const char* name, |
58 const char* dependency, bool enabled); | 78 const char* dependency, bool enabled); |
59 void Run() { callback_(); } | 79 void Run() { callback_(); } |
60 static CcTest* last() { return last_; } | 80 static CcTest* last() { return last_; } |
61 CcTest* prev() { return prev_; } | 81 CcTest* prev() { return prev_; } |
62 const char* file() { return file_; } | 82 const char* file() { return file_; } |
63 const char* name() { return name_; } | 83 const char* name() { return name_; } |
64 const char* dependency() { return dependency_; } | 84 const char* dependency() { return dependency_; } |
65 bool enabled() { return enabled_; } | 85 bool enabled() { return enabled_; } |
66 static void set_default_isolate(v8::Isolate* default_isolate) { | 86 static void set_default_isolate(v8::Isolate* default_isolate) { |
67 default_isolate_ = default_isolate; | 87 default_isolate_ = default_isolate; |
68 } | 88 } |
69 static v8::Isolate* default_isolate() { return default_isolate_; } | 89 static v8::Isolate* default_isolate() { return default_isolate_; } |
90 static v8::Isolate* isolate() { return context_->GetIsolate(); } | |
91 static v8::Handle<v8::Context> env() { return context_; } | |
92 | |
93 // Helper function to initialize the VM. | |
94 static void InitializeVM(int extensions = NO_EXTENSIONS); | |
Sven Panne
2013/04/09 07:26:28
Use EnumSet<CcTestExtensionFlag> (or perhaps a typ
Michael Starzinger
2013/04/09 09:04:00
Done.
| |
70 | 95 |
71 private: | 96 private: |
72 TestFunction* callback_; | 97 TestFunction* callback_; |
73 const char* file_; | 98 const char* file_; |
74 const char* name_; | 99 const char* name_; |
75 const char* dependency_; | 100 const char* dependency_; |
76 bool enabled_; | 101 bool enabled_; |
102 CcTest* prev_; | |
77 static CcTest* last_; | 103 static CcTest* last_; |
78 CcTest* prev_; | |
79 static v8::Isolate* default_isolate_; | 104 static v8::Isolate* default_isolate_; |
105 static v8::Persistent<v8::Context> context_; | |
80 }; | 106 }; |
81 | 107 |
82 // Switches between all the Api tests using the threading support. | 108 // Switches between all the Api tests using the threading support. |
83 // In order to get a surprising but repeatable pattern of thread | 109 // In order to get a surprising but repeatable pattern of thread |
84 // switching it has extra semaphores to control the order in which | 110 // switching it has extra semaphores to control the order in which |
85 // the tests alternate, not relying solely on the big V8 lock. | 111 // the tests alternate, not relying solely on the big V8 lock. |
86 // | 112 // |
87 // A test is augmented with calls to ApiTestFuzzer::Fuzz() in its | 113 // A test is augmented with calls to ApiTestFuzzer::Fuzz() in its |
88 // callbacks. This will have no effect when we are not running the | 114 // callbacks. This will have no effect when we are not running the |
89 // thread fuzzing test. In the thread fuzzing test it will | 115 // thread fuzzing test. In the thread fuzzing test it will |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
256 static inline void SimulateFullSpace(v8::internal::PagedSpace* space) { | 282 static inline void SimulateFullSpace(v8::internal::PagedSpace* space) { |
257 int old_linear_size = static_cast<int>(space->limit() - space->top()); | 283 int old_linear_size = static_cast<int>(space->limit() - space->top()); |
258 space->Free(space->top(), old_linear_size); | 284 space->Free(space->top(), old_linear_size); |
259 space->SetTop(space->limit(), space->limit()); | 285 space->SetTop(space->limit(), space->limit()); |
260 space->ResetFreeList(); | 286 space->ResetFreeList(); |
261 space->ClearStats(); | 287 space->ClearStats(); |
262 } | 288 } |
263 | 289 |
264 | 290 |
265 #endif // ifndef CCTEST_H_ | 291 #endif // ifndef CCTEST_H_ |
OLD | NEW |