diff options
author | Nirbheek Chauhan <nirbheek@centricular.com> | 2020-01-12 22:49:43 +0530 |
---|---|---|
committer | Nirbheek Chauhan <nirbheek.chauhan@gmail.com> | 2020-01-22 19:34:05 +0530 |
commit | bd17c9ad4f75dde2dd65a06d7cba0dec7ee09c15 (patch) | |
tree | ae79cef2b92faae210f354b8b08e04242706d286 /run_unittests.py | |
parent | b293852d079f2ef873f757d72739e9e79195c1ec (diff) | |
download | meson-bd17c9ad4f75dde2dd65a06d7cba0dec7ee09c15.zip meson-bd17c9ad4f75dde2dd65a06d7cba0dec7ee09c15.tar.gz meson-bd17c9ad4f75dde2dd65a06d7cba0dec7ee09c15.tar.bz2 |
tests: Add a unit test for checksums
Adds a CI dependency on the `pefile` python module.
Diffstat (limited to 'run_unittests.py')
-rwxr-xr-x | run_unittests.py | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/run_unittests.py b/run_unittests.py index b2b2557..ad3d2a3 100755 --- a/run_unittests.py +++ b/run_unittests.py @@ -4655,6 +4655,34 @@ class WindowsTests(BasePlatformTests): def test_link_environment_variable_rust(self): self._check_ld('link', 'rust', 'link') + def test_pefile_checksum(self): + try: + import pefile + except ImportError: + if is_ci(): + raise + raise unittest.SkipTest('pefile module not found') + testdir = os.path.join(self.common_test_dir, '6 linkshared') + self.init(testdir) + self.build() + # Test that binaries have a non-zero checksum + env = get_fake_env() + cc = env.detect_c_compiler(MachineChoice.HOST) + cc_id = cc.get_id() + ld_id = cc.get_linker_id() + dll = glob(os.path.join(self.builddir, '*mycpplib.dll'))[0] + exe = os.path.join(self.builddir, 'cppprog.exe') + for f in (dll, exe): + pe = pefile.PE(f) + msg = 'PE file: {!r}, compiler: {!r}, linker: {!r}'.format(f, cc_id, ld_id) + if cc_id == 'clang-cl': + # Latest clang-cl tested (7.0) does not write checksums out + self.assertFalse(pe.verify_checksum(), msg=msg) + else: + # Verify that a valid checksum was written by all other compilers + self.assertTrue(pe.verify_checksum(), msg=msg) + + @unittest.skipUnless(is_osx(), "requires Darwin") class DarwinTests(BasePlatformTests): ''' |