Chromium Code Reviews| Index: test/cctest/test-debug.cc |
| diff --git a/test/cctest/test-debug.cc b/test/cctest/test-debug.cc |
| index cd08df14fa4ae94cf6c9451f811c5105f369d411..f72ea05f890531224a13833e24b1857bc2810569 100644 |
| --- a/test/cctest/test-debug.cc |
| +++ b/test/cctest/test-debug.cc |
| @@ -7425,3 +7425,46 @@ TEST(DebugBreakStackTrace) { |
| " }" |
| "})()"); |
| } |
| + |
| + |
| +v8::internal::Semaphore terminate_requested_semaphore(0); |
| +v8::internal::Semaphore terminate_fired_semaphore(0); |
| +bool terminate_already_fired = false; |
| + |
| + |
| +static void DebugBreakTriggerTerminate( |
| + const v8::Debug::EventDetails& event_details) { |
| + if (event_details.GetEvent() != v8::Break || terminate_already_fired) return; |
| + terminate_requested_semaphore.Signal(); |
| + // Wait for at most 2 seconds for the terminate request. |
| + CHECK(terminate_fired_semaphore.WaitFor(i::TimeDelta::FromSeconds(2))); |
| + terminate_already_fired = true; |
|
yurys
2014/06/02 11:39:11
Can we also check that TERMINATE_EXECUTION interru
Yang
2014/06/02 11:50:03
Done.
|
| +} |
| + |
| + |
| +class TerminationThread : public v8::internal::Thread { |
| + public: |
| + explicit TerminationThread(v8::Isolate* isolate) : Thread("terminator"), |
| + isolate_(isolate) { } |
| + |
| + virtual void Run() { |
| + terminate_requested_semaphore.Wait(); |
| + v8::V8::TerminateExecution(isolate_); |
| + terminate_fired_semaphore.Signal(); |
| + } |
| + |
| + private: |
| + v8::Isolate* isolate_; |
| +}; |
| + |
| + |
| +TEST(DebugBreakOffThreadTerminate) { |
| + DebugLocalContext env; |
| + v8::Isolate* isolate = env->GetIsolate(); |
| + v8::HandleScope scope(isolate); |
| + v8::Debug::SetDebugEventListener(DebugBreakTriggerTerminate); |
| + TerminationThread terminator(isolate); |
| + terminator.Start(); |
| + v8::Debug::DebugBreak(isolate); |
| + CompileRun("while (true);"); |
| +} |