You are viewing a plain text version of this content. The canonical link for it is here.
Posted to mod_python-commits@quetz.apache.org by jg...@apache.org on 2005/10/22 21:24:03 UTC
svn commit: r327684 - in /httpd/mod_python/trunk/test: htdocs/tests.py
test.py
Author: jgallacher
Date: Sat Oct 22 12:24:00 2005
New Revision: 327684
URL: http://svn.apache.org/viewcvs?rev=327684&view=rev
Log:
Added unittest for req.sendfile(filename) where filename is a symbolic link.
This test is only run when os.name == 'posix'
Ref MODPYTHON-84
Modified:
httpd/mod_python/trunk/test/htdocs/tests.py
httpd/mod_python/trunk/test/test.py
Modified: httpd/mod_python/trunk/test/htdocs/tests.py
URL: http://svn.apache.org/viewcvs/httpd/mod_python/trunk/test/htdocs/tests.py?rev=327684&r1=327683&r2=327684&view=diff
==============================================================================
--- httpd/mod_python/trunk/test/htdocs/tests.py (original)
+++ httpd/mod_python/trunk/test/htdocs/tests.py Sat Oct 22 12:24:00 2005
@@ -687,6 +687,7 @@
def req_sendfile2(req):
+ print "doing sendfile2"
import tempfile
fname = tempfile.mktemp("txt")
f = open(fname, "w")
@@ -696,6 +697,24 @@
req.sendfile(fname)
# os.remove(fname)
+ return apache.OK
+
+def req_sendfile3(req):
+ """Check if sendfile handles symlinks properly.
+ This is only valid on posix systems.
+ """
+
+ import tempfile
+ # note mktemp is deprecated in python 2.3. Should use mkstemp instead.
+ fname = tempfile.mktemp("txt")
+ f = open(fname, "w")
+ f.write("0123456789"*100);
+ f.close()
+ fname_symlink = '%s.lnk' % fname
+ os.symlink(fname, fname_symlink)
+ req.sendfile(fname_symlink)
+ os.remove(fname_symlink)
+ os.remove(fname)
return apache.OK
def srv_register_cleanup(req):
Modified: httpd/mod_python/trunk/test/test.py
URL: http://svn.apache.org/viewcvs/httpd/mod_python/trunk/test/test.py?rev=327684&r1=327683&r2=327684&view=diff
==============================================================================
--- httpd/mod_python/trunk/test/test.py (original)
+++ httpd/mod_python/trunk/test/test.py Sat Oct 22 12:24:00 2005
@@ -646,6 +646,31 @@
if (rsp != "0123456789"*100):
self.fail(`rsp`)
+ def test_req_sendfile3_conf(self):
+
+ c = VirtualHost("*",
+ ServerName("test_req_sendfile3"),
+ DocumentRoot(DOCUMENT_ROOT),
+ Directory(DOCUMENT_ROOT,
+ SetHandler("mod_python"),
+ PythonHandler("tests::req_sendfile3"),
+ PythonDebug("On")))
+
+ return str(c)
+
+ def test_req_sendfile3(self):
+
+ if os.name == 'posix':
+
+ print "\n * Testing req.sendfile() for a file which is a symbolic link"
+
+ rsp = self.vhost_get("test_req_sendfile3")
+
+ if (rsp != "0123456789"*100):
+ self.fail(`rsp`)
+ else:
+ print "\n * Skipping req.sendfile() for a file which is a symbolic link"
+
def test_PythonOption_conf(self):
c = VirtualHost("*",
@@ -1426,6 +1451,7 @@
perRequestSuite.addTest(PerRequestTestCase("test_req_headers_out"))
perRequestSuite.addTest(PerRequestTestCase("test_req_sendfile"))
perRequestSuite.addTest(PerRequestTestCase("test_req_sendfile2"))
+ perRequestSuite.addTest(PerRequestTestCase("test_req_sendfile3"))
perRequestSuite.addTest(PerRequestTestCase("test_PythonOption"))
perRequestSuite.addTest(PerRequestTestCase("test_PythonOption_override"))
perRequestSuite.addTest(PerRequestTestCase("test_PythonOption_remove"))