libcryfs/test/fspp/fuse/statfs/testutils/FuseStatfsTest.h

35 lines
1.5 KiB
C
Raw Normal View History

2014-11-28 22:11:26 +01:00
#pragma once
2015-10-15 13:04:57 +02:00
#ifndef MESSMER_FSPP_TEST_FUSE_STATFS_TESTUTILS_FUSESTATFSTEST_H_
#define MESSMER_FSPP_TEST_FUSE_STATFS_TESTUTILS_FUSESTATFSTEST_H_
2014-11-28 22:11:26 +01:00
#include <string>
#include <functional>
#include <sys/statvfs.h>
2015-02-17 00:48:49 +01:00
#include "../../../testutils/FuseTest.h"
2014-11-28 22:11:26 +01:00
// This class offers some utility functions for testing statfs().
class FuseStatfsTest: public FuseTest {
protected:
const char *FILENAME = "/myfile";
// Set up a temporary filesystem (using the fsimpl mock in FuseTest as filesystem implementation)
// and call the statfs syscall on the given (filesystem-relative) path.
void Statfs(const std::string &path);
// Same as Statfs above, but also return the result of the statfs syscall.
void Statfs(const std::string &path, struct ::statvfs *result);
// These two functions are the same as Statfs above, but they don't fail the test when the statfs syscall
// crashes. Instead, they return the result value of the statfs syscall.
int StatfsReturnError(const std::string &path);
int StatfsReturnError(const std::string &path, struct ::statvfs *result);
2014-11-28 22:11:26 +01:00
// You can specify an implementation, which can modify the (struct statfs *) result,
// our fuse mock filesystem implementation will then return this to fuse on an statfs call.
// This functions then set up a temporary filesystem with this mock, calls statfs on a filesystem node
// and returns the (struct statfs) returned from an statfs syscall to this filesystem.
struct ::statvfs CallStatfsWithImpl(std::function<void(struct ::statvfs*)> implementation);
};
#endif