summaryrefslogtreecommitdiff
path: root/tests/t5_ctrl.py
blob: 48f1cbe84a6d381efe8e2c53c243379db1b38b9c (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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/usr/bin/env python3
'''
t5_ctrl.py - this file is part of S3QL.

Copyright © 2008 Nikolaus Rath <Nikolaus@rath.org>

This work can be distributed under the terms of the GNU GPLv3.
'''

if __name__ == '__main__':
    import pytest
    import sys
    sys.exit(pytest.main([__file__] + sys.argv[1:]))

import s3ql.ctrl
import sys
import t4_fuse

class TestCtrl(t4_fuse.TestFuse):

    def test(self):
        self.mkfs()
        self.mount()
        self.tst_ctrl_flush()
        self.tst_ctrl_drop()
        self.tst_ctrl_log()
        self.tst_ctrl_cachesize()
        self.umount()
        self.fsck()

    def tst_ctrl_flush(self):
        try:
            s3ql.ctrl.main(['flushcache', self.mnt_dir])
        except:
            sys.excepthook(*sys.exc_info())
            pytest.fail("s3qlctrl raised exception")

    def tst_ctrl_drop(self):
        try:
            s3ql.ctrl.main(['dropcache', self.mnt_dir])
        except:
            sys.excepthook(*sys.exc_info())
            pytest.fail("s3qlctrl raised exception")

    def tst_ctrl_log(self):
        try:
            s3ql.ctrl.main(['log', self.mnt_dir, 'warn'])
            s3ql.ctrl.main(['log', self.mnt_dir, 'debug', 's3ql', 'dugong'])
            s3ql.ctrl.main(['log', self.mnt_dir, 'info'])
        except:
            sys.excepthook(*sys.exc_info())
            pytest.fail("s3qlctrl raised exception")

    def tst_ctrl_cachesize(self):
        try:
            s3ql.ctrl.main(['cachesize', self.mnt_dir, '10240'])
        except:
            sys.excepthook(*sys.exc_info())
            pytest.fail("s3qlctrl raised exception")