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

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

Issue 435003: Patch for allowing several V8 instances in process:... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 11 years 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 | « src/zone-inl.h ('k') | 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 11 matching lines...) Expand all
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
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 #include "v8-global-context.h"
32 33
33 #ifndef TEST 34 #ifndef TEST
34 #define TEST(Name) \ 35 #define TEST(Name) \
35 static void Test##Name(); \ 36 static void Test##Name(); \
36 CcTest register_test_##Name(Test##Name, __FILE__, #Name, NULL, true); \ 37 CcTest register_test_##Name(Test##Name, __FILE__, #Name, NULL, true); \
37 static void Test##Name() 38 static void Test##Name()
38 #endif 39 #endif
39 40
40 #ifndef DEPENDENT_TEST 41 #ifndef DEPENDENT_TEST
41 #define DEPENDENT_TEST(Name, Dep) \ 42 #define DEPENDENT_TEST(Name, Dep) \
42 static void Test##Name(); \ 43 static void Test##Name(); \
43 CcTest register_test_##Name(Test##Name, __FILE__, #Name, #Dep, true); \ 44 CcTest register_test_##Name(Test##Name, __FILE__, #Name, #Dep, true); \
44 static void Test##Name() 45 static void Test##Name()
45 #endif 46 #endif
46 47
47 #ifndef DISABLED_TEST 48 #ifndef DISABLED_TEST
48 #define DISABLED_TEST(Name) \ 49 #define DISABLED_TEST(Name) \
49 static void Test##Name(); \ 50 static void Test##Name(); \
50 CcTest register_test_##Name(Test##Name, __FILE__, #Name, NULL, false); \ 51 CcTest register_test_##Name(Test##Name, __FILE__, #Name, NULL, false); \
51 static void Test##Name() 52 static void Test##Name()
52 #endif 53 #endif
53 54
54 class CcTest { 55 class CcTest {
55 public: 56 public:
56 typedef void (TestFunction)(); 57 typedef void (TestFunction)();
57 CcTest(TestFunction* callback, const char* file, const char* name, 58 CcTest(TestFunction* callback, const char* file, const char* name,
58 const char* dependency, bool enabled); 59 const char* dependency, bool enabled);
59 void Run() { callback_(); } 60 void Run();
60 static int test_count(); 61 static int test_count();
61 static CcTest* last() { return last_; } 62 static CcTest* last() { return last_; }
62 CcTest* prev() { return prev_; } 63 CcTest* prev() { return prev_; }
63 const char* file() { return file_; } 64 const char* file() { return file_; }
64 const char* name() { return name_; } 65 const char* name() { return name_; }
65 const char* dependency() { return dependency_; } 66 const char* dependency() { return dependency_; }
66 bool enabled() { return enabled_; } 67 bool enabled() { return enabled_; }
67 private: 68 private:
68 TestFunction* callback_; 69 TestFunction* callback_;
69 const char* file_; 70 const char* file_;
70 const char* name_; 71 const char* name_;
71 const char* dependency_; 72 const char* dependency_;
72 bool enabled_; 73 bool enabled_;
73 static CcTest* last_; 74 static CcTest* last_;
74 CcTest* prev_; 75 CcTest* prev_;
75 }; 76 };
76 77
78 class V8Runner: public v8::internal::Thread {
79 CcTest::TestFunction* callback_;
80
81 virtual void Run() {
82 v8::V8ContextProvider v8context_provider;
83 v8::V8ContextBinder v8context_binder(v8context_provider);
84 callback_();
85 }
86 public:
87 explicit V8Runner(CcTest::TestFunction* callback)
88 :callback_(callback) {}
89 };
90
77 // Switches between all the Api tests using the threading support. 91 // Switches between all the Api tests using the threading support.
78 // In order to get a surprising but repeatable pattern of thread 92 // In order to get a surprising but repeatable pattern of thread
79 // switching it has extra semaphores to control the order in which 93 // switching it has extra semaphores to control the order in which
80 // the tests alternate, not relying solely on the big V8 lock. 94 // the tests alternate, not relying solely on the big V8 lock.
81 // 95 //
82 // A test is augmented with calls to ApiTestFuzzer::Fuzz() in its 96 // A test is augmented with calls to ApiTestFuzzer::Fuzz() in its
83 // callbacks. This will have no effect when we are not running the 97 // callbacks. This will have no effect when we are not running the
84 // thread fuzzing test. In the thread fuzzing test it will 98 // thread fuzzing test. In the thread fuzzing test it will
85 // pseudorandomly select a successor thread and switch execution 99 // pseudorandomly select a successor thread and switch execution
86 // to that thread, suspending the current test. 100 // to that thread, suspending the current test.
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 } 216 }
203 217
204 218
205 // Helper function that compiles and runs the source. 219 // Helper function that compiles and runs the source.
206 static inline v8::Local<v8::Value> CompileRun(const char* source) { 220 static inline v8::Local<v8::Value> CompileRun(const char* source) {
207 return v8::Script::Compile(v8::String::New(source))->Run(); 221 return v8::Script::Compile(v8::String::New(source))->Run();
208 } 222 }
209 223
210 224
211 #endif // ifndef CCTEST_H_ 225 #endif // ifndef CCTEST_H_
OLDNEW
« no previous file with comments | « src/zone-inl.h ('k') | test/cctest/cctest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698