Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp795221imm; Wed, 20 Jun 2018 06:47:50 -0700 (PDT) X-Google-Smtp-Source: ADUXVKL9k9V+OyLGNLe8iZhkYRl5GUS/+2jD72wzOOMv9zRbqqdl2fG+6Kpq1B7GKjF7NKT5XPIy X-Received: by 2002:a63:4346:: with SMTP id q67-v6mr18782875pga.328.1529502470251; Wed, 20 Jun 2018 06:47:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529502470; cv=none; d=google.com; s=arc-20160816; b=GE/adYa0FSyG/WdpXspXLdNYRbf0bH8CVIZ0a8PWFLEjfjdLAW0F4rhL2DvL0+XPpM kTWLwOkPyi1EnRJGYO7lcF60Jv1v06eS+nYvqaZaZUVYjYLXtBRQysWO7NrMIe1Zo7sH NZ9cLXsuZliuS6sZEXT56Gtj/u4L9XnnYFwYizTltIN47jTej1TomeVacMKOxJOav8wW r0OldcAfq0zzwEXCUvg3Mx6MnRTD9nbIwNU4frxQPqY6Hlor3Lpy8VflgPj5CgotpzJH FX5pICs9pkLC5lr/Ca9FLGX6nYZEgBsXwl8UNn6Qnyz1WVVHbWmcEYZ1mNyXWFgZS9tn uLdw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature :arc-authentication-results; bh=XhhoAEzSuRIzZ5InqSnvN90JHf6/laMeDBjYgs3OZ3I=; b=qqid1ISjJEB1Gb1/TV7/NGoYar4UWFtRRXHhwQEQ8YakJMlaa2IeU4gh2O9SC2FdzW YwtJ7109G3sdlthOhHu8hzJYtn4QqSKaUBpTLjLbx+qdRUsw8UA3HVTBZDHDC8Lp0ZfM +XNpFPryT3Ji8/5r1oXPmHyAMgpm1bJkAKuM6ikHkP/2ojLXzXdOVkt2ExsoRU9ObEhQ IQOqxaYfY03robQ7LG6fEjQ+7E1LGHWRsWHc4ODmzhztGD4QxCjWxW/XgEvp9dUz2t3m 4TDn7Gh33PLXSG6h15nKX95u9E7g2uCemDdMkb7WV3pnjqKmek5LlcOR8e+tKv2QdKEP BavQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=rT6Yn4Tx; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e4-v6si1972694pgs.476.2018.06.20.06.47.36; Wed, 20 Jun 2018 06:47:50 -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; dkim=pass header.i=@kernel.org header.s=default header.b=rT6Yn4Tx; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754161AbeFTNq2 (ORCPT + 99 others); Wed, 20 Jun 2018 09:46:28 -0400 Received: from mail.kernel.org ([198.145.29.99]:37432 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753960AbeFTNq1 (ORCPT ); Wed, 20 Jun 2018 09:46:27 -0400 Received: from jouet.infradead.org (unknown [189.40.103.66]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 8564220874; Wed, 20 Jun 2018 13:46:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1529502387; bh=OSTgzCRXjAoXANDdFVPVAnTHSKfIsw8b4/F+8H/orDo=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=rT6Yn4Tx0lZ/Yt8k3Mdm+l07Ol1hpLN8t8nqBY3wen73fgRuyzwGDyfXCDyJXQ5+w h4QS5Oz45MdTd3ZFsRU4uCb8WdfDIqCjTZ5jJkrete2zlILX1ZDyDdsOEJae8c54/B tWVl/T/eF8qVSUlmSzLz8mNAG0GaN1yu3jaYIJW4= Received: by jouet.infradead.org (Postfix, from userid 1000) id CC9851401E5; Wed, 20 Jun 2018 10:46:22 -0300 (-03) Date: Wed, 20 Jun 2018 10:46:22 -0300 From: Arnaldo Carvalho de Melo To: Kim Phillips 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: <20180620134622.GM20477@kernel.org> References: <20180619184952.dac6a3a1e39d3b1d255e7119@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20180619184952.dac6a3a1e39d3b1d255e7119@arm.com> X-Url: http://acmel.wordpress.com User-Agent: Mutt/1.9.2 (2017-12-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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? I think the alternative is cryptic :-\ Thanks, - Arnaldo > BEFORE: > > $ sudo ./perf test -v 64 > 64: probe libc's inet_pton & backtrace it with ping : > --- start --- > test child forked, pid 31942 > ./tests/shell/record+probe_libc_inet_pton.sh: 18: ./tests/shell/record+probe_libc_inet_pton.sh: expected[0]=ping[][0-9 \.:]+probe_libc:inet_pton: \([[:xdigit:]]+\): not found > ./tests/shell/record+probe_libc_inet_pton.sh: 19: ./tests/shell/record+probe_libc_inet_pton.sh: expected[1]=.*inet_pton\+0x[[:xdigit:]]+[[:space:]]\(/lib/x86_64-linux-gnu/libc-2.27.so|inlined\)$: not found > ./tests/shell/record+probe_libc_inet_pton.sh: 29: ./tests/shell/record+probe_libc_inet_pton.sh: expected[2]=getaddrinfo\+0x[[:xdigit:]]+[[:space:]]\(/lib/x86_64-linux-gnu/libc-2.27.so\)$: not found > ./tests/shell/record+probe_libc_inet_pton.sh: 30: ./tests/shell/record+probe_libc_inet_pton.sh: expected[3]=.*\+0x[[:xdigit:]]+[[:space:]]\(.*/bin/ping.*\)$: not found > ping 31963 [004] 83577.670613: probe_libc:inet_pton: (7fe15f87f4b0) > ./tests/shell/record+probe_libc_inet_pton.sh: 39: ./tests/shell/record+probe_libc_inet_pton.sh: Bad substitution > ./tests/shell/record+probe_libc_inet_pton.sh: 41: ./tests/shell/record+probe_libc_inet_pton.sh: Bad substitution > test child finished with -2 > ---- end ---- > probe libc's inet_pton & backtrace it with ping: Skip > > AFTER: > > 64: probe libc's inet_pton & backtrace it with ping : > --- start --- > test child forked, pid 32277 > ping 32295 [001] 83679.690020: probe_libc:inet_pton: (7ff244f504b0) > 7ff244f504b0 __GI___inet_pton+0x0 (/lib/x86_64-linux-gnu/libc-2.27.so) > 7ff244f14ce4 getaddrinfo+0x124 (/lib/x86_64-linux-gnu/libc-2.27.so) > 556ac036b57d _init+0xb75 (/bin/ping) > test child finished with 0 > ---- end ---- > probe libc's inet_pton & backtrace it with ping: Ok > > Cc: Arnaldo Carvalho de Melo > Cc: Peter Zijlstra > Cc: Ingo Molnar > Cc: Alexander Shishkin > Cc: Jiri Olsa > Cc: Namhyung Kim > Cc: Thomas Richter > Cc: Michael Petlan > Cc: "Hendrik Br?ckner" > Cc: Sandipan Das > Signed-off-by: Kim Phillips > --- > Fixed using fake array technique described here: > > https://www.linuxquestions.org/questions/programming-9/basic-bash-how-to-use-eval-to-evaluate-variable-names-made-of-arbitrary-strings-775622/ > > Note that bashisms can also be found with 'checkbashisms': > > $ checkbashisms record+probe_libc_inet_pton.sh > script record+probe_libc_inet_pton.sh does not appear to have a #! interpreter line; > you may get strange results > possible bashism in record+probe_libc_inet_pton.sh line 18 (bash arrays, H[0]): > expected[0]="ping[][0-9 \.:]+probe_libc:inet_pton: \([[:xdigit:]]+\)" > possible bashism in record+probe_libc_inet_pton.sh line 19 (bash arrays, H[0]): > expected[1]=".*inet_pton\+0x[[:xdigit:]]+[[:space:]]\($libc|inlined\)$" > possible bashism in record+probe_libc_inet_pton.sh line 23 (bash arrays, H[0]): > expected[2]="gaih_inet.*\+0x[[:xdigit:]]+[[:space:]]\($libc|inlined\)$" > possible bashism in record+probe_libc_inet_pton.sh line 24 (bash arrays, H[0]): > expected[3]="(__GI_)?getaddrinfo\+0x[[:xdigit:]]+[[:space:]]\($libc|inlined\)$" > possible bashism in record+probe_libc_inet_pton.sh line 25 (bash arrays, H[0]): > expected[4]="main\+0x[[:xdigit:]]+[[:space:]]\(.*/bin/ping.*\)$" > possible bashism in record+probe_libc_inet_pton.sh line 29 (bash arrays, H[0]): > expected[2]="getaddrinfo\+0x[[:xdigit:]]+[[:space:]]\($libc\)$" > possible bashism in record+probe_libc_inet_pton.sh line 30 (bash arrays, H[0]): > expected[3]=".*\+0x[[:xdigit:]]+[[:space:]]\(.*/bin/ping.*\)$" > possible bashism in record+probe_libc_inet_pton.sh line 39 (bash arrays, ${name[0|*|@]}): > echo "$line" | egrep -q "${expected[$idx]}" > possible bashism in record+probe_libc_inet_pton.sh line 41 (bash arrays, ${name[0|*|@]}): > printf "FAIL: expected backtrace entry %d \"%s\" got \"%s\"\n" $idx "${expected[$idx]}" "$line" > possible bashism in record+probe_libc_inet_pton.sh line 44 (let ...): > let idx+=1 > possible bashism in record+probe_libc_inet_pton.sh line 45 (bash arrays, ${name[0|*|@]}): > [ -z "${expected[$idx]}" ] && break > > .../shell/record+probe_libc_inet_pton.sh | 23 ++++++++++--------- > 1 file changed, 12 insertions(+), 11 deletions(-) > > 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..41124fa12913 100755 > --- a/tools/perf/tests/shell/record+probe_libc_inet_pton.sh > +++ b/tools/perf/tests/shell/record+probe_libc_inet_pton.sh > @@ -15,19 +15,20 @@ 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='expected' > + eval ${expected}0="'ping[][0-9 \.:]+probe_libc:inet_pton: \([[:xdigit:]]+\)'" > + eval ${expected}1="'.*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.*\)$" > + eval ${expected}2="'gaih_inet.*\+0x[[:xdigit:]]+[[:space:]]\($libc|inlined\)$'" > + eval ${expected}3="'(__GI_)?getaddrinfo\+0x[[:xdigit:]]+[[:space:]]\($libc|inlined\)$'" > + eval ${expected}4="'main\+0x[[:xdigit:]]+[[:space:]]\(.*/bin/ping.*\)$'" > ;; > *) > eventattr='max-stack=3' > - expected[2]="getaddrinfo\+0x[[:xdigit:]]+[[:space:]]\($libc\)$" > - expected[3]=".*\+0x[[:xdigit:]]+[[:space:]]\(.*/bin/ping.*\)$" > + eval ${expected}2="'getaddrinfo\+0x[[:xdigit:]]+[[:space:]]\($libc\)$'" > + eval ${expected}3="'.*\+0x[[:xdigit:]]+[[:space:]]\(.*/bin/ping.*\)$'" > ;; > esac > > @@ -36,13 +37,13 @@ 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 > echo $line > - echo "$line" | egrep -q "${expected[$idx]}" > + echo "$line" | egrep -q "$(echo $(eval echo \$$expected${idx}))" > 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 "$(echo $(eval echo \$$expected${idx}))" "$line" > exit 1 > fi > - let idx+=1 > - [ -z "${expected[$idx]}" ] && break > + idx=$((idx+1)) > + [ -z "$(echo $(eval echo \$$expected${idx}))" ] && break > done > > # If any statements are executed from this point onwards, > -- > 2.17.1