Fix FileStore::write test and fix missed error report

This commit is contained in:
2017-04-26 01:40:46 -05:00
parent 9cd8eb2167
commit 1b6eee4d85
2 changed files with 8 additions and 17 deletions
+2 -3
View File
@@ -144,7 +144,7 @@ class FileSystemTemplate: public FileSystem {
int write(const char *path, void *buffer, uint64_t size, uint8_t fileType = NormalFile) override;
int write(uint64_t inode, void *buffer, uint64_t size, uint8_t fileType) override;
int write(uint64_t inode, void *buffer, uint64_t size, uint8_t fileType = NormalFile) override;
FileStat stat(const char *path);
@@ -219,7 +219,7 @@ int FileSystemTemplate<FileStore, FS_TYPE>::read(const char *path, void *buffer,
// if inode exists, read the data into buffer
if (inode) {
read(inode, buffer, buffSize);
retval = read(inode, buffer, buffSize);
}
return retval;
@@ -238,7 +238,6 @@ int FileSystemTemplate<FileStore, FS_TYPE>::read(uint64_t inode, void *buffer, s
return m_store->read(inode, buffer, nullptr);
}
return -1;
;
}
#ifdef _MSC_VER
#pragma warning(default:4244)
+6 -14
View File
@@ -132,20 +132,11 @@ map<string, int(*)(string)> tests = {
{
"FileSystem32::write(string)",
[](string) {
// this value will likely need to change if anything about the
// random number generator changes
const auto targetInode = [](int count) {
ox::Random rand;
uint64_t retval = 0;
for (int i = 0; i < count; i++) {
retval = rand.gen();
}
return retval >> 48;
};
int retval = 0;
auto path = "/usr/share/test.txt";
auto data = "test";
auto dataIn = "test string";
auto dataOutLen = ox_strlen(dataIn) + 1;
char dataOut[dataOutLen];
const auto size = 1024 * 1024 * 10;
auto buff = new uint8_t[size];
@@ -156,8 +147,9 @@ map<string, int(*)(string)> tests = {
retval |= fs->mkdir("/usr/share");
retval |= fs->mkdir("/usr/lib");
retval |= fs->write(path, &data, ox_strlen(data) + 1);
retval |= !(fs->findInodeOf(path) == targetInode(5));
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;