From 486d5176749922bf0eb1ffc7d99a4b1b62740be3 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Mon, 24 Mar 2008 07:17:05 +0000 Subject: setup a bit of a test framework --- src/test/Makefile | 2 +- src/test/runtests.sh | 69 ++++++++++++++++++++++++++++++++++++++++++++++ src/test/symbols.sh | 78 ---------------------------------------------------- 3 files changed, 70 insertions(+), 79 deletions(-) create mode 100755 src/test/runtests.sh delete mode 100755 src/test/symbols.sh (limited to 'src/test') diff --git a/src/test/Makefile b/src/test/Makefile index c3e879ea..d7fde60f 100644 --- a/src/test/Makefile +++ b/src/test/Makefile @@ -3,7 +3,7 @@ all: install: check test:: - ./symbols.sh + ./runtests.sh clean: rm -f *.out diff --git a/src/test/runtests.sh b/src/test/runtests.sh new file mode 100755 index 00000000..47bac3b1 --- /dev/null +++ b/src/test/runtests.sh @@ -0,0 +1,69 @@ +#!/bin/sh + +top_srcdir=${top_srcdir:-../..} +. ${top_srcdir}/test/setup_env.sh + +libeinfo_srcdir="${srcdir}/../libeinfo" +libeinfo_builddir="${builddir}/../libeinfo" +librc_srcdir="${srcdir}/../librc" +librc_builddir="${builddir}/../librc" +rc_srcdir="${srcdir}/../rc" +rc_builddir="${builddir}/../rc" + +checkit() { + local base=$1; shift + echo "$@" | tr ' ' '\n' > ${base}.out + diff -u ${base}.list ${base}.out + eend $? + ret=$(($ret + $?)) +} + +ret=0 + +ebegin "Checking exported symbols in libeinfo.so (data)" +checkit einfo.data $( +readelf -Ws ${libeinfo_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 ${libeinfo_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 ${librc_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 ${librc_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_srcdir}/librc.h \ + | sort -u \ + > librc.funcs.hidden.list +readelf -Wr $(grep -l '#include[[:space:]]"librc\.h"' ${librc_srcdir}/*.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 librc.funcs.hidden.out | sed -n '/^+[^+]/s:^+::p') +[ -z "${syms}" ] +eend $? "Missing hidden defs:"$'\n'"${syms}" +ret=$(($ret + $?)) + +exit ${ret} diff --git a/src/test/symbols.sh b/src/test/symbols.sh deleted file mode 100755 index 56fe0489..00000000 --- a/src/test/symbols.sh +++ /dev/null @@ -1,78 +0,0 @@ -#!/bin/sh - -top_srcdir=${top_srcdir:-../..} -srcdir=${builddir:-.} -top_builddir=${top_srcdir:-../..} -builddir=${builddir:-.} - -. ${top_srcdir}/sh/functions.sh - -libeinfo_srcdir="${srcdir}/../libeinfo" -libeinfo_builddir="${builddir}/../libeinfo" -librc_srcdir="${srcdir}/../librc" -librc_builddir="${builddir}/../librc" -rc_srcdir="${srcdir}/../rc" -rc_builddir="${builddir}/../rc" - -make -s -C ${rc_builddir} links - -export LD_LIBRARY_PATH=${libeinfo_builddir}:${librc_builddir}:${LD_LIBRARY_PATH} -export PATH=${rc_builddir}:${PATH} - -checkit() { - local base=$1; shift - echo "$@" | tr ' ' '\n' > ${base}.out - diff -u ${base}.list ${base}.out - eend $? - ret=$(($ret + $?)) -} - -ret=0 - -ebegin "Checking exported symbols in libeinfo.so (data)" -checkit einfo.data $( -readelf -Ws ${libeinfo_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 ${libeinfo_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 ${librc_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 ${librc_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_srcdir}/librc.h \ - | sort -u \ - > librc.funcs.hidden.list -readelf -Wr $(grep -l '#include[[:space:]]"librc\.h"' ${librc_srcdir}/*.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 librc.funcs.hidden.out | sed -n '/^+[^+]/s:^+::p') -[ -z "${syms}" ] -eend $? "Missing hidden defs:"$'\n'"${syms}" -ret=$(($ret + $?)) - -exit ${ret} -- cgit v1.2.3