0
Files
src/testing/libfuzzer/fuzztest_init_helper.h
Adrian Taylor de84dffac2 Reland "fuzztest: no dep //testing->//base"
This is a reland of commit 9eb33a5154

Reason for revert:
This change refers from //testing to //testing/libfuzzer.
//testing/libfuzzer refers onwards to other parts of the Chromium
codebase. It seems that even if no actual targets are included from
these locations, this can still cause gn parsing errors in some cases.
This was known to be a problem for cronet and for Android nocompile
tests, and these problems were avoided in the CL, but it seems the same
applies to some Chrome OS devices - which aren't tested in the Chrome CQ
so this was reverted later.

Reason for reland:
This now includes a follow-up change that I was working on anyway,
squashed into this commit (previously https://crrev.com/5973000).
This breaks the link from //testing/libfuzzer onto any other parts of
Chromium, and thus should make it safe to refer to //testing/libfuzzer
from //testing. This should result in no build having to parse any more
gn files from the rest of the Chromium codebase. It removes the
conditionals that were put in place for cronet and Android nocomoile
builds, which should "just work", and so should any Chrome OS builds.

Original change's description:
> fuzztest: no dep //testing->//base
>
> A previous CL introduced a dependency from //testing onto //base in
> cases where a fuzztest was present in a unit test suite. This was
> thought to be OK because such fuzztests would, for now, only be used in
> a build_with_chromium environment.
>
> However, it turns out that WebRTC pull in libaom and other libraries
> which already have fuzztests, and that those fuzztests break in a
> non-Chromium environment.
>
> This CL moves the fuzztest-supporting code from //base into //testing,
> so that it should all work in a context where //base is unavailable.
>
> This means we can't depend upon base::NoDestructor or
> compiler_specific.h any longer.
>
> This means some types of build now include //testing/libfuzzer
> for the first time, and we need to exclude its transitive dependencies
> on aspects of actual fuzzing code which depend on other parts
> of Chromium.
>
> Testing performed: adding a fuzz test to base_unittests and ensuring
> that --list_fuzz_tests=1 works.
>
> Bug: 376071295
> Cq-Include-Trybots: luci.chromium.try:linux-libfuzzer-asan-rel,win-libfuzzer-asan-rel,linux-centipede-asan-rel
> Change-Id: I1809af76d4e2bd6f14f4872b5618d177741f3fd2
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5953310
> Reviewed-by: Ben Pastene <bpastene@chromium.org>
> Reviewed-by: Daniel Cheng <dcheng@chromium.org>
> Commit-Queue: Adrian Taylor <adetaylor@chromium.org>
> Reviewed-by: Titouan Rigoudy <titouan@chromium.org>
> Cr-Commit-Position: refs/heads/main@{#1375984}

Bug: 376071295, 376708286
Change-Id: I72446f68379c0eb96e3e920fd67589b7dcb2e01b
Cq-Include-Trybots: luci.chromium.try:linux-libfuzzer-asan-rel,win-libfuzzer-asan-rel,linux-centipede-asan-rel
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5982909
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
Reviewed-by: Ben Pastene <bpastene@chromium.org>
Reviewed-by: Andrew Grieve <agrieve@chromium.org>
Commit-Queue: Adrian Taylor <adetaylor@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1376981}
2024-11-01 18:00:22 +00:00

25 lines
866 B
C++

// Copyright 2024 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef TESTING_LIBFUZZER_FUZZTEST_INIT_HELPER_H_
#define TESTING_LIBFUZZER_FUZZTEST_INIT_HELPER_H_
namespace fuzztest_init_helper {
extern void (*initialization_function)(int argc, char** argv);
}
// If we're in a test suite which really has fuzztests,
// the above function pointer will have been populated with
// a function that knows how to initialize FuzzTests. Otherwise,
// it won't, to avoid bringing all of FuzzTests's dependencies
// into all the other Chromium test suites.
inline void MaybeInitFuzztest(int argc, char** argv) {
if (fuzztest_init_helper::initialization_function) {
fuzztest_init_helper::initialization_function(argc, argv);
}
}
#endif // TESTING_LIBFUZZER_FUZZTEST_INIT_HELPER_H_