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

Commit 233f6f58 authored by Chris Manton's avatar Chris Manton
Browse files

Release temporary filedescriptor resource after use

Cluttered orphaned filedescriptors during test

Bug: 194254794
Tag: #refactor
Test: atest --host --iterations 100 net_test_osi

Change-Id: I2d9e627341578b5c18fc7122a657f6e1c32682db
parent 27f888f6
Loading
Loading
Loading
Loading
+8 −2
Original line number Diff line number Diff line
@@ -65,10 +65,13 @@ class WakelockTest : public AllocationTestHarness {
    lock_path_ = tmp_dir_ + "/wake_lock";
    unlock_path_ = tmp_dir_ + "/wake_unlock";

    creat(lock_path_.c_str(), S_IRWXU);
    creat(unlock_path_.c_str(), S_IRWXU);
    lock_path_fd = creat(lock_path_.c_str(), S_IRWXU);
    unlock_path_fd = creat(unlock_path_.c_str(), S_IRWXU);
  }

  int lock_path_fd{-1};
  int unlock_path_fd{-1};

  void TearDown() override {
    is_wake_lock_acquired = false;
    wakelock_cleanup();
@@ -79,6 +82,9 @@ class WakelockTest : public AllocationTestHarness {
    unlink(unlock_path_.c_str());
    rmdir(tmp_dir_.c_str());

    close(lock_path_fd);
    close(unlock_path_fd);

    AllocationTestHarness::TearDown();
  }