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