Skip to contentSkip to conversation

selftests: ksft: Fix finished() helper exit code on skipped tests

PATCH In review Laura Nao 3 participants 3 messages Jul 30, 2024 – Jul 31, 2024 Kselftest

lore
Share & tools
lore

Laura Nao

author
#0 lore raw

PATCH v2 1/1 selftests: ksft: Fix finished() helper exit code on skipped tests

The Python finished() helper currently exits with KSFT_FAIL when there are only passed and skipped tests. Fix the logic to exit with KSFT_PASS instead, making it consistent with its C and bash counterparts (ksft_finished() and ktap_finished() respectively).

Fixes dacf1d7a78bf ("kselftest: Add test to verify probe of devices from discoverable buses")

---
This is a revised version of the patch initially submitted as "[PATCH]
selftests: ksft: Track skipped tests when finishing the test suite":
https://lore.kernel.org/all/[email protected]/

Depends on "[PATCH v2 2/3] kselftest: Move ksft helper module to common directory":
https://lore.kernel.org/all/[email protected]/
(picked through the usb tree, queued for 6.11-rc1)

Changes in v2:
- Reworded the commit title and message to more accurately describe the incorrect behavior of the finished() helper addressed by the patch.

---
 tools/testing/selftests/kselftest/ksft.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/kselftest/ksft.py +1 -1
index cd89fb2bc10e..bf215790a89d 100644
@@ -70,7 +70,7 @@ def test_result(condition, description=""):
 
 
 def finished():
-    if ksft_cnt["pass"] == ksft_num_tests:
+    if ksft_cnt["pass"] + ksft_cnt["skip"] == ksft_num_tests:
         exit_code = KSFT_PASS
     else:
         exit_code = KSFT_FAIL
Signature · 1 line
2.30.2
Reviewed-by on v2 1/1
#1 lore raw
Quoted 8 lines · Laura Nao

The Python finished() helper currently exits with KSFT_FAIL when there are only passed and skipped tests. Fix the logic to exit with KSFT_PASS instead, making it consistent with its C and bash counterparts (ksft_finished() and ktap_finished() respectively).

Fixes dacf1d7a78bf ("kselftest: Add test to verify probe of devices from discoverable buses")
Quoted 22 lines

---
This is a revised version of the patch initially submitted as "[PATCH]
selftests: ksft: Track skipped tests when finishing the test suite":
https://lore.kernel.org/all/[email protected]/

Depends on "[PATCH v2 2/3] kselftest: Move ksft helper module to common directory":
https://lore.kernel.org/all/[email protected]/
(picked through the usb tree, queued for 6.11-rc1)

Changes in v2:
- Reworded the commit title and message to more accurately describe the incorrect behavior of the finished() helper addressed by the patch.

---
 tools/testing/selftests/kselftest/ksft.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/kselftest/ksft.py +0 -0
index cd89fb2bc10e..bf215790a89d 100644

tools/testing/selftests/kselftest/ksft.py def test_result(condition, description=""): · line 73

Quoted 5 lines
tools/testing/selftests/kselftest/ksft.py +1 -1
@@ -70,7 +70,7 @@ def test_result(condition, description=""):
 
 
 def finished():
-    if ksft_cnt["pass"] == ksft_num_tests:
+    if ksft_cnt["pass"] + ksft_cnt["skip"] == ksft_num_tests:

LGTM

Quoted 3 lines
tools/testing/selftests/kselftest/ksft.py +0 -0
         exit_code = KSFT_PASS
     else:
         exit_code = KSFT_FAIL
Signature · 2 lines
BR,
Muhammad Usama Anjum
maintainer
#2 lore raw
Quoted 6 lines · Muhammad Usama Anjum
Quoted 5 lines · Laura Nao

The Python finished() helper currently exits with KSFT_FAIL when there are only passed and skipped tests. Fix the logic to exit with KSFT_PASS instead, making it consistent with its C and bash counterparts (ksft_finished() and ktap_finished() respectively).

Quoted 18 lines
Quoted 3 lines
Fixes dacf1d7a78bf ("kselftest: Add test to verify probe of devices from discoverable buses")
Quoted 13 lines

---
This is a revised version of the patch initially submitted as "[PATCH]
selftests: ksft: Track skipped tests when finishing the test suite":
https://lore.kernel.org/all/[email protected]/

Depends on "[PATCH v2 2/3] kselftest: Move ksft helper module to common directory":
https://lore.kernel.org/all/[email protected]/
(picked through the usb tree, queued for 6.11-rc1)

Changes in v2:
- Reworded the commit title and message to more accurately describe the incorrect behavior of the finished() helper addressed by the patch.

Thank you - Applied to linux-kselftest fixes for Linux 6.11-rc2

thanks,
-- Shuah