Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp1399775imm; Wed, 20 Jun 2018 17:46:45 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJnjNQY8pU52Csb3kbG4BzsVlMcacSIxRsX8ZrkhkHv1w2l5ttEN1ODtWG2mmj0LvBq9sBr X-Received: by 2002:a63:b901:: with SMTP id z1-v6mr674120pge.22.1529542005255; Wed, 20 Jun 2018 17:46:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529542005; cv=none; d=google.com; s=arc-20160816; b=BoTpy7AwcVfhB4D6tUf/7n/5obU6tidlJMsy0TYgSCVetQUorq+ZCpv/tMVYSUbuBu c/kvngCWxPeiUbdhU3T/28scs5Zpi0c9gZ4tY/jgQ70HfnHd+oITHA4WxbrzQ07b7GkV wrmJNG2mmNCZu7zGwvL4qABGQWyCO5IcMLI4FbTSsByr6ApS39I7XpGaaCH50DUF8d3V 2ynrF2CfkKbJ0euXotAtYaB49Jx7HuPYH18jjAlA3SiCZ6ytxwwaBUxw8RNGBY1nHxmf MBYVSeH4xUthUfPwSz/timkEEGiJlSQ96XUYiCijdH5flU/8qkpW3p8Ccf9A7BIKrs/a ns3A== 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=LEWfYyO7JvIna+JRnRw9bs1HNmqiksYCHkLyiUjWKMw=; b=QyWZu4BPAJeCf1Zrnx5hXgX7QVhp05CZjjmW19NnWlkwN0MOXJDuYwY9eKxsGbxEX5 24OQKUuZG+ldes6S/Zss4dSx3rwxbWZQSA1DzDJ1O1wI3KlOdb6s8zXYRRWUumvofcdd LQtERmEnlG+tTg3znuxhhpFrSf37jun9TLz3iQcgeRUxzHCdRPXAG+yZsYcDUM0fqFlm rGcJGIH948RM/vITm6XoT4mSmv5i8JB/XDe1Tive03Z5+1OjV44ZN0carpb8wESH9BHn 9JI/0IYDnhMq0fKfk9Ckrz6v2inSOqyWclcH9Ms8adBd7IvSNbPEEM8kVdiooSyPuW1v 4s7A== 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 f2-v6si3023966pgu.457.2018.06.20.17.46.29; Wed, 20 Jun 2018 17:46:45 -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 S1754342AbeFUApt (ORCPT + 99 others); Wed, 20 Jun 2018 20:45:49 -0400 Received: from foss.arm.com ([217.140.101.70]:44452 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754139AbeFUAps (ORCPT ); Wed, 20 Jun 2018 20:45:48 -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 0BE591435; Wed, 20 Jun 2018 17:45:48 -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 625053F578; Wed, 20 Jun 2018 17:45:47 -0700 (PDT) Date: Wed, 20 Jun 2018 19:45:46 -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: <20180620194546.364cc109430ac51c5a288739@arm.com> In-Reply-To: <20180620134622.GM20477@kernel.org> References: <20180619184952.dac6a3a1e39d3b1d255e7119@arm.com> <20180620134622.GM20477@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 Wed, 20 Jun 2018 10:46:22 -0300 Arnaldo Carvalho de Melo wrote: > Em Tue, Jun 19, 2018 at 06:49:52PM -0500, Kim Phillips escreveu: > > Debian based systems such as Ubuntu have dash as their default shell. > > Even if the normal or root user's shell is bash, certain scripts still > > call /bin/sh, which points to dash, so we fix this perf test by > > rewriting it in a more portable way. > > Isn't it better to just make /bin/bash a requirement for these tests? Perf is more bug-prone in distributions other than its main developers' distributions, and when its own built-in tests start depending on those same (primary) distributions' preferences, tests start to get skipped on the secondary ones, which start to get subsequently ignored and become acceptable to testers, which is a whole pattern I'd like to avoid if at all possible. I'd eventually like to see the real perf run on Android, for example, and adding bash to Android is nontrivial, AFAICT. > I think the alternative is cryptic :-\ I think that's because of the fake array stuff, which technically isn't needed by design. How about something like the following? 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..d5cceaeba42d 100755 --- a/tools/perf/tests/shell/record+probe_libc_inet_pton.sh +++ b/tools/perf/tests/shell/record+probe_libc_inet_pton.sh @@ -14,20 +14,21 @@ 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() { + newline='\n' idx=0 - expected[0]="ping[][0-9 \.:]+probe_libc:inet_pton: \([[:xdigit:]]+\)" - expected[1]=".*inet_pton\+0x[[:xdigit:]]+[[:space:]]\($libc|inlined\)$" + expected="ping[][0-9 \.:]+probe_libc:inet_pton: \([[:xdigit:]]+\)" + expected="${expected}${newline}.*inet_pton\+0x[[:xdigit:]]+[[:space:]]\($libc|inlined\)$" 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.*\)$" + expected="${expected}${newline}gaih_inet.*\+0x[[:xdigit:]]+[[:space:]]\($libc|inlined\)$" + expected="${expected}${newline}(__GI_)?getaddrinfo\+0x[[:xdigit:]]+[[:space:]]\($libc|inlined\)$" + expected="${expected}${newline}main\+0x[[:xdigit:]]+[[:space:]]\(.*/bin/ping.*\)$" ;; *) eventattr='max-stack=3' - expected[2]="getaddrinfo\+0x[[:xdigit:]]+[[:space:]]\($libc\)$" - expected[3]=".*\+0x[[:xdigit:]]+[[:space:]]\(.*/bin/ping.*\)$" + expected="${expected}${newline}getaddrinfo\+0x[[:xdigit:]]+[[:space:]]\($libc\)$" + expected="${expected}${newline}.*\+0x[[:xdigit:]]+[[:space:]]\(.*/bin/ping.*\)$" ;; esac @@ -35,14 +36,16 @@ trace_libc_inet_pton_backtrace() { 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 + [ -z "${line}" ] && break echo $line - echo "$line" | egrep -q "${expected[$idx]}" + idx=$((idx + 1)) + first="$(echo ${expected} | head -$idx | tail -1)" + [ -z "${first}" ] && break + echo "$line" | egrep -q "$first" if [ $? -ne 0 ] ; then - printf "FAIL: expected backtrace entry %d \"%s\" got \"%s\"\n" $idx "${expected[$idx]}" "$line" + printf "FAIL: expected backtrace entry %d \"%s\" got \"%s\"\n" $idx "${first}" "$line" exit 1 fi - let idx+=1 - [ -z "${expected[$idx]}" ] && break done # If any statements are executed from this point onwards, Thanks, Kim