// Copyright 2023 The Pigweed Authors // // Licensed under the Apache License, Version 2.0 (the "License"); you may not // use this file except in compliance with the License. You may obtain a copy of // the License at // // https://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the // License for the specific language governing permissions and limitations under // the License. #pragma once /// @file fuzztest.h /// Stubs for the FuzzTest interface /// /// @rst /// .. warning:: /// This header depends on portions of the standard library that may not /// supported on your device! /// /// This header provides stubs for the full FuzzTest interface, including /// `macros`_ and `domains`_ that include C++ standard library `headers`_ that /// are not permitted in Pigweed. It should only be used in downstream projects /// that support the full standard library on both host and device. It should /// never be used in core Pigweed. /// /// If possible, consider including ``pw_fuzzer/fuzztest.h`` instead. /// /// This header is included when FuzzTest is disabled, e.g. for GN, when /// ``dir_pw_third_party_fuzztest`` or ``pw_toolchain_FUZZING_ENABLED`` are not /// set. Otherwise, ``$dir_pw_third_party_fuzztest/fuzztest.h`` is used instead. /// /// .. _domains: /// https://github.com/google/fuzztest/blob/main/doc/domains-reference.md /// .. _headers: https://pigweed.dev/docs/style_guide.html#permitted-headers /// .. _macros: /// https://github.com/google/fuzztest/blob/main/doc/fuzz-test-macro.md /// @endrst #include #include #include #include #include #include #include #include #include #include "pw_fuzzer/internal/fuzztest.h" namespace fuzztest { // This namespace is here only as a way to disable ADL (argument-dependent // lookup). Names should be used from the fuzztest:: namespace. namespace internal_no_adl { template auto ElementOf(std::vector) { return internal::Domain{}; } inline auto String() { return Arbitrary(); } template inline auto StringOf(internal::Domain inner) { return ContainerOf(std::move(inner)); } inline auto AsciiString() { return StringOf(AsciiChar()); } inline auto PrintableAsciiString() { return StringOf(PrintableAsciiChar()); } template