Skip to content

Commit

Permalink
Make gtest always use simple internal regex engine.
Browse files Browse the repository at this point in the history
In order to allow regex matches in gtest to be shared between Windows and other
systems, we tell gtest to always use it's internal engine.

The syntax supported by the internal engine initially looks like a subset of
POSIX regexs. However character class shortcuts are not valid POSIX.

Even more confusingly the system POSIX regex function often defines extra
features not actually part of the standard allowing regex that work on Linux
fail on Mac OS X.

A search through the code base did not reveal any locations where features not
supported by the internal regex engine where used.

See bug https://code.google.com/p/chromium/issues/detail?id=317224 for more detailed description.

BUG=317224

Review URL: https://codereview.chromium.org/55983002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@241500 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
mithro@mithis.com committed Dec 18, 2013
1 parent 23efc4c commit e260ebc
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 11 deletions.
2 changes: 1 addition & 1 deletion base/message_loop/message_pump_io_ios_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ TEST_F(MessagePumpIOSForIOTest, TestWatchingFromBadThread) {
ASSERT_DEBUG_DEATH(io_loop()->WatchFileDescriptor(
STDOUT_FILENO, false, MessageLoopForIO::WATCH_READ, &watcher, &delegate),
"Check failed: "
"watch_file_descriptor_caller_checker_.CalledOnValidThread()");
"watch_file_descriptor_caller_checker_.CalledOnValidThread\\(\\)");
}

#endif // GTEST_HAS_DEATH_TEST && !defined(NDEBUG)
Expand Down
2 changes: 1 addition & 1 deletion base/message_loop/message_pump_libevent_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ TEST_F(MessagePumpLibeventTest, TestWatchingFromBadThread) {
ASSERT_DEATH(io_loop()->WatchFileDescriptor(
STDOUT_FILENO, false, MessageLoopForIO::WATCH_READ, &watcher, &delegate),
"Check failed: "
"watch_file_descriptor_caller_checker_.CalledOnValidThread()");
"watch_file_descriptor_caller_checker_.CalledOnValidThread\\(\\)");
}

#endif // GTEST_HAS_DEATH_TEST && !defined(NDEBUG)
Expand Down
8 changes: 3 additions & 5 deletions base/process/memory_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,7 @@ TEST(ProcessMemoryTest, MacMallocFailureDoesNotTerminate) {
buf = malloc(std::numeric_limits<size_t>::max() - (2 * PAGE_SIZE) - 1);
},
testing::KilledBySignal(SIGTRAP),
"\\*\\*\\* error: can't allocate region.*"
"(Terminating process due to a potential for future heap "
"corruption){0}");
"\\*\\*\\* error: can't allocate region.*\\n?.*");

base::debug::Alias(buf);
}
Expand All @@ -143,8 +141,8 @@ TEST(ProcessMemoryTest, MacTerminateOnHeapCorruption) {
ASSERT_DEATH(free(buf), "attempting free on address which "
"was not malloc\\(\\)-ed");
#else
ASSERT_DEATH(free(buf), "being freed.*"
"\\*\\*\\* set a breakpoint in malloc_error_break to debug.*"
ASSERT_DEATH(free(buf), "being freed.*\\n?\\.*"
"\\*\\*\\* set a breakpoint in malloc_error_break to debug.*\\n?.*"
"Terminating process due to a potential for future heap corruption");
#endif // ARCH_CPU_64_BITS || defined(ADDRESS_SANITIZER)
}
Expand Down
9 changes: 5 additions & 4 deletions base/tools_sanity_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,15 @@ void WriteValueOutOfArrayBoundsRight(char *ptr, size_t size) {

void MakeSomeErrors(char *ptr, size_t size) {
ReadUninitializedValue(ptr);

HARMFUL_ACCESS(ReadValueOutOfArrayBoundsLeft(ptr),
"heap-buffer-overflow.*2 bytes to the left");
"2 bytes to the left");
HARMFUL_ACCESS(ReadValueOutOfArrayBoundsRight(ptr, size),
"heap-buffer-overflow.*1 bytes to the right");
"1 bytes to the right");
HARMFUL_ACCESS(WriteValueOutOfArrayBoundsLeft(ptr),
"heap-buffer-overflow.*1 bytes to the left");
"1 bytes to the left");
HARMFUL_ACCESS(WriteValueOutOfArrayBoundsRight(ptr, size),
"heap-buffer-overflow.*0 bytes to the right");
"0 bytes to the right");
}

} // namespace
Expand Down
10 changes: 10 additions & 0 deletions testing/gtest.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,16 @@
'dependencies': [
'gtest_prod',
],
'defines': [
# In order to allow regex matches in gtest to be shared between Windows
# and other systems, we tell gtest to always use it's internal engine.
'GTEST_HAS_POSIX_RE=0',
],
'all_dependent_settings': {
'defines': [
'GTEST_HAS_POSIX_RE=0',
],
},
'conditions': [
['OS == "mac" or OS == "ios"', {
'sources': [
Expand Down

0 comments on commit e260ebc

Please sign in to comment.