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

Commit 35ede9f5 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge changes Ib514252d,I77e9a079,Id4733a3a,Ifebdb31e,Ibc4d03fc, ...

* changes:
  Make stack_smp_test host runnable
  Update test/mock_stack_acl
  Remove unused mocks
  Re-point stack tests to use centralized test/mock
  Add test/mock_btif_bluetooth
  test: Fix net_test_osi
  Canonicalize include pathnames
parents 5be7692a 7e945923
Loading
Loading
Loading
Loading
+16 −4
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@
#include "bta/include/bta_hf_client_api.h"
#include "bta/test/common/fake_osi.h"
#include "common/message_loop_thread.h"
#include "test/mock/mock_stack_acl.h"

std::map<std::string, int> mock_function_count_map;

@@ -74,28 +75,37 @@ TEST_F(BtaDmTest, disable_no_acl_links) {
  ASSERT_TRUE(!bta_dm_cb.disabling);
}

extern uint16_t mock_stack_acl_num_links;
TEST_F(BtaDmTest, disable_first_pass_with_acl_links) {
  uint16_t links_up = 1;
  test::mock::stack_acl::BTM_GetNumAclLinks.body = [&links_up]() {
    return links_up;
  };
  bta_dm_cb.disabling = true;
  // ACL link is open
  mock_stack_acl_num_links = bta_dm_cb.device_list.count = 1;
  bta_dm_cb.device_list.count = 1;

  bta_dm_disable();              // Waiting for all ACL connections to drain
  mock_stack_acl_num_links = 0;  // ACL link has closed
  ASSERT_EQ(1, mock_function_count_map["alarm_set_on_mloop"]);
  ASSERT_EQ(0, mock_function_count_map["BTIF_dm_disable"]);

  links_up = 0;
  // First disable pass
  fake_osi_alarm_set_on_mloop_.cb(fake_osi_alarm_set_on_mloop_.data);
  ASSERT_EQ(1, mock_function_count_map["alarm_set_on_mloop"]);
  ASSERT_EQ(1, mock_function_count_map["BTIF_dm_disable"]);
  ASSERT_TRUE(!bta_dm_cb.disabling);

  test::mock::stack_acl::BTM_GetNumAclLinks = {};
}

TEST_F(BtaDmTest, disable_second_pass_with_acl_links) {
  uint16_t links_up = 1;
  test::mock::stack_acl::BTM_GetNumAclLinks.body = [&links_up]() {
    return links_up;
  };
  bta_dm_cb.disabling = true;
  // ACL link is open
  mock_stack_acl_num_links = bta_dm_cb.device_list.count = 1;
  bta_dm_cb.device_list.count = 1;

  bta_dm_disable();  // Waiting for all ACL connections to drain
  ASSERT_EQ(1, mock_function_count_map["alarm_set_on_mloop"]);
@@ -111,4 +121,6 @@ TEST_F(BtaDmTest, disable_second_pass_with_acl_links) {
  fake_osi_alarm_set_on_mloop_.cb(fake_osi_alarm_set_on_mloop_.data);
  ASSERT_EQ(1, mock_function_count_map["BTIF_dm_disable"]);
  ASSERT_TRUE(!bta_dm_cb.disabling);

  test::mock::stack_acl::BTM_GetNumAclLinks = {};
}
+1 −1
Original line number Diff line number Diff line
@@ -22,7 +22,7 @@

#include <stdbool.h>

#include "bta_av_api.h"
#include "bta/include/bta_av_api.h"

// Process 'idle' request from the BTIF state machine during initialization.
void btif_a2dp_on_idle(void);
+5 −1
Original line number Diff line number Diff line
@@ -31,6 +31,7 @@ TEST_F(PropertiesTest, test_default_value) {
}

TEST_F(PropertiesTest, test_successfull_set_and_get_value) {
#if !defined(OS_GENERIC)
  char value[PROPERTY_VALUE_MAX] = "nothing_interesting";
  int ret = osi_property_set("very.useful.set.test", value);
  ASSERT_EQ(0, ret);
@@ -38,6 +39,7 @@ TEST_F(PropertiesTest, test_successfull_set_and_get_value) {
  char received[PROPERTY_VALUE_MAX];
  osi_property_get("very.useful.set.test", received, NULL);
  ASSERT_STREQ(received, "nothing_interesting");
#endif
}

TEST_F(PropertiesTest, test_default_value_int32) {
@@ -47,10 +49,12 @@ TEST_F(PropertiesTest, test_default_value_int32) {
}

TEST_F(PropertiesTest, test_successfull_set_and_get_value_int32) {
#if !defined(OS_GENERIC)
  char value[PROPERTY_VALUE_MAX] = "42";
  int ret = osi_property_set("very.useful.set.test", value);
  ASSERT_EQ(0, ret);

  int32_t received = osi_property_get_int32("very.useful.set.test", 84);
  ASSERT_EQ(received, 42);
#endif
}
+33 −12
Original line number Diff line number Diff line
@@ -339,6 +339,7 @@ cc_test {
cc_test {
    name: "net_test_stack_smp",
    defaults: ["fluoride_defaults"],
    host_supported: true,
    test_suites: ["device-tests"],
    local_include_dirs: [
        "include",
@@ -355,19 +356,39 @@ cc_test {
        "packages/modules/Bluetooth/system/utils/include",
    ],
    srcs: crypto_toolbox_srcs + [
        "smp/smp_keys.cc",
        ":TestCommonMainHandler",
        ":TestMockBtif",
        ":TestMockCommon",
        ":TestMockDevice",
        ":TestMockLegacyHciCommands",
        ":TestMockMainShim",
        ":TestMockStackAcl",
        ":TestMockStackBtm",
        ":TestMockStackL2cap",
        ":TestMockStackMetrics",
        "smp/p_256_curvepara.cc",
        "smp/p_256_ecc_pp.cc",
        "smp/p_256_multprecision.cc",
        "smp/smp_act.cc",
        "smp/smp_api.cc",
        "smp/smp_br_main.cc",
        "smp/smp_keys.cc",
        "smp/smp_l2c.cc",
        "smp/smp_main.cc",
        "smp/smp_utils.cc",
        "test/crypto_toolbox_test.cc",
        "test/stack_smp_test.cc",
    ],
    generated_headers: [
        "BluetoothGeneratedBundlerSchema_h_bfbs",
        "BluetoothGeneratedDumpsysDataSchema_h",
        "BluetoothGeneratedDumpsysBundledSchema_h",
        "BluetoothGeneratedPackets_h",
    ],
    shared_libs: [
        "libcutils",
        "libcrypto",
        "libcutils",
        "libflatbuffers-cpp",
    ],
    static_libs: [
        "liblog",
@@ -763,8 +784,8 @@ cc_test {
        ":TestMockStackBtu",
        ":TestMockStackGap",
        ":TestMockStackGatt",
        ":TestMockStackL2cap",
        ":TestMockStackSmp",
        ":TestStackL2cap",
        "acl/acl.cc",
        "acl/ble_acl.cc",
        "acl/btm_acl.cc",
@@ -875,9 +896,9 @@ cc_test {
        "packages/modules/Bluetooth/system/gd",
    ],
    srcs: crypto_toolbox_srcs + [
        ":TestStackL2cap",
        ":TestStackSdp",
        ":TestStackBtm",
        ":TestMockStackL2cap",
        ":TestMockStackSdp",
        ":TestMockStackBtm",
        ":TestStubLegacyTrace",
        "hid/hidd_api.cc",
        "hid/hidd_conn.cc",
@@ -935,10 +956,10 @@ cc_test {
        ":TestMockLegacyHciCommands",
        ":TestMockMainShim",
        ":TestMockStackAcl",
        ":TestMockStackSmp",
        ":TestStackBtm",
        ":TestStackL2cap",
        ":TestMockStackBtm",
        ":TestMockStackL2cap",
        ":TestMockStackMetrics",
        ":TestMockStackSmp",
        "btu/btu_hcif.cc",
        "btu/btu_task.cc",
        "test/stack_btu_test.cc",
@@ -995,11 +1016,11 @@ cc_test {
        ":TestMockLegacyHciCommands",
        ":TestMockMainShim",
        ":TestMockStackAcl",
        ":TestMockStackBtm",
        ":TestMockStackCryptotoolbox",
        ":TestMockStackL2cap",
        ":TestMockStackSdp",
        ":TestMockStackSmp",
        ":TestStackBtm",
        ":TestStackL2cap",
        ":TestStackSdp",
        "eatt/eatt.cc",
        "gatt/att_protocol.cc",
        "gatt/connection_manager.cc",
+3 −3
Original line number Diff line number Diff line
@@ -19,9 +19,9 @@
#define LOG_TAG "smp_act"

#include <string.h>
#include "btif_api.h"
#include "btif_common.h"
#include "btif_storage.h"
#include "btif/include/btif_api.h"
#include "btif/include/btif_common.h"
#include "btif/include/btif_storage.h"
#include "device/include/interop.h"
#include "internal_include/bt_target.h"
#include "main/shim/shim.h"
Loading