diff options
author | Steven Moreland <smoreland@google.com> | 2021-04-07 22:43:20 +0000 |
---|---|---|
committer | Steven Moreland <smoreland@google.com> | 2021-04-07 23:06:09 +0000 |
commit | dc43fb279f6894383d3cee342085cde2869fcc7d (patch) | |
tree | bbbe33c664e9d835310bf239aff924e8b6beadba /libutils/RefBase_test.cpp | |
parent | 1d68548823d7b1e0bd186b924821cdbd80767be1 (diff) |
libutils: wp::fromExisting bugfix
This API was tested before, but it wasn't used until it is needed in
libbinder. Previously it passed the tests because wp::operator==
compares weak_ptrs which are never deleted, but it doesn't check the
value of m_ptr as well. This assumes that the RefBase implementation is
self-consistent.
Future considerations:
- add additional CHECK (perf?)
- add an additional optional CHECK?
- update all refbase tests to use an embellished form of this operator
Bug: 184190315
Test: libutils_test, boot and kill process when libbinder is using this
API
Change-Id: I66c97386d769529d5efae48e06775d4b4a344025
Diffstat (limited to 'libutils/RefBase_test.cpp')
-rw-r--r-- | libutils/RefBase_test.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/libutils/RefBase_test.cpp b/libutils/RefBase_test.cpp index dcc469e48..93f9654b1 100644 --- a/libutils/RefBase_test.cpp +++ b/libutils/RefBase_test.cpp @@ -242,12 +242,12 @@ TEST(RefBase, ReplacedComparison) { } TEST(RefBase, AssertWeakRefExistsSuccess) { - // uses some other refcounting method, or non at all bool isDeleted; sp<Foo> foo = sp<Foo>::make(&isDeleted); wp<Foo> weakFoo = foo; EXPECT_EQ(weakFoo, wp<Foo>::fromExisting(foo.get())); + EXPECT_EQ(weakFoo.unsafe_get(), wp<Foo>::fromExisting(foo.get()).unsafe_get()); EXPECT_FALSE(isDeleted); foo = nullptr; @@ -255,7 +255,7 @@ TEST(RefBase, AssertWeakRefExistsSuccess) { } TEST(RefBase, AssertWeakRefExistsDeath) { - // uses some other refcounting method, or non at all + // uses some other refcounting method, or none at all bool isDeleted; Foo* foo = new Foo(&isDeleted); |