diff options
author | 2020-11-04 09:43:02 +0200 | |
---|---|---|
committer | 2020-11-04 09:43:02 +0200 | |
commit | a3e87e40f73d5e2dd80f1fa64409bcaeb9a0313e (patch) | |
tree | 9f102fa2bceda7bd1fa7e934cb02f83a88813bda /extra_tests | |
parent | document hpy as part of the release (diff) | |
download | pypy-a3e87e40f73d5e2dd80f1fa64409bcaeb9a0313e.tar.gz pypy-a3e87e40f73d5e2dd80f1fa64409bcaeb9a0313e.tar.bz2 pypy-a3e87e40f73d5e2dd80f1fa64409bcaeb9a0313e.zip |
move test
Diffstat (limited to 'extra_tests')
-rw-r--r-- | extra_tests/test_posix_extra.py | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/extra_tests/test_posix_extra.py b/extra_tests/test_posix_extra.py new file mode 100644 index 0000000000..fe58ec0a7e --- /dev/null +++ b/extra_tests/test_posix_extra.py @@ -0,0 +1,40 @@ +import py +import sys, os, subprocess + + +CODE = """ +import sys, os, thread, time + +fd1, fd2 = os.pipe() +f1 = os.fdopen(fd1, 'r', 0) +f2 = os.fdopen(fd2, 'w', 0) + +def f(): + print "thread started" + x = f1.read(1) + assert x == "X" + print "thread exit" + +thread.start_new_thread(f, ()) +time.sleep(0.5) +if os.fork() == 0: # in the child + time.sleep(0.5) + x = f1.read(1) + assert x == "Y" + print "ok!" + sys.exit() + +f2.write("X") # in the parent +f2.write("Y") # in the parent +time.sleep(1.0) +""" + + +def test_thread_fork_file_lock(): + if not hasattr(os, 'fork'): + py.test.skip("requires 'fork'") + output = subprocess.check_output([sys.executable, '-u', '-c', CODE]) + assert output.splitlines() == [ + 'thread started', + 'thread exit', + 'ok!'] |