summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGreg Hudson <ghudson@mit.edu>2010-04-24 17:33:04 +0000
committerGreg Hudson <ghudson@mit.edu>2010-04-24 17:33:04 +0000
commit96de2891830e8418cdd0cebe83faf047cc74dbba (patch)
treed231be7269c7ba552cc0a2fa1fd940efe7521c0b /src
parentd67798fd6618ecee493f6cb1b150e4ebdf35e3f1 (diff)
downloadkrb5-96de2891830e8418cdd0cebe83faf047cc74dbba.tar.gz
krb5-96de2891830e8418cdd0cebe83faf047cc74dbba.tar.xz
krb5-96de2891830e8418cdd0cebe83faf047cc74dbba.zip
Run Python tests as individual rule commands (friendlier to make -k)
instead of in a loop. Build runenv.py as part of make fake-install; it's harmless if Python is unavailable. Import runenv later in k5test so that we get a beter error message if make fake-install hasn't been run. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@23932 dc483132-0cff-0310-8789-dd5450dbe970
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.in6
-rw-r--r--src/config/post.in28
-rw-r--r--src/config/pre.in6
-rw-r--r--src/tests/Makefile.in5
-rw-r--r--src/tests/gssapi/Makefile.in3
-rw-r--r--src/util/k5test.py21
6 files changed, 30 insertions, 39 deletions
diff --git a/src/Makefile.in b/src/Makefile.in
index 2f64c497ba..35040a1eeb 100644
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -106,7 +106,7 @@ install-headers-prerecurse: install-headers-mkdirs
# install::
# $(MAKE) $(MFLAGS) install.man
-fake-install:
+fake-install: runenv.py
$(RM) -r $(FAKEPREFIX)
@for i in $(INSTALLMKDIRS); do \
$(srcdir)/config/mkinstalldirs util/fakedest$$i; \
@@ -627,13 +627,11 @@ check-unix:: krb5-config
check-prerecurse: fake-install
# Create a test realm and spawn a shell in an environment pointing to it.
-testrealm: fake-install runenv.py
+testrealm: fake-install
PYTHONPATH=$(BUILDTOP):$(top_srcdir)/util $(PYTHON) $(srcdir)/util/testrealm.py
# environment variable settings to propagate to Python-based tests
-check-pytests-yes: runenv.py
-
pyrunenv.vals: Makefile
$(KRB5_RUN_ENV) \
for i in $(KRB5_RUN_VARS); do \
diff --git a/src/config/post.in b/src/config/post.in
index d25484910f..43c218bdff 100644
--- a/src/config/post.in
+++ b/src/config/post.in
@@ -129,28 +129,12 @@ undepend-postrecurse: undepend-recurse
##############################
# Python tests
-check-unix:: check-pytests
-
-# Makefile.in should add dependencies to check-pytests for test
-# programs that need to be built before scripts are run.
-
-check-pytests:: check-pytests-@HAVE_PYTHON@
-
-check-pytests-yes:
- @pytests="$(PYTESTS)"; \
- for t in $$pytests; do \
- echo PYTHONPATH=$(BUILDTOP):$(top_srcdir)/util \
- VALGRIND="$(VALGRIND)" \
- $(PYTHON) $(srcdir)/$$t $(PYTESTFLAGS); \
- PYTHONPATH=$(BUILDTOP):$(top_srcdir)/util \
- VALGRIND="$(VALGRIND)" \
- $(PYTHON) $(srcdir)/$$t $(PYTESTFLAGS) || exit 1; \
- done
-
-check-pytests-no:
- @if test -n "$(PYTESTS)"; then \
- echo "+++ Skipping because Python not available: $(PYTESTS)"; \
- fi
+check-unix:: check-pytests-@HAVE_PYTHON@
+
+# Makefile.in should add rules to check-pytests to execute Python tests.
+check-pytests-yes:: check-pytests
+check-pytests-no::
+check-pytests::
clean:: clean-$(WHAT)
diff --git a/src/config/pre.in b/src/config/pre.in
index a39c0faa5e..a4f56896ed 100644
--- a/src/config/pre.in
+++ b/src/config/pre.in
@@ -244,6 +244,9 @@ host=@krb5_cv_host@
DEJAFLAGS = --debug --srcdir $(srcdir) --host $(host)
RUNTEST = runtest $(DEJAFLAGS)
+RUNPYTEST = PYTHONPATH=$(BUILDTOP):$(top_srcdir)/util \
+ VALGRIND="$(VALGRIND)" $(PYTHON)
+
START_SERVERS = $(STESTDIR)/scripts/start_servers $(TEST_SERVER) $(TEST_PATH)
START_SERVERS_LOCAL = $(STESTDIR)/scripts/start_servers_local
@@ -572,8 +575,7 @@ VALGRIND1 = valgrind --tool=memcheck --log-file=$(VALGRIND_LOGDIR)/vg --trace-ch
# something that looks like an FQDN, with an IPv4 address.
OFFLINE=no
-# Makefile.in should set PYTESTS to a list of Python test scripts to run.
-PYTESTS=
+# Used when running Python tests.
PYTESTFLAGS=
##
diff --git a/src/tests/Makefile.in b/src/tests/Makefile.in
index 66a3db0768..df2c808cde 100644
--- a/src/tests/Makefile.in
+++ b/src/tests/Makefile.in
@@ -2,7 +2,6 @@ mydir=tests
BUILDTOP=$(REL)..
SUBDIRS = resolve asn.1 create hammer verify gssapi dejagnu shlib \
gss-threads misc mkeystash_compat
-PYTESTS = t_general.py t_anonpkinit.py
RUN_SETUP = @KRB5_RUN_ENV@ KRB5_KDC_PROFILE=kdc.conf KRB5_CONFIG=krb5.conf
KRB5_RUN_ENV= @KRB5_RUN_ENV@
@@ -61,6 +60,10 @@ kdb_check: kdc.conf krb5.conf
$(RUN_SETUP) $(VALGRIND) ../kadmin/dbutil/kdb5_util $(KADMIN_OPTS) destroy -f
$(RM) $(TEST_DB)* stash_file
+check-pytests::
+ $(RUNPYTEST) $(srcdir)/t_general.py $(PYTESTFLAGS)
+ $(RUNPYTEST) $(srcdir)/t_anonpkinit.py $(PYTESTFLAGS)
+
clean::
$(RM) kdc.conf
diff --git a/src/tests/gssapi/Makefile.in b/src/tests/gssapi/Makefile.in
index ecd066e7cb..2ba81de61f 100644
--- a/src/tests/gssapi/Makefile.in
+++ b/src/tests/gssapi/Makefile.in
@@ -8,11 +8,10 @@ SRCS= $(srcdir)/t_imp_name.c $(srcdir)/t_s4u.c $(srcdir)/t_namingexts.c $(srcdir
OBJS= t_imp_name.o t_s4u.o t_namingexts.o t_gssexts.o t_spnego.o
-PYTESTS= t_gssapi.py
-
all:: t_imp_name t_s4u t_namingexts t_gssexts t_spnego
check-pytests:: t_spnego
+ $(RUNPYTEST) $(srcdir)/t_gssapi.py $(PYTESTFLAGS)
t_imp_name: t_imp_name.o $(GSS_DEPLIBS) $(KRB5_BASE_DEPLIBS)
$(CC_LINK) -o t_imp_name t_imp_name.o $(GSS_LIBS) $(KRB5_BASE_LIBS)
diff --git a/src/util/k5test.py b/src/util/k5test.py
index f90f8ac51c..74768de9aa 100644
--- a/src/util/k5test.py
+++ b/src/util/k5test.py
@@ -22,9 +22,13 @@
"""A module for krb5 test scripts
-Put test script names in the PYTESTS make variable to get them run
-with the appropriate PYTHONPATH during "make check". Sample test
-script usage:
+To run test scripts during "make check" (if Python 2.4 or later is
+available), add rules like the following to Makeflie.in:
+
+ check-pytests::
+ $(RUNPYTEST) $(srcdir)/t_testname.py $(PYTESTFLAGS)
+
+A sample test script:
from k5test import *
@@ -304,11 +308,6 @@ import string
import subprocess
import sys
-# runenv.py is built in each directory where tests are run, providing
-# the environment variable settings needed for running programs in the
-# build tree. These can vary by platform.
-import runenv
-
# Used when most things go wrong (other than programming errors) so
# that the user sees an error message rather than a Python traceback,
# without help from the test script. The on-exit handler will display
@@ -1022,6 +1021,12 @@ plugins = _find_plugins()
hostname = socket.getfqdn()
null_input = open(os.devnull, 'r')
+# runenv.py is built in the top level by "make fake-install". Import
+# it now (rather than at the beginning of the file) so that we get a
+# friendly error message from _find_plugins() if "make fake-install"
+# has not been run.
+import runenv
+
krb5kdc = os.path.join(buildtop, 'kdc', 'krb5kdc')
kadmind = os.path.join(buildtop, 'kadmin', 'server', 'kadmind')
kadmin = os.path.join(buildtop, 'kadmin', 'cli', 'kadmin')