Loading system/osi/Android.bp +1 −0 Original line number Diff line number Diff line Loading @@ -134,6 +134,7 @@ cc_test { shared_libs: [ "android.hardware.bluetooth@1.0", "android.hardware.bluetooth@1.1", "libbase", "liblog", "libprotobuf-cpp-lite", "libcutils", Loading system/osi/test/array_test.cc +19 −6 Original line number Diff line number Diff line #include "osi/include/array.h" #include <android-base/silent_death_test.h> #include <gtest/gtest.h> #include "AllocationTestHarness.h" #include "osi/include/array.h" class ArrayTest : public AllocationTestHarness {}; using ArrayDeathTest = ArrayTest; TEST_F(ArrayTest, test_new_free_simple) { array_t* array = array_new(4); ASSERT_TRUE(array != NULL); Loading @@ -14,17 +17,27 @@ TEST_F(ArrayTest, test_new_free_simple) { TEST_F(ArrayTest, test_free_null) { array_free(NULL); } TEST_F(ArrayTest, test_invalid_ptr) { TEST_F(ArrayDeathTest, test_invalid_ptr) { ::testing::FLAGS_gtest_death_test_style = "threadsafe"; array_t* array = array_new(4); EXPECT_DEATH(array_ptr(array), ""); { // this will silent SIGABRT sent in EXPECT_DEATH below ScopedSilentDeath _silentDeath; ASSERT_DEATH(array_ptr(array), ""); } array_free(array); } TEST_F(ArrayTest, test_invalid_at) { TEST_F(ArrayDeathTest, test_invalid_at) { ::testing::FLAGS_gtest_death_test_style = "threadsafe"; array_t* array = array_new(4); EXPECT_DEATH(array_at(array, 1), ""); { // this will silent SIGABRT sent in EXPECT_DEATH below ScopedSilentDeath _silentDeath; ASSERT_DEATH(array_at(array, 1), ""); } array_free(array); } Loading system/packet/Android.bp +1 −0 Original line number Diff line number Diff line Loading @@ -64,6 +64,7 @@ cc_test { shared_libs: [ "android.hardware.bluetooth@1.0", "android.hardware.bluetooth@1.1", "libbase", "libbinder_ndk", "libcrypto", ], Loading system/packet/tests/avrcp/get_capabilities_packet_test.cc +14 −3 Original line number Diff line number Diff line Loading @@ -14,6 +14,7 @@ * limitations under the License. */ #include <android-base/silent_death_test.h> #include <gtest/gtest.h> #include "avrcp_test_packets.h" Loading Loading @@ -85,13 +86,23 @@ TEST(GetCapabilityResponseBuilder, duplicateAddTest) { } // Test that trying to to add the wrong type of field to a builder causes death TEST(GetCapabilityResponseBuilder, mismatchAddDeathTest) { TEST(GetCapabilityResponseBuilderDeathTest, mismatchAddDeathTest) { auto builder = GetCapabilitiesResponseBuilder::MakeCompanyIdBuilder(0x000000); { // this will silent SIGABRT sent in ASSERT_DEATH below scop ScopedSilentDeath _silentDeath; ASSERT_DEATH(builder->AddEvent(Event::PLAYBACK_STATUS_CHANGED), "capability_ == Capability::EVENTS_SUPPORTED"); } builder = GetCapabilitiesResponseBuilder::MakeEventsSupportedBuilder( Event::PLAYBACK_STATUS_CHANGED); // this will silent SIGABRT sent in ASSERT_DEATH below ScopedSilentDeath _silentDeath; ASSERT_DEATH(builder->AddCompanyId(0x000000), "capability_ == Capability::COMPANY_ID"); } Loading system/packet/tests/avrcp/get_folder_items_packet_test.cc +21 −6 Original line number Diff line number Diff line Loading @@ -14,6 +14,7 @@ * limitations under the License. */ #include <android-base/silent_death_test.h> #include <gtest/gtest.h> #include "avrcp_test_packets.h" Loading Loading @@ -186,24 +187,38 @@ TEST(GetFolderItemsResponseBuilderTest, builderErrorStatusTest) { ASSERT_EQ(test_packet->GetData(), get_folder_items_inv_scope); } TEST(GetFolderItemsResponseBuilderTest, builderDeathTest) { TEST(GetFolderItemsResponseBuilderDeathTest, builderDeathTest) { auto player = MediaPlayerItem(0x0001, "com.google.android.music", true); auto folder = FolderItem(0x01, 0x00, true, "test folder"); auto song = MediaElementItem(0x01, "test song", std::set<AttributeEntry>()); auto builder = GetFolderItemsResponseBuilder::MakePlayerListBuilder( Status::NO_ERROR, 0x0000, 0xFFFF); { // this will silent SIGABRT sent in ASSERT_DEATH below ScopedSilentDeath _silentDeath; ASSERT_DEATH(builder->AddFolder(folder), "scope_ == Scope::VFS"); ASSERT_DEATH(builder->AddSong(song), "scope_ == Scope::VFS \\|\\| scope_ == Scope::NOW_PLAYING"); } builder = GetFolderItemsResponseBuilder::MakeVFSBuilder(Status::NO_ERROR, 0x0000, 0xFFFF); { // this will silent SIGABRT sent in ASSERT_DEATH below ScopedSilentDeath _silentDeath; ASSERT_DEATH(builder->AddMediaPlayer(player), "scope_ == Scope::MEDIA_PLAYER_LIST"); } builder = GetFolderItemsResponseBuilder::MakeNowPlayingBuilder( Status::NO_ERROR, 0x0000, 0xFFFF); // this will silent SIGABRT sent in ASSERT_DEATH below ScopedSilentDeath _silentDeath; ASSERT_DEATH(builder->AddMediaPlayer(player), "scope_ == Scope::MEDIA_PLAYER_LIST"); ASSERT_DEATH(builder->AddFolder(folder), "scope_ == Scope::VFS"); Loading Loading
system/osi/Android.bp +1 −0 Original line number Diff line number Diff line Loading @@ -134,6 +134,7 @@ cc_test { shared_libs: [ "android.hardware.bluetooth@1.0", "android.hardware.bluetooth@1.1", "libbase", "liblog", "libprotobuf-cpp-lite", "libcutils", Loading
system/osi/test/array_test.cc +19 −6 Original line number Diff line number Diff line #include "osi/include/array.h" #include <android-base/silent_death_test.h> #include <gtest/gtest.h> #include "AllocationTestHarness.h" #include "osi/include/array.h" class ArrayTest : public AllocationTestHarness {}; using ArrayDeathTest = ArrayTest; TEST_F(ArrayTest, test_new_free_simple) { array_t* array = array_new(4); ASSERT_TRUE(array != NULL); Loading @@ -14,17 +17,27 @@ TEST_F(ArrayTest, test_new_free_simple) { TEST_F(ArrayTest, test_free_null) { array_free(NULL); } TEST_F(ArrayTest, test_invalid_ptr) { TEST_F(ArrayDeathTest, test_invalid_ptr) { ::testing::FLAGS_gtest_death_test_style = "threadsafe"; array_t* array = array_new(4); EXPECT_DEATH(array_ptr(array), ""); { // this will silent SIGABRT sent in EXPECT_DEATH below ScopedSilentDeath _silentDeath; ASSERT_DEATH(array_ptr(array), ""); } array_free(array); } TEST_F(ArrayTest, test_invalid_at) { TEST_F(ArrayDeathTest, test_invalid_at) { ::testing::FLAGS_gtest_death_test_style = "threadsafe"; array_t* array = array_new(4); EXPECT_DEATH(array_at(array, 1), ""); { // this will silent SIGABRT sent in EXPECT_DEATH below ScopedSilentDeath _silentDeath; ASSERT_DEATH(array_at(array, 1), ""); } array_free(array); } Loading
system/packet/Android.bp +1 −0 Original line number Diff line number Diff line Loading @@ -64,6 +64,7 @@ cc_test { shared_libs: [ "android.hardware.bluetooth@1.0", "android.hardware.bluetooth@1.1", "libbase", "libbinder_ndk", "libcrypto", ], Loading
system/packet/tests/avrcp/get_capabilities_packet_test.cc +14 −3 Original line number Diff line number Diff line Loading @@ -14,6 +14,7 @@ * limitations under the License. */ #include <android-base/silent_death_test.h> #include <gtest/gtest.h> #include "avrcp_test_packets.h" Loading Loading @@ -85,13 +86,23 @@ TEST(GetCapabilityResponseBuilder, duplicateAddTest) { } // Test that trying to to add the wrong type of field to a builder causes death TEST(GetCapabilityResponseBuilder, mismatchAddDeathTest) { TEST(GetCapabilityResponseBuilderDeathTest, mismatchAddDeathTest) { auto builder = GetCapabilitiesResponseBuilder::MakeCompanyIdBuilder(0x000000); { // this will silent SIGABRT sent in ASSERT_DEATH below scop ScopedSilentDeath _silentDeath; ASSERT_DEATH(builder->AddEvent(Event::PLAYBACK_STATUS_CHANGED), "capability_ == Capability::EVENTS_SUPPORTED"); } builder = GetCapabilitiesResponseBuilder::MakeEventsSupportedBuilder( Event::PLAYBACK_STATUS_CHANGED); // this will silent SIGABRT sent in ASSERT_DEATH below ScopedSilentDeath _silentDeath; ASSERT_DEATH(builder->AddCompanyId(0x000000), "capability_ == Capability::COMPANY_ID"); } Loading
system/packet/tests/avrcp/get_folder_items_packet_test.cc +21 −6 Original line number Diff line number Diff line Loading @@ -14,6 +14,7 @@ * limitations under the License. */ #include <android-base/silent_death_test.h> #include <gtest/gtest.h> #include "avrcp_test_packets.h" Loading Loading @@ -186,24 +187,38 @@ TEST(GetFolderItemsResponseBuilderTest, builderErrorStatusTest) { ASSERT_EQ(test_packet->GetData(), get_folder_items_inv_scope); } TEST(GetFolderItemsResponseBuilderTest, builderDeathTest) { TEST(GetFolderItemsResponseBuilderDeathTest, builderDeathTest) { auto player = MediaPlayerItem(0x0001, "com.google.android.music", true); auto folder = FolderItem(0x01, 0x00, true, "test folder"); auto song = MediaElementItem(0x01, "test song", std::set<AttributeEntry>()); auto builder = GetFolderItemsResponseBuilder::MakePlayerListBuilder( Status::NO_ERROR, 0x0000, 0xFFFF); { // this will silent SIGABRT sent in ASSERT_DEATH below ScopedSilentDeath _silentDeath; ASSERT_DEATH(builder->AddFolder(folder), "scope_ == Scope::VFS"); ASSERT_DEATH(builder->AddSong(song), "scope_ == Scope::VFS \\|\\| scope_ == Scope::NOW_PLAYING"); } builder = GetFolderItemsResponseBuilder::MakeVFSBuilder(Status::NO_ERROR, 0x0000, 0xFFFF); { // this will silent SIGABRT sent in ASSERT_DEATH below ScopedSilentDeath _silentDeath; ASSERT_DEATH(builder->AddMediaPlayer(player), "scope_ == Scope::MEDIA_PLAYER_LIST"); } builder = GetFolderItemsResponseBuilder::MakeNowPlayingBuilder( Status::NO_ERROR, 0x0000, 0xFFFF); // this will silent SIGABRT sent in ASSERT_DEATH below ScopedSilentDeath _silentDeath; ASSERT_DEATH(builder->AddMediaPlayer(player), "scope_ == Scope::MEDIA_PLAYER_LIST"); ASSERT_DEATH(builder->AddFolder(folder), "scope_ == Scope::VFS"); Loading