From 04c39ad56226815f06c7464dc757b20a89e4442b Mon Sep 17 00:00:00 2001 From: Filipe Brandenburger Date: Wed, 25 Apr 2018 00:15:26 -0700 Subject: [PATCH] Add extended unit test for 'install_mode' This new unit test will use the targets in '198 install_mode' and confirm that every file and directory gets the expected mode, ensuring that the setting is properly applied at install time. --- run_unittests.py | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/run_unittests.py b/run_unittests.py index 061e40e10..b599a5f10 100755 --- a/run_unittests.py +++ b/run_unittests.py @@ -2787,6 +2787,39 @@ class LinuxlikeTests(BasePlatformTests): # The chown failed nonfatally if we're not root self.assertEqual(0, statf.st_uid) + def test_installed_modes_extended(self): + ''' + Test that files are installed with correct permissions using install_mode. + ''' + testdir = os.path.join(self.common_test_dir, '201 install_mode') + self.init(testdir) + self.build() + self.install() + + for fsobj, want_mode in [ + ('bin', 'drwxr-x---'), + ('bin/runscript.sh', '-rwxr-sr-x'), + ('bin/trivialprog', '-rwxr-sr-x'), + ('include', 'drwxr-x---'), + ('include/config.h', '-rw-rwSr--'), + ('include/rootdir.h', '-r--r--r-T'), + ('lib', 'drwxr-x---'), + ('lib/libstat.a', '-rw---Sr--'), + ('share', 'drwxr-x---'), + ('share/man', 'drwxr-x---'), + ('share/man/man1', 'drwxr-x---'), + ('share/man/man1/foo.1.gz', '-r--r--r-T'), + ('share/sub1', 'drwxr-x---'), + ('share/sub1/second.dat', '-rwxr-x--t'), + ('subdir', 'drwxr-x---'), + ('subdir/data.dat', '-rw-rwSr--'), + ]: + f = os.path.join(self.installdir, 'usr', *fsobj.split('/')) + found_mode = stat.filemode(os.stat(f).st_mode) + self.assertEqual(want_mode, found_mode, + msg=('Expected file %s to have mode %s but found %s instead.' % + (fsobj, want_mode, found_mode))) + def test_install_umask(self): ''' Test that files are installed with correct permissions using default