add some tests to make sure our exported symbols are sane

This commit is contained in:
Mike Frysinger 2007-09-26 08:44:39 +00:00
parent 9f315994b5
commit 727a2d90ee
8 changed files with 238 additions and 0 deletions

View File

@ -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)

9
src/test/Makefile Normal file
View File

@ -0,0 +1,9 @@
all:
check:
./symbols.sh
clean:
rm -f *.out
.PHONY: all check clean

1
src/test/einfo.data.list Normal file
View File

@ -0,0 +1 @@

26
src/test/einfo.funcs.list Normal file
View File

@ -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

View File

@ -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

1
src/test/rc.data.list Normal file
View File

@ -0,0 +1 @@
rc_environ_fd

65
src/test/rc.funcs.list Normal file
View File

@ -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

68
src/test/symbols.sh Executable file
View File

@ -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}