Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp42486imm; Thu, 21 Jun 2018 13:34:10 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJ5wXhdNV5O/LB5LFVlBvcDtNt4GOuxur29CBzzjHcQcr4hhwZgLBvzYxkACuYcs9T8o+zQ X-Received: by 2002:a17:902:6802:: with SMTP id h2-v6mr29783604plk.113.1529613250871; Thu, 21 Jun 2018 13:34:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529613250; cv=none; d=google.com; s=arc-20160816; b=zj6owR2SYztFMG5P1LZNfG3u/rjDwwgGuZSRzBx89FhPJRy7acy4474EsgHXOznxMp dnCuOFlX6j4MDScDk0kAtS1LbsDyR867O5kz24z+c+bkpihdsa4LM1GqDnzyBKzRpSa5 m3aIwXzQmCIvyfRQ10DEndqryqGEWNvLor6o94ianJ3SnpSeyK9XUK8ymRGw7bZn8A50 vdg/82bPBE4jSOv/pIL3Lr2ASrv8QKonhAb8jY8F1Do58+QtKCu9xHP/hyHhA7Ml+VB+ 6atFA7k9GZeu7/LM/D+2Fsv7CKhYN6qcleXiPsHDVSxiVz6ty/9/XP0qUSWEIuaC0Gey mfbQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :organization:references:in-reply-to:message-id:subject:cc:to:from :date:arc-authentication-results; bh=0NMnVG9pgmxoUs6nmaHlXXL0Mxuijb3LEpcQE8mES3Y=; b=NoWJqqSHPWAdwfZRYmNV9qORkqoAQV+dmlIRq3TReVsSq8oPIlyyyquT490/4oLI8K loiEnFbBSN/kWIyKEXDGZOLjqcp8mfRBPzTF8d7/RPjHaeMc6OZcQdSQPyAPt4Bb5nbS 0G/+BdhuRFxqqGwVma+/bkXUhl8O4V5q2aDhgkHiqkezM245I9XEmiIIveRu/vBVEMNz 7Ep2Tw5XI70vtw+U9Rf9zzWQb8gOZ3oeoMxx84KFFI0gN6/SqZx2grHpJqNTEEM7V3Vg ELlBwfupbDazwNNzaknMadMkouZtxjLg6ANRCZy+b/4w9ypzkyHFFPLqW33tCf72y4SR 39VQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a13-v6si4830965pgn.391.2018.06.21.13.33.56; Thu, 21 Jun 2018 13:34:10 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933609AbeFUUcz (ORCPT + 99 others); Thu, 21 Jun 2018 16:32:55 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:54716 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933012AbeFUUcx (ORCPT ); Thu, 21 Jun 2018 16:32:53 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 5AAEF1596; Thu, 21 Jun 2018 13:32:52 -0700 (PDT) Received: from dupont (usa-sjc-mx-foss1.foss.arm.com [217.140.101.70]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id B3DEB3F557; Thu, 21 Jun 2018 13:32:51 -0700 (PDT) Date: Thu, 21 Jun 2018 15:32:50 -0500 From: Kim Phillips To: Arnaldo Carvalho de Melo Cc: linux-kernel@vger.kernel.org, Peter Zijlstra , Ingo Molnar , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Thomas Richter , Michael Petlan , Hendrik =?ISO-8859-1?Q?Br=FCckner?= , Sandipan Das Subject: Re: [PATCH 2/2] perf test shell: make perf inet_pton test more portable Message-Id: <20180621153250.e29e7fbfbfe14b98341b68f0@arm.com> In-Reply-To: <20180621151800.GU20477@kernel.org> References: <20180619184952.dac6a3a1e39d3b1d255e7119@arm.com> <20180620134622.GM20477@kernel.org> <20180620194546.364cc109430ac51c5a288739@arm.com> <20180621141915.GS20477@kernel.org> <20180621151800.GU20477@kernel.org> Organization: Arm X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.32; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 21 Jun 2018 12:18:00 -0300 Arnaldo Carvalho de Melo wrote: > Would be good if we had some utility that given a two files, one with > regexps, could tell if, line by line, those expressions matched, better, > one that is present in all these OSes... I didn't find any, but given the two-file notion might be acceptable, hopefully you might find the following more readable/acceptable?: diff --git a/tools/perf/tests/shell/record+probe_libc_inet_pton.sh b/tools/perf/tests/shell/record+probe_libc_inet_pton.sh index 263057039693..94e513e62b34 100755 --- a/tools/perf/tests/shell/record+probe_libc_inet_pton.sh +++ b/tools/perf/tests/shell/record+probe_libc_inet_pton.sh @@ -14,35 +14,40 @@ libc=$(grep -w libc /proc/self/maps | head -1 | sed -r 's/.*[[:space:]](\/.*)/\1 nm -Dg $libc 2>/dev/null | fgrep -q inet_pton || exit 254 trace_libc_inet_pton_backtrace() { - idx=0 - expected[0]="ping[][0-9 \.:]+probe_libc:inet_pton: \([[:xdigit:]]+\)" - expected[1]=".*inet_pton\+0x[[:xdigit:]]+[[:space:]]\($libc|inlined\)$" + + expected=`mktemp -u /tmp/expected.XXX` + + echo "ping[][0-9 \.:]+probe_libc:inet_pton: \([[:xdigit:]]+\)" > $expected + echo ".*inet_pton\+0x[[:xdigit:]]+[[:space:]]\($libc|inlined\)$" >> $expected case "$(uname -m)" in s390x) eventattr='call-graph=dwarf,max-stack=4' - expected[2]="gaih_inet.*\+0x[[:xdigit:]]+[[:space:]]\($libc|inlined\)$" - expected[3]="(__GI_)?getaddrinfo\+0x[[:xdigit:]]+[[:space:]]\($libc|inlined\)$" - expected[4]="main\+0x[[:xdigit:]]+[[:space:]]\(.*/bin/ping.*\)$" + echo "gaih_inet.*\+0x[[:xdigit:]]+[[:space:]]\($libc|inlined\)$" >> $expected + echo "(__GI_)?getaddrinfo\+0x[[:xdigit:]]+[[:space:]]\($libc|inlined\)$" >> $expected + echo "main\+0x[[:xdigit:]]+[[:space:]]\(.*/bin/ping.*\)$" >> $expected ;; *) eventattr='max-stack=3' - expected[2]="getaddrinfo\+0x[[:xdigit:]]+[[:space:]]\($libc\)$" - expected[3]=".*\+0x[[:xdigit:]]+[[:space:]]\(.*/bin/ping.*\)$" + echo "getaddrinfo\+0x[[:xdigit:]]+[[:space:]]\($libc\)$" >> $expected + echo ".*\+0x[[:xdigit:]]+[[:space:]]\(.*/bin/ping.*\)$" >> $expected ;; esac - file=`mktemp -u /tmp/perf.data.XXX` + perf_data=`mktemp -u /tmp/perf.data.XXX` + perf_script=`mktemp -u /tmp/perf.script.XXX` + perf record -e probe_libc:inet_pton/$eventattr/ -o $perf_data ping -6 -c 1 ::1 > /dev/null 2>&1 + perf script -i $perf_data > $perf_script - perf record -e probe_libc:inet_pton/$eventattr/ -o $file ping -6 -c 1 ::1 > /dev/null 2>&1 - perf script -i $file | while read line ; do + exec 3<$perf_script + exec 4<$expected + while read line <&3 && read -r pattern <&4; do + [ -z "$pattern" ] && break echo $line - echo "$line" | egrep -q "${expected[$idx]}" + echo "$line" | egrep -q "$pattern" if [ $? -ne 0 ] ; then - printf "FAIL: expected backtrace entry %d \"%s\" got \"%s\"\n" $idx "${expected[$idx]}" "$line" + printf "FAIL: expected backtrace entry \"%s\" got \"%s\"\n" "$pattern" "$line" exit 1 fi - let idx+=1 - [ -z "${expected[$idx]}" ] && break done # If any statements are executed from this point onwards, @@ -58,6 +63,6 @@ skip_if_no_perf_probe && \ perf probe -q $libc inet_pton && \ trace_libc_inet_pton_backtrace err=$? -rm -f ${file} +rm -f ${perf_data} ${perf_script} ${expected} perf probe -q -d probe_libc:inet_pton exit $err Thanks, Kim