summaryrefslogtreecommitdiff
path: root/test/src/mbgl/test/ramdisk.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'test/src/mbgl/test/ramdisk.hpp')
-rw-r--r--test/src/mbgl/test/ramdisk.hpp39
1 files changed, 39 insertions, 0 deletions
diff --git a/test/src/mbgl/test/ramdisk.hpp b/test/src/mbgl/test/ramdisk.hpp
new file mode 100644
index 0000000000..728a87d6e4
--- /dev/null
+++ b/test/src/mbgl/test/ramdisk.hpp
@@ -0,0 +1,39 @@
+#pragma once
+
+#include <cstdio>
+
+#ifdef __APPLE__
+#include <TargetConditionals.h>
+#endif
+
+#if TARGET_OS_OSX
+#define TEST_HAS_RAMDISK 1
+#else
+#define TEST_HAS_RAMDISK 0
+#endif
+
+namespace mbgl {
+namespace test {
+
+#if TEST_HAS_RAMDISK
+
+class RamDisk {
+public:
+ RamDisk(size_t size = 1024 * 1024);
+ ~RamDisk();
+ void setReadOnly();
+ void setReadWrite();
+ void fillDiskExceptFor(size_t remaining = 0);
+ void emptyDisk();
+
+private:
+ void write(const char* command);
+
+private:
+ FILE* child;
+};
+
+#endif
+
+} // namespace test
+} // namespace mbgl