|
|
@ -60,20 +60,19 @@ def main(): |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Run the signals test |
|
|
|
# Run the signals test |
|
|
|
for signame in "SIGINT", "SIGTERM": |
|
|
|
for signum in [signal.SIGINT, signal.SIGTERM]: |
|
|
|
print "running signal test for: {0} ({1} with env {2})".format(signame, " ".join(target), env) |
|
|
|
print "running signal test for: {0} ({1} with env {2})".format(SIGNUM_TO_SIGNAME[signum], " ".join(target), env) |
|
|
|
p = subprocess.Popen(target + [os.path.join(src, "test", "signals", "test.py")], env=dict(os.environ, **env)) |
|
|
|
p = subprocess.Popen(target + [os.path.join(src, "test", "signals", "test.py")], env=dict(os.environ, **env)) |
|
|
|
sig = getattr(signal, signame) |
|
|
|
p.send_signal(signum) |
|
|
|
p.send_signal(sig) |
|
|
|
|
|
|
|
ret = p.wait() |
|
|
|
ret = p.wait() |
|
|
|
assert ret == -sig, "Signals test failed!" |
|
|
|
assert ret == -signum, "Signals test failed (ret was {0}, expected {1})".format(ret, -signum) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Run the process group test |
|
|
|
# Run the process group test |
|
|
|
# This test has Tini spawn a process that ignores SIGUSR1 and spawns a child that doesn't (and waits on the child) |
|
|
|
# This test has Tini spawn a process that ignores SIGUSR1 and spawns a child that doesn't (and waits on the child) |
|
|
|
# We send SIGUSR1 to Tini, and expect the grand-child to terminate, then the child, and then Tini. |
|
|
|
# We send SIGUSR1 to Tini, and expect the grand-child to terminate, then the child, and then Tini. |
|
|
|
print "Running process group test" |
|
|
|
print "Running process group test" |
|
|
|
p = subprocess.Popen([tini, '-g', '--', os.path.join(src, "test", "pgroup", "stage_1.py")], env=dict(os.environ, **env)) |
|
|
|
p = subprocess.Popen([tini, '-g', '--', os.path.join(src, "test", "pgroup", "stage_1.py")], stdout=subprocess.PIPE, stderr=subprocess.PIPE) |
|
|
|
|
|
|
|
|
|
|
|
busy_wait(lambda: len(psutil.Process(p.pid).children(recursive=True)) == 2, 10) |
|
|
|
busy_wait(lambda: len(psutil.Process(p.pid).children(recursive=True)) == 2, 10) |
|
|
|
p.send_signal(signal.SIGUSR1) |
|
|
|
p.send_signal(signal.SIGUSR1) |
|
|
|