Message ID | 20210617184216.2075588-1-irogers@google.com (mailing list archive) |
---|---|
State | Not Applicable |
Headers | show |
Series | [1/4] perf test: Fix non-bash issue with stat bpf counters | expand |
Context | Check | Description |
---|---|---|
netdev/tree_selection | success | Not a local patch |
Em Thu, Jun 17, 2021 at 11:42:13AM -0700, Ian Rogers escreveu: > $(( .. )) is a bash feature but the test's interpreter is !/bin/sh, > switch the code to use expr. Thanks, applied to perf/urgent. - Arnaldo > Signed-off-by: Ian Rogers <irogers@google.com> > --- > tools/perf/tests/shell/stat_bpf_counters.sh | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/tools/perf/tests/shell/stat_bpf_counters.sh b/tools/perf/tests/shell/stat_bpf_counters.sh > index 22eb31e48ca7..2f9948b3d943 100755 > --- a/tools/perf/tests/shell/stat_bpf_counters.sh > +++ b/tools/perf/tests/shell/stat_bpf_counters.sh > @@ -11,9 +11,9 @@ compare_number() > second_num=$2 > > # upper bound is first_num * 110% > - upper=$(( $first_num + $first_num / 10 )) > + upper=$(expr $first_num + $first_num / 10 ) > # lower bound is first_num * 90% > - lower=$(( $first_num - $first_num / 10 )) > + lower=$(expr $first_num - $first_num / 10 ) > > if [ $second_num -gt $upper ] || [ $second_num -lt $lower ]; then > echo "The difference between $first_num and $second_num are greater than 10%." > -- > 2.32.0.288.g62a8d224e6-goog >
Hi Ian, On Thu, 17 Jun 2021 11:42:13 -0700 Ian Rogers <irogers@google.com> wrote: > > $(( .. )) is a bash feature but the test's interpreter is !/bin/sh, > switch the code to use expr. The $(( .. )) syntax is specified in POSIX (see https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_06_04), so unless this caused an actual problem, this change is unnecessary.
On Sun, Jun 20, 2021 at 2:55 PM Stephen Rothwell <sfr@canb.auug.org.au> wrote: > > Hi Ian, > > On Thu, 17 Jun 2021 11:42:13 -0700 Ian Rogers <irogers@google.com> wrote: > > > > $(( .. )) is a bash feature but the test's interpreter is !/bin/sh, > > switch the code to use expr. > > The $(( .. )) syntax is specified in POSIX (see > https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_06_04), > so unless this caused an actual problem, this change is unnecessary. Agreed. The issue I was seeing was: ./tests/shell/stat_bpf_counters.sh: line 14: <not + <not / 10 : syntax error: operand expected (error token is "<not + <not / 10 ") but that syntax error is caused by running the test within a hypervisor. I'll resend the patch set with this one dropped. Thanks, Ian > -- > Cheers, > Stephen Rothwell
diff --git a/tools/perf/tests/shell/stat_bpf_counters.sh b/tools/perf/tests/shell/stat_bpf_counters.sh index 22eb31e48ca7..2f9948b3d943 100755 --- a/tools/perf/tests/shell/stat_bpf_counters.sh +++ b/tools/perf/tests/shell/stat_bpf_counters.sh @@ -11,9 +11,9 @@ compare_number() second_num=$2 # upper bound is first_num * 110% - upper=$(( $first_num + $first_num / 10 )) + upper=$(expr $first_num + $first_num / 10 ) # lower bound is first_num * 90% - lower=$(( $first_num - $first_num / 10 )) + lower=$(expr $first_num - $first_num / 10 ) if [ $second_num -gt $upper ] || [ $second_num -lt $lower ]; then echo "The difference between $first_num and $second_num are greater than 10%."
$(( .. )) is a bash feature but the test's interpreter is !/bin/sh, switch the code to use expr. Signed-off-by: Ian Rogers <irogers@google.com> --- tools/perf/tests/shell/stat_bpf_counters.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)