From cd2e87d575c13df9ae553c42aa3ffd213fd71935 Mon Sep 17 00:00:00 2001 From: Marco A L Barbosa Date: Fri, 27 Oct 2017 07:19:56 -0200 Subject: [PATCH 1/2] Run s390x test in qemu system instead of qemu user --- ci/docker/s390x-unknown-linux-gnu/Dockerfile | 16 +++++++++----- ci/linux-s390x.sh | 18 +++++++++++++++ ci/test-runner-linux | 23 ++++++++++++++++++++ 3 files changed, 52 insertions(+), 5 deletions(-) create mode 100644 ci/linux-s390x.sh create mode 100755 ci/test-runner-linux diff --git a/ci/docker/s390x-unknown-linux-gnu/Dockerfile b/ci/docker/s390x-unknown-linux-gnu/Dockerfile index 49a277d884f56..861f4f9b00ee0 100644 --- a/ci/docker/s390x-unknown-linux-gnu/Dockerfile +++ b/ci/docker/s390x-unknown-linux-gnu/Dockerfile @@ -1,12 +1,18 @@ FROM ubuntu:17.10 RUN apt-get update && apt-get install -y --no-install-recommends \ - gcc libc6-dev qemu-user ca-certificates \ - gcc-s390x-linux-gnu libc6-dev-s390x-cross + curl ca-certificates \ + gcc libc6-dev \ + gcc-s390x-linux-gnu libc6-dev-s390x-cross \ + qemu-system-s390x \ + cpio + +COPY linux-s390x.sh / +RUN bash /linux-s390x.sh + +COPY test-runner-linux / 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 \ + CARGO_TARGET_S390X_UNKNOWN_LINUX_GNU_RUNNER="/test-runner-linux s390x" \ CC_s390x_unknown_linux_gnu=s390x-linux-gnu-gcc \ PATH=$PATH:/rust/bin diff --git a/ci/linux-s390x.sh b/ci/linux-s390x.sh new file mode 100644 index 0000000000000..972abeec569ec --- /dev/null +++ b/ci/linux-s390x.sh @@ -0,0 +1,18 @@ +set -ex + +mkdir -m 777 /qemu +cd /qemu + +curl -LO https://github.com/qemu/qemu/raw/master/pc-bios/s390-ccw.img +curl -LO http://ftp.debian.org/debian/dists/testing/main/installer-s390x/20170828/images/generic/kernel.debian +curl -LO http://ftp.debian.org/debian/dists/testing/main/installer-s390x/20170828/images/generic/initrd.debian + +mv kernel.debian kernel +mv initrd.debian initrd.gz + +mkdir init +cd init +gunzip -c ../initrd.gz | cpio -id +rm ../initrd.gz +cp /usr/s390x-linux-gnu/lib/libgcc_s.so.1 usr/lib/ +chmod a+w . diff --git a/ci/test-runner-linux b/ci/test-runner-linux new file mode 100755 index 0000000000000..7a84b9d438fe5 --- /dev/null +++ b/ci/test-runner-linux @@ -0,0 +1,23 @@ +#!/bin/bash + +set -e + +arch=$1 +prog=$2 + +cd /qemu/init +cp -f $2 prog +find . | cpio --create --format='newc' --quiet | gzip > ../initrd.gz +cd .. + +timeout 30s qemu-system-$arch \ + -m 1024 \ + -nographic \ + -kernel kernel \ + -initrd initrd.gz \ + -append init=/prog > output || true + +# remove kernel messages +tr -d '\r' < output | egrep -v '^\[' + +grep PASSED output > /dev/null From a6c709142d6342b39e1cdca38d32bb6f7434c92b Mon Sep 17 00:00:00 2001 From: Marco A L Barbosa Date: Fri, 27 Oct 2017 08:12:56 -0200 Subject: [PATCH 2/2] Fix some s390x constants --- src/unix/notbsd/linux/s390x.rs | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/src/unix/notbsd/linux/s390x.rs b/src/unix/notbsd/linux/s390x.rs index c2373f5744b44..1d447abfc2438 100644 --- a/src/unix/notbsd/linux/s390x.rs +++ b/src/unix/notbsd/linux/s390x.rs @@ -323,7 +323,7 @@ pub const SFD_CLOEXEC: ::c_int = 0x080000; pub const NCCS: usize = 32; pub const O_TRUNC: ::c_int = 512; -pub const O_LARGEFILE: ::c_int = 0o0100000; +pub const O_LARGEFILE: ::c_int = 0; pub const O_NOATIME: ::c_int = 0o1000000; pub const O_CLOEXEC: ::c_int = 0x80000; pub const O_PATH: ::c_int = 0o10000000; @@ -913,8 +913,8 @@ pub const ECHOPRT: ::tcflag_t = 0o002000; pub const ECHOKE: ::tcflag_t = 0o004000; pub const PENDIN: ::tcflag_t = 0o040000; -pub const POLLWRNORM: ::c_short = 0x004; -pub const POLLWRBAND: ::c_short = 0x100; +pub const POLLWRNORM: ::c_short = 0x100; +pub const POLLWRBAND: ::c_short = 0x200; pub const IXON: ::tcflag_t = 0o002000; pub const IXOFF: ::tcflag_t = 0o010000; @@ -1219,20 +1219,20 @@ pub const SYS_mlock2: ::c_long = 374; pub const SYS_copy_file_range: ::c_long = 375; pub const SYS_preadv2: ::c_long = 376; pub const SYS_pwritev2: ::c_long = 377; -pub const SYS_lchown: ::c_long = 16; -pub const SYS_setuid: ::c_long = 23; -pub const SYS_getuid: ::c_long = 24; -pub const SYS_setgid: ::c_long = 46; -pub const SYS_getgid: ::c_long = 47; -pub const SYS_geteuid: ::c_long = 49; -pub const SYS_setreuid: ::c_long = 70; -pub const SYS_setregid: ::c_long = 71; -pub const SYS_getrlimit: ::c_long = 76; -pub const SYS_getgroups: ::c_long = 80; -pub const SYS_fchown: ::c_long = 95; -pub const SYS_setresuid: ::c_long = 164; -pub const SYS_setresgid: ::c_long = 170; -pub const SYS_getresgid: ::c_long = 171; +pub const SYS_lchown: ::c_long = 198; +pub const SYS_setuid: ::c_long = 213; +pub const SYS_getuid: ::c_long = 199; +pub const SYS_setgid: ::c_long = 214; +pub const SYS_getgid: ::c_long = 200; +pub const SYS_geteuid: ::c_long = 201; +pub const SYS_setreuid: ::c_long = 203; +pub const SYS_setregid: ::c_long = 204; +pub const SYS_getrlimit: ::c_long = 191; +pub const SYS_getgroups: ::c_long = 205; +pub const SYS_fchown: ::c_long = 207; +pub const SYS_setresuid: ::c_long = 208; +pub const SYS_setresgid: ::c_long = 210; +pub const SYS_getresgid: ::c_long = 211; pub const SYS_select: ::c_long = 142; pub const SYS_getegid: ::c_long = 202; pub const SYS_setgroups: ::c_long = 206;