Made file store IO test test 16, 32, and 64 bit file systems.
This commit is contained in:
+4
-3
@@ -13,18 +13,19 @@
|
|||||||
namespace wombat {
|
namespace wombat {
|
||||||
namespace fs {
|
namespace fs {
|
||||||
|
|
||||||
template<typename FsSize_t>
|
template<typename FsT>
|
||||||
class FileStore {
|
class FileStore {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
typedef uint16_t InodeId_t;
|
||||||
|
typedef FsT FsSize_t;
|
||||||
|
|
||||||
struct FsHeader {
|
struct FsHeader {
|
||||||
uint32_t version;
|
uint32_t version;
|
||||||
FsSize_t size;
|
FsSize_t size;
|
||||||
FsSize_t rootInode;
|
FsSize_t rootInode;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef uint16_t InodeId_t;
|
|
||||||
|
|
||||||
struct StatInfo {
|
struct StatInfo {
|
||||||
InodeId_t inodeId;
|
InodeId_t inodeId;
|
||||||
FsSize_t size;
|
FsSize_t size;
|
||||||
|
|||||||
+9
-1
@@ -30,12 +30,20 @@ class FileSystem {
|
|||||||
int read(const char *path, void *buffer);
|
int read(const char *path, void *buffer);
|
||||||
|
|
||||||
FileStat stat(const char *path);
|
FileStat stat(const char *path);
|
||||||
|
|
||||||
|
FileStat stat(typename FileStore::InodeId_t inode);
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename FileStore>
|
template<typename FileStore>
|
||||||
FileStat FileSystem<FileStore>::stat(const char *path) {
|
FileStat FileSystem<FileStore>::stat(const char *path) {
|
||||||
FileStat stat;
|
FileStat stat;
|
||||||
auto s = store->stat(path);
|
return stat;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename FileStore>
|
||||||
|
FileStat FileSystem<FileStore>::stat(typename FileStore::InodeId_t inode) {
|
||||||
|
FileStat stat;
|
||||||
|
auto s = store->stat(inode);
|
||||||
stat.size = s.size;
|
stat.size = s.size;
|
||||||
stat.inode = s.inodeId;
|
stat.inode = s.inodeId;
|
||||||
return stat;
|
return stat;
|
||||||
|
|||||||
+11
-7
@@ -10,14 +10,15 @@
|
|||||||
|
|
||||||
using namespace wombat::fs;
|
using namespace wombat::fs;
|
||||||
|
|
||||||
int main() {
|
template<typename FileStore>
|
||||||
const auto size = 1 << 16;
|
int test() {
|
||||||
|
const auto size = 65535;
|
||||||
uint8_t volume[size];
|
uint8_t volume[size];
|
||||||
char out[6];
|
char out[6];
|
||||||
uint32_t err;
|
uint32_t err;
|
||||||
FileStore32::format(volume, size);
|
typename FileStore::FsSize_t outSize;
|
||||||
FileStore32 fs(volume, volume + size, &err);
|
FileStore::format(volume, size);
|
||||||
uint32_t outSize;
|
FileStore fs(volume, volume + size, &err);
|
||||||
|
|
||||||
if (fs.write(1, (void*) "Hello", 6) ||
|
if (fs.write(1, (void*) "Hello", 6) ||
|
||||||
fs.read(1, (char*) out, &outSize) ||
|
fs.read(1, (char*) out, &outSize) ||
|
||||||
@@ -26,7 +27,7 @@ int main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (fs.write(2, (void*) "World", 6) ||
|
if (fs.write(2, (void*) "World", 6) ||
|
||||||
fs.read(2, (char*) out, nullptr) ||
|
fs.read(2, (char*) out, &outSize) ||
|
||||||
strcmp("World", out)) {
|
strcmp("World", out)) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@@ -37,6 +38,9 @@ int main() {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
return test<FileStore16>() | test<FileStore32>() | test<FileStore64>();
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user