From 02c370110dea06e2aae58f3c9439b837a946b548 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Doktor?= Date: Mon, 4 Jul 2016 11:24:04 +0200 Subject: [PATCH 1/2] selftests: Handle superuser in test_archive correctly MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The superusers default permission is 0o644 while other users is 0o664. This is not handled by zipfile yet so adjust the unittest for now and see what we can do about this in our utils.archive later. Signed-off-by: Lukáš Doktor --- selftests/unit/test_archive.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/selftests/unit/test_archive.py b/selftests/unit/test_archive.py index 76c10fa4df..8cc0b274dd 100644 --- a/selftests/unit/test_archive.py +++ b/selftests/unit/test_archive.py @@ -125,12 +125,15 @@ def get_path(*args): self.assertEqual(os.path.realpath(get_path("link_to_dir")), get_path("dir")) # File permissions + # TODO: Handle permission correctly for all users + # Default perm by user is 0o664 and by root 0o644 + default_perm = 0o664 if os.getuid() else 0o644 self.assertEqual(os.stat(get_path("dir", "file2")).st_mode & 0o777, - 0o664) + default_perm) self.assertEqual(os.stat(get_path("file")).st_mode & 0o777, 0o753) self.assertEqual(os.stat(get_path("dir")).st_mode & 0o777, 0o775) self.assertEqual(os.stat(get_path("link_to_file2")).st_mode & 0o777, - 0o664) + default_perm) self.assertEqual(os.stat(get_path("link_to_dir")).st_mode & 0o777, 0o775) self.assertEqual(os.stat(get_path("link_to_file")).st_mode & 0o777, From d43998ea9975d1f4d2fc6922865e86525b7c7874 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Doktor?= Date: Mon, 4 Jul 2016 11:24:07 +0200 Subject: [PATCH 2/2] selftests: Skip partitions test when mkfs not available MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This test requires mkfs binary in order to run, while it's not really essential for avocado testing. Let's skip it when it's not available. Signed-off-by: Lukáš Doktor --- selftests/unit/test_utils_partition.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/selftests/unit/test_utils_partition.py b/selftests/unit/test_utils_partition.py index 580d2bbb0a..26a11e40d0 100644 --- a/selftests/unit/test_utils_partition.py +++ b/selftests/unit/test_utils_partition.py @@ -26,6 +26,8 @@ class TestPartition(unittest.TestCase): Unit tests for avocado.utils.partition """ + @unittest.skipIf(process.system("which mkfs", ignore_status=True), + "mkfs is required for these tests to run.") def setUp(self): try: process.system("/bin/true", sudo=True)