summaryrefslogtreecommitdiff
path: root/tests/test-symbols.sh
blob: 18e13e9f57f9de220beb99c91758e6dfa2d7168c (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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/bin/bash
#
# Copyright (C) 2016 Colin Walters <walters@verbum.org>
#
# SPDX-License-Identifier: LGPL-2.0+
#
# 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, see <https://www.gnu.org/licenses/>.

set -xeuo pipefail

. $(dirname $0)/libtest.sh

echo '1..3'

released_syms=${G_TEST_SRCDIR}/src/libostree/libostree-released.sym
if echo "$OSTREE_FEATURES" | grep --quiet --no-messages "devel"; then
    devel_syms=${G_TEST_SRCDIR}/src/libostree/libostree-devel.sym
else
    devel_syms=
fi

echo "Verifying all expected symbols are actually exported..."
grep --no-filename ' ostree_[A-Za-z0-9_]*;' ${released_syms} ${devel_syms} | 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
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.
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:"
grep --no-filename '^ostree_' ${G_TEST_SRCDIR}/apidoc/ostree-sections.txt |sort -u > found-documented.txt
diff -u expected-documented.txt found-documented.txt

echo 'ok documented symbols'

# ONLY update this checksum in release commits!
cat > released-sha256.txt <<EOF
165d3d940b7e6e09f39221b983fd17efae8ae40b8b2136a84b422a21e402f771  ${released_syms}
EOF
sha256sum -c released-sha256.txt

echo "ok someone didn't add a symbol to a released version"