seveas / python-prctl

Wrapping prctl for python

Home Page:http://packages.python.org/python-prctl/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Some tests fail when run in a sandbox

catern opened this issue · comments

When run in a sandbox (the Nix build sandbox, since I'm packaging python-prctl for Nix), I see the following test failures (either because they themselves try to enter a sandbox, or they try to access inaccessible things). Maybe you can think of a way to fix the tests so they will work when running already in a sandbox?

This is a minor issue, in the mean time I will work around it by just skipping the failing tests in question.

running build_ext
copying build/lib.linux-x86_64-3.6/_prctl.cpython-36m-x86_64-linux-gnu.so ->
test_capabilities_objects (test_prctl.PrctlTest) ... ok
test_capbset (test_prctl.PrctlTest)
Test the get_capbset/set_capbset functions ... ok
test_capbset_object (test_prctl.PrctlTest)
Test manipulation of the capability bounding set via the capbset object ... ok
test_captoname (test_prctl.PrctlTest) ... ok
test_child_subreaper (test_prctl.PrctlTest) ... ok
test_constants (test_prctl.PrctlTest)
Test whether copying of constants works ... ok
test_dumpable (test_prctl.PrctlTest)
Test manipulation of the dumpable flag ... ok
test_endian (test_prctl.PrctlTest)
Test manipulation of the endianness setting ... ok
test_fpemu (test_prctl.PrctlTest)
Test manipulation of the fpemu setting ... ok
test_fpexc (test_prctl.PrctlTest)
Test manipulation of the fpexc setting ... ok
test_getcaps (test_prctl.PrctlTest)
Test the get_caps function ... ok
test_keepcaps (test_prctl.PrctlTest)
Test manipulation of the keepcaps setting ... ok
test_mce_kill (test_prctl.PrctlTest)
Test the MCE_KILL setting ... ERROR
test_name (test_prctl.PrctlTest)
Test setting the process name ... ok
test_no_new_privs (test_prctl.PrctlTest)
Test the no_new_privs function ... FAIL
test_pdeathsig (test_prctl.PrctlTest)
Test manipulation of the pdeathsig setting ... ok
test_proctitle (test_prctl.PrctlTest)
Test setting the process title, including too long titles ... ERROR
test_ptracer (test_prctl.PrctlTest)
Test manipulation of the ptracer setting ... ok
test_seccomp (test_prctl.PrctlTest)
Test manipulation of the seccomp setting ... FAIL
test_securebits (test_prctl.PrctlTest)
Test manipulation of the securebits flag ... ok
test_securebits_obj (test_prctl.PrctlTest)
Test manipulation of the securebits via the securebits object ... ok
test_setcaps (test_prctl.PrctlTest)
Test the setcaps function ... ok
test_timerslack (test_prctl.PrctlTest)
Test manipulation of the timerslack value ... ok
test_timing (test_prctl.PrctlTest)
Test manipulation of the timing setting ... ok
test_tsc (test_prctl.PrctlTest)
Test manipulation of the timestamp counter flag ... ok
test_unalign (test_prctl.PrctlTest)
Test manipulation of the unaligned access setting ... ok

======================================================================
ERROR: test_mce_kill (test_prctl.PrctlTest)
Test the MCE_KILL setting
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/nix-build-python3.6-python-prctl-1.7.drv-0/python-prctl-1.7/test_prctl.py", line 160, in test_mce_kill
    fd = open('/proc/sys/vm/memory_failure_early_kill')
FileNotFoundError: [Errno 2] No such file or directory: '/proc/sys/vm/memory_failure_early_kill'

======================================================================
ERROR: test_proctitle (test_prctl.PrctlTest)
Test setting the process title, including too long titles
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/nix-build-python3.6-python-prctl-1.7.drv-0/python-prctl-1.7/test_prctl.py", line 197, in test_proctitle
    stdout=subprocess.PIPE).communicate()[0].decode('ascii')
  File "/nix/store/rsa1rsd6c6szy0dmi61599b33aqiy269-python3-3.6.5/lib/python3.6/subprocess.py", line 709, in __init__
    restore_signals, start_new_session)
  File "/nix/store/rsa1rsd6c6szy0dmi61599b33aqiy269-python3-3.6.5/lib/python3.6/subprocess.py", line 1344, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'ps': 'ps'

======================================================================
FAIL: test_no_new_privs (test_prctl.PrctlTest)
Test the no_new_privs function
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/nix-build-python3.6-python-prctl-1.7.drv-0/python-prctl-1.7/test_prctl.py", line 179, in test_no_new_privs
    self.assertEqual(prctl.get_no_new_privs(), 0)
AssertionError: 1 != 0

======================================================================
FAIL: test_seccomp (test_prctl.PrctlTest)
Test manipulation of the seccomp setting
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/nix-build-python3.6-python-prctl-1.7.drv-0/python-prctl-1.7/test_prctl.py", line 231, in test_seccomp
    self.assertEqual(prctl.get_seccomp(), False)
AssertionError: True != False

----------------------------------------------------------------------
Ran 26 tests in 0.010s

FAILED (failures=2, errors=2)
Test failed: <unittest.runner.TextTestResult run=26 errors=2 failures=2>

Looks like /proc and ps are missing in your sandbox. Would it be possible to add those? That only leaves the seccomp and no_new_privs tests, which understandably fail in a sandbox. Is there a way to detect the sandbox?

MCE_KILL test now skipped when appropriate in abb989a