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

Commit 0597c91d authored by Łukasz Rymanowski's avatar Łukasz Rymanowski
Browse files

gd: Sort out flag dependencies and fix advertising tests

Make sure that gd unit test is using bluetooth_flags_c_lib_for_test.
Without this patch both bluetooth_flags_c_lib and
bluetooth_flags_c_lib_for_test was compiled into the test binary.

Also this fixes advertising tests.

Bug: 356594223
Flag: TEST_ONLY
Test: atest bluetooth_test_gd_unit
Change-Id: I37c992ee03bb249cfdcc343fa6e7bd29d26e3e68
parent aa575a0b
Loading
Loading
Loading
Loading
+12 −5
Original line number Diff line number Diff line
@@ -174,7 +174,6 @@ cc_defaults {
        "libbluetooth_smp_pdl",
    ],
    static_libs: [
        "bluetooth_flags_c_lib",
        "libaconfig_storage_read_api_cc",
        "libbase",
        "libbluetooth-dumpsys",
@@ -210,7 +209,10 @@ cc_library {
        "com.android.btservices",
    ],
    min_sdk_version: "31",
    static_libs: ["libchrome"],
    static_libs: [
        "bluetooth_flags_c_lib",
        "libchrome",
    ],
}

cc_library_static {
@@ -229,7 +231,10 @@ cc_library_static {
        "com.android.btservices",
    ],
    min_sdk_version: "31",
    static_libs: ["libchrome"],
    static_libs: [
        "bluetooth_flags_c_lib",
        "libchrome",
    ],
}

cc_library {
@@ -249,6 +254,7 @@ cc_library {
        "-Wno-unused-parameter",
    ],
    static_libs: [
        "bluetooth_flags_c_lib",
        "libbluetooth-types",
        "libbt-common",
        "libchrome",
@@ -271,6 +277,7 @@ cc_library {
        "-DUSE_FAKE_TIMERS",
    ],
    static_libs: [
        "bluetooth_flags_c_lib_for_test",
        "libbluetooth-types",
        "libbt-common",
        "libchrome",
@@ -487,7 +494,7 @@ cc_test {
        "BluetoothGeneratedDumpsysTestData_h",
    ],
    static_libs: [
        "bluetooth_flags_c_lib",
        "bluetooth_flags_c_lib_for_test",
        "libbase",
        "libbluetooth-protos",
        "libbluetooth-types",
@@ -509,12 +516,12 @@ cc_test {
        "libflatbuffers-cpp",
        "libgmock",
        "libosi",
        "server_configurable_flags",
    ],
    shared_libs: [
        "libPlatformProperties",
        "libaconfig_storage_read_api_cc",
        "libcrypto",
        "server_configurable_flags",
    ],
    sanitize: {
        address: true,
+10 −6
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@
#include <flag_macros.h>
#include <gmock/gmock.h>
#include <gtest/gtest.h>
#include <log/log.h>

#include <algorithm>
#include <chrono>
@@ -165,6 +166,7 @@ protected:
class LeAdvertisingManagerTest : public ::testing::Test {
protected:
  void SetUp() override {
    __android_log_set_minimum_priority(ANDROID_LOG_VERBOSE);
    test_hci_layer_ = new HciLayerFake;  // Ownership is transferred to registry
    test_controller_ = new TestController;
    test_acl_manager_ = new TestAclManager;
@@ -182,6 +184,8 @@ protected:
  }

  void TearDown() override {
    TEST_BT::provider_->reset_flags();

    sync_client_handler();
    fake_registry_.SynchronizeModuleHandler(&LeAdvertisingManager::Factory,
                                            std::chrono::milliseconds(20));
@@ -1833,9 +1837,9 @@ TEST_F(LeExtendedAdvertisingManagerTest, use_public_address_type_if_public_addre
  EXPECT_EQ(set_parameters_command.GetOwnAddressType(), OwnAddressType::PUBLIC_DEVICE_ADDRESS);
}

TEST_F_WITH_FLAGS(LeExtendedAdvertisingManagerTest,
                  use_nrpa_if_public_address_policy_non_connectable,
                  REQUIRES_FLAGS_ENABLED(ACONFIG_FLAG(TEST_BT, nrpa_non_connectable_adv))) {
TEST_F(LeExtendedAdvertisingManagerTest, use_nrpa_if_public_address_policy_non_connectable) {
  TEST_BT::provider_->nrpa_non_connectable_adv(true);

  // arrange: use PUBLIC address policy
  test_acl_manager_->SetAddressPolicy(LeAddressManager::AddressPolicy::USE_PUBLIC_ADDRESS);

@@ -1867,9 +1871,9 @@ TEST_F_WITH_FLAGS(LeExtendedAdvertisingManagerTest,
  EXPECT_EQ(address.data()[5] >> 6, 0b00);
}

TEST_F_WITH_FLAGS(LeExtendedAdvertisingManagerTest,
                  use_public_if_requested_with_public_address_policy_non_connectable,
                  REQUIRES_FLAGS_ENABLED(ACONFIG_FLAG(TEST_BT, nrpa_non_connectable_adv))) {
TEST_F(LeExtendedAdvertisingManagerTest,
       use_public_if_requested_with_public_address_policy_non_connectable) {
  TEST_BT::provider_->nrpa_non_connectable_adv(true);
  // arrange: use PUBLIC address policy
  test_acl_manager_->SetAddressPolicy(LeAddressManager::AddressPolicy::USE_PUBLIC_ADDRESS);