Adapt test harness for lib/util and move to regress directory.

This commit is contained in:
Todd C. Miller
2022-02-28 14:15:43 -07:00
parent 6a84523671
commit a57e979962
8 changed files with 32 additions and 59 deletions

3
.gitignore vendored
View File

@@ -67,13 +67,13 @@ lib/util/[a-z]*_test
lib/util/fuzz_[a-z]*
lib/util/regress/**/*.out
lib/util/regress/**/*.err
lib/util/regress/harness
logsrvd/sudo_logsrvd
logsrvd/sudo_sendlog
logsrvd/fuzz_[a-z]*
plugins/sudoers/cvtsudoers
plugins/sudoers/harness
plugins/sudoers/sudoers
plugins/sudoers/sudoreplay
plugins/sudoers/testsudoers
@@ -89,6 +89,7 @@ plugins/sudoers/regress/**/*.json
plugins/sudoers/regress/**/*.ldif
plugins/sudoers/regress/**/*.sudo
plugins/sudoers/regress/**/*.ldif2sudo
plugins/sudoers/regress/harness
plugins/sudoers/regress/iolog_plugin/iolog
plugins/sudoers/regress/testsudoers/test3.d/root

View File

@@ -60,14 +60,16 @@ Makefile$
^lib/util/util\.exp$
^lib/util/[a-z0-9_]+_test$
^lib/util/fuzz_sudo_conf$
^lib/util/regress/harness
^lib/util/regress/.*\.(out|err)$
^logsrvd/sudo_(logsrvd|sendlog)$
^logsrvd/fuzz_logsrvd_conf$
^plugins/sudoers/(cvtsudoers|harness|sudoers|sudoreplay|testsudoers|tsdump|visudo|prologue|check_[a-z0-9_]+)$
^plugins/sudoers/(cvtsudoers|sudoers|sudoreplay|testsudoers|tsdump|visudo|prologue|check_[a-z0-9_]+)$
^plugins/sudoers/fuzz_(policy|sudoers(_ldif)?)$
^plugins/sudoers/.*\.(out|toke|err|json|ldif|sudo|ldif2sudo)$
^plugins/sudoers/regress/harness
^plugins/sudoers/regress/iolog_plugin/iolog$
^plugins/sudoers/regress/testsudoers/test3\.d/root$

View File

@@ -276,6 +276,7 @@ lib/util/regress/getgrouplist/getgrouplist_test.c
lib/util/regress/glob/files
lib/util/regress/glob/globtest.c
lib/util/regress/glob/globtest.in
lib/util/regress/harness.in
lib/util/regress/mktemp/mktemp_test.c
lib/util/regress/parse_gids/parse_gids_test.c
lib/util/regress/progname/progname_test.c
@@ -602,7 +603,6 @@ plugins/sudoers/gram.c
plugins/sudoers/gram.h
plugins/sudoers/gram.y
plugins/sudoers/group_plugin.c
plugins/sudoers/harness.in
plugins/sudoers/hexchar.c
plugins/sudoers/ins_2001.h
plugins/sudoers/ins_classic.h
@@ -814,6 +814,7 @@ plugins/sudoers/regress/fuzz/fuzz_sudoers.dict
plugins/sudoers/regress/fuzz/fuzz_sudoers.out.ok
plugins/sudoers/regress/fuzz/fuzz_sudoers_ldif.c
plugins/sudoers/regress/fuzz/fuzz_sudoers_ldif.dict
plugins/sudoers/regress/harness.in
plugins/sudoers/regress/iolog_plugin/check_iolog_plugin.c
plugins/sudoers/regress/parser/check_addr.c
plugins/sudoers/regress/parser/check_addr.in

9
configure vendored
View File

@@ -32257,7 +32257,9 @@ elif test X"$TMPFILES_D" != X""; then
fi
ac_config_files="$ac_config_files Makefile docs/Makefile examples/Makefile examples/sudoers examples/sudo.conf examples/sudo_logsrvd.conf examples/syslog.conf include/Makefile lib/eventlog/Makefile lib/fuzzstub/Makefile lib/iolog/Makefile lib/logsrv/Makefile lib/protobuf-c/Makefile lib/util/Makefile lib/util/util.exp logsrvd/Makefile src/intercept.exp src/sudo_usage.h src/Makefile plugins/audit_json/Makefile plugins/sample/Makefile plugins/group_file/Makefile plugins/sample_approval/Makefile plugins/system_group/Makefile plugins/sudoers/Makefile plugins/sudoers/harness plugins/sudoers/sudoers"
ac_config_files="$ac_config_files Makefile docs/Makefile examples/Makefile examples/sudoers examples/sudo.conf examples/sudo_logsrvd.conf examples/syslog.conf include/Makefile lib/eventlog/Makefile lib/fuzzstub/Makefile lib/iolog/Makefile lib/logsrv/Makefile lib/protobuf-c/Makefile lib/util/Makefile lib/util/regress/harness lib/util/util.exp logsrvd/Makefile src/intercept.exp src/sudo_usage.h src/Makefile plugins/audit_json/Makefile plugins/sample/Makefile plugins/group_file/Makefile plugins/sample_approval/Makefile plugins/system_group/Makefile plugins/sudoers/Makefile plugins/sudoers/regress/harness plugins/sudoers/sudoers"
ac_config_commands="$ac_config_commands harness"
cat >confcache <<\_ACEOF
@@ -33262,6 +33264,7 @@ do
"lib/logsrv/Makefile") CONFIG_FILES="$CONFIG_FILES lib/logsrv/Makefile" ;;
"lib/protobuf-c/Makefile") CONFIG_FILES="$CONFIG_FILES lib/protobuf-c/Makefile" ;;
"lib/util/Makefile") CONFIG_FILES="$CONFIG_FILES lib/util/Makefile" ;;
"lib/util/regress/harness") CONFIG_FILES="$CONFIG_FILES lib/util/regress/harness" ;;
"lib/util/util.exp") CONFIG_FILES="$CONFIG_FILES lib/util/util.exp" ;;
"logsrvd/Makefile") CONFIG_FILES="$CONFIG_FILES logsrvd/Makefile" ;;
"src/intercept.exp") CONFIG_FILES="$CONFIG_FILES src/intercept.exp" ;;
@@ -33273,8 +33276,9 @@ do
"plugins/sample_approval/Makefile") CONFIG_FILES="$CONFIG_FILES plugins/sample_approval/Makefile" ;;
"plugins/system_group/Makefile") CONFIG_FILES="$CONFIG_FILES plugins/system_group/Makefile" ;;
"plugins/sudoers/Makefile") CONFIG_FILES="$CONFIG_FILES plugins/sudoers/Makefile" ;;
"plugins/sudoers/harness") CONFIG_FILES="$CONFIG_FILES plugins/sudoers/harness" ;;
"plugins/sudoers/regress/harness") CONFIG_FILES="$CONFIG_FILES plugins/sudoers/regress/harness" ;;
"plugins/sudoers/sudoers") CONFIG_FILES="$CONFIG_FILES plugins/sudoers/sudoers" ;;
"harness") CONFIG_COMMANDS="$CONFIG_COMMANDS harness" ;;
*) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;;
esac
@@ -34375,6 +34379,7 @@ ltmain=$ac_aux_dir/ltmain.sh
chmod +x "$ofile"
;;
"harness":C) chmod +x lib/util/regress/harness plugins/sudoers/regress/harness ;;
esac
done # for ac_tag

View File

@@ -5114,7 +5114,8 @@ elif test X"$TMPFILES_D" != X""; then
AC_CONFIG_FILES([etc/init.d/sudo.conf])
fi
AC_CONFIG_FILES([Makefile docs/Makefile examples/Makefile examples/sudoers examples/sudo.conf examples/sudo_logsrvd.conf examples/syslog.conf include/Makefile lib/eventlog/Makefile lib/fuzzstub/Makefile lib/iolog/Makefile lib/logsrv/Makefile lib/protobuf-c/Makefile lib/util/Makefile lib/util/util.exp logsrvd/Makefile src/intercept.exp src/sudo_usage.h src/Makefile plugins/audit_json/Makefile plugins/sample/Makefile plugins/group_file/Makefile plugins/sample_approval/Makefile plugins/system_group/Makefile plugins/sudoers/Makefile plugins/sudoers/harness plugins/sudoers/sudoers])
AC_CONFIG_FILES([Makefile docs/Makefile examples/Makefile examples/sudoers examples/sudo.conf examples/sudo_logsrvd.conf examples/syslog.conf include/Makefile lib/eventlog/Makefile lib/fuzzstub/Makefile lib/iolog/Makefile lib/logsrv/Makefile lib/protobuf-c/Makefile lib/util/Makefile lib/util/regress/harness lib/util/util.exp logsrvd/Makefile src/intercept.exp src/sudo_usage.h src/Makefile plugins/audit_json/Makefile plugins/sample/Makefile plugins/group_file/Makefile plugins/sample_approval/Makefile plugins/system_group/Makefile plugins/sudoers/Makefile plugins/sudoers/regress/harness plugins/sudoers/sudoers])
AC_CONFIG_COMMANDS([harness], [chmod +x lib/util/regress/harness plugins/sudoers/regress/harness])
AC_OUTPUT

View File

@@ -202,6 +202,9 @@ depend: siglist.c signame.c
--builddir=$(abs_top_builddir) lib/util/Makefile.in
cd $(top_builddir) && ./config.status --file lib/util/Makefile
harness: $(srcdir)/regress/harness.in
cd $(top_builddir) && ./config.status --file lib/util/regress/harness
Makefile: $(srcdir)/Makefile.in
cd $(top_builddir) && ./config.status --file lib/util/Makefile
@@ -449,52 +452,8 @@ check: $(TEST_PROGS) check-fuzzer
rm -f ./progname_test2; ln -s ./progname_test ./progname_test2; \
./progname_test2 || rval=`expr $$rval + $$?`; \
rm -f ./progname_test2; \
build_dir=`pwd`; \
cd $(srcdir); \
for dir in sudo_conf sudo_parseln; do \
passed=0; failed=0; total=0; \
mkdir -p $$build_dir/regress/$$dir; \
for t in regress/$$dir/*.in; do \
base=`basename $$t .in`; \
out="$$build_dir/regress/$$dir/$${base}.out"; \
out_ok="regress/$$dir/$${base}.out.ok"; \
err="$$build_dir/regress/$$dir/$${base}.err"; \
err_ok="regress/$$dir/$${base}.err.ok"; \
if test "$$dir" = "sudo_conf"; then \
$$build_dir/conf_test $$t >$$out 2>$$err; \
else \
$$build_dir/parseln_test <$$t >$$out 2>$$err; \
fi; \
if cmp $$out $$out_ok >/dev/null; then \
passed=`expr $$passed + 1`; \
echo "$$dir/$$base: OK"; \
else \
failed=`expr $$failed + 1`; \
echo "$$dir/$$base: FAIL"; \
diff $$out $$out_ok || true; \
fi; \
total=`expr $$total + 1`; \
if test -s $$err_ok; then \
if cmp $$err $$err_ok >/dev/null; then \
passed=`expr $$passed + 1`; \
echo "$$dir/$$base (stderr): OK"; \
else \
failed=`expr $$failed + 1`; \
echo "$$dir/$$base (stderr): FAIL"; \
diff $$err $$err_ok || true; \
fi; \
total=`expr $$total + 1`; \
elif test -s $$err; then \
failed=`expr $$failed + 1`; \
echo "$$dir/$$base (stderr): FAIL"; \
cat $$err 1>&2; \
fi; \
done; \
if test $$failed -ne 0; then \
rval=`expr $$rval + $$failed`; \
fi; \
echo "$$dir: $$passed/$$total tests passed; $$failed/$$total tests failed"; \
done; \
AWK=$(AWK) $(SHELL) regress/harness sudo_conf || rval=`expr $$rval + $$?`; \
AWK=$(AWK) $(SHELL) regress/harness sudo_parseln || rval=`expr $$rval + $$?`; \
exit $$rval; \
fi
@@ -519,7 +478,7 @@ realclean: distclean
cleandir: realclean
.PHONY: clean mostlyclean distclean cleandir clobber realclean \
$(FUZZ_SEED_CORPUS) run-fuzz_sudo_conf
harness $(FUZZ_SEED_CORPUS) run-fuzz_sudo_conf
# Autogenerated dependencies, do not modify
aix.lo: $(srcdir)/aix.c $(incdir)/compat/stdbool.h $(incdir)/sudo_compat.h \

View File

@@ -332,6 +332,9 @@ depend:
--builddir=$(abs_top_builddir) plugins/sudoers/Makefile.in
cd $(top_builddir) && ./config.status --file plugins/sudoers/Makefile
harness: $(srcdir)/regress/harness.in
cd $(top_builddir) && ./config.status --file plugins/sudoers/regress/harness
Makefile: $(srcdir)/Makefile.in
cd $(top_builddir) && ./config.status --file plugins/sudoers/Makefile
@@ -673,10 +676,10 @@ check: $(TEST_PROGS) visudo testsudoers cvtsudoers check-fuzzer
if test -f check_symbols; then \
./check_symbols .libs/sudoers.so $(shlib_exp) || rval=`expr $$rval + $$?`; \
fi; \
AWK=$(AWK) $(SHELL) harness sudoers || rval=`expr $$rval + $$?`; \
AWK=$(AWK) $(SHELL) harness testsudoers || rval=`expr $$rval + $$?`; \
AWK=$(AWK) $(SHELL) harness visudo || rval=`expr $$rval + $$?`; \
AWK=$(AWK) $(SHELL) harness cvtsudoers || rval=`expr $$rval + $$?`; \
AWK=$(AWK) $(SHELL) regress/harness sudoers || rval=`expr $$rval + $$?`; \
AWK=$(AWK) $(SHELL) regress/harness testsudoers || rval=`expr $$rval + $$?`; \
AWK=$(AWK) $(SHELL) regress/harness visudo || rval=`expr $$rval + $$?`; \
AWK=$(AWK) $(SHELL) regress/harness cvtsudoers || rval=`expr $$rval + $$?`; \
exit $$rval; \
fi
@@ -706,7 +709,7 @@ realclean: distclean
cleandir: realclean
.PHONY: clean mostlyclean distclean cleandir clobber realclean \
$(FUZZ_SEED_CORPUS) run-fuzz_policy run-fuzz_sudoers \
harness $(FUZZ_SEED_CORPUS) run-fuzz_policy run-fuzz_sudoers \
run-fuzz_sudoers_ldif
# Autogenerated dependencies, do not modify

View File

@@ -3,7 +3,7 @@
# Simple test harness for sudoers tests.
# usage: harness [-v] test_group [test_name ...]
#
srcdir="@srcdir@"
srcdir="@abs_srcdir@"
SHELL=@SHELL@
verbose=0
rval=0
@@ -23,6 +23,7 @@ if [ $# -eq 0 ]; then
fi
group="$1"
shift
srcdir=${srcdir%"/regress"}
if [ ! -d "$srcdir/regress/$group" ]; then
echo "missing test group: $srcdir/regress/$group" >&2