Skip to content

Commit

Permalink
Add test cases for post processing commands
Browse files Browse the repository at this point in the history
Tests post processing commands and chaining of post-processing commands
  • Loading branch information
JPEWdev committed Dec 5, 2018
1 parent 9259b8a commit 2bf3a3f
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 0 deletions.
12 changes: 12 additions & 0 deletions ci/run_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,18 @@ if [[ -n "${ARCH_NATIVE-}" ]]; then
if "${tini}" -vvv -- -- true; then
exit 1
fi

echo "Testing ${tini} missing post command terminator (should fail)"
# Missing terminator
if "$tini" -P true -- true; then
exit 1
fi

echo "Testing ${tini} missing post command with only a terminator (should fail)"
# Only a terminator
if "$tini" -P \; -- true; then
exit 1
fi
fi

echo "Testing ${tini} supports TINI_VERBOSITY"
Expand Down
12 changes: 12 additions & 0 deletions test/post/stage_1.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#! /bin/sh

case "$1" in
0)
exit 2
;;
1)
exit 3
;;
esac

exit 4
13 changes: 13 additions & 0 deletions test/post/stage_2.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#! /bin/sh

case "$1" in
2)
exit 5
;;
3)
exit 6
;;
esac

exit 4

19 changes: 19 additions & 0 deletions test/run_inner_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,25 @@ def main():
ret = p.wait()
assert ret == code, "Exclusive exit code test failed for %s, exit: %s" % (code, ret)

print "Running post command test for {0}".format(tini)
for in_code, out_code in ((0, 2), (1, 3)):
p = subprocess.Popen([tini, '-P', os.path.join(src, "test", "post", "stage_1.sh"), '{}', ';', '--', 'sh', '-c', 'exit {0}'.format(in_code)],
stdout=DEVNULL, stderr=DEVNULL
)
ret = p.wait()
assert ret == out_code, "post command test failed for %s, exit: %s" % (in_code, ret)

print "Running post command chain test for {0}".format(tini)

for in_code, out_code in ((0, 5), (1, 6)):
post_cmd_1 = os.path.join(src, "test", "post", "stage_1.sh")
post_cmd_2 = os.path.join(src, "test", "post", "stage_2.sh")
p = subprocess.Popen([tini, '-P', post_cmd_1, '{}', ';', '-P', post_cmd_2, '{}', ';', '--', 'sh', '-c', 'exit {0}'.format(in_code)],
stdout=DEVNULL, stderr=DEVNULL
)
ret = p.wait()
assert ret == out_code, "post command test failed for %s, exit: %s" % (in_code, ret)

tests = [([proxy, tini], {}),]

if subreaper_support:
Expand Down

0 comments on commit 2bf3a3f

Please sign in to comment.