From: Ian Rogers <irogers@google.com> Date: 2021-06-17 18:42:31
$(( .. )) 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(-)
@@ -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];thenecho"The difference between $first_num and $second_num are greater than 10%."
From: Ian Rogers <irogers@google.com> Date: 2021-06-17 18:42:39
Having a verbose option will allow shell tests to provide extra failure
details when the fail or skip.
Signed-off-by: Ian Rogers <irogers@google.com>
---
tools/perf/tests/builtin-test.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
From: Ian Rogers <irogers@google.com> Date: 2021-06-17 18:42:43
Provide additional context for when the stat bpf counters test skips.
Signed-off-by: Ian Rogers <irogers@google.com>
---
tools/perf/tests/shell/stat_bpf_counters.sh | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
@@ -22,7 +22,13 @@ compare_number()}# skip if --bpf-counters is not supported-perfstat--bpf-counterstrue>/dev/null2>&1||exit2+if!perfstat--bpf-counterstrue>/dev/null2>&1;then+if["$1"=="-v"];then+echo"Skipping: --bpf-counters not supported"+perf--no-pagerstat--bpf-counterstrue||true+fi+exit2+fibase_cycles=$(perfstat--no-big-num-ecycles--perfbenchschedmessaging-g1-l100-t2>&1|awk'/cycles/ {print $1}')bpf_cycles=$(perfstat--no-big-num--bpf-counters-ecycles--perfbenchschedmessaging-g1-l100-t2>&1|awk'/cycles/ {print $1}')
From: Ian Rogers <irogers@google.com> Date: 2021-06-17 18:42:46
If the test is run on a hypervisor then the cycles event may not be
counted, skip the test in this situation. Fail the test if cycles are
not counted in the subsequent bpf counter run.
Signed-off-by: Ian Rogers <irogers@google.com>
---
tools/perf/tests/shell/stat_bpf_counters.sh | 8 ++++++++
1 file changed, 8 insertions(+)
@@ -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];thenecho"The difference between $first_num and $second_num are greater than 10%."
@@ -22,7 +22,13 @@ compare_number()}# skip if --bpf-counters is not supported-perfstat--bpf-counterstrue>/dev/null2>&1||exit2+if!perfstat--bpf-counterstrue>/dev/null2>&1;then+if["$1"=="-v"];then+echo"Skipping: --bpf-counters not supported"+perf--no-pagerstat--bpf-counterstrue||true+fi+exit2+fibase_cycles=$(perfstat--no-big-num-ecycles--perfbenchschedmessaging-g1-l100-t2>&1|awk'/cycles/ {print $1}')bpf_cycles=$(perfstat--no-big-num--bpf-counters-ecycles--perfbenchschedmessaging-g1-l100-t2>&1|awk'/cycles/ {print $1}')
From: Arnaldo Carvalho de Melo <acme@kernel.org> Date: 2021-06-17 19:21:25
Em Thu, Jun 17, 2021 at 11:42:16AM -0700, Ian Rogers escreveu:
If the test is run on a hypervisor then the cycles event may not be
counted, skip the test in this situation. Fail the test if cycles are
not counted in the subsequent bpf counter run.
probably you need to add a '- 3' after the sizeof above, right?
quoted
+ if (verbose)
+ strncat(script, " -v", sizeof(script));
+
Seemed simple enough, but gcc knows better, I'm removing this one:
tests/builtin-test.c:586:26: error: the value of the size argument in 'strncat' is too large, might lead to a buffer overflow [-Werror,-Wstrncat-size]
strncat(script, " -v", sizeof(script));
^~~~~~~~~~~~~~
tests/builtin-test.c:586:26: note: change the argument to be the free space in the destination buffer minus the terminating null byte
strncat(script, " -v", sizeof(script));
^~~~~~~~~~~~~~
sizeof(script) - strlen(script) - 1
1 error generated.
make[3]: *** [/git/perf-5.13.0-rc4/tools/build/Makefile.build:139: tests] Error 2
77 31.98 ubuntu:21.04 : FAIL gcc version 10.3.0 (Ubuntu 10.3.0-1ubuntu1)
tests/builtin-test.c:586:26: error: the value of the size argument in 'strncat' is too large, might lead to a buffer overflow [-Werror,-Wstrncat-size]
strncat(script, " -v", sizeof(script));
^~~~~~~~~~~~~~
tests/builtin-test.c:586:26: note: change the argument to be the free space in the destination buffer minus the terminating null byte
strncat(script, " -v", sizeof(script));
^~~~~~~~~~~~~~
sizeof(script) - strlen(script) - 1
1 error generated.
make[3]: *** [/git/perf-5.13.0-rc4/tools/build/Makefile.build:139: tests] Error 2
quoted
err = system(script);
if (!err)
return TEST_OK;
--
2.32.0.288.g62a8d224e6-goog
probably you need to add a '- 3' after the sizeof above, right?
Either way is fine, but -3 is ok with me.
quoted
quoted
+ if (verbose)
+ strncat(script, " -v", sizeof(script));
+
Seemed simple enough, but gcc knows better, I'm removing this one:
tests/builtin-test.c:586:26: error: the value of the size argument in 'strncat' is too large, might lead to a buffer overflow [-Werror,-Wstrncat-size]
strncat(script, " -v", sizeof(script));
^~~~~~~~~~~~~~
tests/builtin-test.c:586:26: note: change the argument to be the free space in the destination buffer minus the terminating null byte
strncat(script, " -v", sizeof(script));
^~~~~~~~~~~~~~
sizeof(script) - strlen(script) - 1
1 error generated.
make[3]: *** [/git/perf-5.13.0-rc4/tools/build/Makefile.build:139: tests] Error 2
77 31.98 ubuntu:21.04 : FAIL gcc version 10.3.0 (Ubuntu 10.3.0-1ubuntu1)
tests/builtin-test.c:586:26: error: the value of the size argument in 'strncat' is too large, might lead to a buffer overflow [-Werror,-Wstrncat-size]
strncat(script, " -v", sizeof(script));
^~~~~~~~~~~~~~
tests/builtin-test.c:586:26: note: change the argument to be the free space in the destination buffer minus the terminating null byte
strncat(script, " -v", sizeof(script));
^~~~~~~~~~~~~~
sizeof(script) - strlen(script) - 1
1 error generated.
make[3]: *** [/git/perf-5.13.0-rc4/tools/build/Makefile.build:139: tests] Error 2
Thanks gcc :-) Do you want me to resend the patch?
Ian
quoted
quoted
err = system(script);
if (!err)
return TEST_OK;
--
2.32.0.288.g62a8d224e6-goog
probably you need to add a '- 3' after the sizeof above, right?
Either way is fine, but -3 is ok with me.
quoted
quoted
quoted
+ if (verbose)
+ strncat(script, " -v", sizeof(script));
+
Seemed simple enough, but gcc knows better, I'm removing this one:
tests/builtin-test.c:586:26: error: the value of the size argument in 'strncat' is too large, might lead to a buffer overflow [-Werror,-Wstrncat-size]
strncat(script, " -v", sizeof(script));
^~~~~~~~~~~~~~
tests/builtin-test.c:586:26: note: change the argument to be the free space in the destination buffer minus the terminating null byte
strncat(script, " -v", sizeof(script));
^~~~~~~~~~~~~~
sizeof(script) - strlen(script) - 1
1 error generated.
make[3]: *** [/git/perf-5.13.0-rc4/tools/build/Makefile.build:139: tests] Error 2
77 31.98 ubuntu:21.04 : FAIL gcc version 10.3.0 (Ubuntu 10.3.0-1ubuntu1)
tests/builtin-test.c:586:26: error: the value of the size argument in 'strncat' is too large, might lead to a buffer overflow [-Werror,-Wstrncat-size]
strncat(script, " -v", sizeof(script));
^~~~~~~~~~~~~~
tests/builtin-test.c:586:26: note: change the argument to be the free space in the destination buffer minus the terminating null byte
strncat(script, " -v", sizeof(script));
^~~~~~~~~~~~~~
sizeof(script) - strlen(script) - 1
1 error generated.
make[3]: *** [/git/perf-5.13.0-rc4/tools/build/Makefile.build:139: tests] Error 2
Thanks gcc :-) Do you want me to resend the patch?
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