Merge pull request #116 from chriskuehl/use-bin-bash-exit-status-test

Fix exit_status_test on Fedora
This commit is contained in:
Anthony Sottile 2016-08-26 13:36:05 -07:00 committed by GitHub
commit a91de79a9e

View file

@ -1,4 +1,5 @@
import signal import signal
import sys
from subprocess import Popen from subprocess import Popen
import pytest import pytest
@ -17,7 +18,7 @@ def test_exit_status_regular_exit(exit_status):
@pytest.mark.parametrize('signal', [ @pytest.mark.parametrize('signal', [
signal.SIGTERM, signal.SIGTERM,
signal.SIGINT, signal.SIGHUP,
signal.SIGQUIT, signal.SIGQUIT,
signal.SIGKILL, signal.SIGKILL,
]) ])
@ -26,6 +27,10 @@ def test_exit_status_terminated_by_signal(signal):
"""dumb-init should exit with status 128 + signal when the child process is """dumb-init should exit with status 128 + signal when the child process is
terminated by a signal. terminated by a signal.
""" """
proc = Popen(('dumb-init', 'sh', '-c', 'kill -{0} $$'.format(signal))) # We use Python because sh is "dash" on Debian and "bash" on others.
# https://github.com/Yelp/dumb-init/issues/115
proc = Popen(('dumb-init', sys.executable, '-c', 'import os; os.kill(os.getpid(), {0})'.format(
signal,
)))
proc.wait() proc.wait()
assert proc.returncode == 128 + signal assert proc.returncode == 128 + signal