LCOV - code coverage report
Current view: top level - test/fuzzer - wasm.cc (source / functions) Hit Total Coverage
Test: app.info Lines: 12 13 92.3 %
Date: 2017-10-20 Functions: 1 1 100.0 %

          Line data    Source code
       1             : // Copyright 2016 the V8 project authors. All rights reserved.
       2             : // Use of this source code is governed by a BSD-style license that can be
       3             : // found in the LICENSE file.
       4             : 
       5             : #include <limits.h>
       6             : #include <stddef.h>
       7             : #include <stdint.h>
       8             : 
       9             : #include "include/v8.h"
      10             : #include "src/factory.h"
      11             : #include "src/isolate-inl.h"
      12             : #include "src/isolate.h"
      13             : #include "src/objects-inl.h"
      14             : #include "src/objects.h"
      15             : #include "src/wasm/module-compiler.h"
      16             : #include "src/wasm/wasm-module.h"
      17             : #include "test/common/wasm/flag-utils.h"
      18             : #include "test/common/wasm/wasm-module-runner.h"
      19             : #include "test/fuzzer/fuzzer-support.h"
      20             : #include "test/fuzzer/wasm-fuzzer-common.h"
      21             : 
      22             : namespace i = v8::internal;
      23             : 
      24           1 : extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
      25             :   i::FlagScope<uint32_t> max_mem_flag_scope(&i::FLAG_wasm_max_mem_pages, 32);
      26             :   i::FlagScope<uint32_t> max_table_size_scope(&i::FLAG_wasm_max_table_size,
      27             :                                               100);
      28           1 :   v8_fuzzer::FuzzerSupport* support = v8_fuzzer::FuzzerSupport::Get();
      29           1 :   v8::Isolate* isolate = support->GetIsolate();
      30             :   i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
      31             : 
      32             :   // Clear any pending exceptions from a prior run.
      33           1 :   if (i_isolate->has_pending_exception()) {
      34             :     i_isolate->clear_pending_exception();
      35             :   }
      36             : 
      37             :   v8::Isolate::Scope isolate_scope(isolate);
      38           2 :   v8::HandleScope handle_scope(isolate);
      39           1 :   v8::Context::Scope context_scope(support->GetContext());
      40           2 :   v8::TryCatch try_catch(isolate);
      41           1 :   i::wasm::testing::SetupIsolateForWasmModule(i_isolate);
      42             : 
      43             :   i::HandleScope scope(i_isolate);
      44           1 :   i::wasm::ErrorThrower thrower(i_isolate, "wasm fuzzer");
      45             :   i::MaybeHandle<i::WasmModuleObject> maybe_object = SyncCompile(
      46           2 :       i_isolate, &thrower, i::wasm::ModuleWireBytes(data, data + size));
      47             :   i::Handle<i::WasmModuleObject> module_object;
      48           1 :   if (maybe_object.ToHandle(&module_object)) {
      49           0 :     i::wasm::fuzzer::InterpretAndExecuteModule(i_isolate, module_object);
      50             :   }
      51           1 :   return 0;
      52             : }

Generated by: LCOV version 1.10