summaryrefslogtreecommitdiff
path: root/test/src/mbgl/test/sqlite3_test_fs.hpp
blob: 00351f49ac2490202f9e4098bf42b3dc4cf853f4 (plain)
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
34
35
36
37
38
39
#pragma once

#include <cstdint>

namespace mbgl {
namespace test {

class SQLite3TestFS {
public:
    SQLite3TestFS();
    ~SQLite3TestFS();

    // When enabled, the VFS will log all I/O operations to stdout.
    void setDebug(bool);

    // Allow any type of I/O. Will fail with SQLITE_AUTH if set to false. This is useful to simulate
    // scenarios where the OS blocks an entire app's I/O, e.g. when it's in the background.
    void allowIO(bool);
    
    // Allow files to be opened. Will fail with SQLITE_CANTOPEN if set to false.
    void allowFileOpen(bool);
    
    // Allow files to be created. Will fail with SQLITE_CANTOPEN if set to false.
    void allowFileCreate(bool);
    
    // Allow N bytes to be read, then fail reads with SQLITE_IOERR. -1 == unlimited
    // This limit is global, not per file.
    void setReadLimit(int64_t);
    
    // Allow N bytes to be written, then fail writes with SQLITE_FULL. -1 == unlimited
    // This limit is global, not per file.
    void setWriteLimit(int64_t);
    
    // Reset all restrictions.
    void reset();
};

} // namespace test
} // namespace mbgl