-
Notifications
You must be signed in to change notification settings - Fork 347
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #210 from Villemoes/chdir
chdir to / in parent
- Loading branch information
Showing
2 changed files
with
27 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import os | ||
import shutil | ||
from subprocess import run, PIPE | ||
|
||
import pytest | ||
|
||
@pytest.mark.usefixtures('both_debug_modes', 'both_setsid_modes') | ||
def test_working_directories(): | ||
"""The child process must start in the working directory in which | ||
dumb-init was invoked, but dumb-init itself should not keep a | ||
reference to that.""" | ||
|
||
# We need absolute path to dumb-init since we pass cwd=/tmp to get | ||
# predictable output - so we can't rely on dumb-init being found | ||
# in the "." directory. | ||
dumb_init = os.path.realpath(shutil.which('dumb-init')) | ||
proc = run((dumb_init, | ||
'sh', '-c', 'readlink /proc/$PPID/cwd && readlink /proc/$$/cwd'), | ||
cwd="/tmp", stdout=PIPE, stderr=PIPE) | ||
|
||
assert proc.returncode == 0 | ||
assert proc.stdout == b'/\n/tmp\n' |