fuzzer-support.h 1.15 KB
Newer Older
1 2 3 4 5 6 7
// 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 TEST_FUZZER_FUZZER_SUPPORT_H_
#define TEST_FUZZER_FUZZER_SUPPORT_H_

8
#include "include/libplatform/libplatform.h"
9 10 11 12 13 14 15
#include "include/v8.h"

namespace v8_fuzzer {

class FuzzerSupport {
 public:
  FuzzerSupport(int* argc, char*** argv);
16

17 18
  ~FuzzerSupport();

19 20
  static void InitializeFuzzerSupport(int* argc, char*** argv);

21 22
  static FuzzerSupport* Get();

23 24
  v8::Isolate* GetIsolate() const { return isolate_; }

25
  v8::Local<v8::Context> GetContext();
26

27 28
  bool PumpMessageLoop(v8::platform::MessageLoopBehavior =
                           v8::platform::MessageLoopBehavior::kDoNotWait);
29 30 31 32 33 34

 private:
  // Prevent copying. Not implemented.
  FuzzerSupport(const FuzzerSupport&);
  FuzzerSupport& operator=(const FuzzerSupport&);

35
  static std::unique_ptr<FuzzerSupport> fuzzer_support_;
36
  std::unique_ptr<v8::Platform> platform_;
37
  v8::ArrayBuffer::Allocator* allocator_;
38 39 40 41
  v8::Isolate* isolate_;
  v8::Global<v8::Context> context_;
};

42
}  // namespace v8_fuzzer
43 44

#endif  //  TEST_FUZZER_FUZZER_SUPPORT_H_