From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BD82A47F3C2 for ; Tue, 15 Sep 2026 23:35:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789515321; cv=none; b=sxiuUJ6otE4KkKsp0ozy47yTCEu9t7LP2r7/CzM/4QorC2EHsQktwhV0XRt96culIiIXJvdoUmz0LubotnbTmZoni9x8eTZ00LuMbpNtn14zcOdr/0Gle1s1o/OqBPmf9BNyQzz+J12IozgOb0hjx232AC6n1A37WEoq0eZKUMg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789515321; c=relaxed/simple; bh=7XKz+RJvFwhPljL0LEOP5YJZMivly/gX4hqh5ASA0n0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=q75uMZCRlMzAdhpejyNPbzNAOrt39iP/2ldonNmt7xg0BMUhjmUyUYWBtVNrABtY4Frie40eaPanjNZC/jUBLydO0F+2BzvpSJx5IcfmV9deoYP5/yInms6tAIQdPp8zipqaClED1vfToBOBvCPiY2qWZmS3x+56+Fio4mRhvhA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=iwKp/4ZV; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="iwKp/4ZV" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2F85F1F00893; Tue, 15 Sep 2026 23:35:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1789515319; bh=IejK4nasaq2ypMV8Vm3fqIMlqHcvhIXbbT1nJJuAYaA=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=iwKp/4ZVZI3jGqZ28RdPb0PWWgijhtDyp1vCQcx/arDOOapU89xPRV3cn5zVEo3AP /mxlADJwJ1XSfrvWXaCbUgGSGFELPxJ6l0RHY79B8B7cyPdtr2ttq5IG+M2ZRvZea/ VpGRilSAwW4MVwpIDfj40cMdADAVlFqHB5PJBAsWK/7XSAdUOF3Qxho+7TjisvTUWr cVPp09nYLioAC9a88R9KLrF6oWXoDuzhkhrpXV+aQVv7DuCO53TvxQh4BX3E43dh1Z YHFxLu2AiVEMwBu8uB4KtanaVpBsiHB/rdkK0xWkgeNJwGmkUra/W3EJwgAWfQiuYF qlSIq0rI4M0Lw== From: Song Liu To: live-patching@vger.kernel.org Cc: jpoimboe@kernel.org, peterz@infradead.org, jikos@kernel.org, mbenes@suse.cz, pmladek@suse.com, joe.lawrence@redhat.com, puranjay@kernel.org, kernel-team@meta.com, Song Liu Subject: [PATCH v4 03/58] objtool/klp: Group the klp tests by architecture Date: Tue, 15 Sep 2026 16:33:59 -0700 Message-ID: <20260915233454.2405019-4-song@kernel.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260915233454.2405019-1-song@kernel.org> References: <20260915233454.2405019-1-song@kernel.org> Precedence: bulk X-Mailing-List: live-patching@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Which architecture a test is for is expressed by where it lives: tests are in generic/ or in a directory named for their architecture, each carrying its own fixtures, and the runner executes generic/ plus the one that matches. A test which cannot apply here is then not run at all, rather than running in order to announce that it did not. Layout does this better than a declaration would. There is no x86_only(), and no lookup letting a fixtures// file shadow a generic one of the same name -- an arch-specific test simply carries its own fixtures. Compilers cannot work the same way: CI varies CC over the same tree, so a compiler requirement stays a declaration in the test. What a run leaves out is reported once: # not run: 5 tests in x86/ (this run is arm64) Silence would have been cheaper and wrong. A run covering less than the tree holds must not look like a run that covered all of it. Assisted-by: Claude:claude-opus-5 Signed-off-by: Song Liu --- .../tests/{ => generic}/fixtures/basic.c | 0 .../objtool/tests/{ => generic}/test-basic.sh | 2 +- tools/objtool/tests/lib.sh | 27 ++++++++++++-- tools/objtool/tests/run-tests.sh | 36 ++++++++++++++++--- 4 files changed, 56 insertions(+), 9 deletions(-) rename tools/objtool/tests/{ => generic}/fixtures/basic.c (100%) rename tools/objtool/tests/{ => generic}/test-basic.sh (91%) diff --git a/tools/objtool/tests/fixtures/basic.c b/tools/objtool/tests/generic/fixtures/basic.c similarity index 100% rename from tools/objtool/tests/fixtures/basic.c rename to tools/objtool/tests/generic/fixtures/basic.c diff --git a/tools/objtool/tests/test-basic.sh b/tools/objtool/tests/generic/test-basic.sh similarity index 91% rename from tools/objtool/tests/test-basic.sh rename to tools/objtool/tests/generic/test-basic.sh index 6b769962399a..562edfbc8646 100755 --- a/tools/objtool/tests/test-basic.sh +++ b/tools/objtool/tests/generic/test-basic.sh @@ -3,7 +3,7 @@ # # Only functions whose code changed get cloned into the patch. -. "$(dirname "$0")/lib.sh" +. "$(dirname "$0")/../lib.sh" setup build_pair basic.c diff --git a/tools/objtool/tests/lib.sh b/tools/objtool/tests/lib.sh index 46bdb985765e..fdea9b790c4d 100644 --- a/tools/objtool/tests/lib.sh +++ b/tools/objtool/tests/lib.sh @@ -9,7 +9,10 @@ # of regressions. TESTS_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" -FIXTURES_DIR="$TESTS_DIR/fixtures" + +# Tests live in generic/ or in an architecture directory beside it, and each +# carries its own fixtures. +FIXTURES_DIR="$(cd "$(dirname "$0")/fixtures" 2>/dev/null && pwd)" # The kernel's convention: CROSS_COMPILE is the one knob, with per-tool # overrides for what it does not cover. objtool itself is always a host binary @@ -36,7 +39,7 @@ OBJTOOL="${OBJTOOL:-$TESTS_DIR/../objtool}" # klp_preflight() { - local tmp tool cc_version host cc_arch + local tmp tool cc_version arch host cc_arch bail() { echo "Bail out! $*" >&2; exit 1; } @@ -96,8 +99,26 @@ klp_preflight() esac rm -rf "$tmp" + # Normalize to the kernel's SRCARCH. + case "${ARCH:-$(uname -m)}" in + x86_64|i?86) arch=x86 ;; + aarch64*) arch=arm64 ;; + *) arch="${ARCH:-$(uname -m)}" ;; + esac + + case "$(uname -m)" in + x86_64|i?86) host=x86 ;; + aarch64*) host=arm64 ;; + *) host="$(uname -m)" ;; + esac + + [ -z "$cc_arch" ] || [ "$cc_arch" = "$arch" ] || + bail "ARCH says $arch but '$CC' builds $cc_arch objects;" \ + "the $arch tests would run against the wrong architecture" + + KLP_TEST_ARCH="$arch" KLP_TEST_PREFLIGHT=done - export OBJTOOL CC KLP_TEST_PREFLIGHT + export OBJTOOL CC KLP_TEST_ARCH KLP_TEST_PREFLIGHT cc_version="$($CC --version 2>/dev/null | head -1)" cat </dev/null | wc -l) + [ "$n" -gt 0 ] || continue + echo "# not run: $n test$( [ "$n" = 1 ] || echo s ) in $d/" \ + "(this run is $KLP_TEST_ARCH)" +done + echo "1..${#tests[@]}" rc=0 -- 2.53.0-Meta