diff mbox series

[v1,1/4] kselftest/arm64: Handle more kselftest result codes in MTE helpers

Message ID 20220310144335.2097457-2-broonie@kernel.org (mailing list archive)
State Accepted
Commit 3f374d7972c48bc0824bdabb8f94fe82e54fd07d
Headers show
Series kselftest/arm64: Miscelaneous MTE test updates | expand

Commit Message

Mark Brown March 10, 2022, 2:43 p.m. UTC
The MTE selftests have a helper evaluate_test() which translates a return
code into a call to ksft_test_result_*(). Currently this only handles pass
and fail, silently ignoring any other code. Update the helper to support
skipped tests and log any unknown return codes as an error so we get at
least some diagnostic if anything goes wrong.

Signed-off-by: Mark Brown <broonie@kernel.org>
---
 .../testing/selftests/arm64/mte/mte_common_util.h | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

Comments

Shuah Khan March 10, 2022, 7:40 p.m. UTC | #1
On 3/10/22 7:43 AM, Mark Brown wrote:
> The MTE selftests have a helper evaluate_test() which translates a return
> code into a call to ksft_test_result_*(). Currently this only handles pass
> and fail, silently ignoring any other code. Update the helper to support
> skipped tests and log any unknown return codes as an error so we get at
> least some diagnostic if anything goes wrong.
> 
> Signed-off-by: Mark Brown <broonie@kernel.org>
> ---
>   .../testing/selftests/arm64/mte/mte_common_util.h | 15 +++++++++++++--
>   1 file changed, 13 insertions(+), 2 deletions(-)
> 
> diff --git a/tools/testing/selftests/arm64/mte/mte_common_util.h b/tools/testing/selftests/arm64/mte/mte_common_util.h
> index 195a7d1879e6..2d3e71724e55 100644
> --- a/tools/testing/selftests/arm64/mte/mte_common_util.h
> +++ b/tools/testing/selftests/arm64/mte/mte_common_util.h
> @@ -75,10 +75,21 @@ unsigned int mte_get_pstate_tco(void);
>   /* Test framework static inline functions/macros */
>   static inline void evaluate_test(int err, const char *msg)
>   {
> -	if (err == KSFT_PASS)
> +	switch (err) {
> +	case KSFT_PASS:
>   		ksft_test_result_pass(msg);
> -	else if (err == KSFT_FAIL)
> +		break;
> +	case KSFT_FAIL:
>   		ksft_test_result_fail(msg);
> +		break;
> +	case KSFT_SKIP:
> +		ksft_test_result_skip(msg);
> +		break;
> +	default:
> +		ksft_test_result_error("Unknown return code %d from %s",
> +				       err, msg);
> +		break;
> +	}
>   }
>   
>   static inline int check_allocated_memory(void *ptr, size_t size,
> 

Nice. Thank you for doing this.

Reviewed-by: Shuah Khan <skhan@linuxfoundation.org>

thanks,
-- Shuah
diff mbox series

Patch

diff --git a/tools/testing/selftests/arm64/mte/mte_common_util.h b/tools/testing/selftests/arm64/mte/mte_common_util.h
index 195a7d1879e6..2d3e71724e55 100644
--- a/tools/testing/selftests/arm64/mte/mte_common_util.h
+++ b/tools/testing/selftests/arm64/mte/mte_common_util.h
@@ -75,10 +75,21 @@  unsigned int mte_get_pstate_tco(void);
 /* Test framework static inline functions/macros */
 static inline void evaluate_test(int err, const char *msg)
 {
-	if (err == KSFT_PASS)
+	switch (err) {
+	case KSFT_PASS:
 		ksft_test_result_pass(msg);
-	else if (err == KSFT_FAIL)
+		break;
+	case KSFT_FAIL:
 		ksft_test_result_fail(msg);
+		break;
+	case KSFT_SKIP:
+		ksft_test_result_skip(msg);
+		break;
+	default:
+		ksft_test_result_error("Unknown return code %d from %s",
+				       err, msg);
+		break;
+	}
 }
 
 static inline int check_allocated_memory(void *ptr, size_t size,