[7/8] perf test: Test record with --threads option

Message ID 20221020172643.3458767-8-namhyung@kernel.org
State New
Headers
Series perf test: Improve perf record tests (v2) |

Commit Message

Namhyung Kim Oct. 20, 2022, 5:26 p.m. UTC
  The --threads option changed the perf record behavior significantly, so
it'd be nice if we test it separately.  Add --threads options with
different argument in each test supported and check the result.

Also update the cleanup routine because threads recording produces data
in a directory.

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
 tools/perf/tests/shell/record.sh | 30 ++++++++++++++++++++++++++++--
 1 file changed, 28 insertions(+), 2 deletions(-)
  

Comments

Ian Rogers Oct. 21, 2022, 12:02 a.m. UTC | #1
On Thu, Oct 20, 2022 at 10:26 AM Namhyung Kim <namhyung@kernel.org> wrote:
>
> The --threads option changed the perf record behavior significantly, so
> it'd be nice if we test it separately.  Add --threads options with
> different argument in each test supported and check the result.
>
> Also update the cleanup routine because threads recording produces data
> in a directory.
>
> Signed-off-by: Namhyung Kim <namhyung@kernel.org>

Acked-by: Ian Rogers <irogers@google.com>

Thanks,
Ian

> ---
>  tools/perf/tests/shell/record.sh | 30 ++++++++++++++++++++++++++++--
>  1 file changed, 28 insertions(+), 2 deletions(-)
>
> diff --git a/tools/perf/tests/shell/record.sh b/tools/perf/tests/shell/record.sh
> index c59d1459c960..01aa9531b369 100755
> --- a/tools/perf/tests/shell/record.sh
> +++ b/tools/perf/tests/shell/record.sh
> @@ -13,8 +13,8 @@ testprog=$(mktemp /tmp/__perf_test.prog.XXXXXX)
>  testsym="test_loop"
>
>  cleanup() {
> -  rm -f "${perfdata}"
> -  rm -f "${perfdata}".old
> +  rm -rf "${perfdata}"
> +  rm -rf "${perfdata}".old
>
>    if [ "${testprog}" != "true" ]; then
>      rm -f "${testprog}"
> @@ -171,6 +171,19 @@ test_system_wide() {
>      err=1
>      return
>    fi
> +  if ! perf record -aB --synth=no -e cpu-clock,cs --threads=cpu \
> +    -o "${perfdata}" ${testprog} 2> /dev/null
> +  then
> +    echo "System-wide record [Failed record --threads option]"
> +    err=1
> +    return
> +  fi
> +  if ! perf report -i "${perfdata}" -q | grep -q "${testsym}"
> +  then
> +    echo "System-wide record [Failed --threads missing output]"
> +    err=1
> +    return
> +  fi
>    echo "Basic --system-wide mode test [Success]"
>  }
>
> @@ -188,6 +201,19 @@ test_workload() {
>      err=1
>      return
>    fi
> +  if ! perf record -e cpu-clock,cs --threads=package \
> +    -o "${perfdata}" ${testprog} 2> /dev/null
> +  then
> +    echo "Workload record [Failed record --threads option]"
> +    err=1
> +    return
> +  fi
> +  if ! perf report -i "${perfdata}" -q | grep -q "${testsym}"
> +  then
> +    echo "Workload record [Failed --threads missing output]"
> +    err=1
> +    return
> +  fi
>    echo "Basic target workload test [Success]"
>  }
>
> --
> 2.38.0.135.g90850a2211-goog
>
  
Adrian Hunter Oct. 21, 2022, 8:45 a.m. UTC | #2
On 20/10/22 20:26, Namhyung Kim wrote:
> The --threads option changed the perf record behavior significantly, so
> it'd be nice if we test it separately.  Add --threads options with
> different argument in each test supported and check the result.
> 
> Also update the cleanup routine because threads recording produces data
> in a directory.
> 
> Signed-off-by: Namhyung Kim <namhyung@kernel.org>

Reviewed-by: Adrian Hunter <adrian.hunter@intel.com>

> ---
>  tools/perf/tests/shell/record.sh | 30 ++++++++++++++++++++++++++++--
>  1 file changed, 28 insertions(+), 2 deletions(-)
> 
> diff --git a/tools/perf/tests/shell/record.sh b/tools/perf/tests/shell/record.sh
> index c59d1459c960..01aa9531b369 100755
> --- a/tools/perf/tests/shell/record.sh
> +++ b/tools/perf/tests/shell/record.sh
> @@ -13,8 +13,8 @@ testprog=$(mktemp /tmp/__perf_test.prog.XXXXXX)
>  testsym="test_loop"
>  
>  cleanup() {
> -  rm -f "${perfdata}"
> -  rm -f "${perfdata}".old
> +  rm -rf "${perfdata}"
> +  rm -rf "${perfdata}".old
>  
>    if [ "${testprog}" != "true" ]; then
>      rm -f "${testprog}"
> @@ -171,6 +171,19 @@ test_system_wide() {
>      err=1
>      return
>    fi
> +  if ! perf record -aB --synth=no -e cpu-clock,cs --threads=cpu \
> +    -o "${perfdata}" ${testprog} 2> /dev/null
> +  then
> +    echo "System-wide record [Failed record --threads option]"
> +    err=1
> +    return
> +  fi
> +  if ! perf report -i "${perfdata}" -q | grep -q "${testsym}"
> +  then
> +    echo "System-wide record [Failed --threads missing output]"
> +    err=1
> +    return
> +  fi
>    echo "Basic --system-wide mode test [Success]"
>  }
>  
> @@ -188,6 +201,19 @@ test_workload() {
>      err=1
>      return
>    fi
> +  if ! perf record -e cpu-clock,cs --threads=package \
> +    -o "${perfdata}" ${testprog} 2> /dev/null
> +  then
> +    echo "Workload record [Failed record --threads option]"
> +    err=1
> +    return
> +  fi
> +  if ! perf report -i "${perfdata}" -q | grep -q "${testsym}"
> +  then
> +    echo "Workload record [Failed --threads missing output]"
> +    err=1
> +    return
> +  fi
>    echo "Basic target workload test [Success]"
>  }
>
  

Patch

diff --git a/tools/perf/tests/shell/record.sh b/tools/perf/tests/shell/record.sh
index c59d1459c960..01aa9531b369 100755
--- a/tools/perf/tests/shell/record.sh
+++ b/tools/perf/tests/shell/record.sh
@@ -13,8 +13,8 @@  testprog=$(mktemp /tmp/__perf_test.prog.XXXXXX)
 testsym="test_loop"
 
 cleanup() {
-  rm -f "${perfdata}"
-  rm -f "${perfdata}".old
+  rm -rf "${perfdata}"
+  rm -rf "${perfdata}".old
 
   if [ "${testprog}" != "true" ]; then
     rm -f "${testprog}"
@@ -171,6 +171,19 @@  test_system_wide() {
     err=1
     return
   fi
+  if ! perf record -aB --synth=no -e cpu-clock,cs --threads=cpu \
+    -o "${perfdata}" ${testprog} 2> /dev/null
+  then
+    echo "System-wide record [Failed record --threads option]"
+    err=1
+    return
+  fi
+  if ! perf report -i "${perfdata}" -q | grep -q "${testsym}"
+  then
+    echo "System-wide record [Failed --threads missing output]"
+    err=1
+    return
+  fi
   echo "Basic --system-wide mode test [Success]"
 }
 
@@ -188,6 +201,19 @@  test_workload() {
     err=1
     return
   fi
+  if ! perf record -e cpu-clock,cs --threads=package \
+    -o "${perfdata}" ${testprog} 2> /dev/null
+  then
+    echo "Workload record [Failed record --threads option]"
+    err=1
+    return
+  fi
+  if ! perf report -i "${perfdata}" -q | grep -q "${testsym}"
+  then
+    echo "Workload record [Failed --threads missing output]"
+    err=1
+    return
+  fi
   echo "Basic target workload test [Success]"
 }