targets.sh (3412B)
1 #!/bin/sh 2 # Public target-profile registry and `kit targets` acceptance (KIT-P1-001). 3 4 set -u 5 6 script_dir=$(CDPATH= cd -- "$(dirname "$0")" && pwd) 7 repo_root=$(CDPATH= cd -- "$script_dir/../.." && pwd) 8 KIT=${KIT:-$repo_root/build/kit} 9 KIT_KIT_DIR=$repo_root/test/lib 10 . "$repo_root/test/lib/kit_sh_kit.sh" 11 12 kit_require_kit driver-targets 13 kit_report_init 14 kit_workdir driver-targets 15 work=$KIT_WORK 16 17 audited='linux-glibc-aa64 linux-glibc-x64 linux-glibc-rv64 18 linux-musl-aa64 linux-musl-x64 linux-musl-rv64 19 freebsd-aa64 freebsd-x64 freebsd-rv64 20 windows-aa64 windows-x64 android-aa64 macos-aa64 macos-x64 21 freestanding-aa64 freestanding-x64 freestanding-rv64 freestanding-rv32 22 freestanding-arm32' 23 24 run_ok tsv "$KIT" targets --format=tsv 25 if awk -F '\t' ' 26 NR == 1 { if ($0 != "# kit-targets-v1") exit 1; next } 27 NR == 2 { 28 if ($0 != "selector\ttriple\tarch\tos\tobject\thosted\tlibc\tsysroot\tcapabilities\tprovisioning") exit 1 29 next 30 } 31 NF != 10 { exit 1 } 32 { if (seen[$1]++) exit 1; records++ } 33 END { if (records < 19) exit 1 } 34 ' "$work/tsv.out"; then 35 ok tsv-schema-and-unique-records 36 else 37 not_ok tsv-schema-and-unique-records "$work/tsv.out" 38 fi 39 40 for selector in $audited; do 41 if awk -F '\t' -v want="$selector" '$1 == want { found = 1 } 42 END { exit found ? 0 : 1 }' "$work/tsv.out"; then 43 ok "registry-$selector" 44 else 45 not_ok "registry-$selector" "$work/tsv.out" 46 fi 47 done 48 49 if awk -F '\t' '$1 == "wasm32-wasi" { wasi = 1 } 50 $1 == "wasm32-freestanding" { bare = 1 } 51 END { exit wasi && bare ? 0 : 1 }' "$work/tsv.out"; then 52 ok registry-compiled-wasm-extras 53 else 54 not_ok registry-compiled-wasm-extras "$work/tsv.out" 55 fi 56 57 if awk -F '\t' ' 58 NR <= 2 { next } 59 $1 ~ /^(windows|macos|ios)/ && ("," $9 ",") ~ /,shared,/ { exit 1 } 60 $1 ~ /^(linux-(glibc|musl)|freebsd)-/ && 61 ("," $9 ",") !~ /,shared,/ { exit 1 } 62 $1 == "android-aa64" && ("," $9 ",") !~ /,shared,/ { exit 1 } 63 ' "$work/tsv.out"; then 64 ok registry-shared-capability-matches-driver 65 else 66 not_ok registry-shared-capability-matches-driver "$work/tsv.out" 67 fi 68 69 run_ok triples "$KIT" targets --format=triple 70 if awk -F '\t' 'NR > 2 { print $2 }' "$work/tsv.out" | 71 cmp -s - "$work/triples.out"; then 72 ok triple-format-matches-registry 73 else 74 not_ok triple-format-matches-registry "$work/triples.out" 75 fi 76 77 run_ok human "$KIT" targets 78 contains human-header "$work/human.out" "CAPABILITIES [PROVISION]" 79 contains human-separates-provisioning "$work/human.out" "[sysroot]" 80 81 run_ok detail-selector "$KIT" targets linux-glibc-aa64 82 run_ok detail-triple "$KIT" targets aarch64-linux-gnu 83 same_file detail-selector-and-triple \ 84 "$work/detail-selector.out" "$work/detail-triple.out" 85 for field in architecture os object-format pointer hosted-model libc-model \ 86 sysroot-model capabilities provisioning; do 87 contains "detail-$field" "$work/detail-selector.out" "$field:" 88 done 89 90 run_ok hosted-list /usr/bin/env KIT="$KIT" "$repo_root/scripts/hosted.sh" list 91 if [ "$(wc -l < "$work/hosted-list.out" | tr -d ' ')" -eq 19 ]; then 92 ok hosted-list-count 93 else 94 not_ok hosted-list-count "$work/hosted-list.out" 95 fi 96 for selector in $audited; do 97 if grep -Fx "$selector" "$work/hosted-list.out" >/dev/null 2>&1; then 98 ok "hosted-list-$selector" 99 else 100 not_ok "hosted-list-$selector" "$work/hosted-list.out" 101 fi 102 done 103 104 kit_summary driver-targets 105 kit_exit