From c80fb3a9c8f84f2a57c02ccdfe39d5a012dc0ec7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Doktor?= Date: Mon, 4 Jul 2016 14:01:01 +0200 Subject: [PATCH 1/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 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/selftests/unit/test_utils_partition.py b/selftests/unit/test_utils_partition.py index 26a11e40d0..30adbbde26 100644 --- a/selftests/unit/test_utils_partition.py +++ b/selftests/unit/test_utils_partition.py @@ -26,8 +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.") + @unittest.skipIf(process.system("which mkfs.ext3", ignore_status=True), + "mkfs.ext3 is required for these tests to run.") def setUp(self): try: process.system("/bin/true", sudo=True) From 8f681f960e0cfcf004d5edd695b0a5e1fe23a7f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Doktor?= Date: Mon, 4 Jul 2016 14:01:04 +0200 Subject: [PATCH 2/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 | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/selftests/unit/test_archive.py b/selftests/unit/test_archive.py index 8cc0b274dd..89e01ebddc 100644 --- a/selftests/unit/test_archive.py +++ b/selftests/unit/test_archive.py @@ -105,6 +105,9 @@ def get_path(*args): zip_path = os.path.abspath(os.path.join(os.path.dirname(__file__), os.path.pardir, ".data", "test_archive__symlinks.zip")) + # TODO: Handle permission correctly for all users + # The umask is not yet handled by utils.archive, hardcode it for now + os.umask(2) archive.uncompress(zip_path, self.decompressdir) self.assertTrue(os.path.islink(get_path("link_to_dir"))) self.assertTrue(os.path.islink(get_path("link_to_file"))) @@ -125,15 +128,12 @@ 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, - default_perm) + 0o664) 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, - default_perm) + 0o664) 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,