diff options
author | fanquake <fanquake@gmail.com> | 2020-12-10 11:27:32 +0800 |
---|---|---|
committer | fanquake <fanquake@gmail.com> | 2020-12-10 11:33:36 +0800 |
commit | 054710615c5e96b24046ddd9a3c58f601419d35b (patch) | |
tree | d26b8502d72ee1769d30394dea50544adaaa4b86 | |
parent | 17918a987aee4ed380758a5b2b1b0782b587d59f (diff) | |
parent | ae9b48995bff505ea2b771313cac65d9acf6f29e (diff) |
Merge #20608: contrib: add symbol check test for PE binaries
ae9b48995bff505ea2b771313cac65d9acf6f29e contrib: add symbol check test for PE (fanquake)
Pull request description:
Follow up to #20476. Adds a test for the PE symbol check. One failing case where we link against `-lpdh` and a pass case.
ACKs for top commit:
laanwj:
Code review ACK ae9b48995bff505ea2b771313cac65d9acf6f29e
dongcarl:
Code Review ACK ae9b48995bff505ea2b771313cac65d9acf6f29e
Tree-SHA512: 14109d2c7cb98fb445fe1a7f3078e1e88c49fd29583529c53c75bb625f3060d43df0c64542df72272cff81e1b073f74ce6e437ad0e6617ba2bcccacfd1dc8e53
-rw-r--r-- | Makefile.am | 1 | ||||
-rwxr-xr-x | contrib/devtools/test-symbol-check.py | 37 |
2 files changed, 38 insertions, 0 deletions
diff --git a/Makefile.am b/Makefile.am index dcd4bce0a2..162e0fff00 100644 --- a/Makefile.am +++ b/Makefile.am @@ -350,6 +350,7 @@ if TARGET_DARWIN endif if TARGET_WINDOWS $(AM_V_at) $(PYTHON) $(top_srcdir)/contrib/devtools/test-security-check.py TestSecurityChecks.test_PE + $(AM_V_at) $(PYTHON) $(top_srcdir)/contrib/devtools/test-symbol-check.py TestSymbolChecks.test_PE endif if TARGET_LINUX $(AM_V_at) $(PYTHON) $(top_srcdir)/contrib/devtools/test-security-check.py TestSecurityChecks.test_ELF diff --git a/contrib/devtools/test-symbol-check.py b/contrib/devtools/test-symbol-check.py index b07ec2ffdf..18ed7d61e0 100755 --- a/contrib/devtools/test-symbol-check.py +++ b/contrib/devtools/test-symbol-check.py @@ -120,6 +120,43 @@ class TestSymbolChecks(unittest.TestCase): self.assertEqual(call_symbol_check(cc, source, executable, ['-framework', 'CoreGraphics']), (0, '')) + def test_PE(self): + source = 'test1.c' + executable = 'test1.exe' + cc = 'x86_64-w64-mingw32-gcc' + + with open(source, 'w', encoding="utf8") as f: + f.write(''' + #include <pdh.h> + + int main() + { + PdhConnectMachineA(NULL); + return 0; + } + ''') + + self.assertEqual(call_symbol_check(cc, source, executable, ['-lpdh']), + (1, 'pdh.dll is not in ALLOWED_LIBRARIES!\n' + + executable + ': failed DYNAMIC_LIBRARIES')) + + source = 'test2.c' + executable = 'test2.exe' + with open(source, 'w', encoding="utf8") as f: + f.write(''' + #include <windows.h> + + int main() + { + CoFreeUnusedLibrariesEx(0,0); + return 0; + } + ''') + + self.assertEqual(call_symbol_check(cc, source, executable, ['-lole32']), + (0, '')) + + if __name__ == '__main__': unittest.main() |