Skip to content

Commit

Permalink
Merge pull request #92 from krallin/muslc-binaries
Browse files Browse the repository at this point in the history
Build musl-based binaries
  • Loading branch information
krallin authored Jul 3, 2017
2 parents eb3987c + 540eb7b commit e4e2f43
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 20 deletions.
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ language: generic

env:
matrix:
- CC=gcc ARCH_SUFFIX= ARCH_NATIVE=1 MINIMAL=
- CC=gcc ARCH_SUFFIX=amd64 ARCH_NATIVE=1 MINIMAL=
- CC=arm-linux-gnueabihf-gcc ARCH_SUFFIX=armhf ARCH_NATIVE= MINIMAL=
- CC=aarch64-linux-gnu-gcc ARCH_SUFFIX=arm64 ARCH_NATIVE= MINIMAL=
- CFLAGS="-m32" ARCH_SUFFIX=i386 ARCH_NATIVE= MINIMAL=
- CC=musl-gcc ARCH_SUFFIX=muslc-amd64 ARCH_NATIVE=1 MINIMAL=
- CC=gcc ARCH_SUFFIX=amd64 ARCH_NATIVE=1 MINIMAL=1
global:
- SIGN_BINARIES=1
Expand Down
4 changes: 3 additions & 1 deletion ci/install_deps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,16 @@ DEPS=(
hardening-includes gnupg
)

if [[ "$ARCH_SUFFIX" = "amd64" ]]; then
if [[ -z "${ARCH_SUFFIX-}" ]] || [[ "$ARCH_SUFFIX" = "amd64" ]]; then
true
elif [[ "$ARCH_SUFFIX" = "armhf" ]]; then
DEPS+=(gcc-arm-linux-gnueabihf binutils-arm-linux-gnueabi libc6-dev-armhf-cross)
elif [[ "$ARCH_SUFFIX" = "arm64" ]]; then
DEPS+=(gcc-aarch64-linux-gnu binutils-aarch64-linux-gnu libc6-dev-arm64-cross)
elif [[ "$ARCH_SUFFIX" = "i386" ]]; then
DEPS+=(libc6-dev-i386 gcc-multilib)
elif [[ "$ARCH_SUFFIX" = "muslc-amd64" ]]; then
DEPS+=(musl-tools)
else
echo "Unknown ARCH_SUFFIX=${ARCH_SUFFIX}"
exit 1
Expand Down
25 changes: 17 additions & 8 deletions ci/run_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,14 @@ if [[ -n "${ARCH_NATIVE-}" ]]; then
{
! "$tini" 2>&1
} | grep -q "more verbose"

echo "Testing $tini with: -- true (should succeed)"
"${tini}" -vvv -- true

echo "Testing $tini with: -- -- true (should fail)"
if "${tini}" -vvv -- -- true; then
exit 1
fi
fi

echo "Testing ${tini} supports TINI_VERBOSITY"
Expand Down Expand Up @@ -164,7 +172,12 @@ if [[ -n "${ARCH_NATIVE-}" ]]; then
fi

echo "Checking hardening on $tini"
hardening-check --nopie --nostackprotector --nobindnow "${tini}"
hardening_skip=(--nopie --nostackprotector --nobindnow)
if [[ "$CC" == "musl-gcc" ]]; then
# FORTIFY_SOURCE is a glibc thing
hardening_skip=("${hardening_skip[@]}" --nofortify)
fi
hardening-check "${hardening_skip[@]}" "${tini}"
done

# Quick package audit
Expand Down Expand Up @@ -193,7 +206,7 @@ if [[ -n "${ARCH_NATIVE-}" ]]; then
export CFLAGS # We need them to build our test suite, regardless of FORCE_SUBREAPER

# Install test dependencies
pip install psutil python-prctl bitmap
CC=gcc pip install psutil python-prctl bitmap

# Run tests
python "${SOURCE_DIR}/test/run_inner_tests.py"
Expand All @@ -218,9 +231,7 @@ for tini in tini tini-static; do
to="${DIST_DIR}/${tini}-${ARCH_SUFFIX}"
TINIS+=("$to")
cp "${BUILD_DIR}/${tini}" "$to"
fi

if [[ -n "${ARCH_NATIVE-}" ]]; then
else
to="${DIST_DIR}/${tini}"
TINIS+=("$to")
cp "${BUILD_DIR}/${tini}" "$to"
Expand All @@ -235,9 +246,7 @@ if [[ -n "${ARCH_NATIVE-}" ]]; then
to="${DIST_DIR}/tini_${pkg_version}-${ARCH_SUFFIX}.${pkg_format}"
TINIS+=("$to")
cp "$src" "$to"
fi

if [[ -n "${ARCH_NATIVE-}" ]]; then
else
to="${DIST_DIR}/tini_${pkg_version}.${pkg_format}"
TINIS+=("$to")
cp "$src" "$to"
Expand Down
7 changes: 4 additions & 3 deletions test/run_inner_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,13 @@ def main():


# Run the signals test
for signum in [signal.SIGINT, signal.SIGTERM]:
print "running signal test for: {0} ({1} with env {2})".format(SIGNUM_TO_SIGNAME[signum], " ".join(target), env)
for signum in [signal.SIGTERM, signal.SIGUSR1, signal.SIGUSR2]:
print "running signal test for: {0} ({1} with env {2})".format(signum, " ".join(target), env)
p = subprocess.Popen(target + [os.path.join(src, "test", "signals", "test.py")], env=dict(os.environ, **env))
busy_wait(lambda: len(psutil.Process(p.pid).children(recursive=True)) > 1, 10)
p.send_signal(signum)
ret = p.wait()
assert ret == -signum, "Signals test failed (ret was {0}, expected {1})".format(ret, -signum)
assert ret == 128 + signum, "Signals test failed (ret was {0}, expected {1})".format(ret, 128 + signum)


# Run the process group test
Expand Down
10 changes: 5 additions & 5 deletions test/run_outer_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,17 @@ def target():
# Checks
if thread.is_alive():
subprocess.check_call(self.fail_cmd, **pipe_kwargs)
err = Exception("Test failed with timeout!")
err = Exception("Test failed with timeout!")

elif self.proc.returncode != retcode:
err = Exception("Test failed with unexpected returncode (expected {0}, got {1})".format(retcode, self.proc.returncode))
err = Exception("Test failed with unexpected returncode (expected {0}, got {1})".format(retcode, self.proc.returncode))

if err is not None:
print "FAIL"
print "--- STDOUT ---"
print self.stdout
print getattr(self, "stdout", "no stdout")
print "--- STDERR ---"
print self.stderr
print getattr(self, "stderr", "no stderr")
print "--- ... ---"
raise err
else:
Expand Down Expand Up @@ -146,7 +146,7 @@ def main():
Command(functional_base_cmd + ["/tini/test/reaping/stage_1.py"], fail_cmd).run(timeout=10)

# Signals test
for sig, retcode in [("INT", 1), ("TERM", 143)]:
for sig, retcode in [("TERM", 143), ("USR1", 138), ("USR2", 140)]:
Command(
functional_base_cmd + ["/tini/test/signals/test.py"],
fail_cmd,
Expand Down
13 changes: 10 additions & 3 deletions test/signals/test.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
#!/usr/bin/env python
import time
import signal
import os


def main():
signal.signal(signal.SIGTERM, signal.SIG_DFL)
signal.signal(signal.SIGUSR1, signal.SIG_DFL)
signal.signal(signal.SIGUSR2, signal.SIG_DFL)
os.system("sleep 100")

if __name__ == "__main__":
while 1:
time.sleep(10)
main()

0 comments on commit e4e2f43

Please sign in to comment.