Thomas Orozco 7 years ago committed by Patrick Steinhardt
parent eb0f6de3a5
commit 1487373aa2
  1. 30
      test/pdeathsignal/stage_1.py
  2. 25
      test/pdeathsignal/stage_2.py
  3. 18
      test/run_inner_tests.py

@ -0,0 +1,30 @@
#!/usr/bin/env python
from __future__ import print_function
import os
import sys
import subprocess
def main():
pid = os.getpid()
tini = sys.argv[1]
ret = sys.argv[2]
stage_2 = os.path.join(os.path.dirname(__file__), "stage_2.py")
cmd = [
tini,
"-vvv",
"-p",
"SIGUSR1",
"--",
stage_2,
str(pid),
ret
]
subprocess.Popen(cmd).wait()
if __name__ == "__main__":
main()

@ -0,0 +1,25 @@
#!/usr/bin/env python
from __future__ import print_function
import os
import sys
import signal
import time
def main():
ret = sys.argv[2]
def handler(*args):
with open(ret, "w") as f:
f.write("ok")
sys.exit(0)
signal.signal(signal.SIGUSR1, handler)
pid = int(sys.argv[1])
os.kill(pid, signal.SIGKILL)
time.sleep(5)
if __name__ == "__main__":
main()

@ -9,6 +9,7 @@ import psutil
import bitmap import bitmap
import re import re
import itertools import itertools
import tempfile
DEVNULL = open(os.devnull, 'wb') DEVNULL = open(os.devnull, 'wb')
@ -133,7 +134,7 @@ def main():
assert ret == 1, "Reaping test succeeded (it should have failed)!" assert ret == 1, "Reaping test succeeded (it should have failed)!"
# Test that the signals are properly in place here. # Test that the signals are properly in place here.
print "running signal configuration test" print "Running signal configuration test"
p = subprocess.Popen([os.path.join(build, "sigconf-test"), tini, "cat", "/proc/self/status"], stdout=subprocess.PIPE, stderr=subprocess.PIPE) p = subprocess.Popen([os.path.join(build, "sigconf-test"), tini, "cat", "/proc/self/status"], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
out, err = p.communicate() out, err = p.communicate()
@ -156,6 +157,21 @@ def main():
# Use signum - 1 because the bitmap is 0-indexed but represents signals strting at 1 # Use signum - 1 because the bitmap is 0-indexed but represents signals strting at 1
assert (signum - 1) in props[signal_set_name].nonzero(), "{0} ({1}) is missing in {2}!".format(SIGNUM_TO_SIGNAME[signum], signum, signal_set_name) assert (signum - 1) in props[signal_set_name].nonzero(), "{0} ({1}) is missing in {2}!".format(SIGNUM_TO_SIGNAME[signum], signum, signal_set_name)
# Test parent death signal handling.
if not args_disabled:
print "Running parent death signal test"
f = tempfile.NamedTemporaryFile()
try:
p = subprocess.Popen(
[os.path.join(src, "test", "pdeathsignal", "stage_1.py"), tini, f.name],
stdout=DEVNULL, stderr=DEVNULL
)
p.wait()
busy_wait(lambda: open(f.name).read() == "ok", 10)
finally:
f.close()
print "---------------------------" print "---------------------------"
print "All done, tests as expected" print "All done, tests as expected"
print "---------------------------" print "---------------------------"

Loading…
Cancel
Save