------------------------------------------------------------------------ r13 | sdc | 2006-02-23 14:47:26 -0500 (Thu, 23 Feb 2006) | 21 lines Changed paths: M /mod_python/gentoo-3-2-8/configure.in M /mod_python/gentoo-3-2-8/test/httpdconf.py M /mod_python/gentoo-3-2-8/test/test.py M /mod_python/gentoo-3-2-8/test/testconf.py.in configure tests according to the enviroment variables TEST_SERVER_ROOT, TEST_USER, and TEST_GROUP. Behavior is unchanged if these variables aren't set. Exit with an error code via sys.exit on test failure. Store session information in a new generated subdirectory of TEST_SERVER_ROOT, not in /var as before. Set AllowOverride None in generated test.conf. Listen only on the interface 127.0.0.1. Look for httpd.pid in TEST_SERVER_ROOT when polling for httpd shutdown. The previous call to getcwd assumed too much, causing tests to randomly fail. Inform the user if ugh.pdf (almost certainly not present) isn't the right test file, just because I went and looked up the md5 when I saw this test. ------------------------------------------------------------------------ r17 | sdc | 2006-02-25 02:08:47 -0500 (Sat, 25 Feb 2006) | 3 lines Changed paths: M /mod_python/gentoo-3-2-8/configure.in M /mod_python/gentoo-3-2-8/test/test.py M /mod_python/gentoo-3-2-8/test/testconf.py.in Set PYTHONPATH to configurable TEST_PYTHON_PATH in the environment of each apache run. ------------------------------------------------------------------------ Index: gentoo-3-2-8/test/httpdconf.py =================================================================== --- gentoo-3-2-8/test/httpdconf.py (revision 12) +++ gentoo-3-2-8/test/httpdconf.py (working copy) @@ -83,6 +83,10 @@ def __init__(self, val): Directive.__init__(self, self.__class__.__name__, val) +class AllowOverride(Directive): + def __init__(self, val): + Directive.__init__(self, self.__class__.__name__, val) + class AuthBasicAuthoritative(Directive): # New in Apache 2.2 def __init__(self, val): @@ -121,6 +125,10 @@ def __init__(self, val): Directive.__init__(self, self.__class__.__name__, val) +class Group(Directive): + def __init__(self, val): + Directive.__init__(self, self.__class__.__name__, val) + class IfModule(ContainerTag): def __init__(self, dir, *args): ContainerTag.__init__(self, self.__class__.__name__, dir, args) @@ -273,6 +281,10 @@ def __init__(self, val): Directive.__init__(self, self.__class__.__name__, val) +class User(Directive): + def __init__(self, val): + Directive.__init__(self, self.__class__.__name__, val) + class PythonInterpPerDirectory(Directive): def __init__(self, val='Off'): Directive.__init__(self, self.__class__.__name__, val) Index: gentoo-3-2-8/test/testconf.py.in =================================================================== --- gentoo-3-2-8/test/testconf.py.in (revision 12) +++ gentoo-3-2-8/test/testconf.py.in (working copy) @@ -12,12 +12,18 @@ # Path to the current directory TESTHOME="@TEST_SERVER_ROOT@" +# Path to python libraries, to be set in the apache environment +PYTHONPATH="@TEST_PYTHON_PATH@" + # Path to the Apache modules directory LIBEXECDIR="@LIBEXECDIR@" # Path to the mod_python.so file, should be in the apache modules directory. MOD_PYTHON_SO="@MOD_PYTHON_SO@" +USER="@TEST_USER@" +GROUP="@TEST_GROUP@" + # makes emacs go into python mode ### Local Variables: ### mode:python Index: gentoo-3-2-8/test/test.py =================================================================== --- gentoo-3-2-8/test/test.py (revision 12) +++ gentoo-3-2-8/test/test.py (working copy) @@ -128,7 +128,7 @@ "testconf.py and change the variables HTTPD, TESTHOME, MOD_PYTHON_SO " "and LIBEXECDIR according to their description in the file.\n" ) - sys.exit() + sys.exit(1) else: def testpath(variable,isfile): value = getattr(testconf,variable,'') @@ -151,7 +151,7 @@ good = testpath('MOD_PYTHON_SO',True) and good if not good: print "Please check your testconf.py file" - sys.exit() + sys.exit(1) del testpath del good @@ -180,8 +180,13 @@ CONFIG = os.path.join(TESTHOME, "conf", "test.conf") DOCUMENT_ROOT = os.path.join(TESTHOME, "htdocs") PORT = 0 # this is set in fundUnusedPort() - - + +SESSION_DIR = os.path.join(TESTHOME, 'session') +if os.path.exists(SESSION_DIR): + shutil.rmtree(SESSION_DIR) +os.mkdir(SESSION_DIR) +os.chmod(SESSION_DIR, 0777) + # readBlockSize is required for the test_fileupload_* tests. # We can't import mod_python.util.readBlockSize from a cmd line # interpreter, so we'll hard code it here. @@ -303,6 +308,7 @@ IfModule("!mod_dir.c", LoadModule("dir_module %s" % quoteIfSpace(os.path.join(modpath, "mod_dir.so")))), + Directory('/', AllowOverride('None')), ServerRoot(SERVER_ROOT), ErrorLog("logs/error_log"), LogLevel("debug"), @@ -312,11 +318,16 @@ TypesConfig("conf/mime.types"), PidFile("logs/httpd.pid"), ServerName("127.0.0.1"), - Listen(PORT), + Listen("%s:%s" % ("127.0.0.1", PORT)), PythonOption('PythonOptionTest sample_value'), DocumentRoot(DOCUMENT_ROOT), LoadModule("python_module %s" % quoteIfSpace(MOD_PYTHON_SO))) + if testconf.USER: + s.append(User(testconf.USER)) + if testconf.GROUP: + s.append(Group(testconf.GROUP)) + if APACHE_VERSION == '2.2': # mod_auth has been split into mod_auth_basic and some other modules s.append(IfModule("!mod_auth_basic.c", @@ -343,6 +354,8 @@ httpd = quoteIfSpace(HTTPD) config = quoteIfSpace(CONFIG) cmd = '%s %s -k start -f %s' % (httpd, extra, config) + if testconf.PYTHONPATH: + cmd = "PYTHONPATH='%s' %s" % (testconf.PYTHONPATH, cmd) print " ", cmd os.system(cmd) time.sleep(1) @@ -364,7 +377,7 @@ # Qemu will run about 1/10 the native speed, so 1 second may # not be long enough for apache to shut down. count = 0 - pid_file = os.path.join(os.getcwd(), 'logs/httpd.pid') + pid_file = os.path.join(SERVER_ROOT, 'logs', 'httpd.pid') while os.path.exists(pid_file): time.sleep(1) count += 1 @@ -1008,16 +1021,22 @@ ugh = file('ugh.pdf','rb') content = ugh.read() ugh.close() + digest = md5.new(content).hexdigest() + if digest != '9e8c42be55aac825e7a34d448044d0fe': + raise Exception('bad ugh digest') except: print " * Skipping the test for The UNIX-HATERS handbook file upload." print " To make this test, you need to download ugh.pdf from" print " http://research.microsoft.com/~daniel/uhh-download.html" print " into this script's directory." + + if str(sys.exc_info()[1]) == 'bad ugh digest': + print " (The file ugh.pdf that is currently present is not the " + print " correct file; we're looking for a file with md5: " + print " 9e8c42be55aac825e7a34d448044d0fe.)" else: print " * Testing The UNIX-HATERS handbook file upload support" - digest = md5.new(content).hexdigest() - rsp = self.vhost_post_multipart_form_data( "test_fileupload", variables={'test':'abcd'}, @@ -1624,6 +1643,8 @@ ServerName("test_Session_Session"), DocumentRoot(DOCUMENT_ROOT), Directory(DOCUMENT_ROOT, + PythonOption('session_directory "%s"'% + SESSION_DIR), SetHandler("mod_python"), PythonHandler("tests::Session_Session"), PythonDebug("On"))) @@ -1662,6 +1683,8 @@ ServerName("test_Session_Session"), DocumentRoot(DOCUMENT_ROOT), Directory(DOCUMENT_ROOT, + PythonOption('session_directory "%s"'% + SESSION_DIR), SetHandler("mod_python"), PythonHandler("tests::Session_Session"), PythonDebug("On"))) @@ -2194,5 +2217,5 @@ return mpTestSuite tr = unittest.TextTestRunner() -tr.run(suite()) - +result = tr.run(suite()) +sys.exit(not result.wasSuccessful()) Index: gentoo-3-2-8/configure.in =================================================================== --- gentoo-3-2-8/configure.in (revision 12) +++ gentoo-3-2-8/configure.in (working copy) @@ -280,7 +280,12 @@ # this for the test.py script AC_SUBST(TEST_SERVER_ROOT) -TEST_SERVER_ROOT="`pwd`/test" +if test -z "$TEST_SERVER_ROOT"; then + TEST_SERVER_ROOT="`pwd`/test" +fi +AC_SUBST(TEST_PYTHON_PATH) +AC_SUBST(TEST_USER) +AC_SUBST(TEST_GROUP) AC_SUBST(MOD_PYTHON_SO) MOD_PYTHON_SO="`pwd`/src/mod_python.so"