diff options
| author | jvoisin | 2015-12-03 14:42:21 +0100 |
|---|---|---|
| committer | jvoisin | 2015-12-03 14:42:21 +0100 |
| commit | 70ef290a5db26309bc9112e6007bee77331ddebe (patch) | |
| tree | ca29ac89cf531729428851c827e5cb26974e4da9 /test | |
| parent | 0d3ef2edd7accd04e0b7e39bbf303362b8e8e1c2 (diff) | |
Add some file-attribute related tests
Diffstat (limited to 'test')
| -rw-r--r-- | test/clitest.py | 9 | ||||
| -rw-r--r-- | test/libtest.py | 12 |
2 files changed, 21 insertions, 0 deletions
diff --git a/test/clitest.py b/test/clitest.py index ec3c19c..3b09c62 100644 --- a/test/clitest.py +++ b/test/clitest.py | |||
| @@ -10,6 +10,7 @@ import unittest | |||
| 10 | import subprocess | 10 | import subprocess |
| 11 | import sys | 11 | import sys |
| 12 | import tarfile | 12 | import tarfile |
| 13 | import stat | ||
| 13 | 14 | ||
| 14 | import test | 15 | import test |
| 15 | MAT_PATH = 'mat' | 16 | MAT_PATH = 'mat' |
| @@ -113,6 +114,14 @@ class TestFileAttributes(unittest.TestCase): | |||
| 113 | stdout, _ = proc.communicate() | 114 | stdout, _ = proc.communicate() |
| 114 | self.assertEqual(str(stdout).strip('\n'), '[-] Unable to process empty_file') | 115 | self.assertEqual(str(stdout).strip('\n'), '[-] Unable to process empty_file') |
| 115 | 116 | ||
| 117 | def test_not_readable(self): | ||
| 118 | """ test MAT's behaviour on non-writable file""" | ||
| 119 | open('non_readable', 'a').close() | ||
| 120 | os.chmod('non_readable', 0 & stat.S_IWRITE) | ||
| 121 | proc = subprocess.Popen([MAT_PATH, 'non_readable'], stdout=subprocess.PIPE) | ||
| 122 | stdout, _ = proc.communicate() | ||
| 123 | os.remove('non_readable') | ||
| 124 | |||
| 116 | 125 | ||
| 117 | class TestUnsupported(test.MATTest): | 126 | class TestUnsupported(test.MATTest): |
| 118 | """ test MAT's behaviour on unsupported files """ | 127 | """ test MAT's behaviour on unsupported files """ |
diff --git a/test/libtest.py b/test/libtest.py index 03ae4a1..fa65528 100644 --- a/test/libtest.py +++ b/test/libtest.py | |||
| @@ -7,6 +7,7 @@ | |||
| 7 | 7 | ||
| 8 | import os | 8 | import os |
| 9 | import sys | 9 | import sys |
| 10 | import stat | ||
| 10 | import shutil | 11 | import shutil |
| 11 | import tarfile | 12 | import tarfile |
| 12 | import tempfile | 13 | import tempfile |
| @@ -91,6 +92,17 @@ class TestFileAttributes(unittest.TestCase): | |||
| 91 | self.assertFalse(libmat.mat.create_class_file('empty_file', False, add2archive=True)) | 92 | self.assertFalse(libmat.mat.create_class_file('empty_file', False, add2archive=True)) |
| 92 | os.remove('empty_file') | 93 | os.remove('empty_file') |
| 93 | 94 | ||
| 95 | def test_not_writtable(self): | ||
| 96 | """ test MAT's behaviour on non-writable file""" | ||
| 97 | self.assertFalse(libmat.mat.create_class_file('not_writtable', False, add2archive=True)) | ||
| 98 | |||
| 99 | def test_not_readable(self): | ||
| 100 | """ test MAT's behaviour on non-readable file""" | ||
| 101 | open('non_readable', 'a').close() | ||
| 102 | os.chmod('non_readable', 0 | stat.S_IWRITE) | ||
| 103 | self.assertFalse(libmat.mat.create_class_file('non_readable', False, add2archive=True)) | ||
| 104 | os.remove('non_readable') | ||
| 105 | |||
| 94 | 106 | ||
| 95 | class TestSecureRemove(unittest.TestCase): | 107 | class TestSecureRemove(unittest.TestCase): |
| 96 | """ Test the secure_remove function | 108 | """ Test the secure_remove function |
