From ed1bbcefeaafef460b6e5609de85e13c12e0d2a4 Mon Sep 17 00:00:00 2001 From: fanquake Date: Wed, 2 Dec 2020 16:39:44 +0800 Subject: [PATCH] contrib: add MACHO tests to symbol-check tests --- Makefile.am | 1 + contrib/devtools/test-symbol-check.py | 37 +++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/Makefile.am b/Makefile.am index 798f8b35240..ce8bff0f9a7 100644 --- a/Makefile.am +++ b/Makefile.am @@ -353,6 +353,7 @@ clean-local: clean-docs test-security-check: if TARGET_DARWIN $(AM_V_at) $(PYTHON) $(top_srcdir)/contrib/devtools/test-security-check.py TestSecurityChecks.test_MACHO + $(AM_V_at) $(PYTHON) $(top_srcdir)/contrib/devtools/test-symbol-check.py TestSymbolChecks.test_MACHO endif if TARGET_WINDOWS $(AM_V_at) $(PYTHON) $(top_srcdir)/contrib/devtools/test-security-check.py TestSecurityChecks.test_PE diff --git a/contrib/devtools/test-symbol-check.py b/contrib/devtools/test-symbol-check.py index 48abf60039e..b07ec2ffdf2 100755 --- a/contrib/devtools/test-symbol-check.py +++ b/contrib/devtools/test-symbol-check.py @@ -83,6 +83,43 @@ class TestSymbolChecks(unittest.TestCase): self.assertEqual(call_symbol_check(cc, source, executable, ['-lm']), (0, '')) + def test_MACHO(self): + source = 'test1.c' + executable = 'test1' + cc = 'clang' + + with open(source, 'w', encoding="utf8") as f: + f.write(''' + #include + + int main() + { + XML_ExpatVersion(); + return 0; + } + + ''') + + self.assertEqual(call_symbol_check(cc, source, executable, ['-lexpat']), + (1, 'libexpat.1.dylib is not in ALLOWED_LIBRARIES!\n' + + executable + ': failed DYNAMIC_LIBRARIES')) + + source = 'test2.c' + executable = 'test2' + with open(source, 'w', encoding="utf8") as f: + f.write(''' + #include + + int main() + { + CGMainDisplayID(); + return 0; + } + ''') + + self.assertEqual(call_symbol_check(cc, source, executable, ['-framework', 'CoreGraphics']), + (0, '')) + if __name__ == '__main__': unittest.main()