Permalink
Browse files

Add tests for subreaper-less Tini

If we're going to make subreaper support an option, we should ensure
that running without subreaper support also works.
  • Loading branch information...
krallin committed Sep 6, 2015
1 parent fa1f360 commit 4b3075a11d95aa04d1bb6a6098cfb99262036708
Showing with 45 additions and 10 deletions.
  1. +10 −2 ci/run_build.sh
  2. +7 −2 ddist.sh
  3. +13 −0 run_tests.sh
  4. +15 −6 test/run_inner_tests.py
View
@@ -13,11 +13,18 @@ export SOURCE_DIR="$(readlink -f "${SOURCE_DIR}")"
export DIST_DIR="$(readlink -f "${DIST_DIR}")"
export BUILD_DIR="$(readlink -f "${BUILD_DIR}")"
# Configuration
: ${FORCE_SUBREAPER:="1"}
export FORCE_SUBREAPER
# Our build platform doesn't have those newer Linux flags, but we want Tini to have subreaper support
# We also use those in our tests
export CFLAGS="-DPR_SET_CHILD_SUBREAPER=36 -DPR_GET_CHILD_SUBREAPER=37"
CFLAGS="-DPR_SET_CHILD_SUBREAPER=36 -DPR_GET_CHILD_SUBREAPER=37"
if [[ "${FORCE_SUBREAPER}" -eq 1 ]]; then
# If FORCE_SUBREAPER is requested, then we set those CFLAGS for the Tini build
export CFLAGS
fi
# Ensure Python output is not buffered (to make tests output clearer)
export PYTHONUNBUFFERED=1
@@ -69,6 +76,7 @@ virtualenv --system-site-packages "${VENV}"
# Don't use activate because it does not play nice with nounset
export PATH="${VENV}/bin:${PATH}"
export CFLAGS # We need them to build our test suite, regardless of FORCE_SUBREAPER
# Install test dependencies
pip install psutil python-prctl
View
@@ -14,5 +14,10 @@ rm -f "${HERE}/dist"/*
# Create the build image
docker build -t "${IMG}" .
# Run the build
docker run --rm --volume="${HERE}:${SRC}" -e BUILD_DIR=/tmp/tini-build -e SOURCE_DIR="${SRC}" "${IMG}" "${SRC}/ci/run_build.sh"
# Run test without subreaper support, don't copy build files here
docker run --rm \
--volume="${HERE}:${SRC}" \
-e BUILD_DIR=/tmp/tini-build \
-e SOURCE_DIR="${SRC}" \
-e FORCE_SUBREAPER="${FORCE_SUBREAPER}" \
"${IMG}" "${SRC}/ci/run_build.sh"
View
@@ -0,0 +1,13 @@
#!/bin/bash
set -o errexit
set -o nounset
REL_HERE=$(dirname "${BASH_SOURCE}")
HERE=$(cd "${REL_HERE}"; pwd)
for i in $(seq 0 1); do
export FORCE_SUBREAPER="${i}"
echo "Testing with FORCE_SUBREAPER=${FORCE_SUBREAPER}"
"${HERE}/ddist.sh"
"${HERE}/dtest.sh"
done
View
@@ -13,20 +13,29 @@ def main():
proxy = os.path.join(src, "test", "subreaper-proxy.py")
tini = os.path.join(build, "tini")
for target, env in [
([proxy, tini, "--"], {}),
([tini, "-s", "--"], {}),
([tini, "--"], {"TINI_SUBREAPER": ""}),
]:
subreaper_support = bool(int(os.environ["FORCE_SUBREAPER"]))
tests = [([proxy, tini, "--"], {}),]
if subreaper_support:
tests.extend([
([tini, "-s", "--"], {}),
([tini, "--"], {"TINI_SUBREAPER": ""}),
])
for target, env in tests:
# Run the reaping test
print "Running reaping test ({0} with env {1})".format(" ".join(target), env)
p = subprocess.Popen(target + [os.path.join(src, "test", "reaping", "stage_1.py")],
env=dict(os.environ, **env),
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
out, err = p.communicate()
assert "zombie reaping won't work" not in err, "Warning message was output!"
if subreaper_support:
# If subreaper support sin't available, Tini won't looku p its subreaper bit
# and will output the error message here.
assert "zombie reaping won't work" not in err, "Warning message was output!"
ret = p.wait()
assert ret == 0, "Reaping test failed!"

0 comments on commit 4b3075a

Please sign in to comment.