From a869ae18d256e9db138b76f3e2ddaab0bb1100ac Mon Sep 17 00:00:00 2001 From: Victor Costan Date: Sun, 25 Feb 2018 23:19:23 -0800 Subject: [PATCH] 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 Reviewed-by: Scott Graham --- client/simple_string_dictionary_test.cc | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/client/simple_string_dictionary_test.cc b/client/simple_string_dictionary_test.cc index 6f85e854..5fdeb5bf 100644 --- a/client/simple_string_dictionary_test.cc +++ b/client/simple_string_dictionary_test.cc @@ -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