Commit 3cd864ac by Ned Batchelder

Merge pull request #22 from edx/ned/fix-temp-files

Fix temp file writing
parents ff55f635 462d1df9
...@@ -87,7 +87,7 @@ Other details here that depend on your configuration: ...@@ -87,7 +87,7 @@ Other details here that depend on your configuration:
/the/path/to/your/sandbox-packages/** r, /the/path/to/your/sandbox-packages/** r,
/tmp/codejail-*/ rix, /tmp/codejail-*/ rix,
/tmp/codejail-*/** rix, /tmp/codejail-*/** wrix,
} }
6. Parse the profiles:: 6. Parse the profiles::
......
...@@ -33,6 +33,8 @@ class JailCodeHelpers(object): ...@@ -33,6 +33,8 @@ class JailCodeHelpers(object):
def assertResultOk(self, res): def assertResultOk(self, res):
"""Assert that `res` exited well (0), and had no stderr output.""" """Assert that `res` exited well (0), and had no stderr output."""
if res.stderr:
print "---- stderr:\n%s" % res.stderr
self.assertEqual(res.stderr, "") # pylint: disable=E1101 self.assertEqual(res.stderr, "") # pylint: disable=E1101
self.assertEqual(res.status, 0) # pylint: disable=E1101 self.assertEqual(res.status, 0) # pylint: disable=E1101
...@@ -226,13 +228,16 @@ class TestLimits(JailCodeHelpers, unittest.TestCase): ...@@ -226,13 +228,16 @@ class TestLimits(JailCodeHelpers, unittest.TestCase):
f, path = tempfile.mkstemp() f, path = tempfile.mkstemp()
os.close(f) os.close(f)
with open(path, "w") as f1: with open(path, "w") as f1:
f1.write("hello"*250) try:
with open(path) as f2: f1.write(".".join("%05d" % i for i in xrange(1000)))
print "Got this:", f2.read() except IOError as e:
print "Expected exception: %s" % e
else:
with open(path) as f2:
print "Got this:", f2.read()
""") """)
self.assertNotEqual(res.status, 0) self.assertResultOk(res)
self.assertEqual(res.stdout, "Trying mkstemp\n") self.assertIn("Expected exception", res.stdout)
self.assertIn("IOError", res.stderr)
def test_cant_write_many_small_temp_files(self): def test_cant_write_many_small_temp_files(self):
# We would like this to fail, but there's nothing that checks total # We would like this to fail, but there's nothing that checks total
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment