1cff27d90SPuranjay Mohan#!/bin/bash 2cff27d90SPuranjay Mohan# SPDX-License-Identifier: GPL-2.0 3cff27d90SPuranjay Mohan# 4cff27d90SPuranjay Mohan# Run the objtool klp tests. Each test-*.sh prints one TAP result line. 5c009fabcSSong Liu# 6*d76312b8SSong Liu# Tests live in generic/ and in a directory per architecture. A run executes 7*d76312b8SSong Liu# generic/ plus the one matching this architecture, so a test which cannot 8*d76312b8SSong Liu# apply here is not run rather than reporting a skip; what was left out is 9*d76312b8SSong Liu# reported once, as a comment, so differing coverage is still visible. 10*d76312b8SSong Liu# 11c009fabcSSong Liu# The harness checks the environment once up front and fails the run if the 12c009fabcSSong Liu# suite cannot execute, rather than letting every test skip and exit 0. 13cff27d90SPuranjay Mohan 14cff27d90SPuranjay Mohanset -u 15cff27d90SPuranjay Mohan 16cff27d90SPuranjay Mohancd "$(dirname "$0")" || exit 1 17cff27d90SPuranjay Mohan 18*d76312b8SSong Liu# Sourcing the harness runs its preflight, which decides which architecture 19*d76312b8SSong Liu# this run is for -- so the test list cannot be built before it has, and the 20*d76312b8SSong Liu# tests inherit the answers rather than working them out again. 21c009fabcSSong Liu. ./lib.sh 22c009fabcSSong Liu 23*d76312b8SSong Liudirs=( generic ) 24*d76312b8SSong Liu[ -d "$KLP_TEST_ARCH" ] && dirs+=( "$KLP_TEST_ARCH" ) 25*d76312b8SSong Liu 26*d76312b8SSong Liutests=() 27*d76312b8SSong Liufor d in "${dirs[@]}"; do 28*d76312b8SSong Liu for t in "$d"/test-*.sh; do 29*d76312b8SSong Liu [ -f "$t" ] && tests+=( "$t" ) 30*d76312b8SSong Liu done 31*d76312b8SSong Liudone 32*d76312b8SSong Liu[ "${#tests[@]}" -gt 0 ] || { echo "1..0 # SKIP no tests found"; exit 0; } 33*d76312b8SSong Liu 34*d76312b8SSong Liu# Tests for another architecture are absent from this run entirely. Say how 35*d76312b8SSong Liu# many, so a run which covers less than the tree holds does not look like one 36*d76312b8SSong Liu# that covers all of it. 37*d76312b8SSong Liufor d in */; do 38*d76312b8SSong Liu d="${d%/}" 39*d76312b8SSong Liu case "$d" in generic|"$KLP_TEST_ARCH") continue ;; esac 40*d76312b8SSong Liu n=$(ls "$d"/test-*.sh 2>/dev/null | wc -l) 41*d76312b8SSong Liu [ "$n" -gt 0 ] || continue 42*d76312b8SSong Liu echo "# not run: $n test$( [ "$n" = 1 ] || echo s ) in $d/" \ 43*d76312b8SSong Liu "(this run is $KLP_TEST_ARCH)" 44*d76312b8SSong Liudone 45*d76312b8SSong Liu 46cff27d90SPuranjay Mohanecho "1..${#tests[@]}" 47cff27d90SPuranjay Mohan 48cff27d90SPuranjay Mohanrc=0 49cff27d90SPuranjay Mohanfor t in "${tests[@]}"; do 50cff27d90SPuranjay Mohan ./"$t" || rc=1 51cff27d90SPuranjay Mohandone 52cff27d90SPuranjay Mohan 53cff27d90SPuranjay Mohanexit $rc 54