From 2e11d9e14ce1a2cf0353363e4239a9d1fa147694 Mon Sep 17 00:00:00 2001 From: Bryant Mairs Date: Thu, 10 Aug 2017 10:33:19 -0700 Subject: [PATCH 1/8] Add more fcntl and seal constants for Android/Linux We now create an additional binary `linux_fcntl` for testing this since there are header conflicts when including all necessary headers. This binary is run on all platforms even though it's empty on all non- Android/non-Linux platforms. Testing has been switched from a custom binary to using a runner-less test (or pair of tests). This means that for local development a simple `cd libc-test && cargo test` will run all the tests. CI has also been updated here to reflect that. --- README.md | 2 +- appveyor.yml | 2 +- ci/run.sh | 59 +++++++++++++++++++++++---------- libc-test/Cargo.toml | 10 ++++++ libc-test/build.rs | 33 +++++++++++++++++- libc-test/test/linux_fcntl.rs | 6 ++++ libc-test/{src => test}/main.rs | 2 +- src/macros.rs | 37 --------------------- src/unix/notbsd/mod.rs | 8 +++++ 9 files changed, 100 insertions(+), 59 deletions(-) create mode 100644 libc-test/test/linux_fcntl.rs rename libc-test/{src => test}/main.rs (60%) diff --git a/README.md b/README.md index 67535d211e9c0..7b2d778ea182b 100644 --- a/README.md +++ b/README.md @@ -93,7 +93,7 @@ With that in mind, the steps for adding a new API are: We have two automated tests running on [Travis](https://travis-ci.org/rust-lang/libc): 1. [`libc-test`](https://github.com/alexcrichton/ctest) - - `cd libc-test && cargo run` + - `cd libc-test && cargo test` - Use the `skip_*()` functions in `build.rs` if you really need a workaround. 2. Style checker - `rustc ci/style.rs && ./style src` diff --git a/appveyor.yml b/appveyor.yml index 22ef8a5601f50..3121825b953ac 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -24,7 +24,7 @@ build: false test_script: - cargo test --target %TARGET% - - cargo run --manifest-path libc-test/Cargo.toml --target %TARGET% + - cargo test --manifest-path libc-test/Cargo.toml --target %TARGET% cache: - target diff --git a/ci/run.sh b/ci/run.sh index 1b8226e521473..d9dddfa30f805 100755 --- a/ci/run.sh +++ b/ci/run.sh @@ -70,12 +70,14 @@ fi case "$TARGET" in *-apple-ios) - cargo rustc --manifest-path libc-test/Cargo.toml --target $TARGET -- \ - -C link-args=-mios-simulator-version-min=7.0 + cargo rustc --manifest-path libc-test/Cargo.toml --target $TARGET \ + --test main -- -C link-args=-mios-simulator-version-min=7.0 + cargo rustc --manifest-path libc-test/Cargo.toml --target $TARGET \ + --test linux-fcntl -- -C link-args=-mios-simulator-version-min=7.0 ;; *) - cargo build --manifest-path libc-test/Cargo.toml --target $TARGET + cargo build --manifest-path libc-test/Cargo.toml --target $TARGET --tests ;; esac @@ -95,61 +97,81 @@ case "$TARGET" in fi emulator @$arch -no-window $accel & adb wait-for-device - adb push $CARGO_TARGET_DIR/$TARGET/debug/libc-test /data/local/tmp/libc-test - adb shell /data/local/tmp/libc-test 2>&1 | tee /tmp/out + 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 - ./deploy_and_run_on_ios_simulator $CARGO_TARGET_DIR/$TARGET/debug/libc-test + ./deploy_and_run_on_ios_simulator $CARGO_TARGET_DIR/$TARGET/debug/main-* + ./deploy_and_run_on_ios_simulator $CARGO_TARGET_DIR/$TARGET/debug/linux_fcntl-* ;; x86_64-apple-ios) rustc -O ./ci/ios/deploy_and_run_on_ios_simulator.rs - ./deploy_and_run_on_ios_simulator $CARGO_TARGET_DIR/$TARGET/debug/libc-test + ./deploy_and_run_on_ios_simulator $CARGO_TARGET_DIR/$TARGET/debug/main-* + ./deploy_and_run_on_ios_simulator $CARGO_TARGET_DIR/$TARGET/debug/linux_fcntl-* ;; arm-unknown-linux-gnueabihf) - qemu-arm -L /usr/arm-linux-gnueabihf $CARGO_TARGET_DIR/$TARGET/debug/libc-test + qemu-arm -L /usr/arm-linux-gnueabihf $CARGO_TARGET_DIR/$TARGET/debug/main-* + qemu-arm -L /usr/arm-linux-gnueabihf $CARGO_TARGET_DIR/$TARGET/debug/linux_fcntl-* ;; mips-unknown-linux-gnu) - qemu-mips -L /usr/mips-linux-gnu $CARGO_TARGET_DIR/$TARGET/debug/libc-test + qemu-mips -L /usr/mips-linux-gnu $CARGO_TARGET_DIR/$TARGET/debug/main-* + qemu-mips -L /usr/mips-linux-gnu $CARGO_TARGET_DIR/$TARGET/debug/linux_fcntl-* ;; mips64-unknown-linux-gnuabi64) - qemu-mips64 -L /usr/mips64-linux-gnuabi64 $CARGO_TARGET_DIR/$TARGET/debug/libc-test + qemu-mips64 -L /usr/mips64-linux-gnuabi64 $CARGO_TARGET_DIR/$TARGET/debug/main-* + qemu-mips64 -L /usr/mips64-linux-gnuabi64 $CARGO_TARGET_DIR/$TARGET/debug/linux_fcntl-* ;; mips-unknown-linux-musl) qemu-mips -L /toolchain/staging_dir/toolchain-mips_34kc_gcc-5.3.0_musl-1.1.15 \ - $CARGO_TARGET_DIR/$TARGET/debug/libc-test + $CARGO_TARGET_DIR/$TARGET/debug/main-* + qemu-mips -L /toolchain/staging_dir/toolchain-mips_34kc_gcc-5.3.0_musl-1.1.15 \ + $CARGO_TARGET_DIR/$TARGET/debug/linux_fcntl-* ;; mipsel-unknown-linux-musl) - qemu-mipsel -L /toolchain $CARGO_TARGET_DIR/$TARGET/debug/libc-test + qemu-mipsel -L /toolchain $CARGO_TARGET_DIR/$TARGET/debug/main-* + qemu-mipsel -L /toolchain $CARGO_TARGET_DIR/$TARGET/debug/linux_fcntl-* ;; powerpc-unknown-linux-gnu) - qemu-ppc -L /usr/powerpc-linux-gnu $CARGO_TARGET_DIR/$TARGET/debug/libc-test + qemu-ppc -L /usr/powerpc-linux-gnu $CARGO_TARGET_DIR/$TARGET/debug/main-* + qemu-ppc -L /usr/powerpc-linux-gnu $CARGO_TARGET_DIR/$TARGET/debug/linux_fcntl-* ;; powerpc64-unknown-linux-gnu) - qemu-ppc64 -L /usr/powerpc64-linux-gnu $CARGO_TARGET_DIR/$TARGET/debug/libc-test + qemu-ppc64 -L /usr/powerpc64-linux-gnu $CARGO_TARGET_DIR/$TARGET/debug/main-* + qemu-ppc64 -L /usr/powerpc64-linux-gnu $CARGO_TARGET_DIR/$TARGET/debug/linux_fcntl-* ;; aarch64-unknown-linux-gnu) - qemu-aarch64 -L /usr/aarch64-linux-gnu/ $CARGO_TARGET_DIR/$TARGET/debug/libc-test + qemu-aarch64 -L /usr/aarch64-linux-gnu/ $CARGO_TARGET_DIR/$TARGET/debug/main-* + qemu-aarch64 -L /usr/aarch64-linux-gnu/ $CARGO_TARGET_DIR/$TARGET/debug/linux_fcntl-* ;; s390x-unknown-linux-gnu) # TODO: in theory we should execute this, but qemu segfaults immediately :( - # qemu-s390x -L /usr/s390x-linux-gnu/ $CARGO_TARGET_DIR/$TARGET/debug/libc-test + # qemu-s390x -L /usr/s390x-linux-gnu/ $CARGO_TARGET_DIR/$TARGET/debug/main-* + # qemu-s390x -L /usr/s390x-linux-gnu/ $CARGO_TARGET_DIR/$TARGET/debug/linux_fcntl-* ;; *-rumprun-netbsd) - rumprun-bake hw_virtio /tmp/libc-test.img $CARGO_TARGET_DIR/$TARGET/debug/libc-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 @@ -157,6 +179,7 @@ case "$TARGET" in ;; *) - $CARGO_TARGET_DIR/$TARGET/debug/libc-test + $CARGO_TARGET_DIR/$TARGET/debug/main-* + $CARGO_TARGET_DIR/$TARGET/debug/linux_fcntl-* ;; esac diff --git a/libc-test/Cargo.toml b/libc-test/Cargo.toml index 4e7c88450e6ae..30ea54634f6de 100644 --- a/libc-test/Cargo.toml +++ b/libc-test/Cargo.toml @@ -9,3 +9,13 @@ libc = { path = ".." } [build-dependencies] ctest = "0.1" + +[[test]] +name = "main" +path = "test/main.rs" +harness = false + +[[test]] +name = "linux-fcntl" +path = "test/linux_fcntl.rs" +harness = false diff --git a/libc-test/build.rs b/libc-test/build.rs index 6b6e865eb136e..ee30e0329ca6e 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -468,6 +468,11 @@ fn main() { // it's been fixed in CI. "MADV_SOFT_OFFLINE" if mips && linux => true, + // These constants are tested in a separate test program generated below because there + // are header conflicts if we try to include the headers that define them here. + "F_CANCELLK" | "F_ADD_SEALS" | "F_GET_SEALS" => true, + "F_SEAL_SEAL" | "F_SEAL_SHRINK" | "F_SEAL_GROW" | "F_SEAL_WRITE" => true, + _ => false, } }); @@ -641,5 +646,31 @@ fn main() { } }); - cfg.generate("../src/lib.rs", "all.rs"); + cfg.generate("../src/lib.rs", "main.rs"); + + // On Linux or Android also generate another script for testing linux/fcntl declarations. + // These cannot be tested normally because including both `linux/fcntl.h` and `fcntl.h` + // fails on a lot of platforms. + let mut cfg = ctest::TestGenerator::new(); + cfg.skip_type(|_| true) + .skip_struct(|_| true) + .skip_fn(|_| true); + if android || linux { + // musl defines these directly in `fcntl.h` + if musl { + cfg.header("fcntl.h"); + } else { + cfg.header("linux/fcntl.h"); + } + cfg.skip_const(move |name| { + match name { + "F_CANCELLK" | "F_ADD_SEALS" | "F_GET_SEALS" => false, + "F_SEAL_SEAL" | "F_SEAL_SHRINK" | "F_SEAL_GROW" | "F_SEAL_WRITE" => false, + _ => true, + } + }); + } else { + cfg.skip_const(|_| true); + } + cfg.generate("../src/lib.rs", "linux_fcntl.rs"); } diff --git a/libc-test/test/linux_fcntl.rs b/libc-test/test/linux_fcntl.rs new file mode 100644 index 0000000000000..1c4635b12999c --- /dev/null +++ b/libc-test/test/linux_fcntl.rs @@ -0,0 +1,6 @@ +#![allow(bad_style, improper_ctypes)] +extern crate libc; + +use libc::*; + +include!(concat!(env!("OUT_DIR"), "/linux_fcntl.rs")); diff --git a/libc-test/src/main.rs b/libc-test/test/main.rs similarity index 60% rename from libc-test/src/main.rs rename to libc-test/test/main.rs index fff188d321171..3d336102bba45 100644 --- a/libc-test/src/main.rs +++ b/libc-test/test/main.rs @@ -3,4 +3,4 @@ extern crate libc; use libc::*; -include!(concat!(env!("OUT_DIR"), "/all.rs")); +include!(concat!(env!("OUT_DIR"), "/main.rs")); diff --git a/src/macros.rs b/src/macros.rs index 5811c84c3aaa5..8429442014418 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -69,40 +69,3 @@ macro_rules! f { macro_rules! __item { ($i:item) => ($i) } - -#[cfg(test)] -mod tests { - cfg_if! { - if #[cfg(test)] { - use std::option::Option as Option2; - fn works1() -> Option2 { Some(1) } - } else { - fn works1() -> Option { None } - } - } - - cfg_if! { - if #[cfg(foo)] { - fn works2() -> bool { false } - } else if #[cfg(test)] { - fn works2() -> bool { true } - } else { - fn works2() -> bool { false } - } - } - - cfg_if! { - if #[cfg(foo)] { - fn works3() -> bool { false } - } else { - fn works3() -> bool { true } - } - } - - #[test] - fn it_works() { - assert!(works1().is_some()); - assert!(works2()); - assert!(works3()); - } -} diff --git a/src/unix/notbsd/mod.rs b/src/unix/notbsd/mod.rs index e19c7f21de6cb..73eaf4ab1e532 100644 --- a/src/unix/notbsd/mod.rs +++ b/src/unix/notbsd/mod.rs @@ -212,9 +212,17 @@ pub const F_SETFL: ::c_int = 4; pub const F_SETLEASE: ::c_int = 1024; pub const F_GETLEASE: ::c_int = 1025; pub const F_NOTIFY: ::c_int = 1026; +pub const F_CANCELLK: ::c_int = 1029; pub const F_DUPFD_CLOEXEC: ::c_int = 1030; pub const F_SETPIPE_SZ: ::c_int = 1031; pub const F_GETPIPE_SZ: ::c_int = 1032; +pub const F_ADD_SEALS: ::c_int = 1033; +pub const F_GET_SEALS: ::c_int = 1034; + +pub const F_SEAL_SEAL: ::c_int = 0x0001; +pub const F_SEAL_SHRINK: ::c_int = 0x0002; +pub const F_SEAL_GROW: ::c_int = 0x0004; +pub const F_SEAL_WRITE: ::c_int = 0x0008; // TODO(#235): Include file sealing fcntls once we have a way to verify them. From 362134d8d60dffdd039dee39b536a31b5c0c98db Mon Sep 17 00:00:00 2001 From: Bryant Mairs Date: Mon, 21 Aug 2017 08:31:33 -0700 Subject: [PATCH 2/8] Simplify iOS builds by using Cargo's RUSTFLAGS support --- ci/run.sh | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/ci/run.sh b/ci/run.sh index d9dddfa30f805..0d27a85435b7c 100755 --- a/ci/run.sh +++ b/ci/run.sh @@ -68,18 +68,11 @@ if [ "$QEMU" != "" ]; then exec grep "^PASSED .* tests" $CARGO_TARGET_DIR/out.log fi -case "$TARGET" in - *-apple-ios) - cargo rustc --manifest-path libc-test/Cargo.toml --target $TARGET \ - --test main -- -C link-args=-mios-simulator-version-min=7.0 - cargo rustc --manifest-path libc-test/Cargo.toml --target $TARGET \ - --test linux-fcntl -- -C link-args=-mios-simulator-version-min=7.0 - ;; - - *) - cargo build --manifest-path libc-test/Cargo.toml --target $TARGET --tests - ;; -esac +# 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 From 2f06a79e23116f8b31d14137ab7c6579883d8174 Mon Sep 17 00:00:00 2001 From: Bryant Mairs Date: Mon, 21 Aug 2017 20:28:56 -0700 Subject: [PATCH 3/8] Run CI tests using cargo This works by specifying a "runner" for actually executing the binary. This doesn't apply to the Android or NetBSD runs because there isn't a simple binary that just runs the executable. --- ci/run.sh | 53 ++++++++++++++++++++++++++--------------------------- 1 file changed, 26 insertions(+), 27 deletions(-) diff --git a/ci/run.sh b/ci/run.sh index 0d27a85435b7c..5afa27a2879b8 100755 --- a/ci/run.sh +++ b/ci/run.sh @@ -90,6 +90,7 @@ case "$TARGET" in 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 @@ -100,65 +101,64 @@ case "$TARGET" in i386-apple-ios) rustc -O ./ci/ios/deploy_and_run_on_ios_simulator.rs - ./deploy_and_run_on_ios_simulator $CARGO_TARGET_DIR/$TARGET/debug/main-* - ./deploy_and_run_on_ios_simulator $CARGO_TARGET_DIR/$TARGET/debug/linux_fcntl-* + 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 - ./deploy_and_run_on_ios_simulator $CARGO_TARGET_DIR/$TARGET/debug/main-* - ./deploy_and_run_on_ios_simulator $CARGO_TARGET_DIR/$TARGET/debug/linux_fcntl-* + 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) - qemu-arm -L /usr/arm-linux-gnueabihf $CARGO_TARGET_DIR/$TARGET/debug/main-* - qemu-arm -L /usr/arm-linux-gnueabihf $CARGO_TARGET_DIR/$TARGET/debug/linux_fcntl-* + 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) - qemu-mips -L /usr/mips-linux-gnu $CARGO_TARGET_DIR/$TARGET/debug/main-* - qemu-mips -L /usr/mips-linux-gnu $CARGO_TARGET_DIR/$TARGET/debug/linux_fcntl-* + 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) - qemu-mips64 -L /usr/mips64-linux-gnuabi64 $CARGO_TARGET_DIR/$TARGET/debug/main-* - qemu-mips64 -L /usr/mips64-linux-gnuabi64 $CARGO_TARGET_DIR/$TARGET/debug/linux_fcntl-* + 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) - qemu-mips -L /toolchain/staging_dir/toolchain-mips_34kc_gcc-5.3.0_musl-1.1.15 \ - $CARGO_TARGET_DIR/$TARGET/debug/main-* - qemu-mips -L /toolchain/staging_dir/toolchain-mips_34kc_gcc-5.3.0_musl-1.1.15 \ - $CARGO_TARGET_DIR/$TARGET/debug/linux_fcntl-* + 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) - qemu-mipsel -L /toolchain $CARGO_TARGET_DIR/$TARGET/debug/main-* - qemu-mipsel -L /toolchain $CARGO_TARGET_DIR/$TARGET/debug/linux_fcntl-* - ;; + 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) - qemu-ppc -L /usr/powerpc-linux-gnu $CARGO_TARGET_DIR/$TARGET/debug/main-* - qemu-ppc -L /usr/powerpc-linux-gnu $CARGO_TARGET_DIR/$TARGET/debug/linux_fcntl-* + 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) - qemu-ppc64 -L /usr/powerpc64-linux-gnu $CARGO_TARGET_DIR/$TARGET/debug/main-* - qemu-ppc64 -L /usr/powerpc64-linux-gnu $CARGO_TARGET_DIR/$TARGET/debug/linux_fcntl-* + 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) - qemu-aarch64 -L /usr/aarch64-linux-gnu/ $CARGO_TARGET_DIR/$TARGET/debug/main-* - qemu-aarch64 -L /usr/aarch64-linux-gnu/ $CARGO_TARGET_DIR/$TARGET/debug/linux_fcntl-* + 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 :( - # qemu-s390x -L /usr/s390x-linux-gnu/ $CARGO_TARGET_DIR/$TARGET/debug/main-* - # qemu-s390x -L /usr/s390x-linux-gnu/ $CARGO_TARGET_DIR/$TARGET/debug/linux_fcntl-* + #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 & @@ -172,7 +172,6 @@ case "$TARGET" in ;; *) - $CARGO_TARGET_DIR/$TARGET/debug/main-* - $CARGO_TARGET_DIR/$TARGET/debug/linux_fcntl-* + cargo test --manifest-path libc-test/Cargo.toml --target $TARGET ;; esac From 476b9821dcc4d3481dd26da8576cb67845819ab2 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Mon, 21 Aug 2017 17:01:06 -0700 Subject: [PATCH 4/8] Update lock file --- Cargo.lock | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2f5810956c572..3810241832806 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -16,22 +16,15 @@ name = "ctest" version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "gcc 0.3.51 (registry+https://github.com/rust-lang/crates.io-index)", + "gcc 0.3.53 (registry+https://github.com/rust-lang/crates.io-index)", "syntex_syntax 0.27.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "gcc" -version = "0.3.51" +version = "0.3.53" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "generate-files" -version = "0.1.0" -dependencies = [ - "ctest 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "kernel32-sys" version = "0.2.2" @@ -43,12 +36,12 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.28" -source = "registry+https://github.com/rust-lang/crates.io-index" +version = "0.2.29" [[package]] name = "libc" version = "0.2.29" +source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "log" @@ -66,7 +59,7 @@ version = "0.27.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.28 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.29 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)", "term 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)", @@ -100,9 +93,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [metadata] "checksum bitflags 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "32866f4d103c4e438b1db1158aa1b1a80ee078e5d77a59a2f906fd62a577389c" "checksum ctest 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "6ca66d610c7d9d6b7c51834ceeffe83b40b71be9f6793e350cff093428f73591" -"checksum gcc 0.3.51 (registry+https://github.com/rust-lang/crates.io-index)" = "120d07f202dcc3f72859422563522b66fe6463a4c513df062874daad05f85f0a" +"checksum gcc 0.3.53 (registry+https://github.com/rust-lang/crates.io-index)" = "e8310f7e9c890398b0e80e301c4f474e9918d2b27fca8f48486ca775fa9ffc5a" "checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" -"checksum libc 0.2.28 (registry+https://github.com/rust-lang/crates.io-index)" = "bb7b49972ee23d8aa1026c365a5b440ba08e35075f18c459980c7395c221ec48" +"checksum libc 0.2.29 (registry+https://github.com/rust-lang/crates.io-index)" = "8a014d9226c2cc402676fbe9ea2e15dd5222cd1dd57f576b5b283178c944a264" "checksum log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)" = "880f77541efa6e5cc74e76910c9884d9859683118839d6a1dc3b11e63512565b" "checksum rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)" = "dcf128d1287d2ea9d80910b5f1120d0b8eede3fbf1abe91c40d39ea7d51e6fda" "checksum syntex_syntax 0.27.0 (registry+https://github.com/rust-lang/crates.io-index)" = "82b078749c05271b2aebae7230331c903c38128d5a3dec72625d9e3a411a5b69" From ce276177f2d79b065859ce945c010de03769d30f Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Mon, 21 Aug 2017 17:01:12 -0700 Subject: [PATCH 5/8] Remove warnings in libc-test --- libc-test/test/linux_fcntl.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libc-test/test/linux_fcntl.rs b/libc-test/test/linux_fcntl.rs index 1c4635b12999c..4c8ad52a91e86 100644 --- a/libc-test/test/linux_fcntl.rs +++ b/libc-test/test/linux_fcntl.rs @@ -1,4 +1,5 @@ -#![allow(bad_style, improper_ctypes)] +#![allow(bad_style, improper_ctypes, unused)] + extern crate libc; use libc::*; From bcbfa856511f4f7bdacb8188eadcc7cbe38727e2 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Mon, 21 Aug 2017 17:06:12 -0700 Subject: [PATCH 6/8] Leverage Cargo's target runner support to execute tests --- .travis.yml | 8 +- .../aarch64-unknown-linux-gnu/Dockerfile | 4 +- .../arm-unknown-linux-gnueabihf/Dockerfile | 4 +- ci/docker/mips-unknown-linux-gnu/Dockerfile | 4 +- ci/docker/mips-unknown-linux-musl/Dockerfile | 6 +- .../mips64-unknown-linux-gnuabi64/Dockerfile | 4 +- .../mipsel-unknown-linux-musl/Dockerfile | 6 +- .../powerpc-unknown-linux-gnu/Dockerfile | 4 +- .../powerpc64-unknown-linux-gnu/Dockerfile | 4 +- ci/docker/s390x-unknown-linux-gnu/Dockerfile | 3 + ci/docker/x86_64-rumprun-netbsd/Dockerfile | 6 +- ci/docker/x86_64-rumprun-netbsd/runtest.rs | 54 +++++++++ ci/run.sh | 108 +----------------- 13 files changed, 87 insertions(+), 128 deletions(-) create mode 100644 ci/docker/x86_64-rumprun-netbsd/runtest.rs diff --git a/.travis.yml b/.travis.yml index c63272adb6795..555b72bd763c1 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 2a02f632103f0..18214a3e646f9 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 53da39825c2d3..9fe71dcf87cb0 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 f4997a702f61b..c66abd471b0f8 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 ba8e34642f61a..3fb0eebb8019f 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 a864a31ccee8f..b9921fcc50d22 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 36666743fb40c..a2c3bc4d2969b 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 489f8dd57faa9..106ada444a0da 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 51ebcca7e8165..a6ab66a9a617b 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 4cd9d4ae4faed..49a277d884f56 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 129771e76b74d..a486d05b2ebea 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 0000000000000..94b5946080b69 --- /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(); + } + } +} diff --git a/ci/run.sh b/ci/run.sh index 5afa27a2879b8..7a1736c837157 100755 --- a/ci/run.sh +++ b/ci/run.sh @@ -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 From d4240220057afe518921912c0832f70d67b19de3 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Mon, 21 Aug 2017 22:48:18 -0700 Subject: [PATCH 7/8] Update Android images/runners --- ci/docker/aarch64-linux-android/Dockerfile | 13 +++++++ ci/docker/arm-linux-androideabi/Dockerfile | 13 +++++++ ci/docker/i686-linux-android/Dockerfile | 13 +++++++ ci/run-docker.sh | 1 + ci/run.sh | 2 +- ci/runtest-android.rs | 41 ++++++++++++++++++++++ 6 files changed, 82 insertions(+), 1 deletion(-) create mode 100644 ci/runtest-android.rs diff --git a/ci/docker/aarch64-linux-android/Dockerfile b/ci/docker/aarch64-linux-android/Dockerfile index 7ad84926bf82b..345540a3f0775 100644 --- a/ci/docker/aarch64-linux-android/Dockerfile +++ b/ci/docker/aarch64-linux-android/Dockerfile @@ -29,4 +29,17 @@ RUN chmod 755 /android/sdk/tools/* /android/sdk/tools/qemu/linux-x86_64/* ENV PATH=$PATH:/rust/bin \ CARGO_TARGET_AARCH64_LINUX_ANDROID_LINKER=aarch64-linux-android-gcc \ + CARGO_TARGET_AARCH64_LINUX_ANDROID_RUNNER=/tmp/runtest \ HOME=/tmp + +ADD runtest-android.rs /tmp/runtest.rs +ENTRYPOINT [ \ + "bash", \ + "-c", \ + # set SHELL so android can detect a 64bits system, see + # http://stackoverflow.com/a/41789144 + "SHELL=/bin/dash emulator @aarch64 -no-window & \ + rustc /tmp/runtest.rs -o /tmp/runtest && \ + exec \"$@\"", \ + "--" \ +] diff --git a/ci/docker/arm-linux-androideabi/Dockerfile b/ci/docker/arm-linux-androideabi/Dockerfile index 054941416dfb5..554f078729356 100644 --- a/ci/docker/arm-linux-androideabi/Dockerfile +++ b/ci/docker/arm-linux-androideabi/Dockerfile @@ -29,4 +29,17 @@ RUN chmod 755 /android/sdk/tools/* /android/sdk/tools/qemu/linux-x86_64/* ENV PATH=$PATH:/rust/bin \ CARGO_TARGET_ARM_LINUX_ANDROIDEABI_LINKER=arm-linux-androideabi-gcc \ + CARGO_TARGET_ARM_LINUX_ANDROIDEABI_RUNNER=/tmp/runtest \ HOME=/tmp + +ADD runtest-android.rs /tmp/runtest.rs +ENTRYPOINT [ \ + "bash", \ + "-c", \ + # set SHELL so android can detect a 64bits system, see + # http://stackoverflow.com/a/41789144 + "SHELL=/bin/dash emulator @arm -no-window & \ + rustc /tmp/runtest.rs -o /tmp/runtest && \ + exec \"$@\"", \ + "--" \ +] diff --git a/ci/docker/i686-linux-android/Dockerfile b/ci/docker/i686-linux-android/Dockerfile index bee904379645f..7671f78b4f8f2 100644 --- a/ci/docker/i686-linux-android/Dockerfile +++ b/ci/docker/i686-linux-android/Dockerfile @@ -29,4 +29,17 @@ RUN chmod 755 /android/sdk/tools/* /android/sdk/tools/qemu/linux-x86_64/* ENV PATH=$PATH:/rust/bin \ CARGO_TARGET_I686_LINUX_ANDROID_LINKER=i686-linux-android-gcc \ + CARGO_TARGET_I686_LINUX_ANDROID_RUNNER=/tmp/runtest \ HOME=/tmp + +ADD runtest-android.rs /tmp/runtest.rs +ENTRYPOINT [ \ + "bash", \ + "-c", \ + # set SHELL so android can detect a 64bits system, see + # http://stackoverflow.com/a/41789144 + "SHELL=/bin/dash emulator @i686 -no-window -no-accel & \ + rustc /tmp/runtest.rs -o /tmp/runtest && \ + exec \"$@\"", \ + "--" \ +] diff --git a/ci/run-docker.sh b/ci/run-docker.sh index deafa99226666..662a1d491ad70 100755 --- a/ci/run-docker.sh +++ b/ci/run-docker.sh @@ -14,6 +14,7 @@ run() { docker run \ --user `id -u`:`id -g` \ --rm \ + --init \ --volume $HOME/.cargo:/cargo \ $kvm \ --env CARGO_HOME=/cargo \ diff --git a/ci/run.sh b/ci/run.sh index 7a1736c837157..ddf18fd2aa204 100755 --- a/ci/run.sh +++ b/ci/run.sh @@ -68,4 +68,4 @@ if [ "$QEMU" != "" ]; then exec grep "^PASSED .* tests" $CARGO_TARGET_DIR/out.log fi -cargo test --manifest-path libc-test/Cargo.toml --target $TARGET +exec cargo test --manifest-path libc-test/Cargo.toml --target $TARGET diff --git a/ci/runtest-android.rs b/ci/runtest-android.rs new file mode 100644 index 0000000000000..a8f8db83ffb61 --- /dev/null +++ b/ci/runtest-android.rs @@ -0,0 +1,41 @@ +use std::env; +use std::process::Command; +use std::path::{Path, PathBuf}; + +fn main() { + assert_eq!(env::args_os().len(), 2); + let test = PathBuf::from(env::args_os().nth(1).unwrap()); + let dst = Path::new("/data/local/tmp").join(test.file_name().unwrap()); + + let status = Command::new("adb") + .arg("wait-for-device") + .status() + .expect("failed to run rumprun-bake"); + assert!(status.success()); + + let status = Command::new("adb") + .arg("push") + .arg(&test) + .arg(&dst) + .status() + .expect("failed to run rumprun-bake"); + assert!(status.success()); + + let output = Command::new("adb") + .arg("shell") + .arg(&dst) + .output() + .expect("failed to run rumprun-bake"); + assert!(status.success()); + + println!("status: {}\nstdout ---\n{}\nstderr ---\n{}", + output.status, + String::from_utf8_lossy(&output.stdout), + String::from_utf8_lossy(&output.stderr)); + + let stdout = String::from_utf8_lossy(&output.stdout); + let mut lines = stdout.lines().filter(|l| l.starts_with("PASSED ")); + if !lines.any(|l| l.contains(" tests")) { + panic!("failed to find successful test run"); + } +} From b7902df689b11af70dd05e04430ad1d4c4afbb39 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Tue, 22 Aug 2017 07:02:32 -0700 Subject: [PATCH 8/8] Add ios flags to ios invocations --- .travis.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 555b72bd763c1..c1c3d24d21ff6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -50,12 +50,16 @@ matrix: - env: TARGET=aarch64-unknown-linux-gnu - os: osx osx_image: xcode8.2 - env: TARGET=i386-apple-ios CARGO_TARGET_I386_APPLE_IOS_RUNNER=$HOME/runtest + env: TARGET=i386-apple-ios + CARGO_TARGET_I386_APPLE_IOS_RUNNER=$HOME/runtest + RUSTFLAGS=-Clink-arg=-mios-simulator-version-min=7.0 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 CARGO_TARGET_X86_64_APPLE_IOS_RUNNER=$HOME/runtest + env: TARGET=x86_64-apple-ios + CARGO_TARGET_X86_64_APPLE_IOS_RUNNER=$HOME/runtest + RUSTFLAGS=-Clink-arg=-mios-simulator-version-min=7.0 before_install: rustc ./ci/ios/deploy_and_run_on_ios_simulator.rs -o $HOME/runtest - env: TARGET=x86_64-rumprun-netbsd