From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796213758; b=tm9hAhXTBUW+LZlYqoR6Sj83acayn+DkzjISOauJq6yfRa3eCwlFk2bIOcB89gGnicSK oq5e71MBOb6lS/4GZOcWdcMEV8zYjX2d0J3p2q5tlEYqUdGYXQAMuTQLjK4nPV8gYJADd 6x2LCrbsV7yeK9qVuCBXy1JiqMmJE/RPDWqhRm5ENav2Qyrk4tlnMwy4xi7pT/UkjrYHr nJ+/2xffowzJoJGl08HPpUDX4DKHZMXOJkrVCYp3aMSUFdYWmCvmRuUbRn4ImMLL3bTyn ejDRFCo/T/7duPmYMm7gfYJwjZKf9dFkK6SB5+gUMZNzHPL9FzHxjqpwt8vadbP9bBA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796213758; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:MIME-Version:Content-Transfer-Encoding; bh=5uorgTS1r+sXxdb90n8hzExQcQmIPzV7kDS6LxzZrlk=; b=tTVJNJU2Izt0UdjYfImxeR0NmE5s0iYpuBnjECy4wKFfh16lR4lcjJcYwdkh0nu69+bY dOnrz/8x93RJzkzNKtM216HTs9snLlGgioda+5NkEziUZyYpnm2bjKMsI1a6LJGPYmEpA zE6XDx277B71/1lgLHXQBslkJgJmbBuSfdDAVOOV7P5kiJAAYr+9r/SFnbtNaVbpWfWDt agVLmnjCJCd7QX4VazCjvDhWbCpiP7H6xHPS0q7qwR2qpNzWdAMZUddkJSwsztTeu9NMU rAROLfcXTLvyDM3L/cJGkkjSHyVsU+QJ6OX2Go/EhTX/O63f0GHsFoFlNChIMZfQLog== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Fe91Q3Rs; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8415B606A32D for ; Wed, 2 Dec 2026 12:15:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Fe91Q3Rs Received: by smtp.kernel.org (Postfix) with ESMTPSA id 74BB91F0089A; Wed, 2 Dec 2026 12:15:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796213758; bh=5uorgTS1r+sXxdb90n8hzExQcQmIPzV7kDS6LxzZrlk=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Fe91Q3Rsw1VWEt0Hu6slIfYfGtdfJMp5bv2XaKx+WTRQvzkLJP88tHbwVjT9t1HlP QKyCuIR71oBCCmRZ4FkbeYNDyqw8tHX9F96HkVcfoSAs5r9NBhZOqBILghVPtDMQ6z Jdpio+nciJ03J74ScmID0y1JWtYIarMM+l1sodhWcyTCACsxmVCc1OH9kW7HFl0EMq AqNMWbV4z3Ifnkw2WJJLDKzi06iLqZTnzymSbGFDyo/8nGBiqAUt9+2s8OLUH8W2LS FASQhw2dY3quxyQyWFHdHMPo6lm2Fux1IAoFoC8anQ54SgVMQz2XvyIGB+sqXPADoz lLlwYEAMUASJA== From: Arnaldo Carvalho de Melo To: Namhyung Kim Cc: Ingo Molnar , Thomas Gleixner , James Clark , Jiri Olsa , Ian Rogers , Adrian Hunter , Clark Williams , linux-perf-users@vger.kernel.org, Arnaldo Carvalho de Melo , Athira Rajeev Subject: [PATCH v3 17/18] perf tests probe: Exercise the variable and line listing Date: Wed, 2 Dec 2026 09:14:33 -0300 Message-ID: <20261202121434.2224-18-acme@kernel.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20261202121434.2224-1-acme@kernel.org> References: <20261202121434.2224-1-acme@kernel.org> X-Mailing-List: linux-perf-users@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Arnaldo Carvalho de Melo Show the variables, source lines and probe-able functions of a kernel function, and check the missing argument error. Reviewed-by: Athira Rajeev Tested-by: Athira Rajeev Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/tests/shell/probe_vars.sh | 87 ++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100755 tools/perf/tests/shell/probe_vars.sh diff --git a/tools/perf/tests/shell/probe_vars.sh b/tools/perf/tests/shell/probe_vars.sh new file mode 100755 index 0000000000000000..bacf055d84bd92cb --- /dev/null +++ b/tools/perf/tests/shell/probe_vars.sh @@ -0,0 +1,87 @@ +#!/bin/bash +# perf probe variable and line listing tests +# SPDX-License-Identifier: GPL-2.0 + +set -e + +. "$(dirname $0)"/lib/probe.sh + +skip_if_no_perf_probe || exit 2 + +err=0 +out=$(mktemp /tmp/__perf_test_probe_vars.out.XXXXX) + +cleanup() { + rm -f "${out}" + + trap - EXIT TERM INT +} + +trap_cleanup() { + echo "Unexpected signal in ${FUNCNAME[1]}" + cleanup + exit 1 +} +trap trap_cleanup EXIT TERM INT + +run_probe() { + local desc="$1" expect="$2" + + shift 2 + echo "Probe ${desc}" + if ! perf probe "$@" > "${out}" 2>&1; then + echo "Probe ${desc} [Failed: perf probe failed]" + cat "${out}" + err=1 + return + fi + if [ -n "${expect}" ] && ! grep -q "${expect}" "${out}"; then + echo "Probe ${desc} [Failed: missing '${expect}']" + cat "${out}" + err=1 + return + fi + echo "Probe ${desc} [Success]" +} + +# The variable and line listings need debug info, skip when the kernel +# was built without it. +if ! perf probe -V schedule > "${out}" 2>&1; then + echo "Probe variable listing [Skipped: no debug info for schedule]" + cleanup + exit 2 +fi + +run_probe "vars" "Available variables at schedule" -V schedule +run_probe "vars long option" "Available variables at schedule" --vars schedule +run_probe "vars offset" "Available variables at schedule" -V schedule+0 + +# -V only reads DWARF, while -L also opens the C source file at the path +# recorded in the debug info, which may not be installed. +if perf probe -L schedule > "${out}" 2>&1; then + run_probe "line" "schedule" -L schedule + run_probe "line long option" "schedule" --line schedule +else + echo "Probe line listing [Skipped: no kernel source for schedule]" +fi + +if [ "$(id -u)" = 0 ]; then + run_probe "funcs" "schedule" --funcs + run_probe "funcs filter" "schedule" --funcs "sched*" +else + echo "Probe funcs [Skipped: needs root to read the kernel symbols]" +fi + +echo "Probe missing add argument" +if perf probe -a > "${out}" 2>&1; then + echo "Probe missing add argument [Failed: accepted no argument]" + err=1 +else + if ! grep -q "Usage:" "${out}"; then + echo "Probe missing add argument [Failed: missing usage]" + err=1 + fi +fi + +cleanup +exit $err -- 2.56.0