diff options
author | Alex Crichton <alex@alexcrichton.com> | 2017-08-21 17:06:12 -0700 |
---|---|---|
committer | Alex Crichton <alex@alexcrichton.com> | 2017-08-21 21:41:37 -0700 |
commit | bcbfa856511f4f7bdacb8188eadcc7cbe38727e2 (patch) | |
tree | 7486c106ede85be9a1004c4eb3d2058d928716d2 | |
parent | ce276177f2d79b065859ce945c010de03769d30f (diff) | |
download | rust-libc-bcbfa856511f4f7bdacb8188eadcc7cbe38727e2.tar.gz |
Leverage Cargo's target runner support to execute tests
-rw-r--r-- | .travis.yml | 8 | ||||
-rw-r--r-- | ci/docker/aarch64-unknown-linux-gnu/Dockerfile | 4 | ||||
-rw-r--r-- | ci/docker/arm-unknown-linux-gnueabihf/Dockerfile | 4 | ||||
-rw-r--r-- | ci/docker/mips-unknown-linux-gnu/Dockerfile | 4 | ||||
-rw-r--r-- | ci/docker/mips-unknown-linux-musl/Dockerfile | 6 | ||||
-rw-r--r-- | ci/docker/mips64-unknown-linux-gnuabi64/Dockerfile | 4 | ||||
-rw-r--r-- | ci/docker/mipsel-unknown-linux-musl/Dockerfile | 6 | ||||
-rw-r--r-- | ci/docker/powerpc-unknown-linux-gnu/Dockerfile | 4 | ||||
-rw-r--r-- | ci/docker/powerpc64-unknown-linux-gnu/Dockerfile | 4 | ||||
-rw-r--r-- | ci/docker/s390x-unknown-linux-gnu/Dockerfile | 3 | ||||
-rw-r--r-- | ci/docker/x86_64-rumprun-netbsd/Dockerfile | 6 | ||||
-rw-r--r-- | ci/docker/x86_64-rumprun-netbsd/runtest.rs | 54 | ||||
-rwxr-xr-x | ci/run.sh | 108 |
13 files changed, 87 insertions, 128 deletions
diff --git a/.travis.yml b/.travis.yml index c63272adb6..555b72bd76 100644 --- a/.travis.yml +++ b/.travis.yml @@ -50,10 +50,14 @@ matrix: - env: TARGET=aarch64-unknown-linux-gnu - os: osx osx_image: xcode8.2 - env: TARGET=i386-apple-ios + env: TARGET=i386-apple-ios CARGO_TARGET_I386_APPLE_IOS_RUNNER=$HOME/runtest + before_install: + rustc ./ci/ios/deploy_and_run_on_ios_simulator.rs -o $HOME/runtest - os: osx osx_image: xcode8.2 - env: TARGET=x86_64-apple-ios + env: TARGET=x86_64-apple-ios CARGO_TARGET_X86_64_APPLE_IOS_RUNNER=$HOME/runtest + before_install: + rustc ./ci/ios/deploy_and_run_on_ios_simulator.rs -o $HOME/runtest - env: TARGET=x86_64-rumprun-netbsd - env: TARGET=powerpc-unknown-linux-gnu - env: TARGET=powerpc64-unknown-linux-gnu diff --git a/ci/docker/aarch64-unknown-linux-gnu/Dockerfile b/ci/docker/aarch64-unknown-linux-gnu/Dockerfile index 2a02f63210..18214a3e64 100644 --- a/ci/docker/aarch64-unknown-linux-gnu/Dockerfile +++ b/ci/docker/aarch64-unknown-linux-gnu/Dockerfile @@ -1,7 +1,7 @@ FROM ubuntu:17.10 -RUN apt-get update -RUN apt-get install -y --no-install-recommends \ +RUN apt-get update && apt-get install -y --no-install-recommends \ gcc libc6-dev ca-certificates \ gcc-aarch64-linux-gnu libc6-dev-arm64-cross qemu-user ENV CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc \ + CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_RUNNER="qemu-aarch64 -L /usr/aarch64-linux-gnu" \ PATH=$PATH:/rust/bin diff --git a/ci/docker/arm-unknown-linux-gnueabihf/Dockerfile b/ci/docker/arm-unknown-linux-gnueabihf/Dockerfile index 53da39825c..9fe71dcf87 100644 --- a/ci/docker/arm-unknown-linux-gnueabihf/Dockerfile +++ b/ci/docker/arm-unknown-linux-gnueabihf/Dockerfile @@ -1,7 +1,7 @@ FROM ubuntu:17.10 -RUN apt-get update -RUN apt-get install -y --no-install-recommends \ +RUN apt-get update && apt-get install -y --no-install-recommends \ gcc libc6-dev ca-certificates \ gcc-arm-linux-gnueabihf libc6-dev-armhf-cross qemu-user ENV CARGO_TARGET_ARM_UNKNOWN_LINUX_GNUEABIHF_LINKER=arm-linux-gnueabihf-gcc \ + CARGO_TARGET_ARM_UNKNOWN_LINUX_GNUEABIHF_RUNNER="qemu-arm -L /usr/arm-linux-gnueabihf" \ PATH=$PATH:/rust/bin diff --git a/ci/docker/mips-unknown-linux-gnu/Dockerfile b/ci/docker/mips-unknown-linux-gnu/Dockerfile index f4997a702f..c66abd471b 100644 --- a/ci/docker/mips-unknown-linux-gnu/Dockerfile +++ b/ci/docker/mips-unknown-linux-gnu/Dockerfile @@ -1,10 +1,10 @@ FROM ubuntu:17.10 -RUN apt-get update -RUN apt-get install -y --no-install-recommends \ +RUN apt-get update && apt-get install -y --no-install-recommends \ gcc libc6-dev qemu-user ca-certificates \ gcc-mips-linux-gnu libc6-dev-mips-cross \ qemu-system-mips ENV CARGO_TARGET_MIPS_UNKNOWN_LINUX_GNU_LINKER=mips-linux-gnu-gcc \ + CARGO_TARGET_MIPS_UNKNOWN_LINUX_GNU_RUNNER="qemu-mips -L /usr/mips-linux-gnu" \ PATH=$PATH:/rust/bin diff --git a/ci/docker/mips-unknown-linux-musl/Dockerfile b/ci/docker/mips-unknown-linux-musl/Dockerfile index ba8e34642f..3fb0eebb80 100644 --- a/ci/docker/mips-unknown-linux-musl/Dockerfile +++ b/ci/docker/mips-unknown-linux-musl/Dockerfile @@ -1,7 +1,6 @@ FROM ubuntu:17.10 -RUN apt-get update -RUN apt-get install -y --no-install-recommends \ +RUN apt-get update && apt-get install -y --no-install-recommends \ gcc libc6-dev qemu-user ca-certificates qemu-system-mips curl \ bzip2 @@ -14,4 +13,5 @@ RUN curl -L https://s3.amazonaws.com/rust-lang-ci/libc/OpenWrt-SDK-ar71xx-generi ENV PATH=$PATH:/rust/bin:/toolchain/staging_dir/toolchain-mips_34kc_gcc-5.3.0_musl-1.1.15/bin \ CC_mips_unknown_linux_musl=mips-openwrt-linux-gcc \ - CARGO_TARGET_MIPS_UNKNOWN_LINUX_MUSL_LINKER=mips-openwrt-linux-gcc + CARGO_TARGET_MIPS_UNKNOWN_LINUX_MUSL_LINKER=mips-openwrt-linux-gcc \ + CARGO_TARGET_MIPS_UNKNOWN_LINUX_MUSL_RUNNER="qemu-mips -L /toolchain/staging_dir/toolchain-mips_34kc_gcc-5.3.0_musl-1.1.15" diff --git a/ci/docker/mips64-unknown-linux-gnuabi64/Dockerfile b/ci/docker/mips64-unknown-linux-gnuabi64/Dockerfile index a864a31cce..b9921fcc50 100644 --- a/ci/docker/mips64-unknown-linux-gnuabi64/Dockerfile +++ b/ci/docker/mips64-unknown-linux-gnuabi64/Dockerfile @@ -1,11 +1,11 @@ FROM ubuntu:17.10 -RUN apt-get update -RUN apt-get install -y --no-install-recommends \ +RUN apt-get update && apt-get install -y --no-install-recommends \ gcc libc6-dev qemu-user ca-certificates \ gcc-mips64-linux-gnuabi64 libc6-dev-mips64-cross \ qemu-system-mips64 ENV CARGO_TARGET_MIPS64_UNKNOWN_LINUX_GNUABI64_LINKER=mips64-linux-gnuabi64-gcc \ + CARGO_TARGET_MIPS64_UNKNOWN_LINUX_GNUABI64_RUNNER="qemu-mips64 -L /usr/mips64-linux-gnuabi64" \ CC_mips64_unknown_linux_gnuabi64=mips64-linux-gnuabi64-gcc \ PATH=$PATH:/rust/bin diff --git a/ci/docker/mipsel-unknown-linux-musl/Dockerfile b/ci/docker/mipsel-unknown-linux-musl/Dockerfile index 36666743fb..a2c3bc4d29 100644 --- a/ci/docker/mipsel-unknown-linux-musl/Dockerfile +++ b/ci/docker/mipsel-unknown-linux-musl/Dockerfile @@ -1,7 +1,6 @@ FROM ubuntu:17.10 -RUN apt-get update -RUN apt-get install -y --no-install-recommends \ +RUN apt-get update && apt-get install -y --no-install-recommends \ gcc libc6-dev qemu-user ca-certificates qemu-system-mips curl \ bzip2 @@ -14,4 +13,5 @@ RUN curl -L https://s3.amazonaws.com/rust-lang-ci/libc/OpenWrt-Toolchain-malta-l ENV PATH=$PATH:/rust/bin:/toolchain/bin \ CC_mipsel_unknown_linux_musl=mipsel-openwrt-linux-gcc \ - CARGO_TARGET_MIPSEL_UNKNOWN_LINUX_MUSL_LINKER=mipsel-openwrt-linux-gcc + CARGO_TARGET_MIPSEL_UNKNOWN_LINUX_MUSL_LINKER=mipsel-openwrt-linux-gcc \ + CARGO_TARGET_MIPSEL_UNKNOWN_LINUX_MUSL_RUNNER="qemu-mipsel -L /toolchain" diff --git a/ci/docker/powerpc-unknown-linux-gnu/Dockerfile b/ci/docker/powerpc-unknown-linux-gnu/Dockerfile index 489f8dd57f..106ada444a 100644 --- a/ci/docker/powerpc-unknown-linux-gnu/Dockerfile +++ b/ci/docker/powerpc-unknown-linux-gnu/Dockerfile @@ -1,10 +1,10 @@ FROM ubuntu:17.10 -RUN apt-get update -RUN apt-get install -y --no-install-recommends \ +RUN apt-get update && apt-get install -y --no-install-recommends \ gcc libc6-dev qemu-user 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 \ + CARGO_TARGET_POWERPC_UNKNOWN_LINUX_GNU_RUNNER="qemu-ppc -L /usr/powerpc-linux-gnu" \ PATH=$PATH:/rust/bin diff --git a/ci/docker/powerpc64-unknown-linux-gnu/Dockerfile b/ci/docker/powerpc64-unknown-linux-gnu/Dockerfile index 51ebcca7e8..a6ab66a9a6 100644 --- a/ci/docker/powerpc64-unknown-linux-gnu/Dockerfile +++ b/ci/docker/powerpc64-unknown-linux-gnu/Dockerfile @@ -1,11 +1,11 @@ FROM ubuntu:17.10 -RUN apt-get update -RUN apt-get install -y --no-install-recommends \ +RUN apt-get update && apt-get install -y --no-install-recommends \ gcc libc6-dev qemu-user ca-certificates \ gcc-powerpc64-linux-gnu libc6-dev-ppc64-cross \ qemu-system-ppc ENV CARGO_TARGET_POWERPC64_UNKNOWN_LINUX_GNU_LINKER=powerpc64-linux-gnu-gcc \ + CARGO_TARGET_POWERPC64_UNKNOWN_LINUX_GNU_RUNNER="qemu-ppc64 -L /usr/powerpc64-linux-gnu" \ CC=powerpc64-linux-gnu-gcc \ PATH=$PATH:/rust/bin diff --git a/ci/docker/s390x-unknown-linux-gnu/Dockerfile b/ci/docker/s390x-unknown-linux-gnu/Dockerfile index 4cd9d4ae4f..49a277d884 100644 --- a/ci/docker/s390x-unknown-linux-gnu/Dockerfile +++ b/ci/docker/s390x-unknown-linux-gnu/Dockerfile @@ -5,5 +5,8 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ gcc-s390x-linux-gnu libc6-dev-s390x-cross ENV CARGO_TARGET_S390X_UNKNOWN_LINUX_GNU_LINKER=s390x-linux-gnu-gcc \ + # TODO: in theory we should execute this, but qemu segfaults immediately :( + # CARGO_TARGET_S390X_UNKNOWN_LINUX_GNU_RUNNER="qemu-s390x -L /usr/s390x-linux-gnu" \ + CARGO_TARGET_S390X_UNKNOWN_LINUX_GNU_RUNNER=true \ CC_s390x_unknown_linux_gnu=s390x-linux-gnu-gcc \ PATH=$PATH:/rust/bin diff --git a/ci/docker/x86_64-rumprun-netbsd/Dockerfile b/ci/docker/x86_64-rumprun-netbsd/Dockerfile index 129771e76b..a486d05b2e 100644 --- a/ci/docker/x86_64-rumprun-netbsd/Dockerfile +++ b/ci/docker/x86_64-rumprun-netbsd/Dockerfile @@ -3,4 +3,8 @@ USER root RUN apt-get update RUN apt-get install -y --no-install-recommends \ qemu -ENV PATH=$PATH:/rust/bin +ENV PATH=$PATH:/rust/bin \ + CARGO_TARGET_X86_64_RUMPRUN_NETBSD_RUNNER=/tmp/runtest + +ADD docker/x86_64-rumprun-netbsd/runtest.rs /tmp/ +ENTRYPOINT ["sh", "-c", "rustc /tmp/runtest.rs -o /tmp/runtest && exec \"$@\"", "--"] diff --git a/ci/docker/x86_64-rumprun-netbsd/runtest.rs b/ci/docker/x86_64-rumprun-netbsd/runtest.rs new file mode 100644 index 0000000000..94b5946080 --- /dev/null +++ b/ci/docker/x86_64-rumprun-netbsd/runtest.rs @@ -0,0 +1,54 @@ +use std::env; +use std::process::{Command, Stdio}; +use std::sync::mpsc; +use std::thread; +use std::time::Duration; +use std::io::{BufRead, BufReader, Read}; + +fn main() { + assert_eq!(env::args().len(), 2); + + let status = Command::new("rumprun-bake") + .arg("hw_virtio") + .arg("/tmp/libc-test.img") + .arg(env::args().nth(1).unwrap()) + .status() + .expect("failed to run rumprun-bake"); + assert!(status.success()); + + let mut child = Command::new("qemu-system-x86_64") + .arg("-nographic") + .arg("-vga").arg("none") + .arg("-m").arg("64") + .arg("-kernel").arg("/tmp/libc-test.img") + .stdout(Stdio::piped()) + .stderr(Stdio::piped()) + .spawn() + .expect("failed to spawn qemu"); + + let mut stdout = child.stdout.take().unwrap(); + let mut stderr = child.stderr.take().unwrap(); + let (tx, rx) = mpsc::channel(); + let tx2 = tx.clone(); + let t1 = thread::spawn(move || find_ok(&mut stdout, tx)); + let t2 = thread::spawn(move || find_ok(&mut stderr, tx2)); + + let res = rx.recv_timeout(Duration::new(5, 0)); + child.kill().unwrap(); + t1.join().unwrap(); + t2.join().unwrap(); + + if res.is_err() { + panic!("didn't find success"); + } +} + +fn find_ok(input: &mut Read, tx: mpsc::Sender<()>) { + for line in BufReader::new(input).lines() { + let line = line.unwrap(); + println!("{}", line); + if line.starts_with("PASSED ") && line.contains(" tests") { + tx.send(()).unwrap(); + } + } +} @@ -68,110 +68,4 @@ if [ "$QEMU" != "" ]; then exec grep "^PASSED .* tests" $CARGO_TARGET_DIR/out.log fi -# Build all tests making sure that the iOS builds are handled properly. -if [[ "$TARGET" == *-apple-ios ]]; then - export RUSTFLAGS="-C link-args=-mios-simulator-version-min=7.0" -fi -cargo build --manifest-path libc-test/Cargo.toml --target $TARGET --tests - -case "$TARGET" in - # Android emulator for x86_64 does not work on travis (missing hardware - # acceleration). Tests are run on case *). See ci/android-sysimage.sh for - # informations about how tests are run. - arm-linux-androideabi | aarch64-linux-android | i686-linux-android) - # set SHELL so android can detect a 64bits system, see - # http://stackoverflow.com/a/41789144 - # https://issues.jenkins-ci.org/browse/JENKINS-26930?focusedCommentId=230791&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-230791 - export SHELL=/bin/dash - arch=$(echo $TARGET | cut -d- -f1) - accel="-no-accel" - if emulator -accel-check; then - accel="" - fi - emulator @$arch -no-window $accel & - adb wait-for-device - # TODO: replace these steps with a single program so that it can be used as a runner for cargo test - adb push $CARGO_TARGET_DIR/$TARGET/debug/main-* /data/local/tmp/main - adb shell /data/local/tmp/main 2>&1 | tee /tmp/out - grep "^PASSED .* tests" /tmp/out - adb push $CARGO_TARGET_DIR/$TARGET/debug/linux_fcntl-* /data/local/tmp/linux_fcntl - adb shell /data/local/tmp/linux_fcntl 2>&1 | tee /tmp/out - grep "^PASSED .* tests" /tmp/out - ;; - - i386-apple-ios) - rustc -O ./ci/ios/deploy_and_run_on_ios_simulator.rs - export CARGO_TARGET_I386_APPLE_IOS_RUNNER="./deploy_and_run_on_ios_simulator" - cargo test --manifest-path libc-test/Cargo.toml --target $TARGET - ;; - - x86_64-apple-ios) - rustc -O ./ci/ios/deploy_and_run_on_ios_simulator.rs - export CARGO_TARGET_X86_64_APPLE_IOS_RUNNER="./deploy_and_run_on_ios_simulator" - cargo test --manifest-path libc-test/Cargo.toml --target $TARGET - ;; - - arm-unknown-linux-gnueabihf) - export CARGO_TARGET_ARM_UNKNOWN_LINUX_GNUEABIHF_RUNNER="qemu-arm -L /usr/arm-linux-gnueabihf" - cargo test --manifest-path libc-test/Cargo.toml --target $TARGET - ;; - - mips-unknown-linux-gnu) - export CARGO_TARGET_MIPS_UNKNOWN_LINUX_GNU_RUNNER="qemu-mips -L /usr/mips-linux-gnu" - cargo test --manifest-path libc-test/Cargo.toml --target $TARGET - ;; - - mips64-unknown-linux-gnuabi64) - export CARGO_TARGET_MIPS64_UNKNOWN_LINUX_GNUABI64_RUNNER="qemu-mips64 -L /usr/mips64-linux-gnuabi64" - cargo test --manifest-path libc-test/Cargo.toml --target $TARGET - ;; - - mips-unknown-linux-musl) - export CARGO_TARGET_MIPS_UNKNOWN_LINUX_MUSL_RUNNER="qemu-mips -L /toolchain/staging_dir/toolchain-mips_34kc_gcc-5.3.0_musl-1.1.15" - cargo test --manifest-path libc-test/Cargo.toml --target $TARGET - ;; - - mipsel-unknown-linux-musl) - export CARGO_TARGET_MIPSEL_UNKNOWN_LINUX_MUSL_RUNNER="qemu-mipsel -L /toolchain" - cargo test --manifest-path libc-test/Cargo.toml --target $TARGET - ;; - - powerpc-unknown-linux-gnu) - export CARGO_TARGET_POWERPC_UNKNOWN_LINUX_GNU_RUNNER="qemu-ppc -L /usr/powerpc-linux-gnu" - cargo test --manifest-path libc-test/Cargo.toml --target $TARGET - ;; - - powerpc64-unknown-linux-gnu) - export CARGO_TARGET_POWERPC64_UNKNOWN_LINUX_GNU_RUNNER="qemu-ppc64 -L /usr/powerpc64-linux-gnu" - cargo test --manifest-path libc-test/Cargo.toml --target $TARGET - ;; - - aarch64-unknown-linux-gnu) - export CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_RUNNER="qemu-aarch64 -L /usr/aarch64-linux-gnu" - cargo test --manifest-path libc-test/Cargo.toml --target $TARGET - ;; - - s390x-unknown-linux-gnu) - # TODO: in theory we should execute this, but qemu segfaults immediately :( - #export CARGO_TARGET_S390X_UNKNOWN_LINUX_GNU_RUNNER="qemu-s390x -L /usr/s390x-linux-gnu" - #cargo test --manifest-path libc-test/Cargo.toml --target $TARGET - ;; - - *-rumprun-netbsd) - # TODO: replace these steps with a single program so that it can be used as a runner for cargo test - rumprun-bake hw_virtio /tmp/libc-test.img $CARGO_TARGET_DIR/$TARGET/debug/main-* - qemu-system-x86_64 -nographic -vga none -m 64 \ - -kernel /tmp/libc-test.img 2>&1 | tee /tmp/out & - sleep 5 - grep "^PASSED .* tests" /tmp/out - rumprun-bake hw_virtio /tmp/libc-test.img $CARGO_TARGET_DIR/$TARGET/debug/linux_fcntl-* - qemu-system-x86_64 -nographic -vga none -m 64 \ - -kernel /tmp/libc-test.img 2>&1 | tee /tmp/out & - sleep 5 - grep "^PASSED .* tests" /tmp/out - ;; - - *) - cargo test --manifest-path libc-test/Cargo.toml --target $TARGET - ;; -esac +cargo test --manifest-path libc-test/Cargo.toml --target $TARGET |