From 727a2d90ee9fae3a9186c03a0049bdd990cae78e Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Wed, 26 Sep 2007 08:44:39 +0000 Subject: add some tests to make sure our exported symbols are sane --- src/Makefile | 3 ++ src/test/Makefile | 9 ++++++ src/test/einfo.data.list | 1 + src/test/einfo.funcs.list | 26 +++++++++++++++ src/test/librc.funcs.hidden.list | 65 ++++++++++++++++++++++++++++++++++++++ src/test/rc.data.list | 1 + src/test/rc.funcs.list | 65 ++++++++++++++++++++++++++++++++++++++ src/test/symbols.sh | 68 ++++++++++++++++++++++++++++++++++++++++ 8 files changed, 238 insertions(+) create mode 100644 src/test/Makefile create mode 100644 src/test/einfo.data.list create mode 100644 src/test/einfo.funcs.list create mode 100644 src/test/librc.funcs.hidden.list create mode 100644 src/test/rc.data.list create mode 100644 src/test/rc.funcs.list create mode 100755 src/test/symbols.sh diff --git a/src/Makefile b/src/Makefile index d657d9eb..251db00e 100644 --- a/src/Makefile +++ b/src/Makefile @@ -157,6 +157,9 @@ clean: clean-links rm -f $(TARGET) rm -f *.o *~ *.core *.so .depend +check: + $(MAKE) -C test $@ + -include .depend _DEPS != ls *.c *.h .depend: $(_DEPS)$(wildcard *.c *.h) diff --git a/src/test/Makefile b/src/test/Makefile new file mode 100644 index 00000000..e1747c25 --- /dev/null +++ b/src/test/Makefile @@ -0,0 +1,9 @@ +all: + +check: + ./symbols.sh + +clean: + rm -f *.out + +.PHONY: all check clean diff --git a/src/test/einfo.data.list b/src/test/einfo.data.list new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/src/test/einfo.data.list @@ -0,0 +1 @@ + diff --git a/src/test/einfo.funcs.list b/src/test/einfo.funcs.list new file mode 100644 index 00000000..da91cc95 --- /dev/null +++ b/src/test/einfo.funcs.list @@ -0,0 +1,26 @@ +ebegin +ebeginv +ebracket +ecolor +eend +eendv +eerror +eerrorn +eerrorx +eindent +eindentv +einfo +einfon +einfov +einfovn +elog +eoutdent +eoutdentv +eprefix +ewarn +ewarnn +ewarnv +ewarnvn +ewarnx +ewend +ewendv diff --git a/src/test/librc.funcs.hidden.list b/src/test/librc.funcs.hidden.list new file mode 100644 index 00000000..e7351de8 --- /dev/null +++ b/src/test/librc.funcs.hidden.list @@ -0,0 +1,65 @@ +rc_allow_plug +rc_env_bool +rc_exists +rc_filter_env +rc_find_pids +rc_free_deptree +rc_get_config +rc_get_config_entry +rc_get_depends +rc_get_depinfo +rc_get_deptype +rc_get_list +rc_get_runlevel +rc_get_runlevels +rc_get_service_option +rc_is_dir +rc_is_exec +rc_is_file +rc_is_link +rc_load_deptree +rc_ls_dir +rc_make_env +rc_mark_service +rc_order_services +rc_resolve_service +rc_rm_dir +rc_runlevel_exists +rc_runlevel_starting +rc_runlevel_stopping +rc_schedule_clear +rc_schedule_start_service +rc_service_add +rc_service_daemons_crashed +rc_service_delete +rc_service_description +rc_service_exists +rc_service_in_runlevel +rc_service_options +rc_services_in_runlevel +rc_services_in_state +rc_services_scheduled +rc_services_scheduled_by +rc_service_started_daemon +rc_service_state +rc_set_runlevel +rc_set_service_daemon +rc_set_service_option +rc_start_service +rc_stop_service +rc_strcatpaths +rc_strlist_add +rc_strlist_addsort +rc_strlist_addsortc +rc_strlist_addsortu +rc_strlist_addu +rc_strlist_delete +rc_strlist_free +rc_strlist_join +rc_strlist_reverse +rc_update_deptree +rc_waitpid +rc_wait_service +rc_xmalloc +rc_xrealloc +rc_xstrdup diff --git a/src/test/rc.data.list b/src/test/rc.data.list new file mode 100644 index 00000000..1756ec79 --- /dev/null +++ b/src/test/rc.data.list @@ -0,0 +1 @@ +rc_environ_fd diff --git a/src/test/rc.funcs.list b/src/test/rc.funcs.list new file mode 100644 index 00000000..e7351de8 --- /dev/null +++ b/src/test/rc.funcs.list @@ -0,0 +1,65 @@ +rc_allow_plug +rc_env_bool +rc_exists +rc_filter_env +rc_find_pids +rc_free_deptree +rc_get_config +rc_get_config_entry +rc_get_depends +rc_get_depinfo +rc_get_deptype +rc_get_list +rc_get_runlevel +rc_get_runlevels +rc_get_service_option +rc_is_dir +rc_is_exec +rc_is_file +rc_is_link +rc_load_deptree +rc_ls_dir +rc_make_env +rc_mark_service +rc_order_services +rc_resolve_service +rc_rm_dir +rc_runlevel_exists +rc_runlevel_starting +rc_runlevel_stopping +rc_schedule_clear +rc_schedule_start_service +rc_service_add +rc_service_daemons_crashed +rc_service_delete +rc_service_description +rc_service_exists +rc_service_in_runlevel +rc_service_options +rc_services_in_runlevel +rc_services_in_state +rc_services_scheduled +rc_services_scheduled_by +rc_service_started_daemon +rc_service_state +rc_set_runlevel +rc_set_service_daemon +rc_set_service_option +rc_start_service +rc_stop_service +rc_strcatpaths +rc_strlist_add +rc_strlist_addsort +rc_strlist_addsortc +rc_strlist_addsortu +rc_strlist_addu +rc_strlist_delete +rc_strlist_free +rc_strlist_join +rc_strlist_reverse +rc_update_deptree +rc_waitpid +rc_wait_service +rc_xmalloc +rc_xrealloc +rc_xstrdup 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} -- cgit v1.2.3