Skip to content

Commit

Permalink
ci: Enable coredump
Browse files Browse the repository at this point in the history
  • Loading branch information
tesuji committed Apr 24, 2019
1 parent ad0add1 commit 5e6d357
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 15 deletions.
37 changes: 37 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ dist: xenial
services:
- docker
language: rust
addons:
apt:
packages:
- gdb

git:
depth: false
Expand Down Expand Up @@ -71,10 +75,43 @@ script:
else
PATH="$HOME/rust/bin:$PATH" sh ci/run.sh;
fi
# Check the formatting last because test failures are more interesting to have
# discovered for contributors lacking some platform access for testing beforehand
- if [ "${TARGET}" = x86_64-unknown-linux-gnu ]; then
shellcheck -s dash -e SC1090 -- rustup-init.sh ci/*.sh;
cargo fmt --all -- --check;
fi

# Random attempt at debugging currently. Just poking around in here to see if
# anything shows up.
after_failure:
# Dump backtrace for macOS
- ls -lat "$HOME"/Library/Logs/DiagnosticReports/
- find "$HOME"/Library/Logs/DiagnosticReports
-type f
-name '*.crash'
-not -name '*.stage2-*.crash'
-not -name 'com.apple.CoreSimulator.CoreSimulatorService-*.crash'
-exec printf travis_fold":start:crashlog\n\033[31;1m%s\033[0m\n" {} \;
-exec head -750 {} \;
-exec echo travis_fold":"end:crashlog \; || true

# Dump backtrace for Linux
- ln -s . checkout &&
for CORE in obj/cores/core.*; do
EXE=$(echo $CORE | sed 's@obj/cores/core\.[0-9]*\.!checkout!\(.*\)@\1@;y@!@/@');
if [ -f "$EXE" ]; then
printf travis_fold":start:crashlog\n\033[31;1m%s\033[0m\n" "$CORE";
gdb --batch -q -c "$CORE" "$EXE"
-iex 'set auto-load off'
-iex 'dir src/'
-iex 'set sysroot .'
-ex bt
-ex q;
echo travis_fold":"end:crashlog;
fi;
done || true

before_deploy:
- sh ci/prepare-deploy-travis.sh

Expand Down
39 changes: 29 additions & 10 deletions ci/build-run-docker.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
#!/bin/bash

script_dir=$(cd "$(dirname "$0")" && pwd)
root_dir="$TRAVIS_BUILD_DIR"
script_dir="$root_dir/ci"
objdir="$root_dir"/obj

. "$script_dir/shared.sh"

set -e
# Disable cause it makes shared script not to work properly
#set -x

mkdir -p target
mkdir -p "$HOME"/.cargo
mkdir -p "$objdir"/cores
mkdir -p "$HOME"/.cache/sccache

# Enable core dump on Linux
sudo sh -c 'echo "/checkout/obj/cores/core.%p.%E" > /proc/sys/kernel/core_pattern';

DOCKER="$1"
TARGET="$2"
Expand All @@ -27,23 +35,34 @@ if [ -f "ci/docker/$DOCKER/Dockerfile" ]; then
travis_fold end "build.Dockerfile.${DOCKER}"
fi

# Run containers as privileged as it should give them access to some more
# syscalls such as ptrace and whatnot. In the upgrade to LLVM 5.0 it was
# discovered that the leak sanitizer apparently needs these syscalls nowadays so
# we'll need `--privileged` for at least the `x86_64-gnu` builder, so this just
# goes ahead and sets it for all builders.
# shellcheck disable=SC2016
docker run \
--entrypoint sh \
--entrypoint /bin/sh \
--user "$(id -u)":"$(id -g)" \
--volume "$(rustc --print sysroot)":/travis-rust:ro \
--volume "$(pwd)":/src:ro \
--volume "$(pwd)"/target:/src/target \
--workdir /src \
--volume "$(rustc --print sysroot)":/rustc-sysroot:ro \
--volume "$root_dir":/checkout:ro \
--volume "$root_dir"/target:/checkout/target \
--volume "$objdir":/checkout/obj \
--workdir /checkout \
--privileged \
--env TARGET="$TARGET" \
--env SKIP_TESTS="$SKIP_TESTS" \
--env CARGO_HOME=/src/target/cargo-home \
--env CARGO_TARGET_DIR=/src/target \
--volume "$HOME/.cargo:/cargo" \
--env CARGO_HOME=/cargo \
--env CARGO_TARGET_DIR=/checkout/target \
--env LIBZ_SYS_STATIC=1 \
--volume "$HOME"/.cache/sccache:/sccache \
--env SCCACHE_DIR=/sccache \
--tty \
--init \
--rm \
"$DOCKER" \
-c 'PATH="$PATH":/travis-rust/bin exec sh ci/run.sh'
-c 'PATH="$PATH":/rustc-sysroot/bin sh ci/run.sh'

# check that rustup-init was built with ssl support
# see https://github.com/rust-lang/rustup.rs/issues/1051
Expand Down
4 changes: 3 additions & 1 deletion ci/fetch-rust-docker.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#!/bin/bash

script_dir=$(cd "$(dirname "$0")" && pwd)
root_dir="$TRAVIS_BUILD_DIR"
script_dir="$root_dir/ci"

. "$script_dir/shared.sh"

set -e
Expand Down
11 changes: 7 additions & 4 deletions ci/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

set -ex

# only enable core dump on Linux
if [ -f /proc/sys/kernel/core_pattern ]; then
# shellcheck disable=SC2169
# `-c` exists in Ubuntu 14.04 and later at least
ulimit -c unlimited
fi

rustc -vV
cargo -vV
rustfmt -vV
Expand All @@ -12,7 +19,3 @@ if [ -z "$SKIP_TESTS" ]; then
cargo test --release -p download --target "$TARGET" --features vendored-openssl
cargo test --release --target "$TARGET" --features vendored-openssl
fi

# Check the formatting last because test failures are more interesting to have
# discovered for contributors lacking some platform access for testing beforehand
cargo fmt --all -- --check

0 comments on commit 5e6d357

Please sign in to comment.