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

Side by Side Diff: test/cctest/cctest.h

Issue 23519010: cleanup cctest generally and remove ctest::context (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: arm fix Created 7 years, 3 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | test/cctest/cctest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 CcTest(TestFunction* callback, const char* file, const char* name, 85 CcTest(TestFunction* callback, const char* file, const char* name,
86 const char* dependency, bool enabled, bool initialize); 86 const char* dependency, bool enabled, bool initialize);
87 void Run(); 87 void Run();
88 static CcTest* last() { return last_; } 88 static CcTest* last() { return last_; }
89 CcTest* prev() { return prev_; } 89 CcTest* prev() { return prev_; }
90 const char* file() { return file_; } 90 const char* file() { return file_; }
91 const char* name() { return name_; } 91 const char* name() { return name_; }
92 const char* dependency() { return dependency_; } 92 const char* dependency() { return dependency_; }
93 bool enabled() { return enabled_; } 93 bool enabled() { return enabled_; }
94 94
95 static v8::Handle<v8::Context> env() {
96 return v8::Local<v8::Context>::New(isolate(), context_);
97 }
98
99 static v8::Isolate* isolate() { 95 static v8::Isolate* isolate() {
100 return default_isolate_; 96 isolate_used_ = true;
97 return isolate_;
101 } 98 }
102 99
103 static i::Isolate* i_isolate() { 100 static i::Isolate* i_isolate() {
104 return reinterpret_cast<i::Isolate*>(isolate()); 101 return reinterpret_cast<i::Isolate*>(isolate());
105 } 102 }
106 103
107 static i::Heap* heap() { 104 static i::Heap* heap() {
108 return i_isolate()->heap(); 105 return i_isolate()->heap();
109 } 106 }
110 107
111 // Helper function to initialize the VM. 108 // TODO(dcarney): Remove.
112 static void InitializeVM(CcTestExtensionFlags extensions = NO_EXTENSIONS); 109 // This must be called first in a test.
110 static void InitializeVM() {
111 CHECK(!isolate_used_);
112 CHECK(!initialize_called_);
113 initialize_called_ = true;
114 v8::HandleScope handle_scope(CcTest::isolate());
115 v8::Context::New(CcTest::isolate())->Enter();
116 }
117
118 // Helper function to configure a context.
119 // Must be in a HandleScope.
120 static v8::Local<v8::Context> NewContext(
121 CcTestExtensionFlags extensions,
122 v8::Isolate* isolate = CcTest::isolate());
113 123
114 private: 124 private:
115 friend int main(int argc, char** argv); 125 friend int main(int argc, char** argv);
116 TestFunction* callback_; 126 TestFunction* callback_;
117 const char* file_; 127 const char* file_;
118 const char* name_; 128 const char* name_;
119 const char* dependency_; 129 const char* dependency_;
120 bool enabled_; 130 bool enabled_;
121 bool initialize_; 131 bool initialize_;
122 CcTest* prev_; 132 CcTest* prev_;
123 static CcTest* last_; 133 static CcTest* last_;
124 static v8::Isolate* default_isolate_; 134 static v8::Isolate* isolate_;
125 enum InitializationState {kUnset, kUnintialized, kInitialized}; 135 static bool initialize_called_;
126 static InitializationState initialization_state_; 136 static bool isolate_used_;
127 static v8::Persistent<v8::Context> context_;
128 }; 137 };
129 138
130 // Switches between all the Api tests using the threading support. 139 // Switches between all the Api tests using the threading support.
131 // In order to get a surprising but repeatable pattern of thread 140 // In order to get a surprising but repeatable pattern of thread
132 // switching it has extra semaphores to control the order in which 141 // switching it has extra semaphores to control the order in which
133 // the tests alternate, not relying solely on the big V8 lock. 142 // the tests alternate, not relying solely on the big V8 lock.
134 // 143 //
135 // A test is augmented with calls to ApiTestFuzzer::Fuzz() in its 144 // A test is augmented with calls to ApiTestFuzzer::Fuzz() in its
136 // callbacks. This will have no effect when we are not running the 145 // callbacks. This will have no effect when we are not running the
137 // thread fuzzing test. In the thread fuzzing test it will 146 // thread fuzzing test. In the thread fuzzing test it will
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 static inline void SimulateFullSpace(v8::internal::PagedSpace* space) { 334 static inline void SimulateFullSpace(v8::internal::PagedSpace* space) {
326 int old_linear_size = static_cast<int>(space->limit() - space->top()); 335 int old_linear_size = static_cast<int>(space->limit() - space->top());
327 space->Free(space->top(), old_linear_size); 336 space->Free(space->top(), old_linear_size);
328 space->SetTop(space->limit(), space->limit()); 337 space->SetTop(space->limit(), space->limit());
329 space->ResetFreeList(); 338 space->ResetFreeList();
330 space->ClearStats(); 339 space->ClearStats();
331 } 340 }
332 341
333 342
334 #endif // ifndef CCTEST_H_ 343 #endif // ifndef CCTEST_H_
OLDNEW
« no previous file with comments | « no previous file | test/cctest/cctest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698