continue host fs unittests

This commit is contained in:
Robin Müller 2022-08-11 09:59:14 +02:00
parent 20eee2c469
commit e796e025b6
No known key found for this signature in database
GPG Key ID: 71B58F8A3CDFA9AC
2 changed files with 26 additions and 2 deletions

View File

@ -18,7 +18,8 @@ class HostFilesystem : public HasFileSystemIF {
ReturnValue_t rename(const char *oldPath, char *newPath, FileSystemArgsIF *args) override; ReturnValue_t rename(const char *oldPath, char *newPath, FileSystemArgsIF *args) override;
std::error_code errorCode; std::error_code errorCode;
using HasFileSystemIF::createFile;
using HasFileSystemIF::removeFile;
private: private:
}; };
#endif // FSFW_HAL_HOSTFILESYSTEM_H #endif // FSFW_HAL_HOSTFILESYSTEM_H

View File

@ -1,5 +1,28 @@
#include <catch2/catch_test_macros.hpp> #include <catch2/catch_test_macros.hpp>
#include "fsfw_hal/host/HostFilesystem.h" #include "fsfw_hal/host/HostFilesystem.h"
#include <filesystem>
TEST_CASE("Host Filesystem", "[hal][host]") { auto hostFs = HostFilesystem(); } TEST_CASE("Host Filesystem", "[hal][host]") {
namespace fs = std::filesystem;
auto hostFs = HostFilesystem();
auto tmpDir = fs::temp_directory_path();
SECTION("Create file") {
fs::path file = tmpDir / "hello.txt";
FilesystemParams params(file.c_str());
REQUIRE(hostFs.createFile(params) == result::OK);
REQUIRE(fs::exists(file));
REQUIRE_NOTHROW(fs::remove(file));
}
SECTION("Remove File") {
fs::path file = tmpDir / "hello.txt";
FilesystemParams params(file.c_str());
REQUIRE(hostFs.createFile(params) == result::OK);
REQUIRE(fs::exists(file));
REQUIRE(hostFs.removeFile(file.c_str()) == result::OK);
REQUIRE(not fs::exists(file));
}
}