Chromium Code Reviews| Index: test/cctest/wasm/test-run-wasm-module-helper.h |
| diff --git a/test/cctest/wasm/test-run-wasm-module-helper.h b/test/cctest/wasm/test-run-wasm-module-helper.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..924f17a409562fb0c357b239a754930aad97591f |
| --- /dev/null |
| +++ b/test/cctest/wasm/test-run-wasm-module-helper.h |
| @@ -0,0 +1,49 @@ |
| +// Copyright 2016 the V8 project authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef V8_TEST_RUN_WASM_MODULE_HELPER_H |
| +#define V8_TEST_RUN_WASM_MODULE_HELPER_H |
| + |
| +#include <stdlib.h> |
| +#include <string.h> |
| + |
| +#include "src/wasm/encoder.h" |
| +#include "src/wasm/module-decoder.h" |
| +#include "src/wasm/wasm-js.h" |
| +#include "src/wasm/wasm-module.h" |
| + |
| +#include "test/cctest/cctest.h" |
| + |
| +using namespace v8::base; |
| +using namespace v8::internal; |
| +using namespace v8::internal::compiler; |
| +using namespace v8::internal::wasm; |
| + |
| +class TestRunWasmModuleHelper { |
|
bradnelson
2016/08/31 22:42:08
Land as a separate refactor (but I think you said
titzer
2016/09/05 13:01:45
I'm not sure we need to extract this out. It shoul
aseemgarg
2016/10/10 17:35:17
removed file. Moved to different test type.
|
| + public: |
| + static void TestModule(Zone* zone, WasmModuleBuilder* builder, |
| + int32_t expected_result) { |
| + ZoneBuffer buffer(zone); |
| + builder->WriteTo(buffer); |
| + |
| + Isolate* isolate = CcTest::InitIsolateOnce(); |
| + HandleScope scope(isolate); |
| + WasmJs::InstallWasmFunctionMap(isolate, isolate->native_context()); |
| + int32_t result = |
| + testing::CompileAndRunWasmModule(isolate, buffer.begin(), buffer.end()); |
| + CHECK_EQ(expected_result, result); |
| + } |
| + |
| + static void ExportAs(WasmFunctionBuilder* f, const char* name) { |
| + f->SetExported(); |
| + f->SetName(name, static_cast<int>(strlen(name))); |
| + } |
| + |
| + static void ExportAsMain(WasmFunctionBuilder* f) { |
| + static const char kMainName[] = "main"; |
| + ExportAs(f, kMainName); |
| + } |
| +}; |
| + |
| +#endif // V8_TEST_RUN_WASM_MODULE_HELPER_H |