diff options
author | Radek Podgorny <radek@podgorny.cz> | 2014-04-11 11:21:49 +0200 |
---|---|---|
committer | Radek Podgorny <radek@podgorny.cz> | 2014-04-11 11:21:49 +0200 |
commit | 0c13bbf72030e75d8262ec13f096629bb538a142 (patch) | |
tree | 8c5bc6490efe023de41209eb696d02e6a24aa3c2 | |
parent | 81add20e7f07ff41a710354e72ad59e667ca20de (diff) | |
download | unionfs-fuse-0c13bbf72030e75d8262ec13f096629bb538a142.tar.gz |
added some preliminary testing code (in python)
-rwxr-xr-x | test.py | 73 |
1 files changed, 73 insertions, 0 deletions
@@ -0,0 +1,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 |