[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <c0d1ac9ce2bf43029c1c97bfcc9029c4@AcuMS.aculab.com>
Date: Tue, 12 Jan 2021 11:17:18 +0000
From: David Laight <David.Laight@...LAB.COM>
To: 'Jiri Olsa' <jolsa@...hat.com>, Namhyung Kim <namhyung@...nel.org>
CC: Arnaldo Carvalho de Melo <acme@...nel.org>,
Ingo Molnar <mingo@...nel.org>,
Peter Zijlstra <peterz@...radead.org>,
Mark Rutland <mark.rutland@....com>,
Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
LKML <linux-kernel@...r.kernel.org>,
Stephane Eranian <eranian@...gle.com>,
Ian Rogers <irogers@...gle.com>,
"Jin Yao" <yao.jin@...ux.intel.com>
Subject: RE: [PATCH] perf test: Fix shadow stat test for non-bash shells
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)
Powered by blists - more mailing lists