8 #include <framework/utilities/FileSystem.h>
9 #include <framework/utilities/ScopeGuard.h>
11 #include <gtest/gtest.h>
20 namespace fs = std::filesystem;
23 TEST(Utilities, TemporaryFile)
29 ASSERT_TRUE(temp.is_open());
30 ASSERT_TRUE(fs::exists(filename));
32 ASSERT_FALSE(fs::exists(filename));
40 ASSERT_TRUE(FileSystem::fileExists(filename));
41 ASSERT_FALSE(FileSystem::isDir(filename));
42 ASSERT_TRUE(FileSystem::fileDirExists(filename));
46 auto pwd = ScopeGuard::guardWorkingDirectory(fs::temp_directory_path());
47 std::string relname = fs::relative(filename, fs::temp_directory_path()).string();
48 ASSERT_TRUE(FileSystem::fileExists(relname));
50 ASSERT_FALSE(FileSystem::fileExists(relname));
53 ASSERT_FALSE(FileSystem::fileExists(filename));
54 ASSERT_FALSE(FileSystem::isDir(filename));
55 ASSERT_TRUE(FileSystem::fileDirExists(filename));
57 ASSERT_TRUE(FileSystem::isDir(
"/"));
62 std::string filename = temp.
getName();
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));
Helper class for locking a file.
Helper file to create a temporary file and ensure deletion if object goes out of scope.
std::string getName() const
get filename of the temporary file
Utility functions related to filename validation and filesystem access.
TEST(TestgetDetectorRegion, TestgetDetectorRegion)
Test Constructors.
Abstract base class for different kinds of events.