Commit 0054f109 authored by Jonathan Metzman's avatar Jonathan Metzman Committed by Commit Bot

[libfuzzer] Delete Text to Speech Fuzzer

Fuzzer is causing flakiness in CQ.
It can be added back if build issues are fixed.

Bug: 1028212
Change-Id: I45e764e20af1cbc59763cff32f4d379d67b47278
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2142589Reviewed-by: default avatarMax Moroz <mmoroz@chromium.org>
Reviewed-by: default avatarDominic Mazzoni <dmazzoni@chromium.org>
Commit-Queue: Dominic Mazzoni <dmazzoni@chromium.org>
Cr-Commit-Position: refs/heads/master@{#758869}
parent 50d0cc96
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "base/bind.h"
#include "build/build_config.h"
#include "content/public/browser/tts_platform.h"
#if defined(OS_WIN)
#include <objbase.h>
#endif
namespace content {
// Entry point for LibFuzzer.
extern "C" int LLVMFuzzerTestOneInput(const unsigned char* data, size_t size) {
int utterance_id = 0;
std::string utterance;
std::string lang;
VoiceData voice;
UtteranceContinuousParameters params;
params.pitch = 1.0;
params.rate = 1.0;
params.volume = 0.1;
#if defined(OS_WIN)
static bool initialized = false;
if (!initialized) {
initialized = true;
CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED);
}
#endif
// First byte gives us the utterance ID.
size_t i = 0;
if (i < size)
utterance_id = data[i++];
// Decide whether we want to fuzz the language, rate, pitch,
// voice name, and all that. Half the time we'll just leave
// those empty and fuzz only the utterance, otherwise it's
// possible the fuzzer would never spend any effort fuzzing
// utteranes.
if (i < size && (data[i++] % 2 == 0)) {
// The next few bytes determine the language. Ensure that
// we frequently get some common real languages but allow
// arbitrary strings up to 10 characters.
if (i < size) {
int lang_choice = data[i++];
switch (lang_choice) {
case 0:
lang = "";
break;
case 1:
lang = "en";
break;
case 2:
lang = "fr";
break;
case 3:
lang = "es";
break;
default:
int lang_len = 1 + (lang_choice - 4) % 10;
for (int j = 0; j < lang_len; j++) {
if (i < size)
lang.append(1, data[i++]);
}
}
}
// Set native_voice_identifier
if (i < size) {
int voice_len = data[i++] % 10;
for (int j = 0; j < voice_len; j++) {
if (i < size)
voice.native_voice_identifier.append(1, data[i++]);
}
}
// Set rate, pitch.
if (i + 4 <= size) {
params.rate = *reinterpret_cast<const float*>(&data[i]);
i += 4;
}
if (i + 4 <= size) {
params.pitch = *reinterpret_cast<const float*>(&data[i]);
i += 4;
}
}
// The rest of the data becomes the utterance.
while (i < size)
utterance.append(1, data[i++]);
TtsPlatform* tts = TtsPlatform::GetInstance();
CHECK(tts->PlatformImplAvailable());
VLOG(1) << "id=" << utterance_id << " lang='" << lang << "'"
<< " voice='" << voice.native_voice_identifier << "'"
<< " pitch=" << params.pitch << " rate=" << params.rate
<< " volume=" << params.volume << " utterance='" << utterance << "'";
tts->StopSpeaking();
tts->Speak(utterance_id, utterance, lang, voice, params,
base::BindOnce([](bool success) {}));
return 0;
}
} // namespace content
...@@ -161,42 +161,6 @@ fuzzer_test("appcache_fuzzer") { ...@@ -161,42 +161,6 @@ fuzzer_test("appcache_fuzzer") {
] ]
} }
# Note: this compiles and runs on Mac but may cause
# system instability; if you try it out, close other
# programs and then reboot afterwards. It should be
# possible to make it work on Linux if you use the
# --enable-speech-dispatcher flag.
if (is_win) {
fuzzer_test("tts_platform_fuzzer") {
sources = [
"../../browser/speech/mock_tts_controller.cc",
"../../browser/speech/tts_mac.mm",
"../../browser/speech/tts_platform_fuzzer.cc",
"../../browser/speech/tts_platform_impl.cc",
"../../browser/speech/tts_platform_impl.h",
"../../browser/speech/tts_win.cc",
"../../public/browser/tts_controller.h",
"../../public/browser/tts_platform.h",
"//content/common/content_export.h",
]
# Don't try to link the code that calls GetContentClient(), because
# then we'd need to link in most of //content.
defines = [ "NO_CONTENT_CLIENT" ]
# TODO(https://crbug.com/927728): Refactor target to not require this.
check_includes = false
deps = [
"//base",
"//base/test:test_support",
"//third_party/webrtc_overrides:webrtc_component",
"//ui/base",
"//url:url",
]
}
}
fuzzer_test("speech_audio_encoder_fuzzer") { fuzzer_test("speech_audio_encoder_fuzzer") {
sources = [ sources = [
"../../browser/speech/audio_buffer.cc", "../../browser/speech/audio_buffer.cc",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment