Austin Schuh | e89fa2d | 2019-08-14 20:24:23 -0700 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | set -e |
| 3 | # |
| 4 | # Copyright 2018 Google Inc. All rights reserved. |
| 5 | # |
| 6 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 7 | # you may not use this file except in compliance with the License. |
| 8 | # You may obtain a copy of the License at |
| 9 | # |
| 10 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | # |
| 12 | # Unless required by applicable law or agreed to in writing, software |
| 13 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 | # See the License for the specific language governing permissions and |
| 16 | # limitations under the License. |
| 17 | |
| 18 | if [[ "$1" == "mips-unknown-linux-gnu" ]]; then |
| 19 | TARGET_FLAG="--target mips-unknown-linux-gnu" |
| 20 | export CARGO_TARGET_MIPS_UNKNOWN_LINUX_GNU_LINKER=mips-linux-gnu-gcc |
| 21 | export CARGO_TARGET_MIPS_UNKNOWN_LINUX_GNU_RUNNER="qemu-mips -L /usr/mips-linux-gnu" |
| 22 | fi |
| 23 | |
James Kuszmaul | 8e62b02 | 2022-03-22 09:33:25 -0700 | [diff] [blame] | 24 | |
| 25 | function check_test_result() { |
| 26 | if [[ $? == 0 ]]; then |
| 27 | echo OK: $1 passed. |
| 28 | else |
| 29 | echo KO: $1 failed. |
| 30 | exit 1 |
| 31 | fi |
| 32 | } |
| 33 | |
| 34 | cd ./rust_serialize_test |
| 35 | cargo run $TARGET_FLAG -- --quiet |
| 36 | check_test_result "Rust serde tests" |
| 37 | |
James Kuszmaul | 3b15b0c | 2022-11-08 14:03:16 -0800 | [diff] [blame] | 38 | cd ../rust_no_std_compilation_test |
| 39 | rustup install nightly |
| 40 | rustup component add rust-src --toolchain nightly |
| 41 | rustup target add thumbv7m-none-eabi |
| 42 | cargo +nightly build |
| 43 | check_test_result "Rust flatbuffers test no_std compilation" |
| 44 | |
James Kuszmaul | 8e62b02 | 2022-03-22 09:33:25 -0700 | [diff] [blame] | 45 | cd ../rust_usage_test |
Austin Schuh | e89fa2d | 2019-08-14 20:24:23 -0700 | [diff] [blame] | 46 | cargo test $TARGET_FLAG -- --quiet |
James Kuszmaul | 8e62b02 | 2022-03-22 09:33:25 -0700 | [diff] [blame] | 47 | check_test_result "Rust tests" |
| 48 | |
James Kuszmaul | 3b15b0c | 2022-11-08 14:03:16 -0800 | [diff] [blame] | 49 | cargo test $TARGET_FLAG --no-default-features -- --quiet |
James Kuszmaul | 8e62b02 | 2022-03-22 09:33:25 -0700 | [diff] [blame] | 50 | check_test_result "Rust tests (no_std)" |
Austin Schuh | e89fa2d | 2019-08-14 20:24:23 -0700 | [diff] [blame] | 51 | |
Austin Schuh | 272c613 | 2020-11-14 16:37:52 -0800 | [diff] [blame] | 52 | cargo run $TARGET_FLAG --bin=flatbuffers_alloc_check |
James Kuszmaul | 8e62b02 | 2022-03-22 09:33:25 -0700 | [diff] [blame] | 53 | check_test_result "Rust flatbuffers heap alloc test" |
Austin Schuh | 272c613 | 2020-11-14 16:37:52 -0800 | [diff] [blame] | 54 | |
| 55 | cargo run $TARGET_FLAG --bin=flexbuffers_alloc_check |
James Kuszmaul | 8e62b02 | 2022-03-22 09:33:25 -0700 | [diff] [blame] | 56 | check_test_result "Rust flexbuffers heap alloc test" |
| 57 | |
James Kuszmaul | 3b15b0c | 2022-11-08 14:03:16 -0800 | [diff] [blame] | 58 | rustup component add clippy |
| 59 | cargo clippy $TARGET_FLAG |
| 60 | check_test_result "No Cargo clippy lints test" |
Austin Schuh | e89fa2d | 2019-08-14 20:24:23 -0700 | [diff] [blame] | 61 | |
| 62 | cargo bench $TARGET_FLAG |
James Kuszmaul | 8e62b02 | 2022-03-22 09:33:25 -0700 | [diff] [blame] | 63 | |
| 64 | # This test is dependent on flatc. |
| 65 | if [[ -f ../../flatc ]]; then |
| 66 | cd outdir |
| 67 | cargo test |
| 68 | check_test_result "Rust generated file in \$OUT_DIR" |
| 69 | cd .. |
| 70 | fi |
| 71 | |
| 72 | # RUST_NIGHTLY environment variable set in dockerfile. |
| 73 | if [[ $RUST_NIGHTLY == 1 ]]; then |
| 74 | rustup +nightly component add miri |
| 75 | MIRIFLAGS="-Zmiri-disable-isolation" cargo +nightly miri test |
| 76 | fi |