[ox/fs] Remove old file system code
This commit is contained in:
50
deps/ox/src/ox/fs/test/CMakeLists.txt
vendored
50
deps/ox/src/ox/fs/test/CMakeLists.txt
vendored
@@ -1,49 +1,10 @@
|
||||
cmake_minimum_required(VERSION 2.8)
|
||||
|
||||
add_executable(
|
||||
FileStoreFormat
|
||||
filestore_format.cpp
|
||||
)
|
||||
|
||||
add_executable(
|
||||
FileSystemFormat
|
||||
filesystem_format.cpp
|
||||
)
|
||||
|
||||
add_executable(
|
||||
FileStoreIO
|
||||
filestoreio.cpp
|
||||
)
|
||||
|
||||
add_executable(
|
||||
FSTests
|
||||
tests.cpp
|
||||
)
|
||||
|
||||
target_link_libraries(
|
||||
FileStoreFormat
|
||||
OxFS
|
||||
OxStd
|
||||
OxTrace
|
||||
OxMetalClaw
|
||||
)
|
||||
|
||||
target_link_libraries(
|
||||
FileSystemFormat
|
||||
OxFS
|
||||
OxStd
|
||||
OxTrace
|
||||
OxMetalClaw
|
||||
)
|
||||
|
||||
target_link_libraries(
|
||||
FileStoreIO
|
||||
OxFS
|
||||
OxStd
|
||||
OxTrace
|
||||
OxMetalClaw
|
||||
)
|
||||
|
||||
target_link_libraries(
|
||||
FSTests
|
||||
OxFS
|
||||
@@ -52,9 +13,6 @@ target_link_libraries(
|
||||
OxMetalClaw
|
||||
)
|
||||
|
||||
add_test("FileStoreFormat" FileStoreFormat)
|
||||
add_test("FileSystemFormat" FileSystemFormat)
|
||||
add_test("FileStoreIO" FileStoreIO)
|
||||
add_test("Test\\ PathIterator::next1" FSTests PathIterator::next1)
|
||||
add_test("Test\\ PathIterator::next2" FSTests PathIterator::next2)
|
||||
add_test("Test\\ PathIterator::next3" FSTests PathIterator::next3)
|
||||
@@ -65,14 +23,6 @@ add_test("Test\\ PathIterator::hasNext" FSTests PathIterator::hasNext)
|
||||
add_test("Test\\ PathIterator::dirPath" FSTests PathIterator::dirPath)
|
||||
add_test("Test\\ PathIterator::fileName" FSTests PathIterator::fileName)
|
||||
|
||||
add_test("Test\\ FileSystem32::findInodeOf\\ /" FSTests "FileSystem32::findInodeOf /")
|
||||
add_test("Test\\ FileSystem32::write\\(string\\)" FSTests "FileSystem32::write(string)")
|
||||
add_test("Test\\ FileSystem32::rmDirectoryEntry\\(string\\)" FSTests "FileSystem32::rmDirectoryEntry(string)")
|
||||
add_test("Test\\ FileSystem32::remove\\(string,\\ true\\)" FSTests "FileSystem32::remove(string, true)")
|
||||
add_test("Test\\ FileSystem32::move" FSTests "FileSystem32::move")
|
||||
add_test("Test\\ FileSystem32::stripDirectories" FSTests "FileSystem32::stripDirectories")
|
||||
#add_test("Test\\ FileSystem32::ls" FSTests "FileSystem32::ls")
|
||||
|
||||
add_test("Test\\ NodeBuffer::insert" FSTests "NodeBuffer::insert")
|
||||
add_test("Test\\ FileStore::readWrite" FSTests "FileStore::readWrite")
|
||||
|
||||
|
212
deps/ox/src/ox/fs/test/tests.cpp
vendored
212
deps/ox/src/ox/fs/test/tests.cpp
vendored
@@ -18,7 +18,7 @@
|
||||
#include <ox/fs/fs.hpp>
|
||||
#include <ox/std/std.hpp>
|
||||
#include <ox/fs/filestore/filestoretemplate.hpp>
|
||||
#include <ox/fs/filesystem2/filesystem.hpp>
|
||||
#include <ox/fs/filesystem/filesystem.hpp>
|
||||
|
||||
|
||||
using namespace std;
|
||||
@@ -120,216 +120,6 @@ map<string, int(*)(string)> tests = {
|
||||
return retval;
|
||||
}
|
||||
},
|
||||
{
|
||||
"FileSystem32::findInodeOf /",
|
||||
[](string) {
|
||||
int retval = 0;
|
||||
const auto size = 1024;
|
||||
uint8_t buff[size];
|
||||
FileSystem32::format(buff, (FileStore32::FsSize_t) size, true);
|
||||
auto fs = (FileSystem32*) createFileSystem(buff, size);
|
||||
retval |= !(fs->findInodeOf("/") == FileSystem32::INODE_ROOT_DIR);
|
||||
delete fs;
|
||||
return retval;
|
||||
}
|
||||
},
|
||||
{
|
||||
"FileSystem32::write(string)",
|
||||
[](string) {
|
||||
int retval = 0;
|
||||
auto path = "/usr/share/test.txt";
|
||||
auto dataIn = "test string";
|
||||
auto dataOutLen = ox_strlen(dataIn) + 1;
|
||||
auto dataOut = new char[dataOutLen];
|
||||
|
||||
const auto size = 1024 * 1024;
|
||||
auto buff = new uint8_t[size];
|
||||
FileSystem32::format(buff, (FileStore32::FsSize_t) size, true);
|
||||
auto fs = (FileSystem32*) createFileSystem(buff, size);
|
||||
|
||||
retval |= fs->mkdir("/usr");
|
||||
retval |= fs->mkdir("/usr/share");
|
||||
retval |= fs->mkdir("/usr/lib");
|
||||
|
||||
retval |= fs->write(path, (void*) dataIn, ox_strlen(dataIn) + 1);
|
||||
retval |= fs->read(path, dataOut, dataOutLen);
|
||||
retval |= ox_strcmp(dataIn, dataOut) != 0;
|
||||
|
||||
delete fs;
|
||||
delete []buff;
|
||||
delete []dataOut;
|
||||
|
||||
return retval;
|
||||
}
|
||||
},
|
||||
{
|
||||
"FileSystem32::rmDirectoryEntry(string)",
|
||||
[](string) {
|
||||
int retval = 0;
|
||||
auto path = "/usr/share/test.txt";
|
||||
auto dataIn = "test string";
|
||||
auto dataOutLen = ox_strlen(dataIn) + 1;
|
||||
auto dataOut = new char[dataOutLen];
|
||||
|
||||
const auto size = 1024 * 1024 * 10;
|
||||
auto buff = new uint8_t[size];
|
||||
FileSystem32::format(buff, (FileStore32::FsSize_t) size, true);
|
||||
auto fs = (FileSystem32*) createFileSystem(buff, size);
|
||||
|
||||
retval |= fs->mkdir("/usr");
|
||||
retval |= fs->mkdir("/usr/share");
|
||||
|
||||
retval |= fs->write(path, (void*) dataIn, ox_strlen(dataIn) + 1);
|
||||
retval |= fs->read(path, dataOut, dataOutLen);
|
||||
retval |= ox_strcmp(dataIn, dataOut) != 0;
|
||||
|
||||
retval |= fs->rmDirectoryEntry(path);
|
||||
// the lookup should fail
|
||||
retval |= fs->read(path, dataOut, dataOutLen) == 0;
|
||||
|
||||
delete fs;
|
||||
delete []buff;
|
||||
delete []dataOut;
|
||||
|
||||
return retval;
|
||||
}
|
||||
},
|
||||
{
|
||||
"FileSystem32::remove(string, true)",
|
||||
[](string) {
|
||||
int retval = 0;
|
||||
auto dataIn = "test string";
|
||||
auto dataOutLen = 1024 * 64;
|
||||
auto dataOut = new char[dataOutLen];
|
||||
std::vector<uint64_t> inodes;
|
||||
|
||||
const auto size = 1024 * 1024;
|
||||
auto buff = new uint8_t[size];
|
||||
FileSystem32::format(buff, (FileStore32::FsSize_t) size, true);
|
||||
auto fs = (FileSystem32*) createFileSystem(buff, size);
|
||||
|
||||
retval |= fs->mkdir("/usr");
|
||||
retval |= fs->mkdir("/usr/share");
|
||||
retval |= fs->write("/usr/share/test.txt", (void*) dataIn, ox_strlen(dataIn) + 1);
|
||||
|
||||
inodes.push_back(fs->stat("/usr").inode);
|
||||
inodes.push_back(fs->stat("/usr/share").inode);
|
||||
inodes.push_back(fs->stat("/usr/share/test.txt").inode);
|
||||
|
||||
retval |= fs->remove("/usr", true);
|
||||
|
||||
// the lookup should fail
|
||||
for (auto inode : inodes) {
|
||||
retval |= fs->read(inode, dataOut, dataOutLen) == 0;
|
||||
}
|
||||
|
||||
delete fs;
|
||||
delete []buff;
|
||||
delete []dataOut;
|
||||
|
||||
return retval;
|
||||
}
|
||||
},
|
||||
{
|
||||
"FileSystem32::move",
|
||||
[](string) {
|
||||
int retval = 0;
|
||||
auto dataIn = "test string";
|
||||
auto dataOutLen = ox_strlen(dataIn) + 1;
|
||||
auto dataOut = new char[dataOutLen];
|
||||
std::vector<uint64_t> inodes;
|
||||
|
||||
const auto size = 1024 * 1024;
|
||||
auto buff = new uint8_t[size];
|
||||
FileSystem32::format(buff, (FileStore32::FsSize_t) size, true);
|
||||
auto fs = (FileSystem32*) createFileSystem(buff, size);
|
||||
|
||||
retval |= fs->mkdir("/usr");
|
||||
retval |= fs->mkdir("/usr/share");
|
||||
retval |= fs->write("/usr/share/test.txt", (void*) dataIn, ox_strlen(dataIn) + 1);
|
||||
|
||||
retval |= fs->move("/usr/share", "/share");
|
||||
retval |= fs->read("/share/test.txt", dataOut, dataOutLen);
|
||||
retval |= !(ox_strcmp(dataIn, dataOut) == 0);
|
||||
|
||||
delete fs;
|
||||
delete []buff;
|
||||
delete []dataOut;
|
||||
|
||||
return retval;
|
||||
}
|
||||
},
|
||||
{
|
||||
"FileSystem32::stripDirectories",
|
||||
[](string) {
|
||||
int retval = 0;
|
||||
auto dataIn = "test string";
|
||||
auto dataOutLen = ox_strlen(dataIn) + 1;
|
||||
auto dataOut = new char[dataOutLen];
|
||||
std::vector<uint64_t> inodes;
|
||||
|
||||
const auto size = 1024 * 1024;
|
||||
auto buff = new uint8_t[size];
|
||||
FileSystem32::format(buff, (FileStore32::FsSize_t) size, true);
|
||||
auto fs = (FileSystem32*) createFileSystem(buff, size);
|
||||
|
||||
retval |= fs->mkdir("/usr");
|
||||
retval |= fs->mkdir("/usr/share");
|
||||
retval |= fs->write("/usr/share/test.txt", (void*) dataIn, ox_strlen(dataIn) + 1);
|
||||
|
||||
auto inode = fs->stat("/usr/share/test.txt").inode;
|
||||
|
||||
retval |= fs->stripDirectories();
|
||||
|
||||
// make sure normal file is still there and the directories are gone
|
||||
retval |= fs->read(inode, dataOut, dataOutLen);
|
||||
retval |= !(ox_strcmp(dataIn, dataOut) == 0);
|
||||
retval |= !(fs->stat("/usr").inode == 0);
|
||||
retval |= !(fs->stat("/usr/share").inode == 0);
|
||||
|
||||
delete fs;
|
||||
delete []buff;
|
||||
delete []dataOut;
|
||||
|
||||
return retval;
|
||||
}
|
||||
},
|
||||
{
|
||||
"FileSystem32::ls",
|
||||
[](string) {
|
||||
int retval = 0;
|
||||
auto dataIn = "test string";
|
||||
auto dataOutLen = ox_strlen(dataIn) + 1;
|
||||
auto dataOut = new char[dataOutLen];
|
||||
std::vector<uint64_t> inodes;
|
||||
std::vector<DirectoryListing<string>> files;
|
||||
|
||||
const auto size = 1024 * 1024;
|
||||
auto buff = new uint8_t[size];
|
||||
FileSystem32::format(buff, (FileStore32::FsSize_t) size, true);
|
||||
auto fs = (FileSystem32*) createFileSystem(buff, size);
|
||||
|
||||
retval |= fs->mkdir("/usr");
|
||||
retval |= fs->mkdir("/usr/share");
|
||||
retval |= fs->write("/usr/share/a.txt", (void*) dataIn, ox_strlen(dataIn) + 1);
|
||||
retval |= fs->write("/usr/share/b.txt", (void*) dataIn, ox_strlen(dataIn) + 1);
|
||||
retval |= fs->write("/usr/share/c.txt", (void*) dataIn, ox_strlen(dataIn) + 1);
|
||||
|
||||
fs->ls("/usr/share/", &files);
|
||||
|
||||
retval |= !(files[0].name == ".");
|
||||
retval |= !(files[1].name == "..");
|
||||
retval |= !(files[2].name == "a.txt");
|
||||
retval |= !(files[3].name == "b.txt");
|
||||
retval |= !(files[4].name == "c.txt");
|
||||
|
||||
delete fs;
|
||||
delete []buff;
|
||||
delete []dataOut;
|
||||
|
||||
return retval;
|
||||
}
|
||||
},
|
||||
{
|
||||
"Ptr::subPtr",
|
||||
[](string) {
|
||||
|
Reference in New Issue
Block a user