File: FuseStatfsTest.h

package info (click to toggle)
cryfs 1.0.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 28,412 kB
  • sloc: cpp: 150,187; asm: 10,493; python: 1,455; javascript: 65; sh: 50; makefile: 17; xml: 7
file content (33 lines) | stat: -rw-r--r-- 1,531 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#pragma once
#ifndef MESSMER_FSPP_TEST_FUSE_STATFS_TESTUTILS_FUSESTATFSTEST_H_
#define MESSMER_FSPP_TEST_FUSE_STATFS_TESTUTILS_FUSESTATFSTEST_H_

#include <string>
#include <functional>

#include "../../../testutils/FuseTest.h"

// 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);

  // 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