diff options
Diffstat (limited to 'tests/helpers/check_exports.py')
| -rw-r--r-- | tests/helpers/check_exports.py | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/tests/helpers/check_exports.py b/tests/helpers/check_exports.py index 0d10014..acb727d 100644 --- a/tests/helpers/check_exports.py +++ b/tests/helpers/check_exports.py @@ -9,6 +9,7 @@ import subprocess def main(): parser = argparse.ArgumentParser(description=__doc__) parser.add_argument('--allow-export', action='append', default=[]) + parser.add_argument('--platform', choices=['linux', 'darwin'], default='linux') parser.add_argument('nm') parser.add_argument('library') parser.add_argument('headers', nargs='+') @@ -23,10 +24,14 @@ def main(): if not expected: raise SystemExit("No public function declarations found") - output = subprocess.check_output( - [args.nm, "-D", "--defined-only", "--format=posix", args.library], text=True - ) + nm_options = ["-g", "-U", "-P"] if args.platform == 'darwin' else [ + "-D", "--defined-only", "--format=posix" + ] + output = subprocess.check_output([args.nm, *nm_options, args.library], text=True) exported = {line.split()[0] for line in output.splitlines() if line.strip()} + if args.platform == 'darwin': + # Mach-O decorates C symbols with one leading underscore. + exported = {name[1:] if name.startswith('_') else name for name in exported} missing = expected - exported leaked = exported - expected - set(args.allow_export) if missing or leaked: |
