mirror of https://github.com/krallin/tini.git
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.
This commit is contained in:
parent
fa1f3602a6
commit
4b3075a11d
|
@ -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
|
||||
|
|
9
ddist.sh
9
ddist.sh
|
@ -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"
|
||||
|
|
|
@ -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
|
|
@ -13,12 +13,17 @@ 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")],
|
||||
|
@ -26,7 +31,11 @@ def main():
|
|||
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!"
|
||||
|
||||
|
|
Loading…
Reference in New Issue