Merge #13094: tests: Add test for 64-bit Windows PE, modify 32-bit test results

ab3f4dd tests: Add test for 64-bit PE, modify 32-bit test results (Chun Kuan Lee)

Pull request description:

  9a75d29b6f change the error result from `PIE` to `DYNAMIC_BASE`. And there are no test for 64-bit, so I made one

Tree-SHA512: 9d5643dadf4d9fc34ea32d94655bfb98eec2f7bc2820b4b0f525d5acf1cd22f3acf38bf8904dda4f50fd9ca5a5e56d566a392e6f804eea6e50e03cba40048621
This commit is contained in:
Wladimir J. van der Laan 2018-05-07 15:14:33 +02:00
commit bf9b03ddcc
No known key found for this signature in database
GPG key ID: 1E4AED62986CD25D

View file

@ -43,18 +43,28 @@ class TestSecurityChecks(unittest.TestCase):
self.assertEqual(call_security_check(cc, source, executable, ['-Wl,-znoexecstack','-fstack-protector-all','-Wl,-zrelro','-Wl,-z,now','-pie','-fPIE']), self.assertEqual(call_security_check(cc, source, executable, ['-Wl,-znoexecstack','-fstack-protector-all','-Wl,-zrelro','-Wl,-z,now','-pie','-fPIE']),
(0, '')) (0, ''))
def test_PE(self): def test_32bit_PE(self):
source = 'test1.c' source = 'test1.c'
executable = 'test1.exe' executable = 'test1.exe'
cc = 'i686-w64-mingw32-gcc' cc = 'i686-w64-mingw32-gcc'
write_testcode(source) write_testcode(source)
self.assertEqual(call_security_check(cc, source, executable, []), self.assertEqual(call_security_check(cc, source, executable, []),
(1, executable+': failed PIE NX')) (1, executable+': failed DYNAMIC_BASE NX'))
self.assertEqual(call_security_check(cc, source, executable, ['-Wl,--nxcompat']), self.assertEqual(call_security_check(cc, source, executable, ['-Wl,--nxcompat']),
(1, executable+': failed PIE')) (1, executable+': failed DYNAMIC_BASE'))
self.assertEqual(call_security_check(cc, source, executable, ['-Wl,--nxcompat','-Wl,--dynamicbase']), self.assertEqual(call_security_check(cc, source, executable, ['-Wl,--nxcompat','-Wl,--dynamicbase']),
(0, '')) (0, ''))
def test_64bit_PE(self):
source = 'test1.c'
executable = 'test1.exe'
cc = 'x86_64-w64-mingw32-gcc'
write_testcode(source)
self.assertEqual(call_security_check(cc, source, executable, []), (1, executable+': failed DYNAMIC_BASE NX\n'+executable+': warning HIGH_ENTROPY_VA'))
self.assertEqual(call_security_check(cc, source, executable, ['-Wl,--nxcompat']), (1, executable+': failed DYNAMIC_BASE\n'+executable+': warning HIGH_ENTROPY_VA'))
self.assertEqual(call_security_check(cc, source, executable, ['-Wl,--nxcompat','-Wl,--dynamicbase']), (0, executable+': warning HIGH_ENTROPY_VA'))
self.assertEqual(call_security_check(cc, source, executable, ['-Wl,--nxcompat','-Wl,--dynamicbase','-Wl,--high-entropy-va']), (0, ''))
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()