Chromium Code Reviews| Index: test/cctest/test-api.cc |
| diff --git a/test/cctest/test-api.cc b/test/cctest/test-api.cc |
| index 4f38198aaf21c4759dfba3e463940501dd2ed4fb..341246c3376f018cbfb3fe14d1ba8c4ac0b2aa7d 100644 |
| --- a/test/cctest/test-api.cc |
| +++ b/test/cctest/test-api.cc |
| @@ -44,6 +44,7 @@ |
| #include "src/compilation-cache.h" |
| #include "src/debug.h" |
| #include "src/execution.h" |
| +#include "src/futex-emulation.h" |
| #include "src/objects.h" |
| #include "src/parser.h" |
| #include "src/unicode-inl.h" |
| @@ -21848,3 +21849,38 @@ TEST(CompatibleReceiverCheckOnCachedICHandler) { |
| "result;\n", |
| 0); |
| } |
| + |
| +class FutexInterruptionThread : public v8::base::Thread { |
| + public: |
| + explicit FutexInterruptionThread(v8::Isolate* isolate) |
| + : Thread(Options("FutexInterruptionThread")), isolate_(isolate) {} |
| + |
| + virtual void Run() { |
| + // Wait a bit before terminating. |
| + v8::base::OS::Sleep(v8::base::TimeDelta::FromMilliseconds(100)); |
| + v8::V8::TerminateExecution(isolate_); |
| + } |
| + |
| + private: |
| + v8::Isolate* isolate_; |
| +}; |
|
Jarin
2015/07/17 12:55:27
Thanks for the test, you are my hero!
binji
2015/07/17 16:29:21
Thanks :)
|
| + |
| + |
| +TEST(FutexInterruption) { |
| + i::FLAG_harmony_sharedarraybuffer = true; |
| + i::FLAG_harmony_atomics = true; |
| + v8::Isolate* isolate = CcTest::isolate(); |
| + v8::HandleScope scope(isolate); |
| + LocalContext env; |
| + |
| + FutexInterruptionThread timeout_thread(isolate); |
| + |
| + v8::TryCatch try_catch(CcTest::isolate()); |
| + timeout_thread.Start(); |
| + |
| + CompileRun( |
| + "var ab = new SharedArrayBuffer(4);" |
| + "var i32a = new Int32Array(ab);" |
| + "Atomics.futexWait(i32a, 0, 0);"); |
| + CHECK(try_catch.HasTerminated()); |
| +} |