lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220523144952.364370-2-german.gomez@arm.com>
Date:   Mon, 23 May 2022 15:49:52 +0100
From:   German Gomez <german.gomez@....com>
To:     linux-kernel@...r.kernel.org, linux-perf-users@...r.kernel.org,
        acme@...nel.org
Cc:     james.clark@....com, leo.yan@...aro.org,
        German Gomez <german.gomez@....com>,
        Mark Rutland <mark.rutland@....com>,
        Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
        Jiri Olsa <jolsa@...nel.org>,
        Namhyung Kim <namhyung@...nel.org>
Subject: [RFC PATCH 1/1] perf test cs-etm: Add end-to-end tests for CoreSight decoding

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@....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@....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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ