Allow test harness to be run from any directory.

Also add missing copyright notice.
This commit is contained in:
Todd C. Miller
2022-02-28 19:39:33 -07:00
parent a4f847b1d6
commit c2bd52edf8
2 changed files with 85 additions and 46 deletions

View File

@@ -1,9 +1,24 @@
#!/bin/sh
#
# Copyright (c) 2022 Todd C. Miller <Todd.Miller@sudo.ws>
#
# Permission to use, copy, modify, and distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#
# Simple test harness for libsudo_util tests.
# usage: harness [-v] test_group [test_name ...]
#
srcdir="@abs_srcdir@"
builddir="@abs_builddir@"
SHELL=@SHELL@
verbose=0
rval=0
@@ -24,37 +39,38 @@ fi
group="$1"
shift
srcdir=${srcdir%"/regress"}
builddir=${builddir%"/regress"}
if [ ! -d "$srcdir/regress/$group" ]; then
echo "missing test group: $srcdir/regress/$group" >&2
cd $srcdir || exit 1
if [ ! -d "regress/$group" ]; then
echo "missing test group: regress/$group" >&2
exit 1
fi
mkdir -p "regress/$group"
mkdir -p "$builddir/regress/$group"
if [ $# -eq 0 ]; then
tests=
for t in $srcdir/regress/$group/*.in; do
for t in regress/$group/*.in; do
tests="$tests `basename $t .in`"
done
set -- $tests
fi
build_dir=`pwd`
cd $srcdir
while [ $# -ne 0 ]; do
test="$1"
shift
in="regress/$group/${test}.in"
out="$build_dir/regress/$group/${test}.out"
out="$builddir/regress/$group/${test}.out"
out_ok="regress/$group/${test}.out.ok"
err="$build_dir/regress/$group/${test}.err"
err="$builddir/regress/$group/${test}.err"
err_ok="regress/$group/${test}.err.ok"
if [ "$group" = "sudo_conf" ]; then
$build_dir/conf_test $in >$out 2>$err
$builddir/conf_test $in >$out 2>$err
else
$build_dir/parseln_test <$in >$out 2>$err
$builddir/parseln_test <$in >$out 2>$err
fi
ntests=`expr $ntests + 1`