Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1f13820d authored by William Escande's avatar William Escande Committed by Automerger Merge Worker
Browse files

Merge "Silent death test to no longer have a stack crash" into tm-dev am: e62f220b

parents 1e47e532 e62f220b
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -134,6 +134,7 @@ cc_test {
    shared_libs: [
        "android.hardware.bluetooth@1.0",
        "android.hardware.bluetooth@1.1",
        "libbase",
        "liblog",
        "libprotobuf-cpp-lite",
        "libcutils",
+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);
@@ -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);
}

+1 −0
Original line number Diff line number Diff line
@@ -64,6 +64,7 @@ cc_test {
    shared_libs: [
        "android.hardware.bluetooth@1.0",
        "android.hardware.bluetooth@1.1",
        "libbase",
        "libbinder_ndk",
        "libcrypto",
    ],
+14 −3
Original line number Diff line number Diff line
@@ -14,6 +14,7 @@
 * limitations under the License.
 */

#include <android-base/silent_death_test.h>
#include <gtest/gtest.h>

#include "avrcp_test_packets.h"
@@ -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");
}
+21 −6
Original line number Diff line number Diff line
@@ -14,6 +14,7 @@
 * limitations under the License.
 */

#include <android-base/silent_death_test.h>
#include <gtest/gtest.h>

#include "avrcp_test_packets.h"
@@ -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