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

Commit 23a83877 authored by Yi Kong's avatar Yi Kong
Browse files

Remove test that triggers undefined behavior

According to C++ standard, compiler is allowed to produce arbitrary
result if undefined behavior is triggered. It is not meaningful to have
a test to assert the behavior.

We tried to let UBSAN ignore the violation, but it does not work because
the UB happens in a different shared library.

Test: atest bluetooth-test-audio-hal-a2dp-provider-info64.ProviderInfoTest.TestCodecIndexStr
Bug: 334078285
Change-Id: I21bc60fd3211670df01538677b3147e07ba1042e
parent 588637ec
Loading
Loading
Loading
Loading
+2 −9
Original line number Diff line number Diff line
@@ -547,11 +547,8 @@ TEST_F_WITH_FLAGS(ProviderInfoTest,
}

TEST_F_WITH_FLAGS(ProviderInfoTest, TestCodecIndexStr,
                  REQUIRES_FLAGS_ENABLED(
                      ACONFIG_FLAG(TEST_BT, a2dp_offload_codec_extensibility)))
// The test deliberately triggers undefined behaviour with an out of bound
// index.
__attribute__((no_sanitize("undefined"))) {
                  REQUIRES_FLAGS_ENABLED(ACONFIG_FLAG(
                      TEST_BT, a2dp_offload_codec_extensibility))) {
  GetProviderInfoForTesting(true, false);

  auto codecInfoArray = test_source_provider_info.codecInfos;
@@ -567,10 +564,6 @@ __attribute__((no_sanitize("undefined"))) {

  ASSERT_EQ(provider_info->CodecIndexStr(BTAV_A2DP_CODEC_INDEX_SOURCE_EXT_MIN),
            codecInfoArray[3].name);

  ASSERT_EQ(provider_info->CodecIndexStr(static_cast<btav_a2dp_codec_index_t>(
                test_unknown_vendor_codec_id.id)),
            std::nullopt);
}

TEST_F_WITH_FLAGS(ProviderInfoTest, TestSupportsCodec,