Skip to content

Commit

Permalink
Expand and refactor teting infrastructure
Browse files Browse the repository at this point in the history
This commit moves over most of the testing infrastructure to in-tree docker
images that are all dispatched to from Travis (no other test configuration).
This allows versioning modifications to the test infrastructure as well as the
code itself. Additionally separate docker images allows for easy modification of
one without worrying about tampering of others as well as easy addition of new
targets by simply adding a new `Dockerfile`.

Additionally this commit bundles the master version of the `compiler-rt` source
repository from `llvm-mirror/compiler-rt` to test against. The compiler-rt
library itself is compiled as a `cdylib` which is then dynamically located at
runtime and we look for symbols in. There's a few hoops here, but they currently
get the job done.

All tests now execute against both gcc_s and compiler-rt, and this
testing strategy is now all hidden behind a macro as well (refactoring
all existing tests along the way).
  • Loading branch information
alexcrichton committed Sep 29, 2016
1 parent c56a3f8 commit 8e161a7
Show file tree
Hide file tree
Showing 38 changed files with 621 additions and 523 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "compiler-rt/compiler-rt-cdylib/compiler-rt"]
path = compiler-rt/compiler-rt-cdylib/compiler-rt
url = https://github.com/llvm-mirror/compiler-rt
65 changes: 33 additions & 32 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,62 +1,63 @@
dist: trusty
language: generic
language: rust
services: docker
sudo: required
rust: nightly
cache: cargo

matrix:
include:
- env: TARGET=aarch64-unknown-linux-gnu
os: linux
- env: TARGET=arm-unknown-linux-gnueabi
os: linux
# FIXME(rust-lang/rust#36518)
rust: nightly-2016-09-21
- env: TARGET=arm-unknown-linux-gnueabihf
os: linux
- env: TARGET=armv7-unknown-linux-gnueabihf
os: linux
- env: TARGET=i586-unknown-linux-gnu
os: linux
- env: TARGET=i686-apple-darwin
language: ruby
# FIXME(rust-lang/rust#36793)
rust: nightly-2016-09-10
os: osx
- env: TARGET=i686-unknown-linux-gnu
os: linux
# FIXME(rust-lang/rust#36793)
rust: nightly-2016-09-10
- env: TARGET=mips-unknown-linux-gnu
os: linux
- env: TARGET=mipsel-unknown-linux-gnu
os: linux
- env: TARGET=powerpc-unknown-linux-gnu
os: linux
- env: TARGET=powerpc64-unknown-linux-gnu
os: linux
- env: TARGET=powerpc64le-unknown-linux-gnu
os: linux
# QEMU crashes even when executing the simplest cross compiled C program:
# `int main() { return 0; }`
- env: TARGET=powerpc64le-unknown-linux-gnu NO_RUN=1
- env: TARGET=thumbv6m-none-eabi
os: linux
- env: TARGET=thumbv6m-none-eabi WEAK=true
os: linux
install: cargo install xargo --debug -f
script: $HOME/.cargo/bin/xargo build --target $TARGET
- env: TARGET=thumbv7em-none-eabi
os: linux
- env: TARGET=thumbv7em-none-eabi WEAK=true
os: linux
install: cargo install xargo --debug -f
script: $HOME/.cargo/bin/xargo build --target $TARGET
- env: TARGET=thumbv7em-none-eabihf
os: linux
- env: TARGET=thumbv7em-none-eabihf WEAK=true
os: linux
- env: TARGET=thumbv7m-none-eabi
os: linux
- env: TARGET=thumbv7m-none-eabi WEAK=true
os: linux
install: cargo install xargo --debug -f
script: $HOME/.cargo/bin/xargo build --target $TARGET
- env: TARGET=x86_64-apple-darwin
language: ruby
os: osx
- env: TARGET=x86_64-unknown-linux-gnu
os: linux
env: TARGET=x86_64-unknown-linux-gnu

before_install:
- test "$TRAVIS_OS_NAME" = "osx" || docker run --rm --privileged multiarch/qemu-user-static:register

install:
- bash ci/install.sh
- curl https://static.rust-lang.org/rustup.sh |
sh -s -- --add-target=$TARGET --disable-sudo -y --prefix=`rustc --print sysroot`

script:
- bash ci/script.sh
- cargo generate-lockfile
- if [[ $TRAVIS_OS_NAME = "linux" ]]; then
sudo apt-get remove -y qemu-user-static &&
sudo apt-get install -y qemu-user-static &&
sh ci/run-docker.sh $TARGET;
else
cargo test --target $TARGET &&
cargo test --target $TARGET --release;
fi

branches:
only:
Expand Down
5 changes: 2 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,8 @@ optional = true
[dev-dependencies]
quickcheck = "0.3.1"
rand = "0.3.14"

[dev-dependencies.gcc_s]
path = "gcc_s"
gcc_s = { path = "gcc_s" }
compiler-rt = { path = "compiler-rt" }

[features]
weak = ["rlibc/weak"]
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ See [rust-lang/rust#35437][0].

If you are working with a target that doesn't have binary releases of std available via rustup (this
probably means you are building the core crate yourself) and need compiler-rt intrinsics (i.e. you
are probably getting linker errors when building an executable: "undefined reference to
__aeabi_memcpy"), you can use this crate to get those intrinsics and solve the linker errors. To do
are probably getting linker errors when building an executable: `undefined reference to
__aeabi_memcpy`), you can use this crate to get those intrinsics and solve the linker errors. To do
that, simply add this crate as a Cargo dependency (it doesn't matter where in the dependency graph
this crate ends up, as long as it's there):

Expand Down Expand Up @@ -52,7 +52,7 @@ porting that particular intrinsic.
1. [Rust][4] and [C][5] have slightly different operator precedence. C evaluates comparisons (`== !=`) before bitwise operations (`& | ^`), while Rust evaluates the other way.
2. C assumes wrapping operations everywhere. Rust panics on overflow when in debug mode. Consider using the [Wrapping][6] type or the explicit [wrapping_*][7] functions where applicable.
3. Note [C implicit casts][8], especially integer promotion. Rust is much more explicit about casting, so be sure that any cast which affects the output is ported to the Rust implementation.
4. Rust has [many functions][9] for integer or floating point manipulation in the standard library. Consider using one of these functions rather than porting a new one.
4. Rust has [many functions][9] for integer or floating point manipulation in the standard library. Consider using one of these functions rather than porting a new one.

[4]: https://doc.rust-lang.org/reference.html#operator-precedence
[5]: http://en.cppreference.com/w/c/language/operator_precedence
Expand Down
1 change: 1 addition & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ environment:
- TARGET: x86_64-pc-windows-msvc

install:
- git submodule update --init
- curl -sSf -o rustup-init.exe https://win.rustup.rs
- rustup-init.exe --default-host %TARGET% --default-toolchain nightly -y
- set PATH=%PATH%;C:\Users\appveyor\.cargo\bin
Expand Down
1 change: 1 addition & 0 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ fn main() {
if env::var("TARGET").unwrap().ends_with("gnueabihf") {
println!("cargo:rustc-cfg=gnueabihf")
}
println!("cargo:rerun-if-changed=build.rs");
}
10 changes: 10 additions & 0 deletions ci/docker/aarch64-unknown-linux-gnu/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FROM ubuntu:16.04
RUN apt-get update
RUN apt-get install -y --no-install-recommends \
gcc libc6-dev ca-certificates \
gcc-aarch64-linux-gnu libc6-dev-arm64-cross \
qemu-user-static
ENV CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc \
PATH=$PATH:/rust/bin \
QEMU_LD_PREFIX=/usr/aarch64-linux-gnu \
RUST_TEST_THREADS=1
10 changes: 10 additions & 0 deletions ci/docker/arm-unknown-linux-gnueabi/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FROM ubuntu:16.04
RUN apt-get update
RUN apt-get install -y --no-install-recommends \
gcc libc6-dev ca-certificates \
gcc-arm-linux-gnueabi libc6-dev-armel-cross qemu-user-static
ENV CARGO_TARGET_ARM_UNKNOWN_LINUX_GNUEABI_LINKER=arm-linux-gnueabi-gcc \
PATH=$PATH:/rust/bin \
QEMU_LD_PREFIX=/usr/arm-linux-gnueabi \
RUST_TEST_THREADS=1

9 changes: 9 additions & 0 deletions ci/docker/arm-unknown-linux-gnueabihf/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM ubuntu:16.04
RUN apt-get update
RUN apt-get install -y --no-install-recommends \
gcc libc6-dev ca-certificates \
gcc-arm-linux-gnueabihf libc6-dev-armhf-cross qemu-user-static
ENV CARGO_TARGET_ARM_UNKNOWN_LINUX_GNUEABIHF_LINKER=arm-linux-gnueabihf-gcc \
PATH=$PATH:/rust/bin \
QEMU_LD_PREFIX=/usr/arm-linux-gnueabihf \
RUST_TEST_THREADS=1
9 changes: 9 additions & 0 deletions ci/docker/armv7-unknown-linux-gnueabihf/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM ubuntu:16.04
RUN apt-get update
RUN apt-get install -y --no-install-recommends \
gcc libc6-dev ca-certificates \
gcc-arm-linux-gnueabihf libc6-dev-armhf-cross qemu-user-static
ENV CARGO_TARGET_ARMV7_UNKNOWN_LINUX_GNUEABIHF_LINKER=arm-linux-gnueabihf-gcc \
PATH=$PATH:/rust/bin \
QEMU_LD_PREFIX=/usr/arm-linux-gnueabihf \
RUST_TEST_THREADS=1
5 changes: 5 additions & 0 deletions ci/docker/i586-unknown-linux-gnu/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FROM ubuntu:16.04
RUN apt-get update
RUN apt-get install -y --no-install-recommends \
gcc-multilib libc6-dev ca-certificates
ENV PATH=$PATH:/rust/bin
5 changes: 5 additions & 0 deletions ci/docker/i686-unknown-linux-gnu/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FROM ubuntu:16.04
RUN apt-get update
RUN apt-get install -y --no-install-recommends \
gcc-multilib libc6-dev ca-certificates
ENV PATH=$PATH:/rust/bin
12 changes: 12 additions & 0 deletions ci/docker/mips-unknown-linux-gnu/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
FROM ubuntu:16.04

RUN apt-get update
RUN apt-get install -y --no-install-recommends \
gcc libc6-dev ca-certificates \
gcc-mips-linux-gnu libc6-dev-mips-cross \
binfmt-support qemu-user-static qemu-system-mips

ENV CARGO_TARGET_MIPS_UNKNOWN_LINUX_GNU_LINKER=mips-linux-gnu-gcc \
PATH=$PATH:/rust/bin \
QEMU_LD_PREFIX=/usr/mips-linux-gnu \
RUST_TEST_THREADS=1
12 changes: 12 additions & 0 deletions ci/docker/mipsel-unknown-linux-gnu/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
FROM ubuntu:16.04

RUN apt-get update
RUN apt-get install -y --no-install-recommends \
gcc libc6-dev ca-certificates \
gcc-mipsel-linux-gnu libc6-dev-mipsel-cross \
binfmt-support qemu-user-static

ENV CARGO_TARGET_MIPSEL_UNKNOWN_LINUX_GNU_LINKER=mipsel-linux-gnu-gcc \
PATH=$PATH:/rust/bin \
QEMU_LD_PREFIX=/usr/mipsel-linux-gnu \
RUST_TEST_THREADS=1
12 changes: 12 additions & 0 deletions ci/docker/powerpc-unknown-linux-gnu/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
FROM ubuntu:16.04

RUN apt-get update
RUN apt-get install -y --no-install-recommends \
gcc libc6-dev qemu-user-static ca-certificates \
gcc-powerpc-linux-gnu libc6-dev-powerpc-cross \
qemu-system-ppc

ENV CARGO_TARGET_POWERPC_UNKNOWN_LINUX_GNU_LINKER=powerpc-linux-gnu-gcc \
PATH=$PATH:/rust/bin \
QEMU_LD_PREFIX=/usr/powerpc-linux-gnu \
RUST_TEST_THREADS=1
13 changes: 13 additions & 0 deletions ci/docker/powerpc64-unknown-linux-gnu/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM ubuntu:16.04

RUN apt-get update
RUN apt-get install -y --no-install-recommends \
gcc libc6-dev ca-certificates \
gcc-powerpc64-linux-gnu libc6-dev-ppc64-cross \
binfmt-support qemu-user-static qemu-system-ppc

ENV CARGO_TARGET_POWERPC64_UNKNOWN_LINUX_GNU_LINKER=powerpc64-linux-gnu-gcc \
CC_powerpc64_unknown_linux_gnu=powerpc64-linux-gnu-gcc \
PATH=$PATH:/rust/bin \
QEMU_LD_PREFIX=/usr/powerpc64-linux-gnu \
RUST_TEST_THREADS=1
13 changes: 13 additions & 0 deletions ci/docker/powerpc64le-unknown-linux-gnu/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM ubuntu:16.04

RUN apt-get update
RUN apt-get install -y --no-install-recommends \
gcc libc6-dev qemu-user-static ca-certificates \
gcc-powerpc64le-linux-gnu libc6-dev-ppc64el-cross \
qemu-system-ppc

ENV CARGO_TARGET_POWERPC64LE_UNKNOWN_LINUX_GNU_LINKER=powerpc64le-linux-gnu-gcc \
CC_powerpc64le_unknown_linux_gnu=powerpc64le-linux-gnu-gcc \
PATH=$PATH:/rust/bin \
QEMU_LD_PREFIX=/usr/powerpc64le-linux-gnu \
RUST_TEST_THREADS=1
6 changes: 6 additions & 0 deletions ci/docker/x86_64-unknown-linux-gnu/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
FROM ubuntu:16.04
RUN apt-get update
RUN apt-get install -y --no-install-recommends \
gcc libc6-dev ca-certificates
ENV PATH=$PATH:/rust/bin

51 changes: 0 additions & 51 deletions ci/env.sh

This file was deleted.

53 changes: 0 additions & 53 deletions ci/install.sh

This file was deleted.

Loading

0 comments on commit 8e161a7

Please sign in to comment.