openafs/tests/Makefile.in
Michael Meffie 9dd6fa97b6 tests: Add make shell target
Add a makefile target to start an interactive subshell with the
environment required to run tests directly from the command line.  Tests
can also be run from a debugger or from the "runtests" front-end test
runner.

Example usage:

    $ make shell
    ...
    Starting a shell to run tests. Run 'exit' when done.

    # Set the subshell prompt (optional).
    $ PS1="(tests) $PS1"

    # Run tests directly or with a debugger.
    (tests) $ rx/perf-t
    ...
    (tests) $ file rx/perf-t
    rx/perf-t: Perl script text executable
    (tests) $ perl -d rx/perf-t
    ...

    # End the subshell.
    (tests) $ exit
    $

The shell started will be the one discovered by configure, which may not
be the preferred shell for interactive use. To specify a different
shell, define SHELL when running make:

    $ make shell SHELL=/path/to/my/shell

If you use this feature often, you may want to update your shell profile
to automatically set the PS1 when running the test subshell.  For
example, you can append this to your bashrc file:

    # OpenAFS unit test subshell.
    if [[ $MAKECHECK -eq 1 ]]; then
        PS1="(tests) $PS1"
    fi

Thanks to Ben Kaduk for the suggestion.

Change-Id: I8d949d21153396c0da8db186fd35477ad0383f12
Reviewed-on: https://gerrit.openafs.org/15730
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
2024-06-27 09:10:18 -04:00

68 lines
2.2 KiB
Makefile

# Build rules for the OpenAFS test suite.
srcdir=@srcdir@/../src/external/c-tap-harness/tests
abs_top_srcdir=@abs_top_srcdir@
abs_top_builddir=@abs_top_builddir@
include @TOP_OBJDIR@/src/config/Makefile.config
include @TOP_OBJDIR@/src/config/Makefile.pthread
MODULE_CFLAGS = -DC_TAP_SOURCE='"$(abs_top_srcdir)/tests"' \
-DC_TAP_BUILD='"$(abs_top_builddir)/tests"'
SUBDIRS = tap common auth util cmd volser opr rx
all: runtests
@for A in $(SUBDIRS); do cd $$A && $(MAKE) $@ && cd .. || exit 1; done
runtests: runtests.o
$(AFS_LDRULE) runtests.o
runtests.o: $(srcdir)/runtests.c
$(AFS_CCRULE) $(srcdir)/runtests.c
RUNTESTS_V0_DEFAULT=-l $(abs_top_srcdir)/tests/TESTS
RUNTESTS_V1_DEFAULT=-v -l $(abs_top_srcdir)/tests/TESTS
# If $(TESTS) is blank, RUNTESTS_ARGS will expand to RUNTESTS_DEFAULT_, so
# we'll run our default list of tests. If $(TESTS) is not blank,
# $(RUNTESTS_DEFAULT_$(TESTS)) will expand into nothing, so RUNTESTS_ARGS will
# just become effectively $(TESTS).
RUNTESTS_DEFAULT_=$(RUNTESTS_V$(V)_DEFAULT)
RUNTESTS_ARGS=$(RUNTESTS_DEFAULT_$(TESTS)) $(TESTS)
# To run specific tests, run e.g. 'make check TESTS="rx/foo opr/foo"'
check test tests: all runtests
MAKECHECK=1 $(abs_top_srcdir)/tests/libwrap @TOP_OBJDIR@/lib \
./runtests $(RUNTESTS_ARGS)
# To start an interactive subshell with the environment required to run
# the test programs, run 'make shell'. Run 'exit' to end the subshell.
#
# Example usage:
#
# $ make shell
# Starting a shell to run tests. Run 'exit' when done.
# $ PS1="(tests) $PS1" # Optionally set the PS1 in the subshell.
# (tests) $ rx/perf-t # Run tests directly or via a debugger.
# ...
# (tests) $ exit # Exit when done.
#
shell: all runtests
@if [ "x$$MAKECHECK" = "x1" ]; then \
echo "Already in the tests subshell."; \
else \
echo "Starting a shell to run tests. Run 'exit' when done."; \
MAKECHECK=1 \
C_TAP_SOURCE=@abs_top_srcdir@/tests \
C_TAP_BUILD=@abs_top_builddir@/tests \
SOURCE=@abs_top_srcdir@/tests \
BUILD=@abs_top_builddir@/tests \
@abs_top_srcdir@/tests/libwrap @TOP_OBJDIR@/lib $(SHELL); \
fi
install:
clean distclean:
@for A in $(SUBDIRS); do cd $$A && $(MAKE) $@ && cd .. || exit 1; done
$(RM) -f *.o core runtests