From nobody Wed May 1 15:51:06 2024 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 60C7DC433EF for ; Mon, 23 May 2022 14:50:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237422AbiEWOuN (ORCPT ); Mon, 23 May 2022 10:50:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47918 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237406AbiEWOuH (ORCPT ); Mon, 23 May 2022 10:50:07 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 2C169580D0; Mon, 23 May 2022 07:50:06 -0700 (PDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id D9C9F139F; Mon, 23 May 2022 07:50:05 -0700 (PDT) Received: from hype-n1-sdp.warwick.arm.com (hype-n1-sdp.warwick.arm.com [10.32.32.32]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 256233F70D; Mon, 23 May 2022 07:50:04 -0700 (PDT) From: German Gomez 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 , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim 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 Message-Id: <20220523144952.364370-2-german.gomez@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220523144952.364370-1-german.gomez@arm.com> References: <20220523144952.364370-1-german.gomez@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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 --- 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=3Dhttps://github.com/ARM-software/data/raw/984cde8fb0bb22591e2= 84826a80b338bb79c3655/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=3D"$GITHUB_REPO/$1/perf.data" + local data_inject=3D"$GITHUB_REPO/$1/perf.data.inject" + local data_debug=3D"$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/p= erf/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 , 2022 + +set -e +source $(dirname $0)/lib/arm_auxtrace.sh +TEMP_DIR=3D$(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 pe= rf.data.inject. +# The former contains AUXTRACE events. The later contains the expected SAM= PLE 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() {=20 + # 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.in= ject files + + test_decoding "coresight/sort_single_thread" \ + "--itrace=3Di10ib" \ + "--fields hw:cpu,pid,tid,ip,dso,addr,comm,event" + + test_decoding "coresight/sort_multi_thread" \ + "--itrace=3Di100ib" \ + "--fields hw:cpu,pid,tid,ip,dso,addr,comm,event" +} + +test_coresight --=20 2.25.1