]> git.lizzy.rs Git - rust.git/blob - compiler/rustc_codegen_cranelift/scripts/tests.sh
Rollup merge of #81235 - reese:rw-tuple-diagnostics, r=estebank
[rust.git] / compiler / rustc_codegen_cranelift / scripts / tests.sh
1 #!/bin/bash
2
3 set -e
4
5 source build/config.sh
6 source scripts/ext_config.sh
7 MY_RUSTC="$RUSTC $RUSTFLAGS -L crate=target/out --out-dir target/out -Cdebuginfo=2"
8
9 function no_sysroot_tests() {
10     echo "[BUILD] mini_core"
11     $MY_RUSTC example/mini_core.rs --crate-name mini_core --crate-type lib,dylib --target "$TARGET_TRIPLE"
12
13     echo "[BUILD] example"
14     $MY_RUSTC example/example.rs --crate-type lib --target "$TARGET_TRIPLE"
15
16     if [[ "$JIT_SUPPORTED" = "1" ]]; then
17         echo "[JIT] mini_core_hello_world"
18         CG_CLIF_JIT_ARGS="abc bcd" $MY_RUSTC -Cllvm-args=mode=jit -Cprefer-dynamic example/mini_core_hello_world.rs --cfg jit --target "$HOST_TRIPLE"
19
20         echo "[JIT-lazy] mini_core_hello_world"
21         CG_CLIF_JIT_ARGS="abc bcd" $MY_RUSTC -Cllvm-args=mode=jit-lazy -Cprefer-dynamic example/mini_core_hello_world.rs --cfg jit --target "$HOST_TRIPLE"
22     else
23         echo "[JIT] mini_core_hello_world (skipped)"
24     fi
25
26     echo "[AOT] mini_core_hello_world"
27     $MY_RUSTC example/mini_core_hello_world.rs --crate-name mini_core_hello_world --crate-type bin -g --target "$TARGET_TRIPLE"
28     $RUN_WRAPPER ./target/out/mini_core_hello_world abc bcd
29     # (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
30
31     echo "[AOT] arbitrary_self_types_pointers_and_wrappers"
32     $MY_RUSTC example/arbitrary_self_types_pointers_and_wrappers.rs --crate-name arbitrary_self_types_pointers_and_wrappers --crate-type bin --target "$TARGET_TRIPLE"
33     $RUN_WRAPPER ./target/out/arbitrary_self_types_pointers_and_wrappers
34 }
35
36 function base_sysroot_tests() {
37     echo "[AOT] alloc_example"
38     $MY_RUSTC example/alloc_example.rs --crate-type bin --target "$TARGET_TRIPLE"
39     $RUN_WRAPPER ./target/out/alloc_example
40
41     if [[ "$JIT_SUPPORTED" = "1" ]]; then
42         echo "[JIT] std_example"
43         $MY_RUSTC -Cllvm-args=mode=jit -Cprefer-dynamic example/std_example.rs --target "$HOST_TRIPLE"
44
45         echo "[JIT-lazy] std_example"
46         $MY_RUSTC -Cllvm-args=mode=jit-lazy -Cprefer-dynamic example/std_example.rs --cfg lazy_jit --target "$HOST_TRIPLE"
47     else
48         echo "[JIT] std_example (skipped)"
49     fi
50
51     echo "[AOT] dst_field_align"
52     # FIXME Re-add -Zmir-opt-level=2 once rust-lang/rust#67529 is fixed.
53     $MY_RUSTC example/dst-field-align.rs --crate-name dst_field_align --crate-type bin --target "$TARGET_TRIPLE"
54     $RUN_WRAPPER ./target/out/dst_field_align || (echo $?; false)
55
56     echo "[AOT] std_example"
57     $MY_RUSTC example/std_example.rs --crate-type bin --target "$TARGET_TRIPLE"
58     $RUN_WRAPPER ./target/out/std_example arg
59
60     echo "[AOT] subslice-patterns-const-eval"
61     $MY_RUSTC example/subslice-patterns-const-eval.rs --crate-type bin -Cpanic=abort --target "$TARGET_TRIPLE"
62     $RUN_WRAPPER ./target/out/subslice-patterns-const-eval
63
64     echo "[AOT] track-caller-attribute"
65     $MY_RUSTC example/track-caller-attribute.rs --crate-type bin -Cpanic=abort --target "$TARGET_TRIPLE"
66     $RUN_WRAPPER ./target/out/track-caller-attribute
67
68     echo "[AOT] mod_bench"
69     $MY_RUSTC example/mod_bench.rs --crate-type bin --target "$TARGET_TRIPLE"
70     $RUN_WRAPPER ./target/out/mod_bench
71
72     pushd rand
73     rm -r ./target || true
74     ../build/cargo.sh test --workspace
75     popd
76 }
77
78 function extended_sysroot_tests() {
79     pushd simple-raytracer
80     if [[ "$HOST_TRIPLE" = "$TARGET_TRIPLE" ]]; then
81         echo "[BENCH COMPILE] ebobby/simple-raytracer"
82         hyperfine --runs "${RUN_RUNS:-10}" --warmup 1 --prepare "cargo clean" \
83         "RUSTC=rustc RUSTFLAGS='' cargo build" \
84         "../build/cargo.sh build"
85
86         echo "[BENCH RUN] ebobby/simple-raytracer"
87         cp ./target/debug/main ./raytracer_cg_clif
88         hyperfine --runs "${RUN_RUNS:-10}" ./raytracer_cg_llvm ./raytracer_cg_clif
89     else
90         echo "[BENCH COMPILE] ebobby/simple-raytracer (skipped)"
91         echo "[COMPILE] ebobby/simple-raytracer"
92         ../cargo.sh build
93         echo "[BENCH RUN] ebobby/simple-raytracer (skipped)"
94     fi
95     popd
96
97     pushd build_sysroot/sysroot_src/library/core/tests
98     echo "[TEST] libcore"
99     rm -r ./target || true
100     ../../../../../build/cargo.sh test
101     popd
102
103     pushd regex
104     echo "[TEST] rust-lang/regex example shootout-regex-dna"
105     ../build/cargo.sh clean
106     # Make sure `[codegen mono items] start` doesn't poison the diff
107     ../build/cargo.sh build --example shootout-regex-dna
108     cat examples/regexdna-input.txt | ../build/cargo.sh run --example shootout-regex-dna | grep -v "Spawned thread" > res.txt
109     diff -u res.txt examples/regexdna-output.txt
110
111     echo "[TEST] rust-lang/regex tests"
112     ../build/cargo.sh test --tests -- --exclude-should-panic --test-threads 1 -Zunstable-options -q
113     popd
114 }
115
116 case "$1" in
117     "no_sysroot")
118         no_sysroot_tests
119         ;;
120     "base_sysroot")
121         base_sysroot_tests
122         ;;
123     "extended_sysroot")
124         extended_sysroot_tests
125         ;;
126     *)
127         echo "unknown test suite"
128         ;;
129 esac