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

Commit 847b87f6 authored by William Escande's avatar William Escande
Browse files

Sync file on disk + add explicit error log

Bug: 278823133
Test: net_test_device64 --gtest_repeat=100000 --gtest_break_on_failure
Change-Id: I6c6e38e2f87fc6fe64523b644eee057006f48a23
parent 03ed0802
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -26,8 +26,10 @@

#if defined(OS_GENERIC)
#include <base/files/file_util.h>
#include <unistd.h>

#include <filesystem>
#include <system_error>

static const std::filesystem::path kStaticConfigFileConfigFile =
    std::filesystem::temp_directory_path() / "interop_database.conf";
@@ -103,12 +105,17 @@ class InteropTest : public ::testing::Test {
    ASSERT_EQ(fwrite(INTEROP_STATIC_FILE_CONTENT, 1,
                     sizeof(INTEROP_STATIC_FILE_CONTENT), fp),
              sizeof(INTEROP_STATIC_FILE_CONTENT));
    // Force data to be flushed on disk and not only in user-space
    ASSERT_EQ(fsync(fileno(fp)), 0)
        << "Associated ERRNO error is: " << strerror(errno);
    ASSERT_EQ(fclose(fp), 0);
#endif
  }
  virtual void TearDown() override {
#if defined(OS_GENERIC)
    EXPECT_TRUE(std::filesystem::remove(kStaticConfigFileConfigFile));
    std::error_code ec;
    EXPECT_TRUE(std::filesystem::remove(kStaticConfigFileConfigFile, ec))
        << "Associated error is: " << ec;
#endif
  }
};