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

Commit 64c0028e authored by Henri Chataing's avatar Henri Chataing Committed by Gerrit Code Review
Browse files

Merge "RootCanal: Remove option --default_commands_file"

parents 7245d06c 1441d316
Loading
Loading
Loading
Loading
+2 −3
Original line number Diff line number Diff line
@@ -42,8 +42,7 @@ DEFINE_string(controller_properties_file, "", "deprecated");
DEFINE_string(configuration, "", "controller configuration (see config.proto)");
DEFINE_string(configuration_file, "",
              "controller configuration file path (see config.proto)");
DEFINE_string(default_commands_file, "",
              "commands file which root-canal runs it as default");
DEFINE_string(default_commands_file, "", "deprecated");
DEFINE_bool(enable_hci_sniffer, false, "enable hci sniffer");
DEFINE_bool(enable_baseband_sniffer, false, "enable baseband sniffer");
DEFINE_bool(enable_pcap_filter, false, "enable PCAP filter");
@@ -137,7 +136,7 @@ int main(int argc, char** argv) {
      },
      static_cast<int>(FLAGS_test_port), static_cast<int>(FLAGS_hci_port),
      static_cast<int>(FLAGS_link_port), static_cast<int>(FLAGS_link_ble_port),
      configuration_str, FLAGS_default_commands_file, FLAGS_enable_hci_sniffer,
      configuration_str, FLAGS_enable_hci_sniffer,
      FLAGS_enable_baseband_sniffer, FLAGS_enable_pcap_filter,
      FLAGS_disable_address_reuse);

+6 −5
Original line number Diff line number Diff line
@@ -49,11 +49,10 @@ TestEnvironment::TestEnvironment(
    std::function<std::shared_ptr<AsyncDataChannelConnector>(AsyncManager*)>
        open_connector,
    int test_port, int hci_port, int link_port, int link_ble_port,
    const std::string& config_str, const std::string& default_commands_file,
    const std::string& config_str,
    bool enable_hci_sniffer, bool enable_baseband_sniffer,
    bool enable_pcap_filter, bool disable_address_reuse)
    : default_commands_file_(default_commands_file),
      enable_hci_sniffer_(enable_hci_sniffer),
    : enable_hci_sniffer_(enable_hci_sniffer),
      enable_baseband_sniffer_(enable_baseband_sniffer),
      enable_pcap_filter_(enable_pcap_filter) {
  test_socket_server_ = open_server(&async_manager_, test_port);
@@ -232,11 +231,13 @@ void TestEnvironment::SetUpTestChannel() {

  test_channel_.AddPhy({"BR_EDR"});
  test_channel_.AddPhy({"LOW_ENERGY"});
  test_channel_.AddDevice({"beacon", "be:ac:01:55:00:01", "1000"});
  test_channel_.AddDeviceToPhy({"0", "1"});
  test_channel_.AddDevice({"beacon", "be:ac:01:55:00:02", "1000"});
  test_channel_.AddDeviceToPhy({"1", "1"});
  test_channel_.SetTimerPeriod({"5"});
  test_channel_.StartTimer({});

  test_channel_.FromFile(default_commands_file_);

  if (!transport_configured) {
    LOG_ERROR("Test channel SetUp failed.");
    return;
+0 −2
Original line number Diff line number Diff line
@@ -55,7 +55,6 @@ class TestEnvironment {
          open_connector,
      int test_port, int hci_port, int link_port, int link_ble_port,
      std::string const& config_str,
      std::string const& default_commands_file = "",
      bool enable_hci_sniffer = false, bool enable_baseband_sniffer = false,
      bool enable_pcap_filter = false, bool disable_address_reuse = false);

@@ -70,7 +69,6 @@ class TestEnvironment {
  std::shared_ptr<AsyncDataChannelServer> link_socket_server_;
  std::shared_ptr<AsyncDataChannelServer> link_ble_socket_server_;
  std::shared_ptr<AsyncDataChannelConnector> connector_;
  std::string default_commands_file_;
  bool enable_hci_sniffer_;
  bool enable_baseband_sniffer_;
  bool enable_pcap_filter_;
+0 −24
Original line number Diff line number Diff line
@@ -89,30 +89,6 @@ void TestCommandHandler::HandleCommand(const std::string& name,
  active_commands_[name](args);
}

void TestCommandHandler::FromFile(const std::string& file_name) {
  if (file_name.empty()) {
    return;
  }

  std::ifstream file(file_name.c_str());

  const std::regex re("\\s+");

  std::string line;
  while (std::getline(file, line)) {
    auto begin = std::sregex_token_iterator(line.begin(), line.end(), re, -1);
    auto end = std::sregex_token_iterator();
    auto params = std::vector<std::string>(std::next(begin), end);

    HandleCommand(*begin, params);
  }

  if (file.fail()) {
    LOG_ERROR("Error reading commands from file.");
    return;
  }
}

void TestCommandHandler::RegisterSendResponse(
    const std::function<void(const std::string&)> callback) {
  send_response_ = callback;
+0 −3
Original line number Diff line number Diff line
@@ -40,9 +40,6 @@ class TestCommandHandler {
  void HandleCommand(const std::string& name,
                     const std::vector<std::string>& args);

  // Dispatches the action from a file
  void FromFile(const std::string& file_name);

  // Dispatches the action corresponding to the command specified by |name|.
  void RegisterSendResponse(std::function<void(const std::string&)> callback);