mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: German Gomez <german.gomez@arm.com>
To: linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org,
	acme@kernel.org
Cc: james.clark@arm.com, leo.yan@linaro.org,
	German Gomez <german.gomez@arm.com>,
	Mark Rutland <mark.rutland@arm.com>,
	Alexander Shishkin <alexander.shishkin@linux.intel.com>,
	Jiri Olsa <jolsa@kernel.org>, Namhyung Kim <namhyung@kernel.org>
Subject: [RFC PATCH 1/1] perf test cs-etm: Add end-to-end tests for CoreSight decoding
Date: Mon, 23 May 2022 15:49:52 +0100	[thread overview]
Message-ID: <20220523144952.364370-2-german.gomez@arm.com> (raw)
In-Reply-To: <20220523144952.364370-1-german.gomez@arm.com>

Add a shell script to test for regressions in the decoding of CoreSight
samples. The test uses supporting files which are not committed to the
linux repository. Instead they are downloaded from an external source:

[1] perf.data
[2] perf.data.inject
[3] perf.data.tar.bz2

File [1] is an example recording of a CoreSight trace. File [2] is the
output of running perf-inject on file [1] (i.e. the expected samples).
Lastly file [3] are the contents of the "~/.debug" directory.

Signed-off-by: German Gomez <german.gomez@arm.com>
---
 tools/perf/tests/shell/lib/arm_auxtrace.sh    | 21 +++++++
 .../tests/shell/test_arm_coresight_decoder.sh | 57 +++++++++++++++++++
 2 files changed, 78 insertions(+)
 create mode 100644 tools/perf/tests/shell/lib/arm_auxtrace.sh
 create mode 100755 tools/perf/tests/shell/test_arm_coresight_decoder.sh

diff --git a/tools/perf/tests/shell/lib/arm_auxtrace.sh b/tools/perf/tests/shell/lib/arm_auxtrace.sh
new file mode 100644
index 0000000000000..5e117c33a4c98
--- /dev/null
+++ b/tools/perf/tests/shell/lib/arm_auxtrace.sh
@@ -0,0 +1,21 @@
+# TODO(german):
+#	This is a palceholder location, where the test data will/would reside.
+#	We need to find a suitable location to host the perf.data files used for testing
+GITHUB_REPO=https://github.com/ARM-software/data/raw/984cde8fb0bb22591e284826a80b338bb79c3655/perf/
+
+# download test files to the current working directory:
+# 	perf.data         (perf.data that contains auxtrace test data)
+# 	perf.data.inject  (output of perf inject -i perf.data)
+# 	perf.data.tar.bz2 (output of perf archive)
+arm_download_auxtrace_test_files() {
+	local data="$GITHUB_REPO/$1/perf.data"
+	local data_inject="$GITHUB_REPO/$1/perf.data.inject"
+	local data_debug="$GITHUB_REPO/$1/perf.data.tar.bz2"
+
+	# skip the test if the download fails for whetever reason
+	timeout 30 curl -LSs --fail "$data"		> perf.data		|| exit 2
+	timeout 30 curl -LSs --fail "$data_inject"	> perf.data.inject	|| exit 2
+	timeout 30 curl -LSs --fail "$data_debug"	> perf.data.tar.bz2	|| exit 2
+}
+
+export arm_download_auxtrace_test_files
diff --git a/tools/perf/tests/shell/test_arm_coresight_decoder.sh b/tools/perf/tests/shell/test_arm_coresight_decoder.sh
new file mode 100755
index 0000000000000..342a6bc70428f
--- /dev/null
+++ b/tools/perf/tests/shell/test_arm_coresight_decoder.sh
@@ -0,0 +1,57 @@
+#!/bin/bash
+# e2e test Arm CoreSight decoding
+
+# SPDX-License-Identifier: GPL-2.0
+# German Gomez <german.gomez@arm.com>, 2022
+
+set -e
+source $(dirname $0)/lib/arm_auxtrace.sh
+TEMP_DIR=$(mktemp -d)
+
+cleanup_files() {
+	rm -rf ${TEMP_DIR}
+}
+
+trap cleanup_files exit term int
+
+# This test compares the perf-script outputs of the files perf.data and perf.data.inject.
+# The former contains AUXTRACE events. The later contains the expected SAMPLE events.
+test_decoding() {
+	echo "Testing $1..."
+
+	cd $TEMP_DIR
+
+	arm_download_auxtrace_test_files "$1"
+
+	# unpack debug directory
+	rm -rf ~/.debug
+	mkdir ~/.debug
+	tar xf perf.data.tar.bz2 -C ~/.debug
+
+	perf script -i perf.data	$3 $2	| tr -s " " > perf.data.script
+	perf script -i perf.data.inject	$3	| tr -s " " > perf.data.inject.script
+
+	# Fail the test if there are any differences in the generated samples.
+	diff perf.data.script perf.data.inject.script > /dev/null
+}
+
+test_coresight() { 
+	# test only if perf has OpenCSD support
+	if ! ldd perf | grep -q "opencsd"
+	then
+		echo "[Skipped: missing OpenCSD support]"
+		return
+	fi
+
+	# the "--itrace" params must match the ones used to generate perf.data.inject files
+
+	test_decoding "coresight/sort_single_thread"		\
+		      "--itrace=i10ib"				\
+		      "--fields hw:cpu,pid,tid,ip,dso,addr,comm,event"
+
+	test_decoding "coresight/sort_multi_thread"		\
+		      "--itrace=i100ib"				\
+		      "--fields hw:cpu,pid,tid,ip,dso,addr,comm,event"
+}
+
+test_coresight
-- 
2.25.1


  reply	other threads:[~2022-05-23 14:50 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-23 14:49 [RFC PATCH 0/1] " German Gomez
2022-05-23 14:49 ` German Gomez [this message]
2022-05-23 20:04 ` Arnaldo Carvalho de Melo
2022-05-23 21:29   ` Ian Rogers
2022-05-24 13:45     ` German Gomez

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220523144952.364370-2-german.gomez@arm.com \
    --to=german.gomez@arm.com \
    --cc=acme@kernel.org \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=james.clark@arm.com \
    --cc=jolsa@kernel.org \
    --cc=leo.yan@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=namhyung@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®