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

Commit 4e892601 authored by William Escande's avatar William Escande
Browse files

Change the name of snoop log in test

The test name is now part of the temp file name to facilitate debugging

Test: atest bluetooth_test_gd_unit
Bug: 269535256
Change-Id: I1710944a0cd4265dbb024679bea849dbe1097d31
parent 2ab4ba8d
Loading
Loading
Loading
Loading
+18 −15
Original line number Diff line number Diff line
@@ -174,13 +174,16 @@ class SnoopLoggerModuleTest : public Test {

    LOG_DEBUG(
        "Setup for test %s in test suite %s.\n", test_info->name(), test_info->test_suite_name());
    temp_dir_ = std::filesystem::temp_directory_path();
    temp_snoop_log_ = temp_dir_ / "btsnoop_hci.log";
    temp_snoop_log_last_ = temp_dir_ / "btsnoop_hci.log.last";
    temp_snooz_log_ = temp_dir_ / "btsnooz_hci.log";
    temp_snooz_log_last_ = temp_dir_ / "btsnooz_hci.log.last";
    temp_snoop_log_filtered = temp_dir_ / "btsnoop_hci.log.filtered";
    temp_snoop_log_filtered_last = temp_dir_ / "btsnoop_hci.log.filtered.last";
    const std::filesystem::path temp_dir_ = std::filesystem::temp_directory_path();

    temp_snoop_log_ = temp_dir_ / (std::string(test_info->name()) + "_btsnoop_hci.log");
    temp_snoop_log_last_ = temp_dir_ / (std::string(test_info->name()) + "_btsnoop_hci.log.last");
    temp_snooz_log_ = temp_dir_ / (std::string(test_info->name()) + "_btsnooz_hci.log");
    temp_snooz_log_last_ = temp_dir_ / (std::string(test_info->name()) + "_btsnooz_hci.log.last");
    temp_snoop_log_filtered =
        temp_dir_ / (std::string(test_info->name()) + "_btsnoop_hci.log.filtered");
    temp_snoop_log_filtered_last =
        temp_dir_ / (std::string(test_info->name()) + "_btsnoop_hci.log.filtered.last");
    builder_ = new flatbuffers::FlatBufferBuilder();

    DeleteSnoopLogFiles();
@@ -211,6 +214,14 @@ class SnoopLoggerModuleTest : public Test {
        test_info->test_suite_name());
  }

  std::filesystem::path temp_snoop_log_;
  std::filesystem::path temp_snoop_log_last_;
  std::filesystem::path temp_snooz_log_;
  std::filesystem::path temp_snooz_log_last_;
  std::filesystem::path temp_snoop_log_filtered;
  std::filesystem::path temp_snoop_log_filtered_last;

 private:
  void DeleteSnoopLogFiles() {
    if (std::filesystem::exists(temp_snoop_log_)) {
      ASSERT_TRUE(std::filesystem::remove(temp_snoop_log_));
@@ -231,14 +242,6 @@ class SnoopLoggerModuleTest : public Test {
      ASSERT_TRUE(std::filesystem::remove(temp_snooz_log_last_));
    }
  }

  std::filesystem::path temp_dir_;
  std::filesystem::path temp_snoop_log_;
  std::filesystem::path temp_snoop_log_last_;
  std::filesystem::path temp_snooz_log_;
  std::filesystem::path temp_snooz_log_last_;
  std::filesystem::path temp_snoop_log_filtered;
  std::filesystem::path temp_snoop_log_filtered_last;
};

TEST_F(SnoopLoggerModuleTest, empty_snoop_log_test) {