diff options
author | Mike Frysinger <vapier@gentoo.org> | 2008-03-24 07:17:05 +0000 |
---|---|---|
committer | Mike Frysinger <vapier@gentoo.org> | 2008-03-24 07:17:05 +0000 |
commit | 486d5176749922bf0eb1ffc7d99a4b1b62740be3 (patch) | |
tree | 11003906abc925aab4d6a900ededd2e430d8058a | |
parent | 1c9c2f9fcffdc5d66af6e4b3dbf506985ebe438a (diff) |
setup a bit of a test framework
-rw-r--r-- | mk/scripts.mk | 1 | ||||
-rw-r--r-- | sh/Makefile | 3 | ||||
-rwxr-xr-x | sh/runtests.sh | 25 | ||||
-rw-r--r-- | src/test/Makefile | 2 | ||||
-rwxr-xr-x | src/test/runtests.sh (renamed from src/test/symbols.sh) | 11 | ||||
-rwxr-xr-x | test/setup_env.sh | 22 | ||||
-rwxr-xr-x | test/skel.runtests.sh | 5 |
7 files changed, 58 insertions, 11 deletions
diff --git a/mk/scripts.mk b/mk/scripts.mk index 3021c92c..146b56a5 100644 --- a/mk/scripts.mk +++ b/mk/scripts.mk @@ -43,6 +43,7 @@ realinstall: ${BIN} ${CONF} ${CONF_APPEND} install: all realinstall ${INSTALLAFTER} check test:: + @if test -e runtests.sh ; then ./runtests.sh || exit $$? ; fi # A lot of scripts don't have anything to clean # Also, some rm implentation require a file argument regardless of error diff --git a/sh/Makefile b/sh/Makefile index bd55cbda..2f10ef53 100644 --- a/sh/Makefile +++ b/sh/Makefile @@ -18,3 +18,6 @@ _installafter: @# Put functions.sh into the init.d dir so 3rd party apps don't have to @# be multilib aware ln -snf ${PREFIX}/${RC_LIB}/sh/functions.sh ${DESTDIR}/${PREFIX}/${INITDIR} || exit $$? + +check test:: + ./runtests.sh diff --git a/sh/runtests.sh b/sh/runtests.sh new file mode 100755 index 00000000..d0d6a17d --- /dev/null +++ b/sh/runtests.sh @@ -0,0 +1,25 @@ +#!/bin/sh + +top_srcdir=${top_srcdir:-..} +. ${top_srcdir}/test/setup_env.sh + +ret=0 + +tret=0 +ebegin "Testing yesno()" +for f in yes YES Yes true TRUE True 1 ; do + if ! yesno ${f} ; then + ((tret+=1)) + echo "!${f}!" + fi +done +for f in no NO No false FALSE False 0 ; do + if yesno ${f} ; then + ((tret+=1)) + echo "!${f}!" + fi +done +eend ${tret} +((ret+=tret)) + +exit ${ret} 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/symbols.sh b/src/test/runtests.sh index 56fe0489..47bac3b1 100755 --- a/src/test/symbols.sh +++ b/src/test/runtests.sh @@ -1,11 +1,7 @@ #!/bin/sh top_srcdir=${top_srcdir:-../..} -srcdir=${builddir:-.} -top_builddir=${top_srcdir:-../..} -builddir=${builddir:-.} - -. ${top_srcdir}/sh/functions.sh +. ${top_srcdir}/test/setup_env.sh libeinfo_srcdir="${srcdir}/../libeinfo" libeinfo_builddir="${builddir}/../libeinfo" @@ -14,11 +10,6 @@ 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 --git a/test/setup_env.sh b/test/setup_env.sh new file mode 100755 index 00000000..96fdf9d2 --- /dev/null +++ b/test/setup_env.sh @@ -0,0 +1,22 @@ +#!/bin/sh + +if [ -z "${top_srcdir}" ] ; then + echo "You must set top_srcdir before sourcing this file" 1>&2 + exit 1 +fi + +srcdir=${srcdir:-.} +top_builddir=${top_builddir:-${top_srcdir}} +builddir=${builddir:-${srcdir}} + +export LD_LIBRARY_PATH=${top_builddir}/src/libeinfo:${top_builddir}/src/librc:${LD_LIBRARY_PATH} +export PATH=${top_builddir}/src/rc:${PATH} + +${MAKE:-make} -s -C ${top_srcdir}/src/rc links + +. ${top_srcdir}/sh/functions.sh + +if [ $? -ne 0 ] ; then + echo "Sourcing functions.sh failed !?" 1>&2 + exit 1 +fi diff --git a/test/skel.runtests.sh b/test/skel.runtests.sh new file mode 100755 index 00000000..cda20027 --- /dev/null +++ b/test/skel.runtests.sh @@ -0,0 +1,5 @@ +#!/bin/sh + +# top_srcdir=${top_srcdir:-SET/THIS/PATH/OK!?} +. ${top_srcdir}/test/setup_env.sh + |