[libcxx-commits] [PATCH] D154140: [libc++] Add .fuzz.cpp tests and move the fuzzing tests to the normal locations

Louis Dionne via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Fri Jul 7 11:55:16 PDT 2023


ldionne requested changes to this revision.
ldionne added inline comments.
This revision now requires changes to proceed.


================
Comment at: libcxx/utils/libcxx/test/features.py:103-111
+        when=lambda cfg: programSucceeds(cfg, """
+            #include <cstddef>
+            #include <cstdint>
+
+            extern "C" int LLVMFuzzerTestOneInput(const std::uint8_t *, std::size_t) {
+                return 0;
+            }
----------------



================
Comment at: libcxx/utils/libcxx/test/format.py:1
 # ===----------------------------------------------------------------------===##
 #
----------------
You should take a look at `libcxx/utils/ci/oss-fuzz.sh`, it will need to be fixed. `LIBCPP_OSS_FUZZ` won't be needed anymore.


================
Comment at: libcxx/utils/libcxx/test/format.py:228
                               does not support Clang-verify.
 
+    FOO.fuzz.cpp            - Compiles with -fsanitize=fuzzer -O3. This is disabled
----------------
Let's remove `-O3`.


================
Comment at: libcxx/utils/libcxx/test/format.py:229-231
+    FOO.fuzz.cpp            - Compiles with -fsanitize=fuzzer -O3. This is disabled
+                              if the compiler doesn't support libfuzzer or libfuzzer
+                              is built with a different standard library.
----------------



================
Comment at: libcxx/utils/libcxx/test/format.py:384-387
+            steps = [
+                "%dbg(COMPILED WITH) %{cxx} %s %{flags} %{compile_flags} %{link_flags} -fsanitize=fuzzer -O3 -o %t.exe",
+                "%dbg(EXECUTED AS) %{exec} %t.exe %{run_flags}",
             ]
----------------
Let's not hardcode `-O3` in fuzz tests. We should instead run the test suite with optimizations enabled when we mean to. And we should also run these fuzzing tests under OSS fuzz.


================
Comment at: libcxx/utils/libcxx/test/format.py:386
+                "%dbg(COMPILED WITH) %{cxx} %s %{flags} %{compile_flags} %{link_flags} -fsanitize=fuzzer -O3 -o %t.exe",
+                "%dbg(EXECUTED AS) %{exec} %t.exe %{run_flags}",
             ]
----------------
Instead of introducing `%{run_flags}`, let's hardcode `-max_total_time` here in the test format. Eventually we might make it something we can customize via the lit config (globally) if there's a use case for it.

Otherwise we're adding complexity (`RUN_FLAGS:` support) for a very tiny use case.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D154140/new/

https://reviews.llvm.org/D154140



More information about the libcxx-commits mailing list