windows building again

This commit is contained in:
2023-01-26 15:30:23 +01:00
parent e37af4fe70
commit 3e8446ba8b
15 changed files with 167 additions and 97 deletions

View File

@ -26,30 +26,30 @@ TEST_CASE("Host Filesystem", "[hal][host]") {
REQUIRE_NOTHROW(fs::remove_all(dir0));
SECTION("Create file") {
FilesystemParams params(file0.c_str());
FilesystemParams params(file0.string().c_str());
REQUIRE(hostFs.createFile(params) == returnvalue::OK);
CHECK(fs::is_regular_file(file0));
REQUIRE(fs::exists(file0));
}
SECTION("Remove File") {
FilesystemParams params(file0.c_str());
FilesystemParams params(file0.string().c_str());
REQUIRE(hostFs.createFile(params) == returnvalue::OK);
CHECK(fs::is_regular_file(file0));
REQUIRE(fs::exists(file0));
REQUIRE(hostFs.removeFile(file0.c_str()) == returnvalue::OK);
REQUIRE(hostFs.removeFile(file0.string().c_str()) == returnvalue::OK);
REQUIRE(not fs::exists(file0));
}
SECTION("Create Directory") {
FilesystemParams params(dir0.c_str());
FilesystemParams params(dir0.string().c_str());
REQUIRE(hostFs.createDirectory(params) == returnvalue::OK);
CHECK(fs::is_directory(dir0));
REQUIRE(fs::exists(dir0));
}
SECTION("Remove Directory") {
FilesystemParams params(dir0.c_str());
FilesystemParams params(dir0.string().c_str());
REQUIRE(hostFs.createDirectory(params) == returnvalue::OK);
REQUIRE(fs::exists(dir0));
REQUIRE(hostFs.removeDirectory(params) == returnvalue::OK);
@ -57,16 +57,16 @@ TEST_CASE("Host Filesystem", "[hal][host]") {
}
SECTION("Rename File") {
FilesystemParams params(file0.c_str());
FilesystemParams params(file0.string().c_str());
REQUIRE(hostFs.createFile(params) == returnvalue::OK);
CHECK(fs::is_regular_file(file0));
REQUIRE(fs::exists(file0));
REQUIRE(hostFs.rename(file0.c_str(), file1.c_str()) == returnvalue::OK);
REQUIRE(hostFs.rename(file0.string().c_str(), file1.string().c_str()) == returnvalue::OK);
}
SECTION("Write To File") {
std::string data = "hello world!";
FileOpParams params(file0.c_str(), data.size());
FileOpParams params(file0.string().c_str(), data.size());
REQUIRE(hostFs.createFile(params.fsParams) == returnvalue::OK);
CHECK(fs::is_regular_file(file0));
REQUIRE(fs::exists(file0));
@ -88,7 +88,7 @@ TEST_CASE("Host Filesystem", "[hal][host]") {
for (uint8_t& byte : randData) {
byte = distU8(rng);
}
FileOpParams params(file0.c_str(), randData.size() - 256);
FileOpParams params(file0.string().c_str(), randData.size() - 256);
REQUIRE(hostFs.createFile(params.fsParams) == returnvalue::OK);
CHECK(fs::is_regular_file(file0));
REQUIRE(fs::exists(file0));
@ -107,7 +107,7 @@ TEST_CASE("Host Filesystem", "[hal][host]") {
SECTION("Read From File") {
std::string data = "hello world!";
FileOpParams params(file0.c_str(), data.size());
FileOpParams params(file0.string().c_str(), data.size());
REQUIRE(hostFs.createFile(params.fsParams) == returnvalue::OK);
CHECK(fs::is_regular_file(file0));
ofstream of(file0);
@ -138,35 +138,35 @@ TEST_CASE("Host Filesystem", "[hal][host]") {
}
SECTION("Create File but already exists") {
FilesystemParams params(file0.c_str());
FilesystemParams params(file0.string().c_str());
REQUIRE(hostFs.createFile(params) == returnvalue::OK);
REQUIRE(hostFs.createFile(params) == HasFileSystemIF::FILE_ALREADY_EXISTS);
}
SECTION("Remove File but does not exist") {
REQUIRE(hostFs.removeFile(file0.c_str()) == HasFileSystemIF::FILE_DOES_NOT_EXIST);
REQUIRE(hostFs.removeFile(file0.string().c_str()) == HasFileSystemIF::FILE_DOES_NOT_EXIST);
}
SECTION("Create Directory but already exists") {
FileOpParams params(file0.c_str(), 12);
FileOpParams params(file0.string().c_str(), 12);
REQUIRE(hostFs.createDirectory(params.fsParams) == returnvalue::OK);
REQUIRE(hostFs.createDirectory(params.fsParams) == HasFileSystemIF::DIRECTORY_ALREADY_EXISTS);
}
SECTION("Remove Directory but does not exist") {
FilesystemParams params(dir0.c_str());
FilesystemParams params(dir0.string().c_str());
REQUIRE(hostFs.removeDirectory(params) == HasFileSystemIF::DIRECTORY_DOES_NOT_EXIST);
}
SECTION("Remove Directory but is file") {
ofstream of(file0);
FilesystemParams params(file0.c_str());
FilesystemParams params(file0.string().c_str());
REQUIRE(hostFs.removeDirectory(params) == HasFileSystemIF::NOT_A_DIRECTORY);
}
SECTION("Read from file but does not exist") {
std::string data = "hello world!";
FileOpParams params(file0.c_str(), data.size());
FileOpParams params(file0.string().c_str(), data.size());
std::array<uint8_t, 10> readBuf{};
uint8_t* readPtr = readBuf.data();
size_t readSize = 0;
@ -176,39 +176,41 @@ TEST_CASE("Host Filesystem", "[hal][host]") {
SECTION("Write to file but does not exist") {
std::string data = "hello world!";
FileOpParams params(file0.c_str(), data.size());
FileOpParams params(file0.string().c_str(), data.size());
CHECK(hostFs.writeToFile(params, reinterpret_cast<const uint8_t*>(data.c_str())) ==
HasFileSystemIF::FILE_DOES_NOT_EXIST);
}
SECTION("Remove recursively") {
fs::create_directory(dir0.c_str());
fs::create_directory(dir0.string().c_str());
ofstream of(fileInDir0);
CHECK(fs::is_directory(dir0));
CHECK(fs::is_regular_file(fileInDir0));
REQUIRE(hostFs.removeDirectory(FilesystemParams(dir0.c_str()), true) == returnvalue::OK);
REQUIRE(hostFs.removeDirectory(FilesystemParams(dir0.string().c_str()), true) ==
returnvalue::OK);
CHECK(not fs::is_directory(dir0));
CHECK(not fs::is_regular_file(fileInDir0));
}
SECTION("Non-Recursive Removal Fails") {
fs::create_directory(dir0.c_str());
fs::create_directory(dir0.string().c_str());
ofstream of(fileInDir0);
CHECK(fs::is_directory(dir0));
CHECK(fs::is_regular_file(fileInDir0));
REQUIRE(hostFs.removeDirectory(FilesystemParams(dir0.c_str())) ==
REQUIRE(hostFs.removeDirectory(FilesystemParams(dir0.string().c_str())) ==
HasFileSystemIF::DIRECTORY_NOT_EMPTY);
}
SECTION("Create directory with parent directory") {
CHECK(hostFs.createDirectory(FilesystemParams(dirWithParent.c_str()), true) == returnvalue::OK);
CHECK(hostFs.createDirectory(FilesystemParams(dirWithParent.string().c_str()), true) ==
returnvalue::OK);
CHECK(fs::is_directory(dir0));
CHECK(fs::is_directory(dirWithParent));
}
SECTION("Read but provided buffer too small") {
std::string data = "hello world!";
FileOpParams params(file0.c_str(), data.size());
FileOpParams params(file0.string().c_str(), data.size());
ofstream of(file0);
of.write(data.c_str(), static_cast<unsigned int>(data.size()));
of.close();