Author: Matti Picus <[email protected]>
Branch:
Changeset: r70963:6ef1921d8d68
Date: 2014-04-25 10:09 +0300
http://bitbucket.org/pypy/pypy/changeset/6ef1921d8d68/
Log: disable sandbox on windows, fix tests
diff --git a/rpython/translator/sandbox/rsandbox.py
b/rpython/translator/sandbox/rsandbox.py
--- a/rpython/translator/sandbox/rsandbox.py
+++ b/rpython/translator/sandbox/rsandbox.py
@@ -3,6 +3,10 @@
trampolines that marshal their input arguments, dump them to STDOUT,
and wait for an answer on STDIN. Enable with 'translate.py --sandbox'.
"""
+import sys
+if sys.platform == 'win32':
+ raise TypeError("sandbox not supported on windows")
+
import py
from rpython.rlib import rmarshal, types
diff --git a/rpython/translator/sandbox/test/test_sandbox.py
b/rpython/translator/sandbox/test/test_sandbox.py
--- a/rpython/translator/sandbox/test/test_sandbox.py
+++ b/rpython/translator/sandbox/test/test_sandbox.py
@@ -25,7 +25,20 @@
check_str_without_nul=True)
return str(t.compile())
+unsupported_platform = ('False', '')
+if sys.platform == 'win32':
+ unsupported_platform = ('True', 'sandbox not supported on this platform')
+ def test_unavailable():
+ def entry_point(argv):
+ fd = os.open("/tmp/foobar", os.O_RDONLY, 0777)
+ os.close(fd)
+ return 0
+ exc = py.test.raises(TypeError, compile, entry_point)
+ assert str(exc).find('not supported') >= 0
+supported = py.test.mark.skipif(unsupported_platform[0],
reason=unsupported_platform[1])
+
+@supported
def test_open_dup():
def entry_point(argv):
fd = os.open("/tmp/foobar", os.O_RDONLY, 0777)
@@ -43,6 +56,7 @@
f.close()
assert tail == ""
+@supported
def test_read_write():
def entry_point(argv):
fd = os.open("/tmp/foobar", os.O_RDONLY, 0777)
@@ -65,6 +79,7 @@
f.close()
assert tail == ""
+@supported
def test_dup2_access():
def entry_point(argv):
os.dup2(34, 56)
@@ -80,6 +95,7 @@
f.close()
assert tail == ""
+@supported
def test_stat_ftruncate():
from rpython.translator.sandbox.sandlib import RESULTTYPE_STATRESULT
from rpython.rlib.rarithmetic import r_longlong
@@ -101,6 +117,7 @@
f.close()
assert tail == ""
+@supported
def test_time():
def entry_point(argv):
t = time.time()
@@ -116,6 +133,7 @@
f.close()
assert tail == ""
+@supported
def test_getcwd():
def entry_point(argv):
t = os.getcwd()
@@ -131,6 +149,7 @@
f.close()
assert tail == ""
+@supported
def test_oserror():
def entry_point(argv):
try:
@@ -148,6 +167,7 @@
f.close()
assert tail == ""
+@supported
def test_hybrid_gc():
def entry_point(argv):
l = []
@@ -172,6 +192,7 @@
rescode = pipe.wait()
assert rescode == 0
+@supported
def test_segfault_1():
class A:
def __init__(self, m):
@@ -194,6 +215,7 @@
e.close()
assert 'Invalid RPython operation' in errors
+@supported
def test_segfault_2():
py.test.skip("hum, this is one example, but we need to be very careful")
class Base:
@@ -226,6 +248,7 @@
e.close()
assert '...think what kind of errors to get...' in errors
+@supported
def test_safe_alloc():
from rpython.rlib.rmmap import alloc, free
@@ -246,6 +269,7 @@
rescode = pipe.wait()
assert rescode == 0
+@supported
def test_unsafe_mmap():
py.test.skip("Since this stuff is unimplemented, it won't work anyway "
"however, the day it starts working, it should pass test")
@@ -271,6 +295,7 @@
rescode = pipe.wait()
assert rescode == 0
+@supported
class TestPrintedResults:
def run(self, entry_point, args, expected):
diff --git a/rpython/translator/sandbox/test/test_sandlib.py
b/rpython/translator/sandbox/test/test_sandlib.py
--- a/rpython/translator/sandbox/test/test_sandlib.py
+++ b/rpython/translator/sandbox/test/test_sandlib.py
@@ -6,10 +6,10 @@
from rpython.translator.sandbox.sandlib import SimpleIOSandboxedProc
from rpython.translator.sandbox.sandlib import VirtualizedSandboxedProc
from rpython.translator.sandbox.sandlib import VirtualizedSocketProc
-from rpython.translator.sandbox.test.test_sandbox import compile
+from rpython.translator.sandbox.test.test_sandbox import compile, supported
from rpython.translator.sandbox.vfs import Dir, File, RealDir, RealFile
-
+@supported
class MockSandboxedProc(SandboxedProc):
"""A sandbox process wrapper that replays expected syscalls."""
@@ -35,7 +35,7 @@
do_ll_os__ll_os_write = _make_method("write")
do_ll_os__ll_os_close = _make_method("close")
-
+@supported
def test_lib():
def entry_point(argv):
fd = os.open("/tmp/foobar", os.O_RDONLY, 0777)
@@ -63,6 +63,7 @@
proc.handle_forever()
assert proc.seen == len(proc.expected)
+@supported
def test_foobar():
py.test.skip("to be updated")
foobar = rffi.llexternal("foobar", [rffi.CCHARP], rffi.LONG)
@@ -79,6 +80,7 @@
proc.handle_forever()
assert proc.seen == len(proc.expected)
+@supported
def test_simpleio():
def entry_point(argv):
print "Please enter a number:"
@@ -100,6 +102,7 @@
assert output == "Please enter a number:\nThe double is: 42\n"
assert error == ""
+@supported
def test_socketio():
class SocketProc(VirtualizedSocketProc, SimpleIOSandboxedProc):
def build_virtual_root(self):
@@ -116,6 +119,7 @@
output, error = proc.communicate("")
assert output.startswith('HTTP/1.0 503 Service Unavailable')
+@supported
def test_oserror():
def entry_point(argv):
try:
@@ -133,6 +137,7 @@
assert proc.seen == len(proc.expected)
+@supported
class SandboxedProcWithFiles(VirtualizedSandboxedProc, SimpleIOSandboxedProc):
"""A sandboxed process with a simple virtualized filesystem.
@@ -145,6 +150,7 @@
'this.pyc': RealFile(__file__),
})
+@supported
def test_too_many_opens():
def entry_point(argv):
try:
@@ -186,6 +192,7 @@
assert output == "All ok!\n"
assert error == ""
+@supported
def test_fstat():
def compare(a, b, i):
if a != b:
@@ -219,6 +226,7 @@
assert output == "All ok!\n"
assert error == ""
+@supported
def test_lseek():
def char_should_be(c, should):
if c != should:
@@ -248,6 +256,7 @@
assert output == "All ok!\n"
assert error == ""
+@supported
def test_getuid():
def entry_point(argv):
import os
diff --git a/rpython/translator/sandbox/test/test_vfs.py
b/rpython/translator/sandbox/test/test_vfs.py
--- a/rpython/translator/sandbox/test/test_vfs.py
+++ b/rpython/translator/sandbox/test/test_vfs.py
@@ -2,10 +2,13 @@
import sys, stat, os
from rpython.translator.sandbox.vfs import *
from rpython.tool.udir import udir
+from rpython.translator.sandbox.test.test_sandbox import unsupported_platform
HASLINK = hasattr(os, 'symlink')
def setup_module(mod):
+ if unsupported_platform[0] == 'True':
+ py.test.skip(unsupported_platform[1])
d = udir.ensure('test_vfs', dir=1)
d.join('file1').write('somedata1')
d.join('file2').write('somelongerdata2')
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit