Skip to content

Commit 432677c

Browse files
authored
Merge pull request rust-lang#48 from gnzlbg/linux-libc
Test ctest with libc on linux
2 parents dae2780 + d93ac97 commit 432677c

File tree

4 files changed

+60
-1
lines changed

4 files changed

+60
-1
lines changed

.travis.yml

+5-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ matrix:
1313
rust: nightly
1414
after_success:
1515
- travis-cargo --only nightly doc-upload
16-
- name: "libc-test"
16+
- name: "libc-test (osx)"
1717
rust: nightly
1818
os: osx
1919
osx_image: xcode9.4
@@ -25,6 +25,10 @@ matrix:
2525
- |
2626
export TARGET=x86_64-apple-darwin
2727
sh ci/run.sh $TARGET
28+
- name: "libc-test (linux)"
29+
rust: nightly
30+
script: ci/run-docker.sh x86_64-unknown-linux-gnu
31+
2832
script:
2933
- cargo test
3034
- cargo test --manifest-path testcrate/Cargo.toml
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
FROM ubuntu:18.04
2+
RUN apt-get update
3+
RUN apt-get install -y --no-install-recommends \
4+
gcc libc6-dev ca-certificates git
5+
ENV PATH=$PATH:/rust/bin

ci/run-docker.sh

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Small script to run tests for a target (or all targets) inside all the
2+
# respective docker images.
3+
4+
set -ex
5+
6+
run() {
7+
echo "Building docker container for TARGET=${1}"
8+
docker build -t ctest -f ci/docker/$1/Dockerfile ci/
9+
mkdir -p target
10+
target=$1
11+
echo "Running docker"
12+
docker run \
13+
--user `id -u`:`id -g` \
14+
--rm \
15+
--init \
16+
--volume $HOME/.cargo:/cargo-h \
17+
--env CARGO_HOME=/cargo-h \
18+
--volume `rustc --print sysroot`:/rust:ro \
19+
--env TARGET=$target \
20+
--volume `pwd`:/checkout:ro \
21+
--volume `pwd`/target:/checkout/target \
22+
--workdir /checkout \
23+
--privileged \
24+
ctest \
25+
bash \
26+
-c 'PATH=/rust/bin:$PATH exec ci/run.sh'
27+
}
28+
29+
if [ -z "$1" ]; then
30+
for d in `ls ci/docker/`; do
31+
run $d
32+
done
33+
else
34+
run $1
35+
fi

ci/run.sh

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/sh
2+
3+
# Builds and runs tests for a particular target passed as an argument to this
4+
# script.
5+
6+
set -ex
7+
8+
: ${TARGET?"The TARGET environment variable must be set."}
9+
10+
mkdir -p target
11+
git clone https://github.com/rust-lang/libc target/libc
12+
mkdir -p target/libc/target/ctest
13+
sed -i 's@ctest = "0.2.3"@ctest = { path = "../../.." }@g' target/libc/libc-test/Cargo.toml
14+
15+
cargo test --manifest-path target/libc/libc-test/Cargo.toml --target $TARGET

0 commit comments

Comments
 (0)