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

Commit b2556cd4 authored by Chris Manton's avatar Chris Manton
Browse files

legacy: Introduce stack_l2cap_test

Bug: 188077107
Tag: #refactor
Test: gd/cert/run
BYPASS_LONG_LINES_REASON: Bluetooth likes 120 lines

Change-Id: I050c589de1072d4293edc12be7ac5290b70da4f9
parent 626e3480
Loading
Loading
Loading
Loading
+69 −0
Original line number Diff line number Diff line
@@ -1073,3 +1073,72 @@ cc_test {
        },
    },
}

cc_test {
    name: "net_test_stack_l2cap",
    test_suites: ["device-tests"],
    host_supported: true,
    defaults: ["fluoride_defaults"],
    local_include_dirs: [
        "include",
        "test/common",
    ],
    include_dirs: [
        "packages/modules/Bluetooth/system",
        "packages/modules/Bluetooth/system/gd",
        "packages/modules/Bluetooth/system/utils/include",
    ],
    generated_headers: [
        "BluetoothGeneratedDumpsysDataSchema_h",
        "BluetoothGeneratedPackets_h",
    ],
    srcs: [
        ":OsiCompatSources",
        ":TestCommonMainHandler",
        ":TestCommonMockFunctions",
        ":TestCommonStackConfig",
        ":TestMockBta",
        ":TestMockBtif",
        ":TestMockHci",
        ":TestMockLegacyHciCommands",
        ":TestMockMainShim",
        ":TestMockStackAcl",
        ":TestMockStackBtm",
        ":TestMockStackCryptotoolbox",
        ":TestMockStackHcic",
        ":TestMockStackSdp",
        ":TestMockStackSmp",
        "l2cap/l2c_api.cc",
        "l2cap/l2c_ble.cc",
        "l2cap/l2c_csm.cc",
        "l2cap/l2c_fcr.cc",
        "l2cap/l2c_link.cc",
        "l2cap/l2c_main.cc",
        "l2cap/l2c_utils.cc",
        "test/stack_l2cap_test.cc",
    ],
    static_libs: [
        "libbt-common",
        "libbt-protos-lite",
        "libbtdevice",
        "libgmock",
        "liblog",
        "libosi",
    ],
    shared_libs: [
        "libbinder_ndk",
        "libcrypto",
        "libflatbuffers-cpp",
        "libprotobuf-cpp-lite",
    ],
    sanitize: {
        address: true,
        all_undefined: true,
        cfi: true,
        integer_overflow: true,
        scs: true,
        diag: {
            undefined : true
        },
    },
}
+47 −0
Original line number Diff line number Diff line
/*
 * Copyright 2022 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include <gtest/gtest.h>

#include "common/init_flags.h"
#include "internal_include/bt_trace.h"
#include "stack/btm/btm_int_types.h"
#include "stack/include/l2cap_hci_link_interface.h"
#include "stack/l2cap/l2c_int.h"
#include "types/raw_address.h"

tBTM_CB btm_cb;
extern tL2C_CB l2cb;

// Global trace level referred in the code under test
uint8_t appl_trace_level = BT_TRACE_LEVEL_VERBOSE;

extern "C" void LogMsg(uint32_t trace_set_mask, const char* fmt_str, ...) {}

const char* test_flags[] = {
    "INIT_logging_debug_enabled_for_all=true",
    nullptr,
};

class StackL2capTest : public ::testing::Test {
 protected:
  void SetUp() override {
    bluetooth::common::InitFlags::Load(test_flags);
    l2cb = {};  // TODO Use proper init/free APIs
  }

  void TearDown() override {}
};