Skip to content

Commit ed1bbce

Browse files
fanquakelaanwj
authored andcommitted
contrib: add MACHO tests to symbol-check tests
1 parent 5bab08d commit ed1bbce

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
@@ -353,6 +353,7 @@ clean-local: clean-docs
353353
test-security-check:
354354
if TARGET_DARWIN
355355
$(AM_V_at) $(PYTHON) $(top_srcdir)/contrib/devtools/test-security-check.py TestSecurityChecks.test_MACHO
356+
$(AM_V_at) $(PYTHON) $(top_srcdir)/contrib/devtools/test-symbol-check.py TestSymbolChecks.test_MACHO
356357
endif
357358
if TARGET_WINDOWS
358359
$(AM_V_at) $(PYTHON) $(top_srcdir)/contrib/devtools/test-security-check.py TestSecurityChecks.test_PE

contrib/devtools/test-symbol-check.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,43 @@ def test_ELF(self):
8383
self.assertEqual(call_symbol_check(cc, source, executable, ['-lm']),
8484
(0, ''))
8585

86+
def test_MACHO(self):
87+
source = 'test1.c'
88+
executable = 'test1'
89+
cc = 'clang'
90+
91+
with open(source, 'w', encoding="utf8") as f:
92+
f.write('''
93+
#include <expat.h>
94+
95+
int main()
96+
{
97+
XML_ExpatVersion();
98+
return 0;
99+
}
100+
101+
''')
102+
103+
self.assertEqual(call_symbol_check(cc, source, executable, ['-lexpat']),
104+
(1, 'libexpat.1.dylib is not in ALLOWED_LIBRARIES!\n' +
105+
executable + ': failed DYNAMIC_LIBRARIES'))
106+
107+
source = 'test2.c'
108+
executable = 'test2'
109+
with open(source, 'w', encoding="utf8") as f:
110+
f.write('''
111+
#include <CoreGraphics/CoreGraphics.h>
112+
113+
int main()
114+
{
115+
CGMainDisplayID();
116+
return 0;
117+
}
118+
''')
119+
120+
self.assertEqual(call_symbol_check(cc, source, executable, ['-framework', 'CoreGraphics']),
121+
(0, ''))
122+
86123
if __name__ == '__main__':
87124
unittest.main()
88125

0 commit comments

Comments
 (0)