Skip to content

Commit 8ef3f69

Browse files
committedJul 24, 2017
Add a disabled builder for aarch64 emulated tests
This commit adds a disabled builder which will run all tests for the standard library for aarch64 in a QEMU instance. Once we get enough capacity to run this on Travis this can be used to boost our platform coverage of AArch64
1 parent b80e946 commit 8ef3f69

File tree

11 files changed

+3240
-16
lines changed

11 files changed

+3240
-16
lines changed
 

‎configure

+1
Original file line numberDiff line numberDiff line change
@@ -490,6 +490,7 @@ valopt musl-root-armhf "" "arm-unknown-linux-musleabihf install directory"
490490
valopt musl-root-armv7 "" "armv7-unknown-linux-musleabihf install directory"
491491
valopt extra-filename "" "Additional data that is hashed and passed to the -C extra-filename flag"
492492
valopt qemu-armhf-rootfs "" "rootfs in qemu testing, you probably don't want to use this"
493+
valopt qemu-aarch64-rootfs "" "rootfs in qemu testing, you probably don't want to use this"
493494
valopt experimental-targets "" "experimental LLVM targets to build"
494495

495496
if [ -e ${CFG_SRC_DIR}.git ]

‎src/bootstrap/config.rs

+5
Original file line numberDiff line numberDiff line change
@@ -636,6 +636,11 @@ impl Config {
636636
let target = self.target_config.entry(target).or_insert(Target::default());
637637
target.qemu_rootfs = Some(parse_configure_path(value));
638638
}
639+
"CFG_QEMU_AARCH64_ROOTFS" if value.len() > 0 => {
640+
let target = INTERNER.intern_str("aarch64-unknown-linux-gnu");
641+
let target = self.target_config.entry(target).or_insert(Target::default());
642+
target.qemu_rootfs = Some(parse_configure_path(value));
643+
}
639644
_ => {}
640645
}
641646
}

‎src/ci/docker/armhf-gnu/Dockerfile

+2-2
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,11 @@ RUN curl http://cdimage.ubuntu.com/ubuntu-base/releases/16.04/release/ubuntu-bas
6363

6464
# Copy over our init script, which starts up our test server and also a few
6565
# other misc tasks.
66-
COPY armhf-gnu/rcS rootfs/etc/init.d/rcS
66+
COPY scripts/qemu-bare-bones-rcS rootfs/etc/init.d/rcS
6767
RUN chmod +x rootfs/etc/init.d/rcS
6868

6969
# Helper to quickly fill the entropy pool in the kernel.
70-
COPY armhf-gnu/addentropy.c /tmp/
70+
COPY scripts/qemu-bare-bones-addentropy.c /tmp/addentropy.c
7171
RUN arm-linux-gnueabihf-gcc addentropy.c -o rootfs/addentropy -static
7272

7373
# TODO: What is this?!
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
FROM ubuntu:16.04
2+
3+
RUN apt-get update -y && apt-get install -y --no-install-recommends \
4+
bc \
5+
bzip2 \
6+
ca-certificates \
7+
cmake \
8+
cpio \
9+
curl \
10+
file \
11+
g++ \
12+
gcc-aarch64-linux-gnu \
13+
git \
14+
libc6-dev \
15+
libc6-dev-arm64-cross \
16+
make \
17+
python2.7 \
18+
qemu-system-aarch64 \
19+
xz-utils
20+
21+
ENV ARCH=arm64 \
22+
CROSS_COMPILE=aarch64-linux-gnu-
23+
24+
WORKDIR /build
25+
26+
# Compile the kernel that we're going to run and be emulating with. This is
27+
# basically just done to be compatible with the QEMU target that we're going
28+
# to be using when running tests. If any other kernel works or if any
29+
# other QEMU target works with some other stock kernel, we can use that too!
30+
#
31+
# The `config` config file was a previously generated config file for
32+
# the kernel. This file was generated by running `make defconfig`
33+
# followed by `make menuconfig` and then enabling the IPv6 protocol page.
34+
COPY disabled/aarch64-gnu/config /build/.config
35+
RUN curl https://cdn.kernel.org/pub/linux/kernel/v4.x/linux-4.4.42.tar.xz | \
36+
tar xJf - && \
37+
cd /build/linux-4.4.42 && \
38+
cp /build/.config . && \
39+
make -j$(nproc) all && \
40+
cp arch/arm64/boot/Image /tmp && \
41+
cd /build && \
42+
rm -rf linux-4.4.42
43+
44+
# Compile an instance of busybox as this provides a lightweight system and init
45+
# binary which we will boot into. Only trick here is configuring busybox to
46+
# build static binaries.
47+
RUN curl https://www.busybox.net/downloads/busybox-1.21.1.tar.bz2 | tar xjf - && \
48+
cd busybox-1.21.1 && \
49+
make defconfig && \
50+
sed -i 's/.*CONFIG_STATIC.*/CONFIG_STATIC=y/' .config && \
51+
make -j$(nproc) && \
52+
make install && \
53+
mv _install /tmp/rootfs && \
54+
cd /build && \
55+
rm -rf busybox-1.12.1
56+
57+
# Download the ubuntu rootfs, which we'll use as a chroot for all our tests.
58+
WORKDIR /tmp
59+
RUN mkdir rootfs/ubuntu
60+
RUN curl http://cdimage.ubuntu.com/ubuntu-base/releases/16.04/release/ubuntu-base-16.04-core-arm64.tar.gz | \
61+
tar xzf - -C rootfs/ubuntu && \
62+
cd rootfs && mkdir proc sys dev etc etc/init.d
63+
64+
# Copy over our init script, which starts up our test server and also a few
65+
# other misc tasks.
66+
COPY scripts/qemu-bare-bones-rcS rootfs/etc/init.d/rcS
67+
RUN chmod +x rootfs/etc/init.d/rcS
68+
69+
# Helper to quickly fill the entropy pool in the kernel.
70+
COPY scripts/qemu-bare-bones-addentropy.c /tmp/addentropy.c
71+
RUN aarch64-linux-gnu-gcc addentropy.c -o rootfs/addentropy -static
72+
73+
COPY scripts/dumb-init.sh /scripts/
74+
RUN sh /scripts/dumb-init.sh
75+
76+
COPY scripts/sccache.sh /scripts/
77+
RUN sh /scripts/sccache.sh
78+
79+
ENTRYPOINT ["/usr/bin/dumb-init", "--"]
80+
81+
ENV RUST_CONFIGURE_ARGS \
82+
--target=aarch64-unknown-linux-gnu \
83+
--qemu-aarch64-rootfs=/tmp/rootfs
84+
ENV SCRIPT python2.7 ../x.py test --target aarch64-unknown-linux-gnu
85+
ENV NO_CHANGE_USER=1

‎src/ci/docker/disabled/aarch64-gnu/config

+3,100
Large diffs are not rendered by default.

‎src/libstd/sys/unix/process/process_common.rs

+1
Original file line numberDiff line numberDiff line change
@@ -469,6 +469,7 @@ mod tests {
469469
// although the reason isn't very clear as to why. For now this test is
470470
// ignored there.
471471
#[cfg_attr(target_arch = "arm", ignore)]
472+
#[cfg_attr(target_arch = "aarch64", ignore)]
472473
fn test_process_mask() {
473474
unsafe {
474475
// Test to make sure that a signal mask does not get inherited.

‎src/libstd/time/mod.rs

+10-2
Original file line numberDiff line numberDiff line change
@@ -533,9 +533,17 @@ mod tests {
533533
assert!(b > a);
534534
assert_eq!(b - a, Duration::new(1, 0));
535535

536-
// let's assume that we're all running computers later than 2000
537536
let thirty_years = Duration::new(1, 0) * 60 * 60 * 24 * 365 * 30;
538-
assert!(a > thirty_years);
537+
538+
// Right now for CI this test is run in an emulator, and apparently the
539+
// aarch64 emulator's sense of time is that we're still living in the
540+
// 70s.
541+
//
542+
// Otherwise let's assume that we're all running computers later than
543+
// 2000.
544+
if !cfg!(target_arch = "aarch64") {
545+
assert!(a > thirty_years);
546+
}
539547

540548
// let's assume that we're all running computers earlier than 2090.
541549
// Should give us ~70 years to fix this!

‎src/test/codegen/stack-probes.rs

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
// ignore-arm
1212
// ignore-aarch64
1313
// ignore-powerpc
14+
// ignore-aarch64
1415
// ignore-wasm
1516
// ignore-emscripten
1617
// ignore-windows

‎src/tools/remote-test-client/src/main.rs

+35-12
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ fn spawn_emulator(target: &str,
6666
start_android_emulator(server);
6767
} else {
6868
let rootfs = rootfs.as_ref().expect("need rootfs on non-android");
69-
start_qemu_emulator(rootfs, server, tmpdir);
69+
start_qemu_emulator(target, rootfs, server, tmpdir);
7070
}
7171

7272
// Wait for the emulator to come online
@@ -120,7 +120,10 @@ fn start_android_emulator(server: &Path) {
120120
.unwrap();
121121
}
122122

123-
fn start_qemu_emulator(rootfs: &Path, server: &Path, tmpdir: &Path) {
123+
fn start_qemu_emulator(target: &str,
124+
rootfs: &Path,
125+
server: &Path,
126+
tmpdir: &Path) {
124127
// Generate a new rootfs image now that we've updated the test server
125128
// executable. This is the equivalent of:
126129
//
@@ -143,16 +146,36 @@ fn start_qemu_emulator(rootfs: &Path, server: &Path, tmpdir: &Path) {
143146
assert!(t!(child.wait()).success());
144147

145148
// Start up the emulator, in the background
146-
let mut cmd = Command::new("qemu-system-arm");
147-
cmd.arg("-M").arg("vexpress-a15")
148-
.arg("-m").arg("1024")
149-
.arg("-kernel").arg("/tmp/zImage")
150-
.arg("-initrd").arg(&rootfs_img)
151-
.arg("-dtb").arg("/tmp/vexpress-v2p-ca15-tc1.dtb")
152-
.arg("-append").arg("console=ttyAMA0 root=/dev/ram rdinit=/sbin/init init=/sbin/init")
153-
.arg("-nographic")
154-
.arg("-redir").arg("tcp:12345::12345");
155-
t!(cmd.spawn());
149+
match target {
150+
"arm-unknown-linux-gnueabihf" => {
151+
let mut cmd = Command::new("qemu-system-arm");
152+
cmd.arg("-M").arg("vexpress-a15")
153+
.arg("-m").arg("1024")
154+
.arg("-kernel").arg("/tmp/zImage")
155+
.arg("-initrd").arg(&rootfs_img)
156+
.arg("-dtb").arg("/tmp/vexpress-v2p-ca15-tc1.dtb")
157+
.arg("-append")
158+
.arg("console=ttyAMA0 root=/dev/ram rdinit=/sbin/init init=/sbin/init")
159+
.arg("-nographic")
160+
.arg("-redir").arg("tcp:12345::12345");
161+
t!(cmd.spawn());
162+
}
163+
"aarch64-unknown-linux-gnu" => {
164+
let mut cmd = Command::new("qemu-system-aarch64");
165+
cmd.arg("-machine").arg("virt")
166+
.arg("-cpu").arg("cortex-a57")
167+
.arg("-m").arg("1024")
168+
.arg("-kernel").arg("/tmp/Image")
169+
.arg("-initrd").arg(&rootfs_img)
170+
.arg("-append")
171+
.arg("console=ttyAMA0 root=/dev/ram rdinit=/sbin/init init=/sbin/init")
172+
.arg("-nographic")
173+
.arg("-netdev").arg("user,id=net0,hostfwd=tcp::12345-:12345")
174+
.arg("-device").arg("virtio-net-device,netdev=net0,mac=00:00:00:00:00:00");
175+
t!(cmd.spawn());
176+
}
177+
_ => panic!("cannot start emulator for: {}"< target),
178+
}
156179

157180
fn add_files(w: &mut Write, root: &Path, cur: &Path) {
158181
for entry in t!(cur.read_dir()) {

0 commit comments

Comments
 (0)
Please sign in to comment.