051d3d2218b9a8d52a6ff8c8f2cc9239ee49c57e
[platform/upstream/nettle.git] / testsuite / symbols-test
1 #! /bin/sh
2
3 # Check that all exported symbols use the nettle prefix.
4
5 if [ -z "$srcdir" ] ; then
6   srcdir=`pwd`
7 fi
8
9 : ${NM:=nm}
10
11 # * nm on aix seems to generate bogus output including random binary
12 #   data. Using -g is a workaround to get rid of that. But nm -g
13 #   doesn't work on Solaris-2.4, so try nm -g first, and plain nm if
14 #   -g isn't recognized.
15 #
16 # * gcc on x86 generates functions like __i686.get_pc_thunk.bx in pic
17 #   code.
18
19 ( $NM -g ../libnettle.a || $NM ../libnettle.a ) \
20     | grep ' [DRT] ' | egrep -v '( |^|\.)(\.?_?(_?nettle_)|get_pc_thunk)' \
21     | sort -k3 > test1.out
22
23 if [ -s test1.out ] ; then
24     echo Exported symbols in libnettle.a, lacking the nettle prefix:
25     cat test1.out
26     exit 1
27 fi
28
29 if [ -s ../libhogweed.a ] ; then
30     PATTERN='\.?_?_?nettle_|get_pc_thunk'
31     if grep '^#define.*NETTLE_USE_MINI_GMP.*1$' ../version.h >/dev/null ; then
32         PATTERN="$PATTERN|_?(mp_|mpz_|mpn_)"
33     fi
34     ( $NM -g ../libhogweed.a || $NM ../libhogweed.a ) \
35         | grep ' [DRT] ' | egrep -v "( |^|\.)($PATTERN)" \
36         | sort -k3 > test1.out
37
38     if [ -s test1.out ] ; then
39         echo Exported symbols in libhogweed.a, lacking the nettle prefix:
40         cat test1.out
41         exit 1
42     fi
43 fi
44
45 exit 0
46