summaryrefslogtreecommitdiffstats
path: root/libutils
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2017-02-06 10:54:00 -0800
committerElliott Hughes <enh@google.com>2017-02-06 10:54:00 -0800
commit5bae1b866d309f3d59aaab8e9a007413b3c68f83 (patch)
tree48e2f331a36c8becd2dfb76ba43c1b41cb733611 /libutils
parent01b25ab14912712024d5342064c7b70de85e2db8 (diff)
downloadsystem_core-5bae1b866d309f3d59aaab8e9a007413b3c68f83.tar.gz
system_core-5bae1b866d309f3d59aaab8e9a007413b3c68f83.tar.bz2
system_core-5bae1b866d309f3d59aaab8e9a007413b3c68f83.zip
Make __android_log_assert behave more like libc asserts.
If we don't output to stderr too, not only is it annoying to shell users (who won't see anything), it prevents us from writing better gtests that actually make assertions about the assert message. Bug: http://b/23675822 Test: libutils tests still pass Change-Id: I62b3144c385cba4dde485f0b0f9b42aeaef51e9a
Diffstat (limited to 'libutils')
-rw-r--r--libutils/tests/Vector_test.cpp22
1 files changed, 4 insertions, 18 deletions
diff --git a/libutils/tests/Vector_test.cpp b/libutils/tests/Vector_test.cpp
index 671200f4f..e074a921d 100644
--- a/libutils/tests/Vector_test.cpp
+++ b/libutils/tests/Vector_test.cpp
@@ -74,12 +74,9 @@ TEST_F(VectorTest, CopyOnWrite_CopyAndAddElements) {
EXPECT_EQ(other[3], 5);
}
-// TODO: gtest isn't capable of parsing Abort messages formatted by
-// Android (fails differently on host and target), so we always need to
-// use an empty error message for death tests.
TEST_F(VectorTest, SetCapacity_Overflow) {
Vector<int> vector;
- EXPECT_DEATH(vector.setCapacity(SIZE_MAX / sizeof(int) + 1), "");
+ EXPECT_DEATH(vector.setCapacity(SIZE_MAX / sizeof(int) + 1), "Assertion failed");
}
TEST_F(VectorTest, SetCapacity_ShrinkBelowSize) {
@@ -95,20 +92,13 @@ TEST_F(VectorTest, SetCapacity_ShrinkBelowSize) {
ASSERT_EQ(8U, vector.capacity());
}
-// NOTE: All of the tests below are useless because of the "TODO" above.
-// We have no way of knowing *why* the process crashed. Given that we're
-// inserting a NULL array, we'll fail with a SIGSEGV eventually. We need
-// the ability to make assertions on the abort message to make sure we're
-// failing for the right reasons.
TEST_F(VectorTest, _grow_OverflowSize) {
Vector<int> vector;
vector.add(1);
// Checks that the size calculation (not the capacity calculation) doesn't
// overflow : the size here will be (1 + SIZE_MAX).
- //
- // EXPECT_DEATH(vector.insertArrayAt(NULL, 0, SIZE_MAX), "new_size_overflow");
- EXPECT_DEATH(vector.insertArrayAt(NULL, 0, SIZE_MAX), "");
+ EXPECT_DEATH(vector.insertArrayAt(NULL, 0, SIZE_MAX), "new_size overflow");
}
TEST_F(VectorTest, _grow_OverflowCapacityDoubling) {
@@ -116,18 +106,14 @@ TEST_F(VectorTest, _grow_OverflowCapacityDoubling) {
// This should fail because the calculated capacity will overflow even though
// the size of the vector doesn't.
- //
- // EXPECT_DEATH(vector.insertArrayAt(NULL, 0, (SIZE_MAX - 1)), "new_capacity_overflow");
- EXPECT_DEATH(vector.insertArrayAt(NULL, 0, (SIZE_MAX - 1)), "");
+ EXPECT_DEATH(vector.insertArrayAt(NULL, 0, (SIZE_MAX - 1)), "new_capacity overflow");
}
TEST_F(VectorTest, _grow_OverflowBufferAlloc) {
Vector<int> vector;
// This should fail because the capacity * sizeof(int) overflows, even
// though the capacity itself doesn't.
- //
- // EXPECT_DEATH(vector.insertArrayAt(NULL, 0, (SIZE_MAX / 2)), "new_alloc_size overflow");
- EXPECT_DEATH(vector.insertArrayAt(NULL, 0, (SIZE_MAX / 2)), "");
+ EXPECT_DEATH(vector.insertArrayAt(NULL, 0, (SIZE_MAX / 2)), "new_alloc_size overflow");
}
TEST_F(VectorTest, editArray_Shared) {