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

Commit ca1f3cfd authored by Henri Chataing's avatar Henri Chataing
Browse files

RootCanal: Make output pcap trace filenames more identifiable

Generate the files with the pattern:
  rootcanal_$id_$address(_$n).pcap

Where
- $id is the *unique* device identifier
- $address is the *assigned* device address (reused)
- $n serves to dedup identical file names
  (in case rootcanal is restarted)

Test: m root-canal
Bug: 330185630
Flag: EXEMPT, tool change
Change-Id: If5dfedc713bd94e521dafcd0237aa853054bad4e
parent 0780e65a
Loading
Loading
Loading
Loading
+6 −4
Original line number Diff line number Diff line
@@ -118,13 +118,15 @@ void TestEnvironment::SetUpHciServer(
        transport = HciSniffer::Create(transport);
      }
      auto device = HciDevice::Create(transport, properties);
      test_model_.AddHciConnection(device);
      auto device_id = test_model_.AddHciConnection(device);

      if (enable_hci_sniffer_) {
        auto filename = device->GetAddress().ToString() + ".pcap";
        auto filename = "rootcanal_" + std::to_string(device_id) + "_" +
                        device->GetAddress().ToString() + ".pcap";
        for (auto i = 0; std::filesystem::exists(filename); i++) {
          filename =
              device->GetAddress().ToString() + "_" + std::to_string(i) + ".pcap";
          filename = "rootcanal_" + std::to_string(device_id) + "_" +
                     device->GetAddress().ToString() + "_" + std::to_string(i) +
                     ".pcap";
        }
        auto file = std::make_shared<std::ofstream>(filename, std::ios::binary);
        auto sniffer = std::static_pointer_cast<HciSniffer>(transport);