Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp347598pxu; Wed, 14 Oct 2020 03:01:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxBLlwl5sKB5GctKwzTzwuj07RRP0LtFueEjqjzou9ttHjdfZD6EZNM6G6HSyltf/4qeiVt X-Received: by 2002:a05:6402:287:: with SMTP id l7mr4254933edv.212.1602669697125; Wed, 14 Oct 2020 03:01:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1602669697; cv=none; d=google.com; s=arc-20160816; b=yQaZb4VqEeZS6efNukyVHaYWU3ftV2bk/nhXZodC8w/HCtZoBZtHmymyl/WyX7ZbT9 XebNRRi5RseDiybnqUjsLRhhbAdltF8qHuvLh4QkKDhfCnUPUIvl6s3TaJJUkAoFsVOX xHGrAbTUNqbNr4KlB4K09rvMQbsdCE2w1ycl3Ke8BiMVc0Pt5yEa30w3MOUCB977ScWY /XVc5LRMveNg4tzu56845ewbOfoAUpyW6/igRlTpEKSc5hVHqZgTLdOr5lfHgS0SJ5bt iqjxmKwW1NY7z2PHQHdc4ulc8aCgd7I9EORlGXN26V0M2ef3MCXMpXHP7NaUs/pRcVRS PYpw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=HxmTTEV0ktFfeltF1NO77hNEtO7NLN4mqHwdw4M5K6E=; b=QKej3uc++Ifz7wJWjo8N+C1noFP3pOi9pe/Ifw5pjhxiqm0aqHwx4bLZoBVbws5PMu B1NTUZYb7ddMz+Jlklz+/ewJnJe6hEvllFOQ+hB0vB3JYZuuhulS6vBlCdfWjPnRY2Ct 8QLD03tXRTsdw2cPlq/cNR6lI04WJOHJa2LzUrvJXBmkWRTa1+fTTYk2KT+pVR+vxb92 WXSGWpuqpmIfRuVGlYk5c21j7nVlfzaO26924hIWy4UWhoYB4jfe+mR3w12xCuhTy+LT 5gBcMxUiKKdI8QzU5dLiEFy/7N+CX/DR0zZPKQNW4R0V9cLpOuWtTyErN16aTsue7GhJ sGtQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t13si1915778ejr.92.2020.10.14.03.01.13; Wed, 14 Oct 2020 03:01:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732627AbgJMTZp convert rfc822-to-8bit (ORCPT + 99 others); Tue, 13 Oct 2020 15:25:45 -0400 Received: from us-smtp-delivery-44.mimecast.com ([207.211.30.44]:29430 "EHLO us-smtp-delivery-44.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727434AbgJMTZp (ORCPT ); Tue, 13 Oct 2020 15:25:45 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-225-ViS-rgrgMDWrBCn5dzXgaQ-1; Tue, 13 Oct 2020 15:25:38 -0400 X-MC-Unique: ViS-rgrgMDWrBCn5dzXgaQ-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5E14D88EF2E; Tue, 13 Oct 2020 19:25:20 +0000 (UTC) Received: from krava.redhat.com (unknown [10.40.193.3]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7E8005D994; Tue, 13 Oct 2020 19:25:17 +0000 (UTC) From: Jiri Olsa To: Arnaldo Carvalho de Melo Cc: Ian Rogers , lkml , Peter Zijlstra , Ingo Molnar , Mark Rutland , Namhyung Kim , Alexander Shishkin , Michael Petlan , Stephane Eranian Subject: [PATCH 9/9] perf tools: Add build id shell test Date: Tue, 13 Oct 2020 21:24:41 +0200 Message-Id: <20201013192441.1299447-10-jolsa@kernel.org> In-Reply-To: <20201013192441.1299447-1-jolsa@kernel.org> References: <20201013192441.1299447-1-jolsa@kernel.org> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jolsa@kernel.org X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: kernel.org Content-Transfer-Encoding: 8BIT Content-Type: text/plain; charset=WINDOWS-1252 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Adding test for build id cache that adds binary with sha1 and md5 build ids and verifies it's added properly. The test updates build id cache with perf record and perf buildid-cache -a. Acked-by: Ian Rogers Signed-off-by: Jiri Olsa --- tools/perf/tests/shell/buildid.sh | 101 ++++++++++++++++++++++++++++++ 1 file changed, 101 insertions(+) create mode 100755 tools/perf/tests/shell/buildid.sh diff --git a/tools/perf/tests/shell/buildid.sh b/tools/perf/tests/shell/buildid.sh new file mode 100755 index 000000000000..4861a20edee2 --- /dev/null +++ b/tools/perf/tests/shell/buildid.sh @@ -0,0 +1,101 @@ +#!/bin/sh +# build id cache operations +# SPDX-License-Identifier: GPL-2.0 + +# skip if there's no readelf +if ! [ -x "$(command -v readelf)" ]; then + echo "failed: no readelf, install binutils" + exit 2 +fi + +# skip if there's no compiler +if ! [ -x "$(command -v cc)" ]; then + echo "failed: no compiler, install gcc" + exit 2 +fi + +ex_md5=$(mktemp /tmp/perf.ex.MD5.XXX) +ex_sha1=$(mktemp /tmp/perf.ex.SHA1.XXX) + +echo 'int main(void) { return 0; }' | cc -Wl,--build-id=sha1 -o ${ex_sha1} -x c - +echo 'int main(void) { return 0; }' | cc -Wl,--build-id=md5 -o ${ex_md5} -x c - + +echo "test binaries: ${ex_sha1} ${ex_md5}" + +check() +{ + id=`readelf -n ${1} 2>/dev/null | grep 'Build ID' | awk '{print $3}'` + + echo "build id: ${id}" + + link=${build_id_dir}/.build-id/${id:0:2}/${id:2} + echo "link: ${link}" + + if [ ! -h $link ]; then + echo "failed: link ${link} does not exist" + exit 1 + fi + + file=${build_id_dir}/.build-id/${id:0:2}/`readlink ${link}`/elf + echo "file: ${file}" + + if [ ! -x $file ]; then + echo "failed: file ${file} does not exist" + exit 1 + fi + + diff ${file} ${1} + if [ $? -ne 0 ]; then + echo "failed: ${file} do not match" + exit 1 + fi + + echo "OK for ${1}" +} + +test_add() +{ + build_id_dir=$(mktemp -d /tmp/perf.debug.XXX) + perf="perf --buildid-dir ${build_id_dir}" + + ${perf} buildid-cache -v -a ${1} + if [ $? -ne 0 ]; then + echo "failed: add ${1} to build id cache" + exit 1 + fi + + check ${1} + + rm -rf ${build_id_dir} +} + +test_record() +{ + data=$(mktemp /tmp/perf.data.XXX) + build_id_dir=$(mktemp -d /tmp/perf.debug.XXX) + perf="perf --buildid-dir ${build_id_dir}" + + ${perf} record --buildid-all -o ${data} ${1} + if [ $? -ne 0 ]; then + echo "failed: record ${1}" + exit 1 + fi + + check ${1} + + rm -rf ${build_id_dir} + rm -rf ${data} +} + +# add binaries manual via perf buildid-cache -a +test_add ${ex_sha1} +test_add ${ex_md5} + +# add binaries via perf record post processing +test_record ${ex_sha1} +test_record ${ex_md5} + +# cleanup +rm ${ex_sha1} ${ex_md5} + +exit ${err} -- 2.26.2