diff options
author | Karel Zak | 2012-08-03 21:24:51 +0200 |
---|---|---|
committer | Karel Zak | 2012-08-03 21:24:51 +0200 |
commit | 1b03e2cd33a059fdd355c52899e151130777c44f (patch) | |
tree | b6eac3caf34c4bfb0127e67819b32190a11f0cea /tests/functions.sh | |
parent | build-sys: add tests/run-nonroot.sh to automake file (diff) | |
download | kernel-qcow2-util-linux-1b03e2cd33a059fdd355c52899e151130777c44f.tar.gz kernel-qcow2-util-linux-1b03e2cd33a059fdd355c52899e151130777c44f.tar.xz kernel-qcow2-util-linux-1b03e2cd33a059fdd355c52899e151130777c44f.zip |
tests: make compatible with autotools
The command 'make check' is called from 'make distcheck' (which is
used to generate official util-linux tarballs).
It means that tests/ stuff has to be compatible with autotools and
differentiate between source and build directories.
* remove run-nonroot.sh (merged into run.sh
* remove commands.sh.in
* all tests and top level run.sh accept --builddir and --srcdir
command line options
* functions.sh modified to use $top_builddir/tests for output files
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'tests/functions.sh')
-rw-r--r-- | tests/functions.sh | 30 |
1 files changed, 26 insertions, 4 deletions
diff --git a/tests/functions.sh b/tests/functions.sh index 9716534a2..8293539d2 100644 --- a/tests/functions.sh +++ b/tests/functions.sh @@ -86,6 +86,12 @@ function ts_has_option { echo -n $ALL | sed 's/ //g' | awk 'BEGIN { FS="="; RS="--" } /('$NAME'$|'$NAME'=)/ { print "yes" }' } +function ts_option_argument { + NAME="$1" + ALL="$2" + echo -n $ALL | sed 's/ //g' | awk 'BEGIN { FS="="; RS="--" } /'$NAME'=/ { print $2 }' +} + function ts_init_core_env { TS_NS="$TS_COMPONENT/$TS_TESTNAME" TS_OUTPUT="$TS_OUTDIR/$TS_TESTNAME" @@ -118,11 +124,28 @@ function ts_init_env { LC_ALL="POSIX" CHARSET="UTF-8" + export LANG LANGUAGE LC_ALL CHARSET + mydir=$(ts_canonicalize "$mydir") - export LANG LANGUAGE LC_ALL CHARSET + # automake directories + top_srcdir=$(ts_option_argument "srcdir" "$*") + top_builddir=$(ts_option_argument "builddir" "$*") + # where is this script TS_TOPDIR=$(ts_abspath $mydir/../../) + + # default + if [ -z "$top_srcdir" ]; then + top_srcdir="$TS_TOPDIR/.." + fi + if [ -z "$top_builddir" ]; then + top_builddir="$TS_TOPDIR/.." + fi + + top_srcdir=$(ts_abspath $top_srcdir) + top_builddir=$(ts_abspath $top_builddir) + TS_SCRIPT="$mydir/$(basename $0)" TS_SUBDIR=$(dirname $TS_SCRIPT) TS_TESTNAME=$(basename $TS_SCRIPT) @@ -133,8 +156,8 @@ function ts_init_env { TS_SELF="$TS_SUBDIR" - TS_OUTDIR="$TS_TOPDIR/output/$TS_COMPONENT" - TS_DIFFDIR="$TS_TOPDIR/diff/$TS_COMPONENT" + TS_OUTDIR="$top_builddir/tests/output/$TS_COMPONENT" + TS_DIFFDIR="$top_builddir/tests/diff/$TS_COMPONENT" ts_init_core_env @@ -142,7 +165,6 @@ function ts_init_env { BLKID_FILE="$TS_OUTDIR/${TS_TESTNAME}.blkidtab" - declare -a TS_SUID_PROGS declare -a TS_SUID_USER declare -a TS_SUID_GROUP |