xref: /llvm-project/compiler-rt/test/fuzzer/AcquireCrashStateTest.cpp (revision 2946cd701067404b99c39fb29dc9c74bd7193eb3)
1*2946cd70SChandler Carruth // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
2*2946cd70SChandler Carruth // See https://llvm.org/LICENSE.txt for license information.
3*2946cd70SChandler Carruth // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
452fd1690SMatt Morehouse 
552fd1690SMatt Morehouse // Ensures that error reports are suppressed after
652fd1690SMatt Morehouse // __sanitizer_acquire_crash_state() has been called the first time.
752fd1690SMatt Morehouse #include "sanitizer/common_interface_defs.h"
852fd1690SMatt Morehouse 
952fd1690SMatt Morehouse #include <cassert>
1052fd1690SMatt Morehouse #include <cstdint>
1152fd1690SMatt Morehouse #include <cstdlib>
1252fd1690SMatt Morehouse 
LLVMFuzzerTestOneInput(const uint8_t * Data,size_t Size)1352fd1690SMatt Morehouse extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
1452fd1690SMatt Morehouse   assert(Data);
1552fd1690SMatt Morehouse   if (Size == 0) return 0;
1652fd1690SMatt Morehouse   __sanitizer_acquire_crash_state();
1752fd1690SMatt Morehouse   exit(0);  // No report should be generated here.
1852fd1690SMatt Morehouse }
1952fd1690SMatt Morehouse 
20