| 1 | #!/usr/bin/env sh |
| 2 | # |
| 3 | # Copyright (C) 2025 Red Hat, Inc. |
| 4 | # |
| 5 | # Based on rust_to_clang_target() tests from rust-bindgen. |
| 6 | # |
| 7 | # SPDX-License-Identifier: GPL-2.0-or-later |
| 8 | |
| 9 | scripts_dir=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd) |
| 10 | . "$scripts_dir/rust-to-clang-target.sh" |
| 11 | |
| 12 | test_case() { |
| 13 | input="$1" |
| 14 | expected="$2" |
| 15 | result=$(rust_to_clang_target "$input") |
| 16 | |
| 17 | if [ "$result" = "$expected" ]; then |
| 18 | echo " OK: '$input' -> '$result'" |
| 19 | else |
| 20 | echo " FAILED: '$input'" |
| 21 | echo " Expected: '$expected'" |
| 22 | echo " Got: '$result'" |
| 23 | exit 1 |
| 24 | fi |
| 25 | } |
| 26 | |
| 27 | echo "Running tests..." |
| 28 | |
| 29 | test_case "aarch64-apple-ios" "arm64-apple-ios" |
| 30 | test_case "riscv64gc-unknown-linux-gnu" "riscv64-unknown-linux-gnu" |
| 31 | test_case "riscv64imac-unknown-none-elf" "riscv64-unknown-none-elf" |
| 32 | test_case "riscv32imc-unknown-none-elf" "riscv32-unknown-none-elf" |
| 33 | test_case "riscv32imac-unknown-none-elf" "riscv32-unknown-none-elf" |
| 34 | test_case "riscv32imafc-unknown-none-elf" "riscv32-unknown-none-elf" |
| 35 | test_case "riscv32i-unknown-none-elf" "riscv32-unknown-none-elf" |
| 36 | test_case "riscv32imc-esp-espidf" "riscv32-esp-elf" |
| 37 | test_case "xtensa-esp32-espidf" "xtensa-esp32-elf" |
| 38 | test_case "aarch64-apple-ios-sim" "arm64-apple-ios-simulator" |
| 39 | test_case "aarch64-apple-tvos-sim" "arm64-apple-tvos-simulator" |
| 40 | test_case "aarch64-apple-watchos-sim" "arm64-apple-watchos-simulator" |
| 41 | |
| 42 | echo "" |
| 43 | echo "All tests passed!" |