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