@@ -37,11 +37,7 @@ if [ "$QEMU" != "" ]; then
37
37
# This will have a `run.sh` script will which use the artifacts inside to run
38
38
# on the host.
39
39
rm -f $tmpdir /libc-test.img
40
- dd if=/dev/null of=$tmpdir /libc-test.img bs=1M seek=50
41
- mkfs.ext2 -F $tmpdir /libc-test.img
42
- rm -rf $tmpdir /mount
43
40
mkdir $tmpdir /mount
44
- mount -t ext2 -o loop $tmpdir /libc-test.img $tmpdir /mount
45
41
46
42
# If we have a cross compiler, then we just do the standard rigamarole of
47
43
# cross-compiling an executable and then the script to run just executes the
@@ -53,14 +49,14 @@ if [ "$QEMU" != "" ]; then
53
49
# QEMU would time out basically everywhere.
54
50
if [ " $CAN_CROSS " = " 1" ]; then
55
51
cargo build --manifest-path libc-test/Cargo.toml --target $TARGET
56
- cp $CARGO_TARGET_DIR /$TARGET /debug/libc-test $tmpdir /mount/
52
+ cp target /$TARGET /debug/libc-test $tmpdir /mount/
57
53
echo ' exec $1/libc-test' > $tmpdir /mount/run.sh
58
54
else
59
55
rm -rf $tmpdir /generated
60
56
mkdir -p $tmpdir /generated
61
57
cargo build --manifest-path libc-test/generate-files/Cargo.toml
62
58
(cd libc-test && TARGET=$TARGET OUT_DIR=$tmpdir /generated SKIP_COMPILE=1 \
63
- $CARGO_TARGET_DIR /debug/generate-files)
59
+ ../target /debug/generate-files)
64
60
65
61
# Copy this folder into the mounted image, the `run.sh` entry point, and
66
62
# overwrite the standard libc-test Cargo.toml with the overlay one which will
@@ -74,31 +70,27 @@ if [ "$QEMU" != "" ]; then
74
70
cp libc-test/run-generated-Cargo.toml $tmpdir /mount/libc/libc-test/Cargo.toml
75
71
fi
76
72
77
- umount $tmpdir /mount
78
-
79
- # If we can use kvm, prefer that, otherwise just fall back to user-space
80
- # emulation.
81
- if kvm-ok; then
82
- program=kvm
83
- else
84
- program=qemu-system-x86_64
85
- fi
73
+ du -sh $tmpdir /mount
74
+ genext2fs \
75
+ --root $tmpdir /mount \
76
+ --size-in-blocks 100000 \
77
+ $tmpdir /libc-test.img
86
78
87
79
# Pass -snapshot to prevent tampering with the disk images, this helps when
88
80
# running this script in development. The two drives are then passed next,
89
81
# first is the OS and second is the one we just made. Next the network is
90
82
# configured to work (I'm not entirely sure how), and then finally we turn off
91
83
# graphics and redirect the serial console output to out.log.
92
- $program \
84
+ qemu-system-x86_64 \
93
85
-m 1024 \
94
86
-snapshot \
95
87
-drive if=virtio,file=$tmpdir /$qemufile \
96
88
-drive if=virtio,file=$tmpdir /libc-test.img \
97
89
-net nic,model=virtio \
98
90
-net user \
99
91
-nographic \
100
- -vga none 2>&1 | tee $CARGO_TARGET_DIR /out.log
101
- exec grep " ^PASSED .* tests" $CARGO_TARGET_DIR /out.log
92
+ -vga none 2>&1 | tee target /out.log
93
+ exec grep " ^PASSED .* tests" target /out.log
102
94
fi
103
95
104
96
case " $TARGET " in
@@ -116,49 +108,53 @@ case "$TARGET" in
116
108
arm-linux-androideabi)
117
109
emulator @arm-21 -no-window &
118
110
adb wait-for-device
119
- adb push $CARGO_TARGET_DIR /$TARGET /debug/libc-test /data/libc-test
111
+ adb push target /$TARGET /debug/libc-test /data/libc-test
120
112
adb shell /data/libc-test 2>&1 | tee /tmp/out
121
113
grep " ^PASSED .* tests" /tmp/out
122
114
;;
123
115
124
116
arm-unknown-linux-gnueabihf)
125
- qemu-arm -L /usr/arm-linux-gnueabihf $CARGO_TARGET_DIR /$TARGET /debug/libc-test
117
+ qemu-arm -L /usr/arm-linux-gnueabihf target /$TARGET /debug/libc-test
126
118
;;
127
119
128
120
mips-unknown-linux-gnu)
129
- qemu-mips -L /usr/mips-linux-gnu $CARGO_TARGET_DIR /$TARGET /debug/libc-test
121
+ qemu-mips -L /usr/mips-linux-gnu target /$TARGET /debug/libc-test
130
122
;;
131
123
132
124
mips-unknown-linux-musl)
133
125
qemu-mips -L /toolchain/staging_dir/toolchain-mips_34kc_gcc-5.3.0_musl-1.1.15 \
134
- $CARGO_TARGET_DIR /$TARGET /debug/libc-test
126
+ target /$TARGET /debug/libc-test
135
127
;;
136
128
137
129
mipsel-unknown-linux-musl)
138
- qemu-mipsel -L /toolchain $CARGO_TARGET_DIR /$TARGET /debug/libc-test
130
+ qemu-mipsel -L /toolchain target /$TARGET /debug/libc-test
139
131
;;
140
132
141
133
powerpc-unknown-linux-gnu)
142
- qemu-ppc -L /usr/powerpc-linux-gnu $CARGO_TARGET_DIR /$TARGET /debug/libc-test
134
+ qemu-ppc -L /usr/powerpc-linux-gnu target /$TARGET /debug/libc-test
143
135
;;
144
136
145
137
powerpc64-unknown-linux-gnu)
146
- qemu-ppc64 -L /usr/powerpc64-linux-gnu $CARGO_TARGET_DIR /$TARGET /debug/libc-test
138
+ qemu-ppc64 -L /usr/powerpc64-linux-gnu target /$TARGET /debug/libc-test
147
139
;;
148
140
149
141
aarch64-unknown-linux-gnu)
150
- qemu-aarch64 -L /usr/aarch64-linux-gnu/ $CARGO_TARGET_DIR /$TARGET /debug/libc-test
142
+ qemu-aarch64 -L /usr/aarch64-linux-gnu/ target /$TARGET /debug/libc-test
151
143
;;
152
144
153
145
* -rumprun-netbsd)
154
- rumprun-bake hw_virtio /tmp/libc-test.img $CARGO_TARGET_DIR /$TARGET /debug/libc-test
146
+ rumprun-bake hw_virtio /tmp/libc-test.img target /$TARGET /debug/libc-test
155
147
qemu-system-x86_64 -nographic -vga none -m 64 \
156
148
-kernel /tmp/libc-test.img 2>&1 | tee /tmp/out &
157
149
sleep 5
158
150
grep " ^PASSED .* tests" /tmp/out
159
151
;;
160
152
161
153
* )
162
- $CARGO_TARGET_DIR /$TARGET /debug/libc-test
154
+ if [ " $CARGO_TARGET_DIR " == " " ]; then
155
+ target/$TARGET /debug/libc-test
156
+ else
157
+ $CARGO_TARGET_DIR /$TARGET /debug/libc-test
158
+ fi
163
159
;;
164
160
esac
0 commit comments