[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 <clemensh@chromium.org>
Commit-Queue: Andreas Haas <ahaas@chromium.org>
Cr-Commit-Position: refs/heads/master@{#58917}
This commit is contained in:
Andreas Haas 2019-01-18 10:46:49 +01:00 committed by Commit Bot
parent 7fa9de1d14
commit ea26454fb7

View File

@ -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<NativeModule> 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