aboutsummaryrefslogtreecommitdiff
path: root/src/test/symbols.sh
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2007-09-26 08:44:39 +0000
committerMike Frysinger <vapier@gentoo.org>2007-09-26 08:44:39 +0000
commit727a2d90ee9fae3a9186c03a0049bdd990cae78e (patch)
treeae2be97a2e291c1eb6041255b180012d04dbeee7 /src/test/symbols.sh
parent9f315994b5b6a4696a25c4836c47248508ab0d88 (diff)
add some tests to make sure our exported symbols are sane
Diffstat (limited to 'src/test/symbols.sh')
-rwxr-xr-xsrc/test/symbols.sh68
1 files changed, 68 insertions, 0 deletions
diff --git a/src/test/symbols.sh b/src/test/symbols.sh
new file mode 100755
index 00000000..850ab122
--- /dev/null
+++ b/src/test/symbols.sh
@@ -0,0 +1,68 @@
+#!/bin/bash
+
+top_srcdir=${top_srcdir:-../..}
+srcdir=${builddir:-..}
+top_builddir=${top_srcdir:-../..}
+builddir=${builddir:-..}
+
+export LD_LIBRARY_PATH=${builddir}:${LD_LIBRARY_PATH}
+export PATH=${builddir}:${PATH}
+source ${top_srcdir}/sh/functions.sh
+
+checkit() {
+ local base=$1 ; shift
+ echo "$@" | tr ' ' '\n' > ${base}.out
+ diff -u ${base}.list ${base}.out
+ eend $?
+ ((ret+=$?))
+}
+
+ret=0
+
+ebegin "Checking exported symbols in libeinfo.so (data)"
+checkit einfo.data $(
+readelf -Ws ${builddir}/libeinfo.so \
+ | awk '$4 == "OBJECT" && $5 == "GLOBAL" && $7 != "UND" {print $NF}' \
+ | sort -u
+)
+
+ebegin "Checking exported symbols in libeinfo.so (functions)"
+checkit einfo.funcs $(
+readelf -Ws ${builddir}/libeinfo.so \
+ | awk '$4 == "FUNC" && $5 == "GLOBAL" && $7 != "UND" {print $NF}' \
+ | sort -u \
+ | egrep -v \
+ -e '^_(init|fini)$'
+)
+
+ebegin "Checking exported symbols in librc.so (data)"
+checkit rc.data $(
+readelf -Ws ${builddir}/librc.so \
+ | awk '$4 == "OBJECT" && $5 == "GLOBAL" && $7 != "UND" {print $NF}' \
+ | sort -u
+)
+
+ebegin "Checking exported symbols in librc.so (functions)"
+checkit rc.funcs $(
+readelf -Ws ${builddir}/librc.so \
+ | awk '$4 == "FUNC" && $5 == "GLOBAL" && $7 != "UND" {print $NF}' \
+ | sort -u \
+ | egrep -v \
+ -e '^_(init|fini)$'
+)
+
+ebegin "Checking hidden functions in librc.so"
+sed -n '/^librc_hidden_proto/s:.*(\(.*\))$:\1:p' ../librc.h \
+ | sort -u \
+ > librc.funcs.hidden.list
+readelf -Wr $(grep -l '#include[[:space:]]"librc\.h"' ${builddir}/*.c | sed 's:\.c$:.o:') \
+ | awk '$5 ~ /^rc_/ {print $5}' \
+ | sort -u \
+ | egrep -v '^rc_environ_fd$' \
+ > librc.funcs.hidden.out
+syms=$(diff -u librc.funcs.hidden.{list,out} | sed -n '/^+[^+]/s:^+::p')
+[[ -z ${syms} ]]
+eend $? "Missing hidden defs:"$'\n'"${syms}"
+((ret+=$?))
+
+exit ${ret}