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

Commit 4a9653c0 authored by Henri Chataing's avatar Henri Chataing
Browse files

RootCanal: Implement additional LL tests

Implement LL tests LL/DDI/ADV/BV-01-C and LL/DDI/SCN/BV-18-C.
Fix issues with the python3 binding and async manager to make
the advertising test work.

Bug: 253523072
Test: atest --host rootcanal_ll_test
Change-Id: Ie6ffe0a3de638b551f88f9f11f33bd1da0c6b9ff
parent 357b2fbd
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -261,12 +261,13 @@ class FieldParser:
            if size is not None:
                self.check_size_(size)
            array_size = size or 'len(span)'
            array_count = size
            if element_width != 1:
                self.append_(f"if {array_size} % {element_width} != 0:")
                self.append_("    raise Exception('Array size is not a multiple of the element size')")
                self.append_(f"{field.id}_count = int({array_size} / {element_width})")
                array_count = f'{field.id}_count'
            else:
                array_count = array_size
            self.append_(f"{field.id} = []")
            self.append_(f"for n in range({array_count}):")
            span = ('span[n:n + 1]' if element_width == 1 else f'span[n * {element_width}:(n + 1) * {element_width}]')
+3 −0
Original line number Diff line number Diff line
@@ -208,6 +208,7 @@ cc_test_host {
        "rootcanal_defaults",
    ],
    srcs: [
        "test/controller/le/rpa_generation_test.cc",
        "test/controller/le/le_set_random_address_test.cc",
        "test/controller/le/le_clear_filter_accept_list_test.cc",
        "test/controller/le/le_add_device_to_filter_accept_list_test.cc",
@@ -257,8 +258,10 @@ python_test_host {
        ":hci_packets_python3_gen",
        ":link_layer_packets_python3_gen",
        "test/main.py",
        "test/LL/DDI/ADV/BV_01_C.py",
        "test/LL/DDI/SCN/BV_13_C.py",
        "test/LL/DDI/SCN/BV_14_C.py",
        "test/LL/DDI/SCN/BV_18_C.py",
    ],
    data: [
        ":lib_rootcanal_python3",
+1 −1
Original line number Diff line number Diff line
@@ -84,7 +84,7 @@ DualModeController::DualModeController(const std::string& properties_filename,
  link_layer_controller_.RegisterRemoteChannel(
      [this](std::shared_ptr<model::packets::LinkLayerPacketBuilder> packet,
             Phy::Type phy_type) {
        DualModeController::SendLinkLayerPacket(packet, phy_type);
        this->SendLinkLayerPacket(packet, phy_type);
      });

  std::array<uint8_t, 64> supported_commands{0};
+10 −3
Original line number Diff line number Diff line
@@ -88,8 +88,8 @@ class BaseController : public DualModeController {

 private:
  std::function<void(std::shared_ptr<std::vector<uint8_t>>)> send_ll_{};
  AsyncManager async_manager_;
  AsyncTaskId timer_task_id_;
  AsyncManager async_manager_{};
  AsyncTaskId timer_task_id_{kInvalidTaskId};

  BaseController(BaseController const&) = delete;
  DualModeController& operator=(BaseController const&) = delete;
@@ -130,10 +130,17 @@ PYBIND11_MODULE(lib_rootcanal_python3, m) {

  // Implement the constructor with two callback parameters to
  // handle emitted HCI packets and LL packets.
  basic_controller.def(py::init([](py::object hci_handler,
  basic_controller.def(py::init([](std::string address_str,
                                   py::object hci_handler,
                                   py::object ll_handler) {
    std::shared_ptr<BaseController> controller =
        std::make_shared<BaseController>();

    std::optional<bluetooth::hci::Address> address =
        bluetooth::hci::Address::FromString(address_str);
    if (address.has_value()) {
      controller->SetAddress(address.value());
    }
    controller->RegisterEventChannel(
        [=](std::shared_ptr<std::vector<uint8_t>> data) {
          pybind11::gil_scoped_acquire acquire;
+0 −1
Original line number Diff line number Diff line
@@ -4459,7 +4459,6 @@ void LinkLayerController::IncomingLeScanResponsePacket(
             advertising_address.GetAddressType(),
             resolved_advertising_address.ToString().c_str(),
             resolved_advertising_address.GetAddressType());
    return;
  }

  LOG_INFO("Accepting LE Scan response from advertising address %s(%hhx)",
Loading