summaryrefslogtreecommitdiff
path: root/testing/cffi1/test_cffi_binary.py
blob: 2fb042cee81943690009c77e064b1ce626b951e2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import sys, os
import pytest
import _cffi_backend
from testing.support import is_musl

def test_no_unknown_exported_symbols():
    if not hasattr(_cffi_backend, '__file__'):
        pytest.skip("_cffi_backend module is built-in")
    if not sys.platform.startswith('linux') or is_musl:
        pytest.skip("linux-only")
    g = os.popen("objdump -T '%s'" % _cffi_backend.__file__, 'r')
    for line in g:
        if not line.startswith('0'):
            continue
        if line[line.find(' ') + 1] == 'l':
            continue
        if '*UND*' in line:
            continue
        name = line.split()[-1]
        if name.startswith('_') or name.startswith('.'):
            continue
        # a statically-linked libffi will always appear here without header hackage, ignore it if it's internal
        if name.startswith('ffi_') and 'Base' in line:
            continue
        if name not in ('init_cffi_backend', 'PyInit__cffi_backend', 'cffistatic_ffi_call'):
            raise Exception("Unexpected exported name %r" % (name,))
    g.close()