Skip to content

Commit f150863

Browse files
committed
Auto merge of rust-lang#820 - malbarbo:s390x-test, r=alexcrichton
Run s390x tests on qemu system qemu in user mode cannot run binaries produced by rustc (it hangs), so we run the tests in a fully virtualized s390x machine using qemu-system-s390x. Some constants had to be fixed.
2 parents 4feda87 + a6c7091 commit f150863

File tree

4 files changed

+69
-22
lines changed

4 files changed

+69
-22
lines changed
+11-5
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
11
FROM ubuntu:17.10
22

33
RUN apt-get update && apt-get install -y --no-install-recommends \
4-
gcc libc6-dev qemu-user ca-certificates \
5-
gcc-s390x-linux-gnu libc6-dev-s390x-cross
4+
curl ca-certificates \
5+
gcc libc6-dev \
6+
gcc-s390x-linux-gnu libc6-dev-s390x-cross \
7+
qemu-system-s390x \
8+
cpio
9+
10+
COPY linux-s390x.sh /
11+
RUN bash /linux-s390x.sh
12+
13+
COPY test-runner-linux /
614

715
ENV CARGO_TARGET_S390X_UNKNOWN_LINUX_GNU_LINKER=s390x-linux-gnu-gcc \
8-
# TODO: in theory we should execute this, but qemu segfaults immediately :(
9-
# CARGO_TARGET_S390X_UNKNOWN_LINUX_GNU_RUNNER="qemu-s390x -L /usr/s390x-linux-gnu" \
10-
CARGO_TARGET_S390X_UNKNOWN_LINUX_GNU_RUNNER=true \
16+
CARGO_TARGET_S390X_UNKNOWN_LINUX_GNU_RUNNER="/test-runner-linux s390x" \
1117
CC_s390x_unknown_linux_gnu=s390x-linux-gnu-gcc \
1218
PATH=$PATH:/rust/bin

ci/linux-s390x.sh

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
set -ex
2+
3+
mkdir -m 777 /qemu
4+
cd /qemu
5+
6+
curl -LO https://github.com/qemu/qemu/raw/master/pc-bios/s390-ccw.img
7+
curl -LO http://ftp.debian.org/debian/dists/testing/main/installer-s390x/20170828/images/generic/kernel.debian
8+
curl -LO http://ftp.debian.org/debian/dists/testing/main/installer-s390x/20170828/images/generic/initrd.debian
9+
10+
mv kernel.debian kernel
11+
mv initrd.debian initrd.gz
12+
13+
mkdir init
14+
cd init
15+
gunzip -c ../initrd.gz | cpio -id
16+
rm ../initrd.gz
17+
cp /usr/s390x-linux-gnu/lib/libgcc_s.so.1 usr/lib/
18+
chmod a+w .

ci/test-runner-linux

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
arch=$1
6+
prog=$2
7+
8+
cd /qemu/init
9+
cp -f $2 prog
10+
find . | cpio --create --format='newc' --quiet | gzip > ../initrd.gz
11+
cd ..
12+
13+
timeout 30s qemu-system-$arch \
14+
-m 1024 \
15+
-nographic \
16+
-kernel kernel \
17+
-initrd initrd.gz \
18+
-append init=/prog > output || true
19+
20+
# remove kernel messages
21+
tr -d '\r' < output | egrep -v '^\['
22+
23+
grep PASSED output > /dev/null

src/unix/notbsd/linux/s390x.rs

+17-17
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ pub const SFD_CLOEXEC: ::c_int = 0x080000;
323323
pub const NCCS: usize = 32;
324324

325325
pub const O_TRUNC: ::c_int = 512;
326-
pub const O_LARGEFILE: ::c_int = 0o0100000;
326+
pub const O_LARGEFILE: ::c_int = 0;
327327
pub const O_NOATIME: ::c_int = 0o1000000;
328328
pub const O_CLOEXEC: ::c_int = 0x80000;
329329
pub const O_PATH: ::c_int = 0o10000000;
@@ -913,8 +913,8 @@ pub const ECHOPRT: ::tcflag_t = 0o002000;
913913
pub const ECHOKE: ::tcflag_t = 0o004000;
914914
pub const PENDIN: ::tcflag_t = 0o040000;
915915

916-
pub const POLLWRNORM: ::c_short = 0x004;
917-
pub const POLLWRBAND: ::c_short = 0x100;
916+
pub const POLLWRNORM: ::c_short = 0x100;
917+
pub const POLLWRBAND: ::c_short = 0x200;
918918

919919
pub const IXON: ::tcflag_t = 0o002000;
920920
pub const IXOFF: ::tcflag_t = 0o010000;
@@ -1219,20 +1219,20 @@ pub const SYS_mlock2: ::c_long = 374;
12191219
pub const SYS_copy_file_range: ::c_long = 375;
12201220
pub const SYS_preadv2: ::c_long = 376;
12211221
pub const SYS_pwritev2: ::c_long = 377;
1222-
pub const SYS_lchown: ::c_long = 16;
1223-
pub const SYS_setuid: ::c_long = 23;
1224-
pub const SYS_getuid: ::c_long = 24;
1225-
pub const SYS_setgid: ::c_long = 46;
1226-
pub const SYS_getgid: ::c_long = 47;
1227-
pub const SYS_geteuid: ::c_long = 49;
1228-
pub const SYS_setreuid: ::c_long = 70;
1229-
pub const SYS_setregid: ::c_long = 71;
1230-
pub const SYS_getrlimit: ::c_long = 76;
1231-
pub const SYS_getgroups: ::c_long = 80;
1232-
pub const SYS_fchown: ::c_long = 95;
1233-
pub const SYS_setresuid: ::c_long = 164;
1234-
pub const SYS_setresgid: ::c_long = 170;
1235-
pub const SYS_getresgid: ::c_long = 171;
1222+
pub const SYS_lchown: ::c_long = 198;
1223+
pub const SYS_setuid: ::c_long = 213;
1224+
pub const SYS_getuid: ::c_long = 199;
1225+
pub const SYS_setgid: ::c_long = 214;
1226+
pub const SYS_getgid: ::c_long = 200;
1227+
pub const SYS_geteuid: ::c_long = 201;
1228+
pub const SYS_setreuid: ::c_long = 203;
1229+
pub const SYS_setregid: ::c_long = 204;
1230+
pub const SYS_getrlimit: ::c_long = 191;
1231+
pub const SYS_getgroups: ::c_long = 205;
1232+
pub const SYS_fchown: ::c_long = 207;
1233+
pub const SYS_setresuid: ::c_long = 208;
1234+
pub const SYS_setresgid: ::c_long = 210;
1235+
pub const SYS_getresgid: ::c_long = 211;
12361236
pub const SYS_select: ::c_long = 142;
12371237
pub const SYS_getegid: ::c_long = 202;
12381238
pub const SYS_setgroups: ::c_long = 206;

0 commit comments

Comments
 (0)