lkml.org 
[lkml]   [2021]   [Jan]   [12]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRE: [PATCH] perf test: Fix shadow stat test for non-bash shells
Date
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)

\
 
 \ /
  Last update: 2021-01-12 12:20    [W:0.034 / U:0.500 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site