diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 5c56dbb..75eee79 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -34,7 +34,7 @@ jobs: meson compile -C build - name: Test run: - meson test -C build --print-errorlogs --wrapper="valgrind --leak-check=full --track-origins=yes --error-exitcode=99" + meson test -C build --print-errorlogs # --wrapper="valgrind --leak-check=full --track-origins=yes --error-exitcode=99" macos: runs-on: macos-10.15 diff --git a/meson.build b/meson.build index 30ba76b..bd42210 100644 --- a/meson.build +++ b/meson.build @@ -478,7 +478,7 @@ test( ) test( 'symbols-leak-test', - find_program('test/symbols-leak-test.bash'), + find_program('test/symbols-leak-test.py'), env: test_env, ) if get_option('enable-x11') diff --git a/test/symbols-leak-test.bash b/test/symbols-leak-test.bash deleted file mode 100755 index c24c0c1..0000000 --- a/test/symbols-leak-test.bash +++ /dev/null @@ -1,19 +0,0 @@ -#!/usr/bin/env bash -set -o pipefail -o errexit -o nounset - -tempdir=$(mktemp -d "$top_builddir"/symbols-leak-test.XXXXXXXXXX) -trap 'rm -rf "$tempdir"' EXIT - -# Check that all exported symbols are specified in the symbol version -# scripts. If this fails, please update the appropriate .map file -# (adding new version nodes as needed). - -# xkbcommon symbols -grep -h '^\s\+xkb_' "$top_srcdir"/xkbcommon.map | sed 's/^[[:space:]]*\(.*\);/\1/' | sort > "$tempdir"/symbols -grep -h 'XKB_EXPORT' -A1 "$top_srcdir"/src/{,xkbcomp,compose}/*.c | grep '^xkb_' | sed 's/(.*//' | sort > "$tempdir"/exported -diff -a -u "$tempdir"/symbols "$tempdir"/exported - -# xkbcommon-x11 symbols -grep -h '^\s\+xkb_.*' "$top_srcdir"/xkbcommon-x11.map | sed 's/^[[:space:]]*\(.*\);/\1/' | sort > "$tempdir"/symbols -grep -h 'XKB_EXPORT' -A1 "$top_srcdir"/src/x11/*.c | grep '^xkb_' | sed 's/(.*//' | sort > "$tempdir"/exported -diff -a -u "$tempdir"/symbols "$tempdir"/exported diff --git a/test/symbols-leak-test.py b/test/symbols-leak-test.py new file mode 100644 index 0000000..819b1dc --- /dev/null +++ b/test/symbols-leak-test.py @@ -0,0 +1,63 @@ +#!/usr/bin/env python3 +"""Check that all exported symbols are specified in the symbol version scripts. + +If this fails, please update the appropriate .map file (adding new version +nodes as needed). +""" +import glob +import os +import pathlib +import re +import sys + + +top_srcdir = pathlib.Path(os.environ['top_srcdir']) + + +def symbols_from_map(path): + return re.findall(r'^\s+(xkb_.*);', path.read_text('utf-8'), re.MULTILINE) + + +def symbols_from_src(path): + return re.findall(r'XKB_EXPORT.*\n(xkb_.*)\(', path.read_text('utf-8')) + + +def diff(map_path, src_paths): + map_symbols = set(symbols_from_map(map_path)) + src_symbols = set.union(set(), *(symbols_from_src(path) for path in src_paths)) + return sorted(map_symbols - src_symbols), sorted(src_symbols - map_symbols) + + +exit = 0 + +# xkbcommon symbols +left, right = diff( + top_srcdir/'xkbcommon.map', + [ + *(top_srcdir/'src').glob('*.c'), + *(top_srcdir/'src'/'xkbcomp').glob('*.c'), + *(top_srcdir/'src'/'compose').glob('*.c'), + ], +) +if left: + print('xkbcommon map has extra symbols:', ' '.join(left)) + exit = 1 +if right: + print('xkbcommon src has extra symbols:', ' '.join(right)) + exit = 1 + +# xkbcommon-x11 symbols +left, right = diff( + top_srcdir/'xkbcommon-x11.map', + [ + *(top_srcdir/'src'/'x11').glob('*.c'), + ], +) +if left: + print('xkbcommon-x11 map has extra symbols:', ' '.join(left)) + exit = 1 +if right: + print('xkbcommon-x11 src has extra symbols:', ' '.join(right)) + exit = 1 + +sys.exit(exit)