From ea26454fb7ccfe50a6ebb0504f5b3c678274312d Mon Sep 17 00:00:00 2001 From: Andreas Haas Date: Fri, 18 Jan 2019 10:46:49 +0100 Subject: [PATCH] [wasm][streaming] Add test for the ModuleCompiledCallback This test checks that the ModuleCompiledCallback is called eventually. R=clemensh@chromium.org CC=adamk@chromium.org Bug: v8:8677 Change-Id: I360f88064f870dd4a12db019e3c9f72154abf13b Reviewed-on: https://chromium-review.googlesource.com/c/1420759 Reviewed-by: Clemens Hammacher Commit-Queue: Andreas Haas Cr-Commit-Position: refs/heads/master@{#58917} --- .../cctest/wasm/test-streaming-compilation.cc | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/test/cctest/wasm/test-streaming-compilation.cc b/test/cctest/wasm/test-streaming-compilation.cc index 38ea3e6f26..43ba7dfea1 100644 --- a/test/cctest/wasm/test-streaming-compilation.cc +++ b/test/cctest/wasm/test-streaming-compilation.cc @@ -1111,6 +1111,47 @@ STREAM_TEST(TestFunctionSectionWithoutCodeSection) { CHECK(tester.IsPromiseRejected()); } +STREAM_TEST(TestSetModuleCompiledCallback) { + StreamTester tester; + bool callback_called = false; + tester.stream()->SetModuleCompiledCallback( + [&callback_called](const std::shared_ptr module) { + callback_called = true; + }); + + uint8_t code[] = { + U32V_1(4), // body size + U32V_1(0), // locals count + kExprGetLocal, 0, kExprEnd // body + }; + + const uint8_t bytes[] = { + WASM_MODULE_HEADER, // module header + kTypeSectionCode, // section code + U32V_1(1 + SIZEOF_SIG_ENTRY_x_x), // section size + U32V_1(1), // type count + SIG_ENTRY_x_x(kLocalI32, kLocalI32), // signature entry + kFunctionSectionCode, // section code + U32V_1(1 + 3), // section size + U32V_1(3), // functions count + 0, // signature index + 0, // signature index + 0, // signature index + kCodeSectionCode, // section code + U32V_1(1 + arraysize(code) * 3), // section size + U32V_1(3), // functions count + }; + + tester.OnBytesReceived(bytes, arraysize(bytes)); + tester.OnBytesReceived(code, arraysize(code)); + tester.OnBytesReceived(code, arraysize(code)); + tester.OnBytesReceived(code, arraysize(code)); + tester.FinishStream(); + tester.RunCompilerTasks(); + CHECK(tester.IsPromiseFulfilled()); + CHECK(callback_called); +} + #undef STREAM_TEST } // namespace wasm