aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfanquake <fanquake@gmail.com>2020-12-09 22:33:31 +0800
committerfanquake <fanquake@gmail.com>2020-12-09 23:13:24 +0800
commitae9b48995bff505ea2b771313cac65d9acf6f29e (patch)
treed15de382ea89010da02423434b59a1fd6186289d
parent795afe6e63a173a22597a59606e1c58d34cb3f1a (diff)
downloadbitcoin-ae9b48995bff505ea2b771313cac65d9acf6f29e.tar.xz
contrib: add symbol check test for PE
-rw-r--r--Makefile.am1
-rwxr-xr-xcontrib/devtools/test-symbol-check.py37
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()