Skip to content

Commit ae9b489

Browse files
committed
contrib: add symbol check test for PE
1 parent 795afe6 commit ae9b489

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

Makefile.am

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,7 @@ if TARGET_DARWIN
350350
endif
351351
if TARGET_WINDOWS
352352
$(AM_V_at) $(PYTHON) $(top_srcdir)/contrib/devtools/test-security-check.py TestSecurityChecks.test_PE
353+
$(AM_V_at) $(PYTHON) $(top_srcdir)/contrib/devtools/test-symbol-check.py TestSymbolChecks.test_PE
353354
endif
354355
if TARGET_LINUX
355356
$(AM_V_at) $(PYTHON) $(top_srcdir)/contrib/devtools/test-security-check.py TestSecurityChecks.test_ELF

contrib/devtools/test-symbol-check.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,43 @@ def test_MACHO(self):
120120
self.assertEqual(call_symbol_check(cc, source, executable, ['-framework', 'CoreGraphics']),
121121
(0, ''))
122122

123+
def test_PE(self):
124+
source = 'test1.c'
125+
executable = 'test1.exe'
126+
cc = 'x86_64-w64-mingw32-gcc'
127+
128+
with open(source, 'w', encoding="utf8") as f:
129+
f.write('''
130+
#include <pdh.h>
131+
132+
int main()
133+
{
134+
PdhConnectMachineA(NULL);
135+
return 0;
136+
}
137+
''')
138+
139+
self.assertEqual(call_symbol_check(cc, source, executable, ['-lpdh']),
140+
(1, 'pdh.dll is not in ALLOWED_LIBRARIES!\n' +
141+
executable + ': failed DYNAMIC_LIBRARIES'))
142+
143+
source = 'test2.c'
144+
executable = 'test2.exe'
145+
with open(source, 'w', encoding="utf8") as f:
146+
f.write('''
147+
#include <windows.h>
148+
149+
int main()
150+
{
151+
CoFreeUnusedLibrariesEx(0,0);
152+
return 0;
153+
}
154+
''')
155+
156+
self.assertEqual(call_symbol_check(cc, source, executable, ['-lole32']),
157+
(0, ''))
158+
159+
123160
if __name__ == '__main__':
124161
unittest.main()
125162

0 commit comments

Comments
 (0)