Workaround for death test failure when in threadsafe mode on Mac.

Google Test has recently switched the default death test style from
"fast" to "threadsafe". This is a better default, and Chrome will adopt
it on all platforms except for Android.

In threadsafe mode, the death test in
client/simple_string_dictionary_test.cc consistently crashes with the
wrong expectation on Mac. Fortunately, breaking the test up into two
smaller tests makes the failures go away, and also adds a bit of clarity
into what is being tested.

Bug: crashpad:221
Change-Id: I2416647948815cfe46a003da8209af8b7278de2a
Reviewed-on: https://chromium-review.googlesource.com/936043
Commit-Queue: Victor Costan <pwnall@chromium.org>
Reviewed-by: Scott Graham <scottmg@chromium.org>
This commit is contained in:
Victor Costan 2018-02-25 23:19:23 -08:00 committed by Commit Bot
parent fae18c2fc4
commit a869ae18d2

View File

@ -253,21 +253,30 @@ TEST(SimpleStringDictionary, OutOfSpace) {
#if DCHECK_IS_ON()
TEST(SimpleStringDictionaryDeathTest, NullKey) {
TEST(SimpleStringDictionaryDeathTest, SetKeyValueWithNullKey) {
TSimpleStringDictionary<4, 6, 6> map;
ASSERT_DEATH_CHECK(map.SetKeyValue(nullptr, "hello"), "key");
}
TEST(SimpleStringDictionaryDeathTest, GetValueForKeyWithNullKey) {
TSimpleStringDictionary<4, 6, 6> map;
map.SetKeyValue("hi", "there");
ASSERT_DEATH_CHECK(map.GetValueForKey(nullptr), "key");
EXPECT_STREQ("there", map.GetValueForKey("hi"));
ASSERT_DEATH_CHECK(map.GetValueForKey(nullptr), "key");
map.RemoveKey("hi");
EXPECT_EQ(map.GetCount(), 0u);
}
#endif
// The tests above, without DEATH_CHECK assertions.
TEST(SimpleStringDictionaryDeathTest, GetValueForKeyWithoutNullKey) {
TSimpleStringDictionary<4, 6, 6> map;
map.SetKeyValue("hi", "there");
EXPECT_STREQ("there", map.GetValueForKey("hi"));
map.RemoveKey("hi");
EXPECT_EQ(map.GetCount(), 0u);
}
} // namespace
} // namespace test
} // namespace crashpad