This repository was archived by the owner on Dec 9, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.sh
157 lines (132 loc) · 3.33 KB
/
script.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
set -ex
. $(dirname $0)/env.sh
failures=()
try() {
set +e
eval "$2"
if [[ $? != 0 ]]; then
failures+=( $1 )
fi
set -e
}
run() {
cargo run --target $TARGET --bin "${@}"
}
run_apps() {
try 'start.debug' "run start"
try 'hello.debug' "run hello"
try 'panic.debug' "
run panic
[[ \$? == 101 ]] || exit 1
"
try 'start.release' "run start --release"
try 'hello.release' "run hello --release"
try 'panic.release' "
run panic --release
[[ \$? == 101 ]] || exit 1
"
}
run_intrinsics() {
if [[ $LINUX ]]; then
try 'intrinsics' "cargo build --target $TARGET --bin intrinsics"
cp src/bin/intrinsics.rs{,.bk}
sed -i '/compiler_builtins/d' src/bin/intrinsics.rs
set +x
echo 'Intrinsics provided by compiler_builtins'
cargo build --target $TARGET --bin intrinsics 2>&1 | grep undefined | cut -d'`' -f2
set -x
mv src/bin/intrinsics.rs{.bk,}
fi
}
run_unit_tests() {
if [[ $QEMU_LD_PREFIX ]]; then
export RUST_TEST_THREADS=1
fi
try 'cargo_test.debug' "cargo test --target $TARGET"
try 'cargo_test.release' "cargo test --target $TARGET --release"
}
run_std_tests() {
local linker=CC_${TARGET//-/_}
local crates=(
alloc
alloc_system
collections
collectionstest
coretest
getopts
panic_abort
rand
rustc_bitflags
term
test
unwind
)
# FIXME re-enable std
# This has been disabled because it fails when cross testing targets like arm, aarch64 and mips
# due to QEMU limitations
# std
local crate flags lib_rs
for crate in ${crates[@]}; do
flags="--crate-name $crate --target $TARGET --test"
lib_rs=$(rustc --print sysroot)/lib/rustlib/src/rust/src/lib$crate/lib.rs
# debug
if [[ ${!linker} ]]; then
rustc $flags -C linker=${!linker} $lib_rs
else
rustc $flags $lib_rs
fi
try "$crate.debug" "./$crate"
# release
if [[ ${!linker} ]]; then
rustc $flags -C linker=${!linker} -C opt-level=3 $lib_rs
else
rustc $flags -C opt-level=3 $lib_rs
fi
try "$crate.release" "./$crate"
rm $crate
done
}
run_libc_test() {
try 'libc_test' "cargo run --target $TARGET --manifest-path libc/libc-test/Cargo.toml"
}
report_failures() {
set +x
if [[ $failures ]]; then
echo FAILURES
echo --------
for failure in ${failures[@]}; do
echo $failure
done
exit 1
fi
set -x
}
main() {
if [[ $LINUX && ${IN_DOCKER_CONTAINER:-n} == n ]]; then
local gid=$(id -g) group=$(id -g -n) uid=$(id -u) user=$(id -u -n)
docker run \
--entrypoint bash \
--privileged \
-e IN_DOCKER_CONTAINER=y \
-e TARGET=$TARGET \
-e TRAVIS_OS_NAME=$TRAVIS_OS_NAME \
-v $(pwd):/mnt \
japaric/smoke \
-c "
set -ex
update-binfmts --import
groupadd -g $gid $group
useradd -m -g $gid -u $uid $user
cd /mnt
su -c 'bash ci/install.sh && bash ci/script.sh' $user
"
else
run_apps
run_intrinsics
run_unit_tests
run_libc_test
run_std_tests
report_failures
fi
}
main