2022-09-06 19:14:07 -04:00
|
|
|
|
// Copyright 2014 The Crashpad Authors
|
2014-11-04 12:36:29 -05:00
|
|
|
|
//
|
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
|
//
|
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
//
|
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
|
// limitations under the License.
|
|
|
|
|
|
|
|
|
|
#include "minidump/minidump_thread_id_map.h"
|
|
|
|
|
|
2016-01-06 12:22:50 -05:00
|
|
|
|
#include <sys/types.h>
|
|
|
|
|
|
2022-02-28 20:57:19 -08:00
|
|
|
|
#include <iterator>
|
2014-11-04 12:36:29 -05:00
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
|
|
#include "gtest/gtest.h"
|
|
|
|
|
#include "snapshot/test/test_thread_snapshot.h"
|
|
|
|
|
|
|
|
|
|
namespace crashpad {
|
|
|
|
|
namespace test {
|
|
|
|
|
namespace {
|
|
|
|
|
|
|
|
|
|
class MinidumpThreadIDMapTest : public testing::Test {
|
|
|
|
|
public:
|
|
|
|
|
MinidumpThreadIDMapTest()
|
|
|
|
|
: Test(),
|
|
|
|
|
thread_snapshots_(),
|
|
|
|
|
test_thread_snapshots_() {
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-20 12:55:12 -07:00
|
|
|
|
MinidumpThreadIDMapTest(const MinidumpThreadIDMapTest&) = delete;
|
|
|
|
|
MinidumpThreadIDMapTest& operator=(const MinidumpThreadIDMapTest&) = delete;
|
|
|
|
|
|
2014-11-04 12:36:29 -05:00
|
|
|
|
~MinidumpThreadIDMapTest() override {}
|
|
|
|
|
|
|
|
|
|
// testing::Test:
|
|
|
|
|
void SetUp() override {
|
2022-02-28 20:57:19 -08:00
|
|
|
|
for (size_t index = 0; index < std::size(test_thread_snapshots_); ++index) {
|
2014-11-04 12:36:29 -05:00
|
|
|
|
thread_snapshots_.push_back(&test_thread_snapshots_[index]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
static bool MapHasKeyValue(
|
|
|
|
|
const MinidumpThreadIDMap* map, uint64_t key, uint32_t expected_value) {
|
|
|
|
|
auto iterator = map->find(key);
|
|
|
|
|
if (iterator == map->end()) {
|
test: Use (actual, [un]expected) in gtest {ASSERT,EXPECT}_{EQ,NE}
gtest used to require (expected, actual) ordering for arguments to
EXPECT_EQ and ASSERT_EQ, and in failed test assertions would identify
each side as “expected” or “actual.” Tests in Crashpad adhered to this
traditional ordering. After a gtest change in February 2016, it is now
agnostic with respect to the order of these arguments.
This change mechanically updates all uses of these macros to (actual,
expected) by reversing them. This provides consistency with our use of
the logging CHECK_EQ and DCHECK_EQ macros, and makes for better
readability by ordinary native speakers. The rough (but working!)
conversion tool is
https://chromium-review.googlesource.com/c/466727/1/rewrite_expectassert_eq.py,
and “git cl format” cleaned up its output.
EXPECT_NE and ASSERT_NE never had a preferred ordering. gtest never made
a judgment that one side or the other needed to provide an “unexpected”
value. Consequently, some code used (unexpected, actual) while other
code used (actual, unexpected). For consistency with the new EXPECT_EQ
and ASSERT_EQ usage, as well as consistency with CHECK_NE and DCHECK_NE,
this change also updates these use sites to (actual, unexpected) where
one side can be called “unexpected” as, for example, std::string::npos
can be. Unfortunately, this portion was a manual conversion.
References:
https://github.com/google/googletest/blob/master/googletest/docs/Primer.md#binary-comparison
https://github.com/google/googletest/commit/77d6b173380332b1c1bc540532641f410ec82d65
https://github.com/google/googletest/pull/713
Change-Id: I978fef7c94183b8b1ef63f12f5ab4d6693626be3
Reviewed-on: https://chromium-review.googlesource.com/466727
Reviewed-by: Scott Graham <scottmg@chromium.org>
2017-04-04 00:35:21 -04:00
|
|
|
|
EXPECT_NE(iterator, map->end());
|
2014-11-04 12:36:29 -05:00
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
if (iterator->second != expected_value) {
|
test: Use (actual, [un]expected) in gtest {ASSERT,EXPECT}_{EQ,NE}
gtest used to require (expected, actual) ordering for arguments to
EXPECT_EQ and ASSERT_EQ, and in failed test assertions would identify
each side as “expected” or “actual.” Tests in Crashpad adhered to this
traditional ordering. After a gtest change in February 2016, it is now
agnostic with respect to the order of these arguments.
This change mechanically updates all uses of these macros to (actual,
expected) by reversing them. This provides consistency with our use of
the logging CHECK_EQ and DCHECK_EQ macros, and makes for better
readability by ordinary native speakers. The rough (but working!)
conversion tool is
https://chromium-review.googlesource.com/c/466727/1/rewrite_expectassert_eq.py,
and “git cl format” cleaned up its output.
EXPECT_NE and ASSERT_NE never had a preferred ordering. gtest never made
a judgment that one side or the other needed to provide an “unexpected”
value. Consequently, some code used (unexpected, actual) while other
code used (actual, unexpected). For consistency with the new EXPECT_EQ
and ASSERT_EQ usage, as well as consistency with CHECK_NE and DCHECK_NE,
this change also updates these use sites to (actual, unexpected) where
one side can be called “unexpected” as, for example, std::string::npos
can be. Unfortunately, this portion was a manual conversion.
References:
https://github.com/google/googletest/blob/master/googletest/docs/Primer.md#binary-comparison
https://github.com/google/googletest/commit/77d6b173380332b1c1bc540532641f410ec82d65
https://github.com/google/googletest/pull/713
Change-Id: I978fef7c94183b8b1ef63f12f5ab4d6693626be3
Reviewed-on: https://chromium-review.googlesource.com/466727
Reviewed-by: Scott Graham <scottmg@chromium.org>
2017-04-04 00:35:21 -04:00
|
|
|
|
EXPECT_EQ(iterator->second, expected_value);
|
2014-11-04 12:36:29 -05:00
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SetThreadID(size_t index, uint64_t thread_id) {
|
2022-02-28 20:57:19 -08:00
|
|
|
|
ASSERT_LT(index, std::size(test_thread_snapshots_));
|
2014-11-04 12:36:29 -05:00
|
|
|
|
test_thread_snapshots_[index].SetThreadID(thread_id);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const std::vector<const ThreadSnapshot*>& thread_snapshots() const {
|
|
|
|
|
return thread_snapshots_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
std::vector<const ThreadSnapshot*> thread_snapshots_;
|
|
|
|
|
TestThreadSnapshot test_thread_snapshots_[5];
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
TEST_F(MinidumpThreadIDMapTest, NoThreads) {
|
|
|
|
|
// Don’t use thread_snapshots(), because it’s got some threads in it, and the
|
|
|
|
|
// point of this test is to make sure that BuildMinidumpThreadIDMap() works
|
|
|
|
|
// with no threads.
|
|
|
|
|
std::vector<const ThreadSnapshot*> thread_snapshots;
|
|
|
|
|
MinidumpThreadIDMap thread_id_map;
|
|
|
|
|
BuildMinidumpThreadIDMap(thread_snapshots, &thread_id_map);
|
|
|
|
|
|
|
|
|
|
EXPECT_TRUE(thread_id_map.empty());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_F(MinidumpThreadIDMapTest, SimpleMapping) {
|
|
|
|
|
SetThreadID(0, 1);
|
|
|
|
|
SetThreadID(1, 3);
|
|
|
|
|
SetThreadID(2, 5);
|
|
|
|
|
SetThreadID(3, 7);
|
|
|
|
|
SetThreadID(4, 9);
|
|
|
|
|
|
|
|
|
|
MinidumpThreadIDMap thread_id_map;
|
|
|
|
|
BuildMinidumpThreadIDMap(thread_snapshots(), &thread_id_map);
|
|
|
|
|
|
test: Use (actual, [un]expected) in gtest {ASSERT,EXPECT}_{EQ,NE}
gtest used to require (expected, actual) ordering for arguments to
EXPECT_EQ and ASSERT_EQ, and in failed test assertions would identify
each side as “expected” or “actual.” Tests in Crashpad adhered to this
traditional ordering. After a gtest change in February 2016, it is now
agnostic with respect to the order of these arguments.
This change mechanically updates all uses of these macros to (actual,
expected) by reversing them. This provides consistency with our use of
the logging CHECK_EQ and DCHECK_EQ macros, and makes for better
readability by ordinary native speakers. The rough (but working!)
conversion tool is
https://chromium-review.googlesource.com/c/466727/1/rewrite_expectassert_eq.py,
and “git cl format” cleaned up its output.
EXPECT_NE and ASSERT_NE never had a preferred ordering. gtest never made
a judgment that one side or the other needed to provide an “unexpected”
value. Consequently, some code used (unexpected, actual) while other
code used (actual, unexpected). For consistency with the new EXPECT_EQ
and ASSERT_EQ usage, as well as consistency with CHECK_NE and DCHECK_NE,
this change also updates these use sites to (actual, unexpected) where
one side can be called “unexpected” as, for example, std::string::npos
can be. Unfortunately, this portion was a manual conversion.
References:
https://github.com/google/googletest/blob/master/googletest/docs/Primer.md#binary-comparison
https://github.com/google/googletest/commit/77d6b173380332b1c1bc540532641f410ec82d65
https://github.com/google/googletest/pull/713
Change-Id: I978fef7c94183b8b1ef63f12f5ab4d6693626be3
Reviewed-on: https://chromium-review.googlesource.com/466727
Reviewed-by: Scott Graham <scottmg@chromium.org>
2017-04-04 00:35:21 -04:00
|
|
|
|
EXPECT_EQ(thread_id_map.size(), 5u);
|
2014-11-04 12:36:29 -05:00
|
|
|
|
EXPECT_PRED3(MapHasKeyValue, &thread_id_map, 1, 1);
|
|
|
|
|
EXPECT_PRED3(MapHasKeyValue, &thread_id_map, 3, 3);
|
|
|
|
|
EXPECT_PRED3(MapHasKeyValue, &thread_id_map, 5, 5);
|
|
|
|
|
EXPECT_PRED3(MapHasKeyValue, &thread_id_map, 7, 7);
|
|
|
|
|
EXPECT_PRED3(MapHasKeyValue, &thread_id_map, 9, 9);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_F(MinidumpThreadIDMapTest, Truncation) {
|
|
|
|
|
SetThreadID(0, 0x0000000000000000);
|
|
|
|
|
SetThreadID(1, 0x9999999900000001);
|
|
|
|
|
SetThreadID(2, 0x9999999980000001);
|
|
|
|
|
SetThreadID(3, 0x99999999fffffffe);
|
|
|
|
|
SetThreadID(4, 0x99999999ffffffff);
|
|
|
|
|
|
|
|
|
|
MinidumpThreadIDMap thread_id_map;
|
|
|
|
|
BuildMinidumpThreadIDMap(thread_snapshots(), &thread_id_map);
|
|
|
|
|
|
test: Use (actual, [un]expected) in gtest {ASSERT,EXPECT}_{EQ,NE}
gtest used to require (expected, actual) ordering for arguments to
EXPECT_EQ and ASSERT_EQ, and in failed test assertions would identify
each side as “expected” or “actual.” Tests in Crashpad adhered to this
traditional ordering. After a gtest change in February 2016, it is now
agnostic with respect to the order of these arguments.
This change mechanically updates all uses of these macros to (actual,
expected) by reversing them. This provides consistency with our use of
the logging CHECK_EQ and DCHECK_EQ macros, and makes for better
readability by ordinary native speakers. The rough (but working!)
conversion tool is
https://chromium-review.googlesource.com/c/466727/1/rewrite_expectassert_eq.py,
and “git cl format” cleaned up its output.
EXPECT_NE and ASSERT_NE never had a preferred ordering. gtest never made
a judgment that one side or the other needed to provide an “unexpected”
value. Consequently, some code used (unexpected, actual) while other
code used (actual, unexpected). For consistency with the new EXPECT_EQ
and ASSERT_EQ usage, as well as consistency with CHECK_NE and DCHECK_NE,
this change also updates these use sites to (actual, unexpected) where
one side can be called “unexpected” as, for example, std::string::npos
can be. Unfortunately, this portion was a manual conversion.
References:
https://github.com/google/googletest/blob/master/googletest/docs/Primer.md#binary-comparison
https://github.com/google/googletest/commit/77d6b173380332b1c1bc540532641f410ec82d65
https://github.com/google/googletest/pull/713
Change-Id: I978fef7c94183b8b1ef63f12f5ab4d6693626be3
Reviewed-on: https://chromium-review.googlesource.com/466727
Reviewed-by: Scott Graham <scottmg@chromium.org>
2017-04-04 00:35:21 -04:00
|
|
|
|
EXPECT_EQ(thread_id_map.size(), 5u);
|
2014-11-04 12:36:29 -05:00
|
|
|
|
EXPECT_PRED3(MapHasKeyValue, &thread_id_map, 0x0000000000000000, 0x00000000);
|
|
|
|
|
EXPECT_PRED3(MapHasKeyValue, &thread_id_map, 0x9999999900000001, 0x00000001);
|
|
|
|
|
EXPECT_PRED3(MapHasKeyValue, &thread_id_map, 0x9999999980000001, 0x80000001);
|
|
|
|
|
EXPECT_PRED3(MapHasKeyValue, &thread_id_map, 0x99999999fffffffe, 0xfffffffe);
|
|
|
|
|
EXPECT_PRED3(MapHasKeyValue, &thread_id_map, 0x99999999ffffffff, 0xffffffff);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_F(MinidumpThreadIDMapTest, DuplicateThreadID) {
|
|
|
|
|
SetThreadID(0, 2);
|
|
|
|
|
SetThreadID(1, 4);
|
|
|
|
|
SetThreadID(2, 4);
|
|
|
|
|
SetThreadID(3, 6);
|
|
|
|
|
SetThreadID(4, 8);
|
|
|
|
|
|
|
|
|
|
MinidumpThreadIDMap thread_id_map;
|
|
|
|
|
BuildMinidumpThreadIDMap(thread_snapshots(), &thread_id_map);
|
|
|
|
|
|
test: Use (actual, [un]expected) in gtest {ASSERT,EXPECT}_{EQ,NE}
gtest used to require (expected, actual) ordering for arguments to
EXPECT_EQ and ASSERT_EQ, and in failed test assertions would identify
each side as “expected” or “actual.” Tests in Crashpad adhered to this
traditional ordering. After a gtest change in February 2016, it is now
agnostic with respect to the order of these arguments.
This change mechanically updates all uses of these macros to (actual,
expected) by reversing them. This provides consistency with our use of
the logging CHECK_EQ and DCHECK_EQ macros, and makes for better
readability by ordinary native speakers. The rough (but working!)
conversion tool is
https://chromium-review.googlesource.com/c/466727/1/rewrite_expectassert_eq.py,
and “git cl format” cleaned up its output.
EXPECT_NE and ASSERT_NE never had a preferred ordering. gtest never made
a judgment that one side or the other needed to provide an “unexpected”
value. Consequently, some code used (unexpected, actual) while other
code used (actual, unexpected). For consistency with the new EXPECT_EQ
and ASSERT_EQ usage, as well as consistency with CHECK_NE and DCHECK_NE,
this change also updates these use sites to (actual, unexpected) where
one side can be called “unexpected” as, for example, std::string::npos
can be. Unfortunately, this portion was a manual conversion.
References:
https://github.com/google/googletest/blob/master/googletest/docs/Primer.md#binary-comparison
https://github.com/google/googletest/commit/77d6b173380332b1c1bc540532641f410ec82d65
https://github.com/google/googletest/pull/713
Change-Id: I978fef7c94183b8b1ef63f12f5ab4d6693626be3
Reviewed-on: https://chromium-review.googlesource.com/466727
Reviewed-by: Scott Graham <scottmg@chromium.org>
2017-04-04 00:35:21 -04:00
|
|
|
|
EXPECT_EQ(thread_id_map.size(), 4u);
|
2014-11-04 12:36:29 -05:00
|
|
|
|
EXPECT_PRED3(MapHasKeyValue, &thread_id_map, 2, 2);
|
|
|
|
|
EXPECT_PRED3(MapHasKeyValue, &thread_id_map, 4, 4);
|
|
|
|
|
EXPECT_PRED3(MapHasKeyValue, &thread_id_map, 6, 6);
|
|
|
|
|
EXPECT_PRED3(MapHasKeyValue, &thread_id_map, 8, 8);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_F(MinidumpThreadIDMapTest, Collision) {
|
|
|
|
|
SetThreadID(0, 0x0000000000000010);
|
|
|
|
|
SetThreadID(1, 0x0000000000000020);
|
|
|
|
|
SetThreadID(2, 0x0000000000000030);
|
|
|
|
|
SetThreadID(3, 0x0000000000000040);
|
|
|
|
|
SetThreadID(4, 0x0000000100000010);
|
|
|
|
|
|
|
|
|
|
MinidumpThreadIDMap thread_id_map;
|
|
|
|
|
BuildMinidumpThreadIDMap(thread_snapshots(), &thread_id_map);
|
|
|
|
|
|
test: Use (actual, [un]expected) in gtest {ASSERT,EXPECT}_{EQ,NE}
gtest used to require (expected, actual) ordering for arguments to
EXPECT_EQ and ASSERT_EQ, and in failed test assertions would identify
each side as “expected” or “actual.” Tests in Crashpad adhered to this
traditional ordering. After a gtest change in February 2016, it is now
agnostic with respect to the order of these arguments.
This change mechanically updates all uses of these macros to (actual,
expected) by reversing them. This provides consistency with our use of
the logging CHECK_EQ and DCHECK_EQ macros, and makes for better
readability by ordinary native speakers. The rough (but working!)
conversion tool is
https://chromium-review.googlesource.com/c/466727/1/rewrite_expectassert_eq.py,
and “git cl format” cleaned up its output.
EXPECT_NE and ASSERT_NE never had a preferred ordering. gtest never made
a judgment that one side or the other needed to provide an “unexpected”
value. Consequently, some code used (unexpected, actual) while other
code used (actual, unexpected). For consistency with the new EXPECT_EQ
and ASSERT_EQ usage, as well as consistency with CHECK_NE and DCHECK_NE,
this change also updates these use sites to (actual, unexpected) where
one side can be called “unexpected” as, for example, std::string::npos
can be. Unfortunately, this portion was a manual conversion.
References:
https://github.com/google/googletest/blob/master/googletest/docs/Primer.md#binary-comparison
https://github.com/google/googletest/commit/77d6b173380332b1c1bc540532641f410ec82d65
https://github.com/google/googletest/pull/713
Change-Id: I978fef7c94183b8b1ef63f12f5ab4d6693626be3
Reviewed-on: https://chromium-review.googlesource.com/466727
Reviewed-by: Scott Graham <scottmg@chromium.org>
2017-04-04 00:35:21 -04:00
|
|
|
|
EXPECT_EQ(thread_id_map.size(), 5u);
|
2014-11-04 12:36:29 -05:00
|
|
|
|
EXPECT_PRED3(MapHasKeyValue, &thread_id_map, 0x0000000000000010, 0);
|
|
|
|
|
EXPECT_PRED3(MapHasKeyValue, &thread_id_map, 0x0000000000000020, 1);
|
|
|
|
|
EXPECT_PRED3(MapHasKeyValue, &thread_id_map, 0x0000000000000030, 2);
|
|
|
|
|
EXPECT_PRED3(MapHasKeyValue, &thread_id_map, 0x0000000000000040, 3);
|
|
|
|
|
EXPECT_PRED3(MapHasKeyValue, &thread_id_map, 0x0000000100000010, 4);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_F(MinidumpThreadIDMapTest, DuplicateAndCollision) {
|
|
|
|
|
SetThreadID(0, 0x0000000100000010);
|
|
|
|
|
SetThreadID(1, 0x0000000000000010);
|
|
|
|
|
SetThreadID(2, 0x0000000000000020);
|
|
|
|
|
SetThreadID(3, 0x0000000000000030);
|
|
|
|
|
SetThreadID(4, 0x0000000000000020);
|
|
|
|
|
|
|
|
|
|
MinidumpThreadIDMap thread_id_map;
|
|
|
|
|
BuildMinidumpThreadIDMap(thread_snapshots(), &thread_id_map);
|
|
|
|
|
|
test: Use (actual, [un]expected) in gtest {ASSERT,EXPECT}_{EQ,NE}
gtest used to require (expected, actual) ordering for arguments to
EXPECT_EQ and ASSERT_EQ, and in failed test assertions would identify
each side as “expected” or “actual.” Tests in Crashpad adhered to this
traditional ordering. After a gtest change in February 2016, it is now
agnostic with respect to the order of these arguments.
This change mechanically updates all uses of these macros to (actual,
expected) by reversing them. This provides consistency with our use of
the logging CHECK_EQ and DCHECK_EQ macros, and makes for better
readability by ordinary native speakers. The rough (but working!)
conversion tool is
https://chromium-review.googlesource.com/c/466727/1/rewrite_expectassert_eq.py,
and “git cl format” cleaned up its output.
EXPECT_NE and ASSERT_NE never had a preferred ordering. gtest never made
a judgment that one side or the other needed to provide an “unexpected”
value. Consequently, some code used (unexpected, actual) while other
code used (actual, unexpected). For consistency with the new EXPECT_EQ
and ASSERT_EQ usage, as well as consistency with CHECK_NE and DCHECK_NE,
this change also updates these use sites to (actual, unexpected) where
one side can be called “unexpected” as, for example, std::string::npos
can be. Unfortunately, this portion was a manual conversion.
References:
https://github.com/google/googletest/blob/master/googletest/docs/Primer.md#binary-comparison
https://github.com/google/googletest/commit/77d6b173380332b1c1bc540532641f410ec82d65
https://github.com/google/googletest/pull/713
Change-Id: I978fef7c94183b8b1ef63f12f5ab4d6693626be3
Reviewed-on: https://chromium-review.googlesource.com/466727
Reviewed-by: Scott Graham <scottmg@chromium.org>
2017-04-04 00:35:21 -04:00
|
|
|
|
EXPECT_EQ(thread_id_map.size(), 4u);
|
2014-11-04 12:36:29 -05:00
|
|
|
|
EXPECT_PRED3(MapHasKeyValue, &thread_id_map, 0x0000000100000010, 0);
|
|
|
|
|
EXPECT_PRED3(MapHasKeyValue, &thread_id_map, 0x0000000000000010, 1);
|
|
|
|
|
EXPECT_PRED3(MapHasKeyValue, &thread_id_map, 0x0000000000000020, 2);
|
|
|
|
|
EXPECT_PRED3(MapHasKeyValue, &thread_id_map, 0x0000000000000030, 3);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_F(MinidumpThreadIDMapTest, AllDuplicates) {
|
|
|
|
|
SetThreadID(0, 6);
|
|
|
|
|
SetThreadID(1, 6);
|
|
|
|
|
SetThreadID(2, 6);
|
|
|
|
|
SetThreadID(3, 6);
|
|
|
|
|
SetThreadID(4, 6);
|
|
|
|
|
|
|
|
|
|
MinidumpThreadIDMap thread_id_map;
|
|
|
|
|
BuildMinidumpThreadIDMap(thread_snapshots(), &thread_id_map);
|
|
|
|
|
|
test: Use (actual, [un]expected) in gtest {ASSERT,EXPECT}_{EQ,NE}
gtest used to require (expected, actual) ordering for arguments to
EXPECT_EQ and ASSERT_EQ, and in failed test assertions would identify
each side as “expected” or “actual.” Tests in Crashpad adhered to this
traditional ordering. After a gtest change in February 2016, it is now
agnostic with respect to the order of these arguments.
This change mechanically updates all uses of these macros to (actual,
expected) by reversing them. This provides consistency with our use of
the logging CHECK_EQ and DCHECK_EQ macros, and makes for better
readability by ordinary native speakers. The rough (but working!)
conversion tool is
https://chromium-review.googlesource.com/c/466727/1/rewrite_expectassert_eq.py,
and “git cl format” cleaned up its output.
EXPECT_NE and ASSERT_NE never had a preferred ordering. gtest never made
a judgment that one side or the other needed to provide an “unexpected”
value. Consequently, some code used (unexpected, actual) while other
code used (actual, unexpected). For consistency with the new EXPECT_EQ
and ASSERT_EQ usage, as well as consistency with CHECK_NE and DCHECK_NE,
this change also updates these use sites to (actual, unexpected) where
one side can be called “unexpected” as, for example, std::string::npos
can be. Unfortunately, this portion was a manual conversion.
References:
https://github.com/google/googletest/blob/master/googletest/docs/Primer.md#binary-comparison
https://github.com/google/googletest/commit/77d6b173380332b1c1bc540532641f410ec82d65
https://github.com/google/googletest/pull/713
Change-Id: I978fef7c94183b8b1ef63f12f5ab4d6693626be3
Reviewed-on: https://chromium-review.googlesource.com/466727
Reviewed-by: Scott Graham <scottmg@chromium.org>
2017-04-04 00:35:21 -04:00
|
|
|
|
EXPECT_EQ(thread_id_map.size(), 1u);
|
2014-11-04 12:36:29 -05:00
|
|
|
|
EXPECT_PRED3(MapHasKeyValue, &thread_id_map, 6, 6);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace
|
|
|
|
|
} // namespace test
|
|
|
|
|
} // namespace crashpad
|