Skip to content

Commit

Permalink
tensorflow: enable coverage build (google#9568)
Browse files Browse the repository at this point in the history
The current coverage build of Tensorflow is broken because the rsync
commands used copy all files build during the build process to OUT. This
includes a lot of binaries that are not needed for coverage reports, and
this added content causes ~100GB of data to be stored, which is why the
current coverage build fails to due disk space limitations:
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=47817

The coverage reports only need textual files. This PR fixes these
isssues by using rsync with appropriate filters, which should make the
coverage build work again.

Also fixes up the patch.

Signed-off-by: David Korczynski <[email protected]>

Signed-off-by: David Korczynski <[email protected]>
  • Loading branch information
DavidKorczynski authored Feb 2, 2023
1 parent 6e21448 commit 65ca234
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 27 deletions.
16 changes: 12 additions & 4 deletions projects/tensorflow/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@ else
export FUZZTEST_EXTRA_ARGS="${FUZZTEST_EXTRA_ARGS} --local_ram_resources=HOST_RAM*1.0 --local_cpu_resources=HOST_CPUS*.5 --strip=never"
fi

# Do not sync bazel-out to /out/ for coverage builds, as this is done
# at the end of this script instead.
export FUZZTEST_DO_SYNC="no"
compile_fuzztests.sh

# In the CI we bail out after having compiled the first set of fuzzers. This is
Expand Down Expand Up @@ -182,13 +185,18 @@ then
declare -r REMAP_PATH=${OUT}/proc/self/cwd/
mkdir -p ${REMAP_PATH}

# Synchronize the folder bazel-BAZEL_OUT_PROJECT.
declare -r RSYNC_FILTER_ARGS=("--include" "*.h" "--include" "*.cc" "--include" \
"*.hpp" "--include" "*.cpp" "--include" "*.c" "--include" "*/" "--include" "*.inc" \
"--exclude" "*")

# Sync existing code.
${RSYNC_CMD} tensorflow/ ${REMAP_PATH}
${RSYNC_CMD} "${RSYNC_FILTER_ARGS[@]}" tensorflow/ ${REMAP_PATH}

# Sync generated proto files.
${RSYNC_CMD} ./bazel-out/k8-opt/bin/tensorflow/ ${REMAP_PATH}
${RSYNC_CMD} ./bazel-out/k8-opt/bin/external/ ${REMAP_PATH}
${RSYNC_CMD} ./bazel-out/k8-opt/bin/third_party/ ${REMAP_PATH}
${RSYNC_CMD} "${RSYNC_FILTER_ARGS[@]}" ./bazel-out/k8-opt/bin/tensorflow/ ${REMAP_PATH}
${RSYNC_CMD} "${RSYNC_FILTER_ARGS[@]}" ./bazel-out/k8-opt/bin/external/ ${REMAP_PATH}
${RSYNC_CMD} "${RSYNC_FILTER_ARGS[@]}" ./bazel-out/k8-opt/bin/third_party/ ${REMAP_PATH}

# Sync external dependencies. We don't need to include `bazel-tensorflow`.
# Also, remove `external/org_tensorflow` which is a copy of the entire source
Expand Down
28 changes: 5 additions & 23 deletions projects/tensorflow/fuzz_patch.patch
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
diff --git a/tensorflow/security/fuzzing/cc/BUILD b/tensorflow/security/fuzzing/cc/BUILD
index d1f17a34..6b00ccee 100644
index c32a54ab..621d6f8c 100644
--- a/tensorflow/security/fuzzing/cc/BUILD
+++ b/tensorflow/security/fuzzing/cc/BUILD
@@ -8,19 +8,25 @@ load(
@@ -8,19 +8,24 @@ load(
"//tensorflow/security/fuzzing:tf_fuzzing.bzl",
"tf_cc_fuzz_test",
)
+load(
+ "//tensorflow:tensorflow.bzl",
+ "tf_cc_test",
+)
+

package(
# copybara:uncomment default_applicable_licenses = ["//tensorflow:license"],
Expand All @@ -23,27 +22,10 @@ index d1f17a34..6b00ccee 100644
srcs = ["status_fuzz.cc"],
- tags = ["no_oss"],
deps = [
":fuzz_helpers",
":fuzz_domains",
"//tensorflow/core/platform:status",
+ "@com_google_fuzztest//fuzztest",
+ "@com_google_fuzztest//fuzztest:fuzztest_gtest_main",
+ "@com_google_fuzztest//fuzztest",
+ "@com_google_fuzztest//fuzztest:fuzztest_gtest_main",
],
)

diff --git a/tensorflow/workspace2.bzl b/tensorflow/workspace2.bzl
index 0236c258bf5..55e4b394a63 100644
--- a/tensorflow/workspace2.bzl
+++ b/tensorflow/workspace2.bzl
@@ -479,9 +479,9 @@ def _tf_repositories():

tf_http_archive(
name = "com_google_fuzztest",
- sha256 = "3fe79ede8e860ba7331987b2c1f84d3eeaf5bea00fd76398d6ff0006635586c6",
- strip_prefix = "fuzztest-6d79ceb1dc2398e02a39efc23ce40d68baa16a42",
- urls = tf_mirror_urls("https://github.com/google/fuzztest/archive/6d79ceb1dc2398e02a39efc23ce40d68baa16a42.zip"),
+ sha256 = "0867fae7dce74a62d92b0811b0f735e35f9ea3ba8426a3cb7958ff7b158bed53",
+ strip_prefix = "fuzztest-0fdfd1aa286054cbf42bbf93006404caa2b827b8",
+ urls = tf_mirror_urls("https://github.com/google/fuzztest/archive/0fdfd1aa286054cbf42bbf93006404caa2b827b8.zip"),
)

tf_http_archive(

0 comments on commit 65ca234

Please sign in to comment.