| 1 |
|
| 2 |
from __future__ import absolute_import |
| 3 |
import os |
| 4 |
import py |
| 5 |
import sys |
| 6 |
from pypy.module.test_lib_pypy import test_resource |
| 7 |
|
| 8 |
|
| 9 |
from lib_pypy import _pypy_wait |
| 10 |
|
| 11 |
def test_os_wait3(): |
| 12 |
wait3 = _pypy_wait.wait3 |
| 13 |
exit_status = 0x33 |
| 14 |
child = os.fork() |
| 15 |
if child == 0: |
| 16 |
os._exit(exit_status) |
| 17 |
else: |
| 18 |
pid, status, rusage = wait3(0) |
| 19 |
assert child == pid |
| 20 |
assert os.WIFEXITED(status) |
| 21 |
assert os.WEXITSTATUS(status) == exit_status |
| 22 |
assert isinstance(rusage.ru_utime, float) |
| 23 |
assert isinstance(rusage.ru_maxrss, int) |
| 24 |
|
| 25 |
def test_os_wait4(): |
| 26 |
wait4 = _pypy_wait.wait4 |
| 27 |
exit_status = 0x33 |
| 28 |
child = os.fork() |
| 29 |
if child == 0: |
| 30 |
os._exit(exit_status) |
| 31 |
else: |
| 32 |
pid, status, rusage = wait4(child, 0) |
| 33 |
assert child == pid |
| 34 |
assert os.WIFEXITED(status) |
| 35 |
assert os.WEXITSTATUS(status) == exit_status |
| 36 |
assert isinstance(rusage.ru_utime, float) |
| 37 |
assert isinstance(rusage.ru_maxrss, int) |
| 38 |
|
| 39 |
def test_errors(): |
| 40 |
|
| 41 |
if sys.platform != 'darwin': |
| 42 |
py.test.raises(OSError, _pypy_wait.wait3, -999) |
| 43 |
py.test.raises(OSError, _pypy_wait.wait4, -999, -999) |