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=1796213727; b=aASBJZ/a7t8kpGy+3uSJEThsGD94deLGWwiUgo3mDAWqmI/GAf6m2L+BChOPvntFtiJ8 TU0IiJdcm2qhrhtke8C59ygwv05iQQUDoxbhYbRNQmzIAVzlytQrWW/bZDTn1Fwp5tVuz x8L5J+W0KW9FnZ7sVddFN2UaDR9qZln+iWpHHNOceYyWYKI2Y5hmP4biQe26dm2kJUC5Y mUXVh24p0sjA29kH/pP2WEHn4+8hvmAyNLHuYmoQ2itS+CldbijP8lBWEgfg6x7sM0HcG azba5l1Q2J7nfMnF2asZx3E7y76rdgtQvRlFnXmKpAP1K3FaVls8narTrBZN7Gzk2bg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796213727; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:MIME-Version:Content-Transfer-Encoding; bh=QoRn0tC/8E9eW1LPlweVn/DKHWwUrEMvrBrlbYzlg5o=; b=KRletttVfZvGd0a/XWq2PS3EIbSjkVg2B36WnInQwXBmLQIWtR5LlXmhUTBuseJ2mI0N sjbMLouyHN5G98htsm3TBUsqRDyjCzEEKGsH3S+7uEb6WJYd53IXjDJ6Km7y+JxfSitFb 5rhiDhbaFhrmC5SdRqMPPbJIpVbRc2pxoRcRkhrjy8cwohoHXbOWMjPR7HEQ8IV/50QCw n6OisuaKBFAHlOzi06G8z3vPYm3ZjYBQ0k6HwgGpIW8tD0GJ7X8Hhd9IkqoEwLRaKQnG/ Llj56QDk6H+hSTCrZ3GeQQuoUmJK4R0IAiTjZ/biVJTh4+MDcp4hVndCQobgsufI72g== 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=bqsuigNS; 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 142CE606A327 for ; Wed, 2 Dec 2026 12:15:26 +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=bqsuigNS Received: by smtp.kernel.org (Postfix) with ESMTPSA id 265AE1F00896; Wed, 2 Dec 2026 12:15:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796213726; bh=QoRn0tC/8E9eW1LPlweVn/DKHWwUrEMvrBrlbYzlg5o=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=bqsuigNSdcVs0PStb6ZWREwOSJN4GH0Xl32g1gCNE1vRD2zbX1QWYaQmKmX0x0U3+ aZGpJCeiM4SLIU/1coJ6SeII0H/opNiA+g91dI3NI5yHpsNulqVjrwPpw4p9A5as/j FrAZcCe8vAcrLVLazF/o7vkPAZDrK1CZ+H2AGysPIw5LHCaJxOUQP+budTf9cWz/D/ g80SrN6r6qT2SMqQPezkpyiPtlnlgOgIY7huE/zhXhY0lchqKpn9/vG3GJSKCqNCg/ YYmCBQTjHOI6D8BbbATVffRofAwHEPeTnEtb/4WTIAcd6Bbz80MBeSoQQTNlwsowbi IWqOfiWl/iWFw== 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 10/18] perf tests report: Exercise the output and format options Date: Wed, 2 Dec 2026 09:14:26 -0300 Message-ID: <20261202121434.2224-11-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 Cover the Samples column -n adds, the field list, the field separator and the fixed column widths, each checked in the header it prints, and --no-children, checked against a file recorded with call graphs, where the Children column it removes is visible. --disable-order is checked by the rejection it triggers together with a latency field. The options that change nothing in this output, -U, --percentage, --inline and --full-source-path, run as a check that perf takes them and still prints the table. Reviewed-by: Athira Rajeev Tested-by: Athira Rajeev Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/tests/shell/report_options.sh | 122 +++++++++++++++++++++++ 1 file changed, 122 insertions(+) create mode 100755 tools/perf/tests/shell/report_options.sh diff --git a/tools/perf/tests/shell/report_options.sh b/tools/perf/tests/shell/report_options.sh new file mode 100755 index 0000000000000000..7e2bdaca656ce5b2 --- /dev/null +++ b/tools/perf/tests/shell/report_options.sh @@ -0,0 +1,122 @@ +#!/bin/bash +# perf report option tests +# SPDX-License-Identifier: GPL-2.0 + +set -e + +shelldir=$(dirname "$0") +# shellcheck source=lib/perf_has_symbol.sh +. "${shelldir}"/lib/perf_has_symbol.sh + +testprog="perf test -w thloop" +testsym="test_loop" + +skip_test_missing_symbol "${testsym}" + +perfdata=$(mktemp /tmp/__perf_test_report_opts.perf.data.XXXXX) +cgdata=$(mktemp /tmp/__perf_test_report_opts.cg.data.XXXXX) +perfout=$(mktemp /tmp/__perf_test_report_opts.perf.out.XXXXX) +err=0 + +cleanup() { + rm -f "${perfdata}" "${perfdata}".old + rm -f "${cgdata}" "${cgdata}".old + rm -f "${perfout}" + + trap - EXIT TERM INT +} + +trap_cleanup() { + echo "Unexpected signal in ${FUNCNAME[1]}" + cleanup + exit 1 +} +trap trap_cleanup EXIT TERM INT + +check_report() { + local desc="$1" expect="$2" + + shift 2 + echo "Report ${desc}" + if ! perf report -i "${perfdata}" --stdio "$@" > "${perfout}" 2>&1 + then + echo "Report ${desc} [Failed: perf report failed]" + err=1 + return + fi + if ! grep -qE "${expect}" "${perfout}" + then + echo "Report ${desc} [Failed: missing '${expect}']" + cat "${perfout}" + err=1 + return + fi + echo "Report ${desc} [Success]" +} + +# The call graph data, for --no-children: 'absent', when set, must not +# be found in the output +check_cg_report() { + local desc="$1" expect="$2" absent="$3" + + shift 3 + echo "Report ${desc}" + if ! perf report -i "${cgdata}" --stdio "$@" > "${perfout}" 2>&1 + then + echo "Report ${desc} [Failed: perf report failed]" + err=1 + return + fi + if [ -n "${absent}" ] && grep -qE "${absent}" "${perfout}" + then + echo "Report ${desc} [Failed: still has '${absent}']" + err=1 + return + fi + if ! grep -qE "${expect}" "${perfout}" + then + echo "Report ${desc} [Failed: missing '${expect}']" + cat "${perfout}" + err=1 + return + fi + echo "Report ${desc} [Success]" +} + +perf record -q -e cpu-clock --sample-cpu -o "${perfdata}" ${testprog} + +# -n adds a Samples column, -t, joins the header fields with commas, +# -w pads them to the given width. -U, --percentage, --inline and +# --full-source-path change nothing in this output: every entry +# resolves to a symbol, nothing is filtered and no source lines are +# printed, so they run to check that perf takes them and still prints +# the table. +check_report "nr samples" "Overhead[[:space:]]+Samples" -n +check_report "hide unresolved" "^# Overhead" -U +check_report "fields" "^ *perf " -F comm,dso,symbol,period +check_report "percentage" "^# Overhead" --percentage absolute +check_report "field separator" "^# Overhead," -t, +check_report "inline" "^# Overhead" --inline +check_report "full source path" "^# Overhead" --full-source-path +check_report "column widths" "^# {2,}Overhead" -w 20,20,20,20,20,20 + +# --disable-order is rejected together with a latency field, which +# tells that the option reached the event ordering code +echo "Report disable order" +if ! perf report -i "${perfdata}" --stdio -F latency --disable-order 2>&1 | \ + grep -q "incompatible with --disable-order" +then + echo "Report disable order [Failed: missing the rejection]" + err=1 +else + echo "Report disable order [Success]" +fi + +# Recording call graphs adds a Children column, --no-children must +# remove it while keeping the entries +perf record -q --call-graph fp -e cpu-clock --sample-cpu -o "${cgdata}" ${testprog} +check_cg_report "children column" "Children" "" +check_cg_report "no children" "${testsym}" "Children" --no-children + +cleanup +exit $err -- 2.56.0