blob: 136e3facd1a302f06351750edb4774070022bce3 (
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
#!/usr/bin/python3
import unittest
import subprocess
import os
import shutil
def call(cmd):
return subprocess.call(cmd, shell=True)
#enddef
class UnionFSTestCase(unittest.TestCase):
def setUp(self):
os.mkdir('ro')
os.mkdir('rw')
os.mkdir('union')
call('src/unionfs -o cow rw=rw:ro=ro union')
#enddef
def tearDown(self):
call('fusermount -u union')
shutil.rmtree('union')
shutil.rmtree('rw')
shutil.rmtree('ro')
#endef
def test_listing(self):
with open('ro/ro_file', 'w') as f:
f.write('ro_file')
#endwith
with open('rw/rw_file', 'w') as f:
f.write('rw_file')
#endwith
self.assertTrue(set(['ro_file', 'rw_file']) == set(os.listdir('union')))
os.remove('rw/rw_file')
os.remove('ro/ro_file')
#enddef
#endclass
class StatsTestCase(unittest.TestCase):
def setUp(self):
os.mkdir('ro')
os.mkdir('rw')
os.mkdir('union')
call('src/unionfs -o stats rw=rw:ro=ro union')
#enddef
def tearDown(self):
call('fusermount -u union')
shutil.rmtree('union')
shutil.rmtree('rw')
shutil.rmtree('ro')
#enddef
def test_stats_file_exists(self):
self.assertTrue('stats' in os.listdir('union'))
#enddef
#endclass
if __name__ == '__main__':
unittest.main()
#endif
|