Skip to content

Commit

Permalink
add test for chdir("/") behaviour
Browse files Browse the repository at this point in the history
  • Loading branch information
Rasmus Villemoes committed Dec 3, 2020
1 parent 6c2cf1d commit 4a13a35
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions tests/cwd_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import os
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.
proc = run((os.path.join(os.getcwd(), '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'

0 comments on commit 4a13a35

Please sign in to comment.