From: David Laight <David.Laight@ACULAB.COM>
To: 'Jiri Olsa' <jolsa@redhat.com>, Namhyung Kim <namhyung@kernel.org>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>,
Ingo Molnar <mingo@kernel.org>,
Peter Zijlstra <peterz@infradead.org>,
Mark Rutland <mark.rutland@arm.com>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
LKML <linux-kernel@vger.kernel.org>,
Stephane Eranian <eranian@google.com>,
Ian Rogers <irogers@google.com>,
"Jin Yao" <yao.jin@linux.intel.com>
Subject: RE: [PATCH] perf test: Fix shadow stat test for non-bash shells
Date: Tue, 12 Jan 2021 11:17:18 +0000 [thread overview]
Message-ID: <c0d1ac9ce2bf43029c1c97bfcc9029c4@AcuMS.aculab.com> (raw)
In-Reply-To: <20210112093016.GB1252618@krava>
From: Jiri Olsa
> Sent: 12 January 2021 09:30
>
> On Fri, Jan 08, 2021 at 04:47:12PM +0900, Namhyung Kim wrote:
> > It was using some bash-specific features and failed to parse when
> > running with a different shell like below:
...
You don't need a temporary file, one option is:
> > index 249dfe48cf6a..e2c7ac4ed91d 100755
> > --- a/tools/perf/tests/shell/stat+shadow_stat.sh
> > +++ b/tools/perf/tests/shell/stat+shadow_stat.sh
...
> > perf stat -a -A --no-big-num -e cycles,instructions sleep 1 2>&1 | \
> > grep ^CPU | \
> > while read cpu num evt hash ipc rest
> > do
...
> > + if [ "$evt" = "cycles" ]; then
> > + echo $cpu $num >> $results
results="$results $cpu:$num"
> > continue
> > fi
> >
> > # skip if no cycles
> > - local cyc=${results[$cpu]}
> > - if [[ -z $cyc ]]; then
> > + local cyc=$(grep $cpu $results | cut -d' ' -f2)
cyc=${results##* $cpu:}
cyc=$(cyc%% *}
> > + if [ -z "$cyc" ]; then
> > continue
> > fi
I can't remember when 'local' was invented.
You may find shells that don't support it.
In any case, since this is a small standalone file I'd
remove them just in case.
David
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)
next prev parent reply other threads:[~2021-01-12 11:19 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-08 7:47 [PATCH] perf test: Fix shadow stat test for non-bash shells Namhyung Kim
2021-01-12 9:30 ` Jiri Olsa
2021-01-12 11:17 ` David Laight [this message]
2021-01-14 3:19 ` Namhyung Kim
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=c0d1ac9ce2bf43029c1c97bfcc9029c4@AcuMS.aculab.com \
--to=david.laight@aculab.com \
--cc=acme@kernel.org \
--cc=alexander.shishkin@linux.intel.com \
--cc=eranian@google.com \
--cc=irogers@google.com \
--cc=jolsa@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mingo@kernel.org \
--cc=namhyung@kernel.org \
--cc=peterz@infradead.org \
--cc=yao.jin@linux.intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox