[03/29] selftests/mm: Dump a summary in run_vmtests.sh

Message ID 20230330160646.3106903-1-peterx@redhat.com
State New
Headers
Series selftests/mm: Split / Refactor userfault test |

Commit Message

Peter Xu March 30, 2023, 4:06 p.m. UTC
  Dump a summary after running whatever test specified.  Useful for human
runners to identify any kind of failures (besides exit code).

Signed-off-by: Peter Xu <peterx@redhat.com>
---
 tools/testing/selftests/mm/run_vmtests.sh | 8 ++++++++
 1 file changed, 8 insertions(+)
  

Comments

Axel Rasmussen March 30, 2023, 7:07 p.m. UTC | #1
On Thu, Mar 30, 2023 at 9:06 AM Peter Xu <peterx@redhat.com> wrote:
>
> Dump a summary after running whatever test specified.  Useful for human
> runners to identify any kind of failures (besides exit code).
>
> Signed-off-by: Peter Xu <peterx@redhat.com>
> ---
>  tools/testing/selftests/mm/run_vmtests.sh | 8 ++++++++
>  1 file changed, 8 insertions(+)
>
> diff --git a/tools/testing/selftests/mm/run_vmtests.sh b/tools/testing/selftests/mm/run_vmtests.sh
> index c0f93b668c0c..9cc33984aa9f 100644
> --- a/tools/testing/selftests/mm/run_vmtests.sh
> +++ b/tools/testing/selftests/mm/run_vmtests.sh
> @@ -5,6 +5,9 @@
>  # Kselftest framework requirement - SKIP code is 4.
>  ksft_skip=4
>
> +count_pass=0
> +count_fail=0
> +count_skip=0
>  exitcode=0
>
>  usage() {
> @@ -149,11 +152,14 @@ run_test() {
>                 "$@"
>                 local ret=$?
>                 if [ $ret -eq 0 ]; then
> +                       count_pass=$(( $count_pass + 1 ))

Actually, inside $(( )) there's no need to prefix variable names with
$ too. Running "shellcheck" over the script written this way will
generate a warning.

Same applies below.

>                         echo "[PASS]"
>                 elif [ $ret -eq $ksft_skip ]; then
> +                       count_skip=$(( $count_skip + 1 ))
>                         echo "[SKIP]"
>                         exitcode=$ksft_skip
>                 else
> +                       count_fail=$(( $count_fail + 1 ))
>                         echo "[FAIL]"
>                         exitcode=1
>                 fi
> @@ -279,4 +285,6 @@ CATEGORY="soft_dirty" run_test ./soft-dirty
>  # COW tests
>  CATEGORY="cow" run_test ./cow
>
> +echo "SUMMARY: PASS=${count_pass} SKIP=${count_skip} FAIL=${count_fail}"
> +
>  exit $exitcode
> --
> 2.39.1
>

Besides the nitpick:

Reviewed-by: Axel Rasmussen <axelrasmussen@google.com>
  
Peter Xu March 30, 2023, 10:28 p.m. UTC | #2
On Thu, Mar 30, 2023 at 12:07:24PM -0700, Axel Rasmussen wrote:
> On Thu, Mar 30, 2023 at 9:06 AM Peter Xu <peterx@redhat.com> wrote:
> >
> > Dump a summary after running whatever test specified.  Useful for human
> > runners to identify any kind of failures (besides exit code).
> >
> > Signed-off-by: Peter Xu <peterx@redhat.com>
> > ---
> >  tools/testing/selftests/mm/run_vmtests.sh | 8 ++++++++
> >  1 file changed, 8 insertions(+)
> >
> > diff --git a/tools/testing/selftests/mm/run_vmtests.sh b/tools/testing/selftests/mm/run_vmtests.sh
> > index c0f93b668c0c..9cc33984aa9f 100644
> > --- a/tools/testing/selftests/mm/run_vmtests.sh
> > +++ b/tools/testing/selftests/mm/run_vmtests.sh
> > @@ -5,6 +5,9 @@
> >  # Kselftest framework requirement - SKIP code is 4.
> >  ksft_skip=4
> >
> > +count_pass=0
> > +count_fail=0
> > +count_skip=0
> >  exitcode=0
> >
> >  usage() {
> > @@ -149,11 +152,14 @@ run_test() {
> >                 "$@"
> >                 local ret=$?
> >                 if [ $ret -eq 0 ]; then
> > +                       count_pass=$(( $count_pass + 1 ))
> 
> Actually, inside $(( )) there's no need to prefix variable names with
> $ too. Running "shellcheck" over the script written this way will
> generate a warning.
> 
> Same applies below.

Sure, I'll fix.

> 
> >                         echo "[PASS]"
> >                 elif [ $ret -eq $ksft_skip ]; then
> > +                       count_skip=$(( $count_skip + 1 ))
> >                         echo "[SKIP]"
> >                         exitcode=$ksft_skip
> >                 else
> > +                       count_fail=$(( $count_fail + 1 ))
> >                         echo "[FAIL]"
> >                         exitcode=1
> >                 fi
> > @@ -279,4 +285,6 @@ CATEGORY="soft_dirty" run_test ./soft-dirty
> >  # COW tests
> >  CATEGORY="cow" run_test ./cow
> >
> > +echo "SUMMARY: PASS=${count_pass} SKIP=${count_skip} FAIL=${count_fail}"
> > +
> >  exit $exitcode
> > --
> > 2.39.1
> >
> 
> Besides the nitpick:
> 
> Reviewed-by: Axel Rasmussen <axelrasmussen@google.com>

Thanks!
  
David Hildenbrand April 3, 2023, 7:49 a.m. UTC | #3
On 31.03.23 00:28, Peter Xu wrote:
> On Thu, Mar 30, 2023 at 12:07:24PM -0700, Axel Rasmussen wrote:
>> On Thu, Mar 30, 2023 at 9:06 AM Peter Xu <peterx@redhat.com> wrote:
>>>
>>> Dump a summary after running whatever test specified.  Useful for human
>>> runners to identify any kind of failures (besides exit code).
>>>
>>> Signed-off-by: Peter Xu <peterx@redhat.com>
>>> ---
>>>   tools/testing/selftests/mm/run_vmtests.sh | 8 ++++++++
>>>   1 file changed, 8 insertions(+)
>>>
>>> diff --git a/tools/testing/selftests/mm/run_vmtests.sh b/tools/testing/selftests/mm/run_vmtests.sh
>>> index c0f93b668c0c..9cc33984aa9f 100644
>>> --- a/tools/testing/selftests/mm/run_vmtests.sh
>>> +++ b/tools/testing/selftests/mm/run_vmtests.sh
>>> @@ -5,6 +5,9 @@
>>>   # Kselftest framework requirement - SKIP code is 4.
>>>   ksft_skip=4
>>>
>>> +count_pass=0
>>> +count_fail=0
>>> +count_skip=0
>>>   exitcode=0
>>>
>>>   usage() {
>>> @@ -149,11 +152,14 @@ run_test() {
>>>                  "$@"
>>>                  local ret=$?
>>>                  if [ $ret -eq 0 ]; then
>>> +                       count_pass=$(( $count_pass + 1 ))
>>
>> Actually, inside $(( )) there's no need to prefix variable names with
>> $ too. Running "shellcheck" over the script written this way will
>> generate a warning.
>>
>> Same applies below.
> 
> Sure, I'll fix.

With that

Reviewed-by: David Hildenbrand <david@redhat.com>
  
Mike Rapoport April 7, 2023, 9:15 a.m. UTC | #4
On Thu, Mar 30, 2023 at 12:06:46PM -0400, Peter Xu wrote:
> Dump a summary after running whatever test specified.  Useful for human
> runners to identify any kind of failures (besides exit code).
> 
> Signed-off-by: Peter Xu <peterx@redhat.com>

Reviewed-by: Mike Rapoport (IBM) <rppt@kernel.org>

> ---
>  tools/testing/selftests/mm/run_vmtests.sh | 8 ++++++++
>  1 file changed, 8 insertions(+)
> 
> diff --git a/tools/testing/selftests/mm/run_vmtests.sh b/tools/testing/selftests/mm/run_vmtests.sh
> index c0f93b668c0c..9cc33984aa9f 100644
> --- a/tools/testing/selftests/mm/run_vmtests.sh
> +++ b/tools/testing/selftests/mm/run_vmtests.sh
> @@ -5,6 +5,9 @@
>  # Kselftest framework requirement - SKIP code is 4.
>  ksft_skip=4
> 
> +count_pass=0
> +count_fail=0
> +count_skip=0
>  exitcode=0
> 
>  usage() {
> @@ -149,11 +152,14 @@ run_test() {
>  		"$@"
>  		local ret=$?
>  		if [ $ret -eq 0 ]; then
> +			count_pass=$(( $count_pass + 1 ))
>  			echo "[PASS]"
>  		elif [ $ret -eq $ksft_skip ]; then
> +			count_skip=$(( $count_skip + 1 ))
>  			echo "[SKIP]"
>  			exitcode=$ksft_skip
>  		else
> +			count_fail=$(( $count_fail + 1 ))
>  			echo "[FAIL]"
>  			exitcode=1
>  		fi
> @@ -279,4 +285,6 @@ CATEGORY="soft_dirty" run_test ./soft-dirty
>  # COW tests
>  CATEGORY="cow" run_test ./cow
> 
> +echo "SUMMARY: PASS=${count_pass} SKIP=${count_skip} FAIL=${count_fail}"
> +
>  exit $exitcode
> -- 
> 2.39.1
>
  

Patch

diff --git a/tools/testing/selftests/mm/run_vmtests.sh b/tools/testing/selftests/mm/run_vmtests.sh
index c0f93b668c0c..9cc33984aa9f 100644
--- a/tools/testing/selftests/mm/run_vmtests.sh
+++ b/tools/testing/selftests/mm/run_vmtests.sh
@@ -5,6 +5,9 @@ 
 # Kselftest framework requirement - SKIP code is 4.
 ksft_skip=4
 
+count_pass=0
+count_fail=0
+count_skip=0
 exitcode=0
 
 usage() {
@@ -149,11 +152,14 @@  run_test() {
 		"$@"
 		local ret=$?
 		if [ $ret -eq 0 ]; then
+			count_pass=$(( $count_pass + 1 ))
 			echo "[PASS]"
 		elif [ $ret -eq $ksft_skip ]; then
+			count_skip=$(( $count_skip + 1 ))
 			echo "[SKIP]"
 			exitcode=$ksft_skip
 		else
+			count_fail=$(( $count_fail + 1 ))
 			echo "[FAIL]"
 			exitcode=1
 		fi
@@ -279,4 +285,6 @@  CATEGORY="soft_dirty" run_test ./soft-dirty
 # COW tests
 CATEGORY="cow" run_test ./cow
 
+echo "SUMMARY: PASS=${count_pass} SKIP=${count_skip} FAIL=${count_fail}"
+
 exit $exitcode