Remove demo_fuzz and fix OSSFuzz error.

Since we have a fuzzer for `Status`, we no longer need `demo_fuzz.cc` and the associated `demo_fuzz` `BUILD` target.

The `Status` fuzzer fails to compile in OSSFuzz as `string` is not `std::string`. Fix this in the same commit.

PiperOrigin-RevId: 316184164
Change-Id: I7001533e899c0aea399da19fd1b72099294d6be2
This commit is contained in:
Mihai Maruseac 2020-06-12 15:01:43 -07:00 committed by TensorFlower Gardener
parent 710cc7e0e5
commit f36313a753
3 changed files with 1 additions and 38 deletions

View File

@ -11,11 +11,6 @@ package(
licenses = ["notice"], # Apache 2.0
)
tf_fuzz_target(
name = "demo_fuzz",
srcs = ["demo_fuzz.cc"],
)
tf_fuzz_target(
name = "status_fuzz",
srcs = ["status_fuzz.cc"],

View File

@ -1,32 +0,0 @@
/* Copyright 2020 The TensorFlow Authors. All Rights Reserved.
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
http://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.
==============================================================================*/
#include <cstdint>
#include <cstdlib>
// This is a demo fuzzer to test that the entire framework functions correctly.
// Once we start moving the existing fuzzers to this framework we will delete
// this.
// TODO(mihaimaruseac): Delete this when no longer needed
void DemoFuzzer(const uint8_t* data, size_t size) {
// Trigger a small bug that should be found by the fuzzer quite quickly
if (size > 10 && size % 3 == 2)
if (data[0] > data[1])
if (data[5] % data[2] == data[3]) abort();
}
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
DemoFuzzer(data, size);
return 0;
}

View File

@ -57,7 +57,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
}
tensorflow::Status s = tensorflow::Status(error_code, error_message);
const string actual_message = s.ToString();
const std::string actual_message = s.ToString();
const std::size_t pos = actual_message.rfind(error_message);
assert(pos != std::string::npos); // Suffix is error message
assert(pos > 0); // Prefix is error code