diff options
| author | Egor Tensin <egor@tensin.name> | 2026-03-30 11:49:10 +0200 |
|---|---|---|
| committer | Egor Tensin <egor@tensin.name> | 2026-03-30 11:54:40 +0200 |
| commit | 4cd3a9cdf65a8f0b96de21420b98b8e02181e4f4 (patch) | |
| tree | 08b54a4313cdb41a883b244ffcbb423dbf7ced46 /test/scripts/verify_symbols.sh | |
| parent | remove examples "dynamic" & "static" (diff) | |
| download | cmake-common-4cd3a9cdf65a8f0b96de21420b98b8e02181e4f4.tar.gz cmake-common-4cd3a9cdf65a8f0b96de21420b98b8e02181e4f4.zip | |
move testing-only things into test/
Diffstat (limited to 'test/scripts/verify_symbols.sh')
| -rwxr-xr-x | test/scripts/verify_symbols.sh | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/test/scripts/verify_symbols.sh b/test/scripts/verify_symbols.sh new file mode 100755 index 0000000..73cc6ba --- /dev/null +++ b/test/scripts/verify_symbols.sh @@ -0,0 +1,43 @@ +#!/usr/bin/env bash + +set -o errexit -o nounset -o pipefail + +script_name="$( basename -- "${BASH_SOURCE[0]}" )" +readonly script_name + +main() { + if [ "$#" -lt 1 ]; then + echo "usage: $script_name BIN_PATH [SYMBOL...]" >&2 + return 1 + fi + + local path="$1" + shift + + local nm + nm="$( nm --demangle -- "$path" 2>&1 )" + + if [ "$#" -eq 0 ]; then + if [ "$nm" == "nm: $path: no symbols" ]; then + echo "$script_name: file '$path' has no symbols, as expected" + return 0 + else + echo "$script_name: file '$path' should not have symbols, but it does" >&2 + return 1 + fi + fi + + local symbol + for symbol; do + if echo "$nm" | grep -F -e " $symbol"; then + echo "$script_name: file '$path' has symbol '$symbol'" + else + echo "$script_name: symbol '$symbol' wasn't found in file '$path'" + echo "$script_name: here's the complete symbol list:" + echo "$nm" + return 1 + fi + done +} + +main "$@" |
