tricu

A lazy functional language based on Tree Calculus
Log | Files | Refs | README | LICENSE

test_exports.py (895B)


      1 """Fresh-process checks of the complete C surface."""
      2 import ctypes
      3 import sys
      4 import subprocess
      5 
      6 library = ctypes.CDLL(sys.argv[1])
      7 core_names = ('init', 'abi_version', 'context_new', 'context_free', 'retain',
      8              'release', 'leaf', 'stem', 'fork', 'apply', 'reduce', 'kind', 'child',
      9              'from_u64', 'to_u64', 'to_bool', 'from_bytes', 'to_bytes',
     10              'from_utf8', 'to_utf8', 'last_error', 'buffer_free')
     11 for name in core_names:
     12     assert getattr(library, 'tricu_' + name)
     13 for name in ('load_bundle', 'run_io'):
     14     assert getattr(library, 'tricu_' + name)
     15 
     16 if len(sys.argv) > 2 and sys.argv[2] == 'public-only':
     17     symbols = subprocess.check_output(['nm', '-D', '--defined-only', sys.argv[1]], text=True)
     18     expected = core_names + ('load_bundle', 'run_io')
     19     assert {line.split()[-1] for line in symbols.splitlines()} == {'tricu_' + name for name in expected}