[libc++] Refactor the fuzzing tests

Define all the fuzzing tests in libcxx/test/libcxx/fuzzing, and get
rid of the ad-hoc libcxx/fuzzing directory, which wasn't properly
integrated with the build system or test suite.

As a fly-by change, this also reduces the dependencies of fuzzing tests
on large library components like <iostream>, to make them work on more
platforms.

GitOrigin-RevId: b4bd194378851c2f421477d4147019d10f2420ac
diff --git a/utils/ci/oss-fuzz.sh b/utils/ci/oss-fuzz.sh
index eac1a27..8a9421a 100755
--- a/utils/ci/oss-fuzz.sh
+++ b/utils/ci/oss-fuzz.sh
@@ -4,20 +4,16 @@
 # This script runs the continuous fuzzing tests on OSS-Fuzz.
 #
 
-if [[ $SANITIZER = *undefined* ]]; then
-  CXXFLAGS="$CXXFLAGS -fsanitize=unsigned-integer-overflow -fsanitize-trap=unsigned-integer-overflow"
+if [[ ${SANITIZER} = *undefined* ]]; then
+  CXXFLAGS="${CXXFLAGS} -fsanitize=unsigned-integer-overflow -fsanitize-trap=unsigned-integer-overflow"
 fi
 
-for f in $(grep -v "#" libcxx/fuzzing/RoutineNames.txt); do
-  cat > ${f}_fuzzer.cc <<EOF
-#include "fuzzing/fuzzing.h"
-#include <cassert>
-extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
-  int result = fuzzing::$f(data, size);
-  assert(result == 0); return 0;
-}
-EOF
-  $CXX $CXXFLAGS -std=c++11 ${f}_fuzzer.cc ./libcxx/fuzzing/fuzzing.cpp \
-      -nostdinc++ -cxx-isystem ./libcxx/include -iquote ./libcxx \
-      -o $OUT/$f $LIB_FUZZING_ENGINE
+for test in libcxx/test/libcxx/fuzzing/*.pass.cpp; do
+    ${CXX} ${CXXFLAGS} \
+        -std=c++14 \
+        -DLIBCPP_OSS_FUZZ \
+        -nostdinc++ -cxx-isystem libcxx/include \
+        -o "${OUT}/$(basename ${test})" \
+        ${test} \
+        ${LIB_FUZZING_ENGINE}
 done