summaryrefslogtreecommitdiff
path: root/ci/run.sh
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2016-06-10 05:03:23 -0700
committerAlex Crichton <alex@alexcrichton.com>2016-06-15 03:33:30 -0700
commit3eb4a48b1b63909a8898aa37b5f610a63d776f4d (patch)
treef19cb2c4ee40427aae9f986435c6d7072b03637e /ci/run.sh
parent70dce055ebcbb7ef21fa045d95c79fe6b8263d9f (diff)
downloadrust-libc-3eb4a48b1b63909a8898aa37b5f610a63d776f4d.tar.gz
Use docker for all CI tests and images
Previously we were somewhat half-Docker, half-Travis, half apt-get, etc. This commit alters the CI infrastructure to use Docker images for each target. This should make it much easier to update the images and tweak various bits and pieces of installed software. Additionally, it's also much clearer now what's needed for each suite of tests! Some images were updated a bit (e.g. musl is now 1.1.14), but other images encountered failures when updating so they're not getting updated just yet.
Diffstat (limited to 'ci/run.sh')
-rwxr-xr-x[-rw-r--r--]ci/run.sh96
1 files changed, 89 insertions, 7 deletions
diff --git a/ci/run.sh b/ci/run.sh
index 706bf7a1d1..aea1de8dfe 100644..100755
--- a/ci/run.sh
+++ b/ci/run.sh
@@ -6,6 +6,89 @@
set -ex
TARGET=$1
+
+# If we're going to run tests inside of a qemu image, then we don't need any of
+# the scripts below. Instead, download the image, prepare a filesystem which has
+# the current state of this repository, and then run the image.
+#
+# It's assume that all images, when run with two disks, will run the `run.sh`
+# script from the second which we place inside.
+if [ "$QEMU" != "" ]; then
+ tmpdir=/tmp/qemu-img-creation
+ mkdir -p $tmpdir
+ if [ ! -f $tmpdir/$QEMU ]; then
+ curl https://people.mozilla.org/~acrichton/libc-test/qemu/$QEMU.gz | \
+ gunzip -d > $tmpdir/$QEMU
+ fi
+
+ # Create a mount a fresh new filesystem image that we'll later pass to QEMU.
+ # This will have a `run.sh` script will which use the artifacts inside to run
+ # on the host.
+ rm -f $tmpdir/libc-test.img
+ dd if=/dev/null of=$tmpdir/libc-test.img bs=1M seek=50
+ mkfs.ext2 -F $tmpdir/libc-test.img
+ rm -rf $tmpdir/mount
+ mkdir $tmpdir/mount
+ mount -t ext2 -o loop $tmpdir/libc-test.img $tmpdir/mount
+
+ # If we have a cross compiler, then we just do the standard rigamarole of
+ # cross-compiling an executable and then the script to run just executes the
+ # binary.
+ #
+ # If we don't have a cross-compiler, however, then we need to do some crazy
+ # acrobatics to get this to work. Generate all.{c,rs} on the host which will
+ # be compiled inside QEMU. Do this here because compiling syntex_syntax in
+ # QEMU would time out basically everywhere.
+ if [ "$CAN_CROSS" = "1" ]; then
+ cargo build --manifest-path libc-test/Cargo.toml --target $TARGET
+ cp $CARGO_TARGET_DIR/$TARGET/debug/libc-test $tmpdir/mount/
+ echo 'exec $1/libc-test' > $tmpdir/mount/run.sh
+ else
+ rm -rf $tmpdir/generated
+ mkdir -p $tmpdir/generated
+ cargo build --manifest-path libc-test/generate-files/Cargo.toml
+ (cd libc-test && TARGET=$TARGET OUT_DIR=$tmpdir/generated SKIP_COMPILE=1 \
+ $CARGO_TARGET_DIR/debug/generate-files)
+
+ # Copy this folder into the mounted image, the `run.sh` entry point, and
+ # overwrite the standard libc-test Cargo.toml with the overlay one which will
+ # assume the all.{c,rs} test files have already been generated
+ mkdir $tmpdir/mount/libc
+ cp -r Cargo.* libc-test src ci $tmpdir/mount/libc/
+ ln -s libc-test/target $tmpdir/mount/libc/target
+ cp ci/run-qemu.sh $tmpdir/mount/run.sh
+ echo $TARGET | tee -a $tmpdir/mount/TARGET
+ cp $tmpdir/generated/* $tmpdir/mount/libc/libc-test
+ cp libc-test/run-generated-Cargo.toml $tmpdir/mount/libc/libc-test/Cargo.toml
+ fi
+
+ umount $tmpdir/mount
+
+ # If we can use kvm, prefer that, otherwise just fall back to user-space
+ # emulation.
+ if kvm-ok; then
+ program=kvm
+ else
+ program=qemu-system-x86_64
+ fi
+
+ # Pass -snapshot to prevent tampering with the disk images, this helps when
+ # running this script in development. The two drives are then passed next,
+ # first is the OS and second is the one we just made. Next the network is
+ # configured to work (I'm not entirely sure how), and then finally we turn off
+ # graphics and redirect the serial console output to out.log.
+ $program \
+ -m 1024 \
+ -snapshot \
+ -drive if=virtio,file=$tmpdir/$QEMU \
+ -drive if=virtio,file=$tmpdir/libc-test.img \
+ -net nic,model=virtio \
+ -net user \
+ -nographic \
+ -vga none 2>&1 | tee $CARGO_TARGET_DIR/out.log
+ 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 -- \
@@ -21,26 +104,25 @@ case "$TARGET" in
arm-linux-androideabi)
emulator @arm-21 -no-window &
adb wait-for-device
- adb push /tmp/$TARGET/debug/libc-test /data/libc-test
+ adb push $CARGO_TARGET_DIR/$TARGET/debug/libc-test /data/libc-test
adb shell /data/libc-test 2>&1 | tee /tmp/out
grep "^PASSED .* tests" /tmp/out
;;
arm-unknown-linux-gnueabihf)
- qemu-arm -L /usr/arm-linux-gnueabihf libc-test/target/$TARGET/debug/libc-test
+ qemu-arm -L /usr/arm-linux-gnueabihf $CARGO_TARGET_DIR/$TARGET/debug/libc-test
;;
mips-unknown-linux-gnu)
- qemu-mips -L /usr/mips-linux-gnu /tmp/$TARGET/debug/libc-test
+ qemu-mips -L /usr/mips-linux-gnu $CARGO_TARGET_DIR/$TARGET/debug/libc-test
;;
aarch64-unknown-linux-gnu)
- qemu-aarch64 -L /usr/aarch64-linux-gnu/ \
- libc-test/target/$TARGET/debug/libc-test
+ qemu-aarch64 -L /usr/aarch64-linux-gnu/ $CARGO_TARGET_DIR/$TARGET/debug/libc-test
;;
*-rumprun-netbsd)
- rumprun-bake hw_virtio /tmp/libc-test.img /tmp/$TARGET/debug/libc-test
+ rumprun-bake hw_virtio /tmp/libc-test.img $CARGO_TARGET_DIR/$TARGET/debug/libc-test
qemu-system-x86_64 -nographic -vga none -m 64 \
-kernel /tmp/libc-test.img 2>&1 | tee /tmp/out &
sleep 5
@@ -48,6 +130,6 @@ case "$TARGET" in
;;
*)
- libc-test/target/$TARGET/debug/libc-test
+ $CARGO_TARGET_DIR/$TARGET/debug/libc-test
;;
esac