8#include <framework/utilities/FileSystem.h>
9#include <framework/utilities/ScopeGuard.h>
11#include <gtest/gtest.h>
20namespace fs = std::filesystem;
23 TEST(Utilities, TemporaryFile)
27 FileSystem::TemporaryFile temp;
29 ASSERT_TRUE(temp.is_open());
30 ASSERT_TRUE(fs::exists(filename));
32 ASSERT_FALSE(fs::exists(filename));
34 TEST(Utilities, FileSystem)
38 FileSystem::TemporaryFile temp;
47 std::string relname = fs::relative(filename, fs::temp_directory_path()).string();
61 FileSystem::TemporaryFile temp;
62 std::string filename = temp.
getName();
65 FileSystem::Lock lk(filename);
66 EXPECT_TRUE(lk.lock(0));
68 if (pid_t pid = fork()) {
72 EXPECT_TRUE(lk.lock(0));
74 waitpid(pid, &status, 0);
75 EXPECT_TRUE(WIFEXITED(status));
76 EXPECT_EQ(0, WEXITSTATUS(status));
83 FileSystem::Lock lk2(filename);
std::string getName() const
get filename of the temporary file
static bool fileDirExists(const std::string &filename)
Check if the dir containing the filename exists.
static bool isDir(const std::string &filename)
Check if filename points to an existing directory.
static bool fileExists(const std::string &filename)
Check if the file with given filename exists.
static ScopeGuard guardWorkingDirectory()
Create a ScopeGuard of the current working directory.
Abstract base class for different kinds of events.