Skip to content

Commit cb36760

Browse files
committed
Split the actual tests out into scripts/tests.sh
1 parent 324e63d commit cb36760

File tree

2 files changed

+106
-94
lines changed

2 files changed

+106
-94
lines changed

scripts/tests.sh

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
function no_sysroot_tests() {
2+
RUSTC=$RUSTC" "$RUSTFLAGS" -L crate=target/out --out-dir target/out -Cdebuginfo=2"
3+
4+
echo "[BUILD] mini_core"
5+
$RUSTC example/mini_core.rs --crate-name mini_core --crate-type lib,dylib --target $TARGET_TRIPLE
6+
7+
echo "[BUILD] example"
8+
$RUSTC example/example.rs --crate-type lib --target $TARGET_TRIPLE
9+
10+
if [[ "$JIT_SUPPORTED" = "1" ]]; then
11+
echo "[JIT] mini_core_hello_world"
12+
CG_CLIF_JIT_ARGS="abc bcd" $RUSTC --jit example/mini_core_hello_world.rs --cfg jit --target $HOST_TRIPLE
13+
else
14+
echo "[JIT] mini_core_hello_world (skipped)"
15+
fi
16+
17+
echo "[AOT] mini_core_hello_world"
18+
$RUSTC example/mini_core_hello_world.rs --crate-name mini_core_hello_world --crate-type bin -g --target $TARGET_TRIPLE
19+
$RUN_WRAPPER ./target/out/mini_core_hello_world abc bcd
20+
# (echo "break set -n main"; echo "run"; sleep 1; echo "si -c 10"; sleep 1; echo "frame variable") | lldb -- ./target/out/mini_core_hello_world abc bcd
21+
22+
echo "[AOT] arbitrary_self_types_pointers_and_wrappers"
23+
$RUSTC example/arbitrary_self_types_pointers_and_wrappers.rs --crate-name arbitrary_self_types_pointers_and_wrappers --crate-type bin --target $TARGET_TRIPLE
24+
$RUN_WRAPPER ./target/out/arbitrary_self_types_pointers_and_wrappers
25+
}
26+
27+
function base_sysroot_tests() {
28+
echo "[AOT] alloc_example"
29+
$RUSTC example/alloc_example.rs --crate-type bin --target $TARGET_TRIPLE
30+
$RUN_WRAPPER ./target/out/alloc_example
31+
32+
if [[ "$JIT_SUPPORTED" = "1" ]]; then
33+
echo "[JIT] std_example"
34+
$RUSTC --jit example/std_example.rs --target $HOST_TRIPLE
35+
else
36+
echo "[JIT] std_example (skipped)"
37+
fi
38+
39+
echo "[AOT] dst_field_align"
40+
# FIXME Re-add -Zmir-opt-level=2 once rust-lang/rust#67529 is fixed.
41+
$RUSTC example/dst-field-align.rs --crate-name dst_field_align --crate-type bin --target $TARGET_TRIPLE
42+
$RUN_WRAPPER ./target/out/dst_field_align || (echo $?; false)
43+
44+
echo "[AOT] std_example"
45+
$RUSTC example/std_example.rs --crate-type bin --target $TARGET_TRIPLE
46+
$RUN_WRAPPER ./target/out/std_example arg
47+
48+
echo "[AOT] subslice-patterns-const-eval"
49+
$RUSTC example/subslice-patterns-const-eval.rs --crate-type bin -Cpanic=abort --target $TARGET_TRIPLE
50+
$RUN_WRAPPER ./target/out/subslice-patterns-const-eval
51+
52+
echo "[AOT] track-caller-attribute"
53+
$RUSTC example/track-caller-attribute.rs --crate-type bin -Cpanic=abort --target $TARGET_TRIPLE
54+
$RUN_WRAPPER ./target/out/track-caller-attribute
55+
56+
echo "[AOT] mod_bench"
57+
$RUSTC example/mod_bench.rs --crate-type bin --target $TARGET_TRIPLE
58+
$RUN_WRAPPER ./target/out/mod_bench
59+
60+
pushd rand
61+
rm -r ./target || true
62+
../cargo.sh test --workspace
63+
popd
64+
}
65+
66+
function extended_sysroot_tests() {
67+
pushd simple-raytracer
68+
if [[ "$HOST_TRIPLE" = "$TARGET_TRIPLE" ]]; then
69+
echo "[BENCH COMPILE] ebobby/simple-raytracer"
70+
hyperfine --runs ${RUN_RUNS:-10} --warmup 1 --prepare "cargo clean" \
71+
"RUSTC=rustc RUSTFLAGS='' cargo build" \
72+
"../cargo.sh build"
73+
74+
echo "[BENCH RUN] ebobby/simple-raytracer"
75+
cp ./target/debug/main ./raytracer_cg_clif
76+
hyperfine --runs ${RUN_RUNS:-10} ./raytracer_cg_llvm ./raytracer_cg_clif
77+
else
78+
echo "[BENCH COMPILE] ebobby/simple-raytracer (skipped)"
79+
echo "[COMPILE] ebobby/simple-raytracer"
80+
../cargo.sh build
81+
echo "[BENCH RUN] ebobby/simple-raytracer (skipped)"
82+
fi
83+
popd
84+
85+
pushd build_sysroot/sysroot_src/library/core/tests
86+
echo "[TEST] libcore"
87+
rm -r ./target || true
88+
../../../../../cargo.sh test
89+
popd
90+
91+
pushd regex
92+
echo "[TEST] rust-lang/regex example shootout-regex-dna"
93+
../cargo.sh clean
94+
# Make sure `[codegen mono items] start` doesn't poison the diff
95+
../cargo.sh build --example shootout-regex-dna
96+
cat examples/regexdna-input.txt | ../cargo.sh run --example shootout-regex-dna | grep -v "Spawned thread" > res.txt
97+
diff -u res.txt examples/regexdna-output.txt
98+
99+
echo "[TEST] rust-lang/regex tests"
100+
../cargo.sh test --tests -- --exclude-should-panic --test-threads 1 -Zunstable-options
101+
popd
102+
}

test.sh

Lines changed: 4 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -13,107 +13,17 @@ fi
1313

1414
# Config
1515
source scripts/config.sh
16+
source scripts/tests.sh
1617
export CG_CLIF_INCR_CACHE_DISABLED=1
17-
RUSTC=$RUSTC" "$RUSTFLAGS" -L crate=target/out --out-dir target/out -Cdebuginfo=2"
1818

1919
# Cleanup
2020
rm -r target/out || true
2121

22-
# Perform all tests
23-
echo "[BUILD] mini_core"
24-
$RUSTC example/mini_core.rs --crate-name mini_core --crate-type lib,dylib --target $TARGET_TRIPLE
25-
26-
echo "[BUILD] example"
27-
$RUSTC example/example.rs --crate-type lib --target $TARGET_TRIPLE
28-
29-
if [[ "$JIT_SUPPORTED" = "1" ]]; then
30-
echo "[JIT] mini_core_hello_world"
31-
CG_CLIF_JIT_ARGS="abc bcd" $RUSTC --jit example/mini_core_hello_world.rs --cfg jit --target $HOST_TRIPLE
32-
else
33-
echo "[JIT] mini_core_hello_world (skipped)"
34-
fi
35-
36-
echo "[AOT] mini_core_hello_world"
37-
$RUSTC example/mini_core_hello_world.rs --crate-name mini_core_hello_world --crate-type bin -g --target $TARGET_TRIPLE
38-
$RUN_WRAPPER ./target/out/mini_core_hello_world abc bcd
39-
# (echo "break set -n main"; echo "run"; sleep 1; echo "si -c 10"; sleep 1; echo "frame variable") | lldb -- ./target/out/mini_core_hello_world abc bcd
40-
41-
echo "[AOT] arbitrary_self_types_pointers_and_wrappers"
42-
$RUSTC example/arbitrary_self_types_pointers_and_wrappers.rs --crate-name arbitrary_self_types_pointers_and_wrappers --crate-type bin --target $TARGET_TRIPLE
43-
$RUN_WRAPPER ./target/out/arbitrary_self_types_pointers_and_wrappers
22+
no_sysroot_tests
4423

4524
echo "[BUILD] sysroot"
4625
time ./build_sysroot/build_sysroot.sh --release
4726

48-
echo "[AOT] alloc_example"
49-
$RUSTC example/alloc_example.rs --crate-type bin --target $TARGET_TRIPLE
50-
$RUN_WRAPPER ./target/out/alloc_example
51-
52-
if [[ "$JIT_SUPPORTED" = "1" ]]; then
53-
echo "[JIT] std_example"
54-
$RUSTC --jit example/std_example.rs --target $HOST_TRIPLE
55-
else
56-
echo "[JIT] std_example (skipped)"
57-
fi
58-
59-
echo "[AOT] dst_field_align"
60-
# FIXME Re-add -Zmir-opt-level=2 once rust-lang/rust#67529 is fixed.
61-
$RUSTC example/dst-field-align.rs --crate-name dst_field_align --crate-type bin --target $TARGET_TRIPLE
62-
$RUN_WRAPPER ./target/out/dst_field_align || (echo $?; false)
63-
64-
echo "[AOT] std_example"
65-
$RUSTC example/std_example.rs --crate-type bin --target $TARGET_TRIPLE
66-
$RUN_WRAPPER ./target/out/std_example arg
67-
68-
echo "[AOT] subslice-patterns-const-eval"
69-
$RUSTC example/subslice-patterns-const-eval.rs --crate-type bin -Cpanic=abort --target $TARGET_TRIPLE
70-
$RUN_WRAPPER ./target/out/subslice-patterns-const-eval
71-
72-
echo "[AOT] track-caller-attribute"
73-
$RUSTC example/track-caller-attribute.rs --crate-type bin -Cpanic=abort --target $TARGET_TRIPLE
74-
$RUN_WRAPPER ./target/out/track-caller-attribute
75-
76-
echo "[AOT] mod_bench"
77-
$RUSTC example/mod_bench.rs --crate-type bin --target $TARGET_TRIPLE
78-
$RUN_WRAPPER ./target/out/mod_bench
79-
80-
pushd rand
81-
rm -r ./target || true
82-
../cargo.sh test --workspace
83-
popd
84-
85-
pushd simple-raytracer
86-
if [[ "$HOST_TRIPLE" = "$TARGET_TRIPLE" ]]; then
87-
echo "[BENCH COMPILE] ebobby/simple-raytracer"
88-
hyperfine --runs ${RUN_RUNS:-10} --warmup 1 --prepare "cargo clean" \
89-
"RUSTC=rustc RUSTFLAGS='' cargo build" \
90-
"../cargo.sh build"
91-
92-
echo "[BENCH RUN] ebobby/simple-raytracer"
93-
cp ./target/debug/main ./raytracer_cg_clif
94-
hyperfine --runs ${RUN_RUNS:-10} ./raytracer_cg_llvm ./raytracer_cg_clif
95-
else
96-
echo "[BENCH COMPILE] ebobby/simple-raytracer (skipped)"
97-
echo "[COMPILE] ebobby/simple-raytracer"
98-
../cargo.sh build
99-
echo "[BENCH RUN] ebobby/simple-raytracer (skipped)"
100-
fi
101-
popd
102-
103-
pushd build_sysroot/sysroot_src/library/core/tests
104-
echo "[TEST] libcore"
105-
rm -r ./target || true
106-
../../../../../cargo.sh test
107-
popd
108-
109-
pushd regex
110-
echo "[TEST] rust-lang/regex example shootout-regex-dna"
111-
../cargo.sh clean
112-
# Make sure `[codegen mono items] start` doesn't poison the diff
113-
../cargo.sh build --example shootout-regex-dna
114-
cat examples/regexdna-input.txt | ../cargo.sh run --example shootout-regex-dna | grep -v "Spawned thread" > res.txt
115-
diff -u res.txt examples/regexdna-output.txt
27+
base_sysroot_tests
11628

117-
echo "[TEST] rust-lang/regex tests"
118-
../cargo.sh test --tests -- --exclude-should-panic --test-threads 1 -Zunstable-options
119-
popd
29+
extended_sysroot_tests

0 commit comments

Comments
 (0)