Linux Kernel Selftest development
 help / color / mirror / Atom feed
* [PATCH] selftests: firmware: conform test to TAP
@ 2024-05-20 16:37 Muhammad Usama Anjum
  2024-07-01  8:33 ` Muhammad Usama Anjum
  0 siblings, 1 reply; 3+ messages in thread
From: Muhammad Usama Anjum @ 2024-05-20 16:37 UTC (permalink / raw)
  To: Shuah Khan, Muhammad Usama Anjum; +Cc: kernel, linux-kselftest, linux-kernel

Conform the layout, informational and status messages to TAP. No
functional change is intended other than the layout of output messages.
Without using TAP messages, the passed/failed/skip test names cannot be
found. This is a prepartory patch, more patches will be sent to comform
the test completely.

Signed-off-by: Muhammad Usama Anjum <usama.anjum@collabora.com>
---
 .../selftests/firmware/fw_run_tests.sh        | 63 ++++++++++++-------
 1 file changed, 40 insertions(+), 23 deletions(-)

diff --git a/tools/testing/selftests/firmware/fw_run_tests.sh b/tools/testing/selftests/firmware/fw_run_tests.sh
index f6d95a2d51249..5063c75345680 100755
--- a/tools/testing/selftests/firmware/fw_run_tests.sh
+++ b/tools/testing/selftests/firmware/fw_run_tests.sh
@@ -6,6 +6,9 @@
 
 set -e
 
+DIR="$(dirname $(readlink -f "$0"))"
+source "${DIR}"/../kselftest/ktap_helpers.sh
+
 TEST_DIR=$(dirname $0)
 source $TEST_DIR/fw_lib.sh
 
@@ -26,54 +29,68 @@ run_tests()
 	proc_set_force_sysfs_fallback $1
 	proc_set_ignore_sysfs_fallback $2
 	$TEST_DIR/fw_upload.sh
+
+	ktap_test_pass "Completed"
 }
 
 run_test_config_0001()
 {
-	echo "-----------------------------------------------------"
-	echo "Running kernel configuration test 1 -- rare"
-	echo "Emulates:"
-	echo "CONFIG_FW_LOADER=y"
-	echo "CONFIG_FW_LOADER_USER_HELPER=n"
-	echo "CONFIG_FW_LOADER_USER_HELPER_FALLBACK=n"
+	ktap_print_msg "-----------------------------------------------------"
+	ktap_print_msg "Running kernel configuration test 1 -- rare"
+	ktap_print_msg "Emulates:"
+	ktap_print_msg "CONFIG_FW_LOADER=y"
+	ktap_print_msg "CONFIG_FW_LOADER_USER_HELPER=n"
+	ktap_print_msg "CONFIG_FW_LOADER_USER_HELPER_FALLBACK=n"
 	run_tests 0 1
 }
 
 run_test_config_0002()
 {
-	echo "-----------------------------------------------------"
-	echo "Running kernel configuration test 2 -- distro"
-	echo "Emulates:"
-	echo "CONFIG_FW_LOADER=y"
-	echo "CONFIG_FW_LOADER_USER_HELPER=y"
-	echo "CONFIG_FW_LOADER_USER_HELPER_FALLBACK=n"
+	ktap_print_msg "-----------------------------------------------------"
+	ktap_print_msg "Running kernel configuration test 2 -- distro"
+	ktap_print_msg "Emulates:"
+	ktap_print_msg "CONFIG_FW_LOADER=y"
+	ktap_print_msg "CONFIG_FW_LOADER_USER_HELPER=y"
+	ktap_print_msg "CONFIG_FW_LOADER_USER_HELPER_FALLBACK=n"
 	proc_set_ignore_sysfs_fallback 0
 	run_tests 0 0
 }
 
 run_test_config_0003()
 {
-	echo "-----------------------------------------------------"
-	echo "Running kernel configuration test 3 -- android"
-	echo "Emulates:"
-	echo "CONFIG_FW_LOADER=y"
-	echo "CONFIG_FW_LOADER_USER_HELPER=y"
-	echo "CONFIG_FW_LOADER_USER_HELPER_FALLBACK=y"
+	ktap_print_msg "-----------------------------------------------------"
+	ktap_print_msg "Running kernel configuration test 3 -- android"
+	ktap_print_msg "Emulates:"
+	ktap_print_msg "CONFIG_FW_LOADER=y"
+	ktap_print_msg "CONFIG_FW_LOADER_USER_HELPER=y"
+	ktap_print_msg "CONFIG_FW_LOADER_USER_HELPER_FALLBACK=y"
 	run_tests 1 0
 }
 
+ktap_print_header
+
 check_mods
 check_setup
 
-echo "Running namespace test: "
-$TEST_DIR/fw_namespace $DIR/trigger_request
-echo "OK"
-
 if [ -f $FW_FORCE_SYSFS_FALLBACK ]; then
+	ktap_set_plan "4"
+
 	run_test_config_0001
 	run_test_config_0002
 	run_test_config_0003
 else
-	echo "Running basic kernel configuration, working with your config"
+	ktap_set_plan "2"
+
+	ktap_print_msg "Running basic kernel configuration, working with your config"
 	run_tests
 fi
+
+ktap_print_msg "Running namespace test: "
+$TEST_DIR/fw_namespace $DIR/trigger_request
+if [ $? -eq 0 ]; then
+    ktap_test_pass "fw_namespace completed successfully"
+else
+    ktap_test_fail "fw_namespace failed"
+fi
+
+ktap_finished
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] selftests: firmware: conform test to TAP
  2024-05-20 16:37 [PATCH] selftests: firmware: conform test to TAP Muhammad Usama Anjum
@ 2024-07-01  8:33 ` Muhammad Usama Anjum
  2024-07-10 18:13   ` Shuah Khan
  0 siblings, 1 reply; 3+ messages in thread
From: Muhammad Usama Anjum @ 2024-07-01  8:33 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Kees Cook
  Cc: Muhammad Usama Anjum, kernel, linux-kselftest, linux-kernel,
	Shuah Khan

Adding missing maintainer and reviser.

On 5/20/24 9:37 PM, Muhammad Usama Anjum wrote:
> Conform the layout, informational and status messages to TAP. No
> functional change is intended other than the layout of output messages.
> Without using TAP messages, the passed/failed/skip test names cannot be
> found. This is a prepartory patch, more patches will be sent to comform
> the test completely.
> 
> Signed-off-by: Muhammad Usama Anjum <usama.anjum@collabora.com>
> ---
>  .../selftests/firmware/fw_run_tests.sh        | 63 ++++++++++++-------
>  1 file changed, 40 insertions(+), 23 deletions(-)
> 
> diff --git a/tools/testing/selftests/firmware/fw_run_tests.sh b/tools/testing/selftests/firmware/fw_run_tests.sh
> index f6d95a2d51249..5063c75345680 100755
> --- a/tools/testing/selftests/firmware/fw_run_tests.sh
> +++ b/tools/testing/selftests/firmware/fw_run_tests.sh
> @@ -6,6 +6,9 @@
>  
>  set -e
>  
> +DIR="$(dirname $(readlink -f "$0"))"
> +source "${DIR}"/../kselftest/ktap_helpers.sh
> +
>  TEST_DIR=$(dirname $0)
>  source $TEST_DIR/fw_lib.sh
>  
> @@ -26,54 +29,68 @@ run_tests()
>  	proc_set_force_sysfs_fallback $1
>  	proc_set_ignore_sysfs_fallback $2
>  	$TEST_DIR/fw_upload.sh
> +
> +	ktap_test_pass "Completed"
>  }
>  
>  run_test_config_0001()
>  {
> -	echo "-----------------------------------------------------"
> -	echo "Running kernel configuration test 1 -- rare"
> -	echo "Emulates:"
> -	echo "CONFIG_FW_LOADER=y"
> -	echo "CONFIG_FW_LOADER_USER_HELPER=n"
> -	echo "CONFIG_FW_LOADER_USER_HELPER_FALLBACK=n"
> +	ktap_print_msg "-----------------------------------------------------"
> +	ktap_print_msg "Running kernel configuration test 1 -- rare"
> +	ktap_print_msg "Emulates:"
> +	ktap_print_msg "CONFIG_FW_LOADER=y"
> +	ktap_print_msg "CONFIG_FW_LOADER_USER_HELPER=n"
> +	ktap_print_msg "CONFIG_FW_LOADER_USER_HELPER_FALLBACK=n"
>  	run_tests 0 1
>  }
>  
>  run_test_config_0002()
>  {
> -	echo "-----------------------------------------------------"
> -	echo "Running kernel configuration test 2 -- distro"
> -	echo "Emulates:"
> -	echo "CONFIG_FW_LOADER=y"
> -	echo "CONFIG_FW_LOADER_USER_HELPER=y"
> -	echo "CONFIG_FW_LOADER_USER_HELPER_FALLBACK=n"
> +	ktap_print_msg "-----------------------------------------------------"
> +	ktap_print_msg "Running kernel configuration test 2 -- distro"
> +	ktap_print_msg "Emulates:"
> +	ktap_print_msg "CONFIG_FW_LOADER=y"
> +	ktap_print_msg "CONFIG_FW_LOADER_USER_HELPER=y"
> +	ktap_print_msg "CONFIG_FW_LOADER_USER_HELPER_FALLBACK=n"
>  	proc_set_ignore_sysfs_fallback 0
>  	run_tests 0 0
>  }
>  
>  run_test_config_0003()
>  {
> -	echo "-----------------------------------------------------"
> -	echo "Running kernel configuration test 3 -- android"
> -	echo "Emulates:"
> -	echo "CONFIG_FW_LOADER=y"
> -	echo "CONFIG_FW_LOADER_USER_HELPER=y"
> -	echo "CONFIG_FW_LOADER_USER_HELPER_FALLBACK=y"
> +	ktap_print_msg "-----------------------------------------------------"
> +	ktap_print_msg "Running kernel configuration test 3 -- android"
> +	ktap_print_msg "Emulates:"
> +	ktap_print_msg "CONFIG_FW_LOADER=y"
> +	ktap_print_msg "CONFIG_FW_LOADER_USER_HELPER=y"
> +	ktap_print_msg "CONFIG_FW_LOADER_USER_HELPER_FALLBACK=y"
>  	run_tests 1 0
>  }
>  
> +ktap_print_header
> +
>  check_mods
>  check_setup
>  
> -echo "Running namespace test: "
> -$TEST_DIR/fw_namespace $DIR/trigger_request
> -echo "OK"
> -
>  if [ -f $FW_FORCE_SYSFS_FALLBACK ]; then
> +	ktap_set_plan "4"
> +
>  	run_test_config_0001
>  	run_test_config_0002
>  	run_test_config_0003
>  else
> -	echo "Running basic kernel configuration, working with your config"
> +	ktap_set_plan "2"
> +
> +	ktap_print_msg "Running basic kernel configuration, working with your config"
>  	run_tests
>  fi
> +
> +ktap_print_msg "Running namespace test: "
> +$TEST_DIR/fw_namespace $DIR/trigger_request
> +if [ $? -eq 0 ]; then
> +    ktap_test_pass "fw_namespace completed successfully"
> +else
> +    ktap_test_fail "fw_namespace failed"
> +fi
> +
> +ktap_finished

-- 
BR,
Muhammad Usama Anjum

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] selftests: firmware: conform test to TAP
  2024-07-01  8:33 ` Muhammad Usama Anjum
@ 2024-07-10 18:13   ` Shuah Khan
  0 siblings, 0 replies; 3+ messages in thread
From: Shuah Khan @ 2024-07-10 18:13 UTC (permalink / raw)
  To: Muhammad Usama Anjum, Greg Kroah-Hartman, Kees Cook
  Cc: kernel, linux-kselftest, linux-kernel, Shuah Khan, Shuah Khan

On 7/1/24 02:33, Muhammad Usama Anjum wrote:
> Adding missing maintainer and reviser.
> 
> On 5/20/24 9:37 PM, Muhammad Usama Anjum wrote:
>> Conform the layout, informational and status messages to TAP. No
>> functional change is intended other than the layout of output messages.
>> Without using TAP messages, the passed/failed/skip test names cannot be
>> found. This is a prepartory patch, more patches will be sent to comform
>> the test completely.

For these kinds of patches, I would like to see the output before and
after and justification on what these changes are necessary since there
are wrappers that add summary tap messages.

Sprinkling ktap messages in tests can make the output hard to read

thanks,
-- Shuah

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-07-10 18:13 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-20 16:37 [PATCH] selftests: firmware: conform test to TAP Muhammad Usama Anjum
2024-07-01  8:33 ` Muhammad Usama Anjum
2024-07-10 18:13   ` Shuah Khan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox