2016-03-23 15:18:27 -04:00
#!/bin/bash
#
# Copyright (C) 2016 Colin Walters <walters@verbum.org>
#
2018-01-30 20:26:26 +01:00
# SPDX-License-Identifier: LGPL-2.0+
#
2016-03-23 15:18:27 -04:00
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the
# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
# Boston, MA 02111-1307, USA.
2017-06-14 21:44:04 -04:00
set -xeuo pipefail
2016-03-23 15:18:27 -04:00
2020-06-17 14:35:18 -07:00
. $( dirname $0 ) /libtest.sh
2017-06-14 21:44:04 -04:00
echo '1..3'
2016-03-23 15:18:27 -04:00
2017-06-14 21:44:04 -04:00
released_syms = ${ G_TEST_SRCDIR } /src/libostree/libostree-released.sym
2017-06-20 17:38:15 +01:00
if echo " $OSTREE_FEATURES " | grep --quiet --no-messages "devel" ; then
2017-06-19 11:23:45 -04:00
devel_syms = ${ G_TEST_SRCDIR } /src/libostree/libostree-devel.sym
else
devel_syms =
fi
2017-05-01 10:59:33 +01:00
if echo " $OSTREE_FEATURES " | grep --quiet --no-messages "experimental" ; then
experimental_sym = " ${ G_TEST_SRCDIR } /src/libostree/libostree-experimental.sym "
experimental_sections = " ${ G_TEST_SRCDIR } /apidoc/ostree-experimental-sections.txt "
else
experimental_sym = ""
experimental_sections = ""
fi
2016-04-15 15:49:05 -04:00
echo "Verifying all expected symbols are actually exported..."
2017-06-14 21:44:04 -04:00
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
2017-05-01 10:59:33 +01:00
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
2016-03-23 15:18:27 -04:00
diff -u expected-symbols.txt found-symbols.txt
2020-06-17 14:35:18 -07:00
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"
2016-04-15 15:49:05 -04:00
echo "ok exports"
2016-03-23 15:18:27 -04:00
2016-04-15 15:49:05 -04:00
# cmd__private__ is private. The fetcher symbol should not have been made public.
grep -E -v '(ostree_cmd__private__)|(ostree_fetcher_config_flags_get_type)' found-symbols.txt > expected-documented.txt
echo "Verifying all public symbols are documented:"
2017-05-19 11:00:34 -04:00
grep --no-filename '^ostree_' ${ G_TEST_SRCDIR } /apidoc/ostree-sections.txt $experimental_sections | sort -u > found-documented.txt
2016-04-15 15:49:05 -04:00
diff -u expected-documented.txt found-documented.txt
echo 'ok documented symbols'
2017-06-14 21:44:04 -04:00
# ONLY update this checksum in release commits!
cat > released-sha256.txt <<EOF
2020-09-25 15:01:09 -04:00
f341345be2da30ab8043ac3d555f75edaae25aaad9f81a933fb4e33a47fe7cc4 ${ released_syms }
2017-06-14 21:44:04 -04:00
EOF
sha256sum -c released-sha256.txt
echo "ok someone didn't add a symbol to a released version"