lkml.org 
[lkml]   [2021]   [Jan]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH] perf test: Fix shadow stat test for non-bash shells
Hello,

On Tue, Jan 12, 2021 at 8:17 PM David Laight <David.Laight@aculab.com> wrote:
>
> 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.

Thanks for your review, I'll make the change.

Thanks,
Namhyung

\
 
 \ /
  Last update: 2021-01-14 04:22    [W:0.429 / U:0.272 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site