tests: Check that example symbol isn't released

For the motivation for this see #2132.
This commit is contained in:
Matthew Leeds 2020-06-17 14:35:18 -07:00
parent 33c95812bb
commit d21181653e
2 changed files with 22 additions and 0 deletions

View File

@ -115,6 +115,16 @@ assert_file_has_content () {
done
}
assert_file_has_content_once () {
fpath=$1
shift
for re in "$@"; do
if ! test $(grep -e "$re" "$fpath" | wc -l) = "1"; then
_fatal_print_file "$fpath" "File '$fpath' doesn't match regexp '$re' exactly once"
fi
done
}
assert_file_has_content_literal () {
fpath=$1; shift
for s in "$@"; do

View File

@ -21,6 +21,8 @@
set -xeuo pipefail
. $(dirname $0)/libtest.sh
echo '1..3'
released_syms=${G_TEST_SRCDIR}/src/libostree/libostree-released.sym
@ -41,6 +43,16 @@ echo "Verifying all expected symbols are actually exported..."
grep --no-filename ' ostree_[A-Za-z0-9_]*;' ${released_syms} ${devel_syms} ${experimental_sym} | sed -e 's,^ *\([A-Za-z0-9_]*\);,\1,' | sort -u > expected-symbols.txt
eu-readelf -a ${G_TEST_BUILDDIR}/.libs/libostree-1.so | grep 'FUNC.*GLOBAL.*DEFAULT.*@@LIBOSTREE_' | sed -e 's,^.* \(ostree_[A-Za-z0-9_]*\)@@LIBOSTREE_[0-9A-Z_.]*,\1,' |sort -u > found-symbols.txt
diff -u expected-symbols.txt found-symbols.txt
echo "Checking that the example symbol wasn't copy-pasted..."
if test -f ${devel_syms}; then
assert_file_has_content_once ${devel_syms} "someostree_symbol_deleteme"
fi
if test -f ${experimental_sym}; then
assert_not_file_has_content ${experimental_sym} "someostree_symbol_deleteme"
fi
assert_not_file_has_content ${released_syms} "someostree_symbol_deleteme"
echo "ok exports"
# cmd__private__ is private. The fetcher symbol should not have been made public.