Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1106)

Unified Diff: test/fuzzer/regexp.cc

Issue 1660463002: [regexp, fuzzer] improve regexp fuzzer coverage. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: revert test cases Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | test/fuzzer/testcfg.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/fuzzer/regexp.cc
diff --git a/test/fuzzer/regexp.cc b/test/fuzzer/regexp.cc
index f5ba5c9ea98ec024b90f4eaadf2a439d9f925c9c..ce8f924d9e21207cf1e9d43170107ca853158541 100644
--- a/test/fuzzer/regexp.cc
+++ b/test/fuzzer/regexp.cc
@@ -14,6 +14,12 @@
namespace i = v8::internal;
+void Test(v8::Isolate* isolate, i::Handle<i::JSRegExp> regexp,
+ i::Handle<i::String> subject, i::Handle<i::JSArray> results_array) {
+ v8::TryCatch try_catch(isolate);
+ USE(i::RegExpImpl::Exec(regexp, subject, 0, results_array));
+}
+
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
v8_fuzzer::FuzzerSupport* support = v8_fuzzer::FuzzerSupport::Get();
v8::Isolate* isolate = support->GetIsolate();
@@ -42,7 +48,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
const uint8_t one_byte_array[6] = {'f', 'o', 'o', 'b', 'a', 'r'};
const i::uc16 two_byte_array[6] = {'f', 0xD83D, 0xDCA9, 'b', 'a', 0x2603};
- i::Handle<i::JSArray> results_array = factory->NewJSArray(4);
+ i::Handle<i::JSArray> results_array = factory->NewJSArray(5);
i::Handle<i::String> one_byte =
factory->NewStringFromOneByte(i::Vector<const uint8_t>(one_byte_array, 6))
.ToHandleChecked();
@@ -51,13 +57,17 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
.ToHandleChecked();
for (int flags = 0; flags <= kAllFlags; flags++) {
- v8::TryCatch try_catch(isolate);
- i::MaybeHandle<i::JSRegExp> maybe_regexp =
- i::JSRegExp::New(source, static_cast<i::JSRegExp::Flags>(flags));
i::Handle<i::JSRegExp> regexp;
- if (!maybe_regexp.ToHandle(&regexp)) continue;
- USE(i::RegExpImpl::Exec(regexp, one_byte, 0, results_array).is_null() &&
- i::RegExpImpl::Exec(regexp, two_byte, 0, results_array).is_null());
+ {
+ v8::TryCatch try_catch(isolate);
+ i::MaybeHandle<i::JSRegExp> maybe_regexp =
+ i::JSRegExp::New(source, static_cast<i::JSRegExp::Flags>(flags));
+ if (!maybe_regexp.ToHandle(&regexp)) continue;
+ }
+ Test(isolate, regexp, one_byte, results_array);
+ Test(isolate, regexp, two_byte, results_array);
+ Test(isolate, regexp, factory->empty_string(), results_array);
+ Test(isolate, regexp, source, results_array);
}
return 0;
« no previous file with comments | « no previous file | test/fuzzer/testcfg.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698