Skip to contentSkip to conversation

selftests: Warn about skipped tests in result summary

PATCH Superseded Laura Nao 3 participants 4 messages Nov 22, 2024 – Nov 25, 2024 Kselftest

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Laura Nao

author
#0 lore raw

PATCH 1/1 selftests: Warn about skipped tests in result summary

Update the functions that print the test totals at the end of a selftest to include a warning message when skipped tests are detected. The message advises users that skipped tests may indicate missing configuration options and suggests enabling them to improve coverage.

---
This patch follows up on a previous discussion[1] and aims to highlight skipped tests for the user's attention.

[1] https://lore.kernel.org/lkml/[email protected]/

---
 tools/testing/selftests/kselftest.h               | 4 ++++
 tools/testing/selftests/kselftest/ksft.py         | 3 +++
 tools/testing/selftests/kselftest/ktap_helpers.sh | 4 ++++
 3 files changed, 11 insertions(+)
tools/testing/selftests/kselftest.h +4 -0
index 29fedf609611..d3f64b333acd 100644
@@ -147,6 +147,10 @@ static inline void ksft_set_plan(unsigned int plan)
 
 static inline void ksft_print_cnts(void)
 {
+	if (ksft_cnt.ksft_xskip > 0)
+		printf(
+			"# Skipped tests detected. Consider enabling relevant config options to improve coverage.\n"
+		);
 	if (ksft_plan != ksft_test_num())
 		printf("# Planned tests != run tests (%u != %u)\n",
 			ksft_plan, ksft_test_num());
tools/testing/selftests/kselftest/ksft.py +3 -0
index bf215790a89d..7675a15a1264 100644
@@ -27,6 +27,9 @@ def set_plan(num_tests):
 
 
 def print_cnts():
+    if ksft_cnt['skip'] > 0:
+        print("# Skipped tests detected. Consider enabling relevant config options to improve coverage.")
+
     print(
         f"# Totals: pass:{ksft_cnt['pass']} fail:{ksft_cnt['fail']} xfail:0 xpass:0 skip:{ksft_cnt['skip']} error:0"
     )
tools/testing/selftests/kselftest/ktap_helpers.sh +4 -0
index 79a125eb24c2..a4211221ccd6 100644
@@ -107,5 +107,9 @@ ktap_finished() {
 }
 
 ktap_print_totals() {
+	if [ "$KTAP_CNT_SKIP" -gt 0 ]; then
+		echo "# Skipped tests detected. " \
+			"Consider enabling relevant config options to improve coverage."
+	fi
 	echo "# Totals: pass:$KTAP_CNT_PASS fail:$KTAP_CNT_FAIL xfail:0 xpass:0 skip:$KTAP_CNT_SKIP error:0"
 }
Signature · 1 line
2.30.2
maintainer
#1 lore raw
Quoted 22 lines · Laura Nao

Update the functions that print the test totals at the end of a selftest to include a warning message when skipped tests are detected. The message advises users that skipped tests may indicate missing configuration options and suggests enabling them to improve coverage.

---
This patch follows up on a previous discussion[1] and aims to highlight skipped tests for the user's attention.

[1] https://lore.kernel.org/lkml/[email protected]/

---
  tools/testing/selftests/kselftest.h               | 4 ++++
  tools/testing/selftests/kselftest/ksft.py         | 3 +++
  tools/testing/selftests/kselftest/ktap_helpers.sh | 4 ++++
  3 files changed, 11 insertions(+)
tools/testing/selftests/kselftest.h +0 -0
index 29fedf609611..d3f64b333acd 100644

tools/testing/selftests/kselftest.h static inline void ksft_set_plan(unsigned int plan) · line 152

Quoted 6 lines
tools/testing/selftests/kselftest.h +3 -0
@@ -147,6 +147,10 @@ static inline void ksft_set_plan(unsigned int plan)
 
  static inline void ksft_print_cnts(void)
  {
+	if (ksft_cnt.ksft_xskip > 0)
+		printf(
+			"# Skipped tests detected. Consider enabling relevant config options to improve coverage.\n"

I like this. How about printing the number of skipped tests in this message also to make it easy to parse.

Same comment on other print messages,

Quoted 23 lines
tools/testing/selftests/kselftest.h +1 -0
+		);
  	if (ksft_plan != ksft_test_num())
  		printf("# Planned tests != run tests (%u != %u)\n",
  			ksft_plan, ksft_test_num());
tools/testing/selftests/kselftest/ksft.py +3 -0
index bf215790a89d..7675a15a1264 100644
@@ -27,6 +27,9 @@ def set_plan(num_tests):
 
 
  def print_cnts():
+    if ksft_cnt['skip'] > 0:
+        print("# Skipped tests detected. Consider enabling relevant config options to improve coverage.")
+
      print(
          f"# Totals: pass:{ksft_cnt['pass']} fail:{ksft_cnt['fail']} xfail:0 xpass:0 skip:{ksft_cnt['skip']} error:0"
      )
tools/testing/selftests/kselftest/ktap_helpers.sh +0 -0
index 79a125eb24c2..a4211221ccd6 100644

tools/testing/selftests/kselftest/ktap_helpers.sh ktap_finished() { · line 115

Quoted 9 lines
tools/testing/selftests/kselftest/ktap_helpers.sh +4 -0
@@ -107,5 +107,9 @@ ktap_finished() {
  }
 
  ktap_print_totals() {
+	if [ "$KTAP_CNT_SKIP" -gt 0 ]; then
+		echo "# Skipped tests detected. " \
+			"Consider enabling relevant config options to improve coverage."
+	fi
  	echo "# Totals: pass:$KTAP_CNT_PASS fail:$KTAP_CNT_FAIL xfail:0 xpass:0 skip:$KTAP_CNT_SKIP error:0"
  }

thanks,
-- Shuah

#2 lore raw

Hi Laura,

Thank you for making change.

Quoted 18 lines · Shuah
Quoted 17 lines · Laura Nao

Update the functions that print the test totals at the end of a selftest to include a warning message when skipped tests are detected. The message advises users that skipped tests may indicate missing configuration options and suggests enabling them to improve coverage.

---
This patch follows up on a previous discussion[1] and aims to highlight skipped tests for the user's attention.

[1] https://lore.kernel.org/lkml/[email protected]/
---
  tools/testing/selftests/kselftest.h               | 4 ++++ tools/testing/selftests/kselftest/ksft.py         | 3 +++ tools/testing/selftests/kselftest/ktap_helpers.sh | 4 ++++

  3 files changed, 11 insertions(+)
Quoted 10 lines

tools/testing/selftests/kselftest.h static inline void ksft_set_plan(unsigned int plan) · line 151

Quoted 10 lines
tools/testing/selftests/kselftest.h +3 -0
index 29fedf609611..d3f64b333acd 100644
@@ -147,6 +147,10 @@ static inline void ksft_set_plan(unsigned int plan)
     static inline void ksft_print_cnts(void)
   {
+    if (ksft_cnt.ksft_xskip > 0)
+        printf(
+            "# Skipped tests detected. Consider enabling relevant config options to improve coverage.\n"

Looks good. Printing the number of skipped tests would be an improvement. I'm thinking about a case where some tests got failed and some skipped. Would this warning be useful in that case?

Quoted 39 lines

I like this. How about printing the number of skipped tests in this message also to make it easy to parse.

Same comment on other print messages,

Quoted 27 lines
tools/testing/selftests/kselftest.h +1 -0
+        );
       if (ksft_plan != ksft_test_num())
           printf("# Planned tests != run tests (%u != %u)\n",
               ksft_plan, ksft_test_num());
tools/testing/selftests/kselftest/ksft.py +0 -0
index bf215790a89d..7675a15a1264 100644
@@ -27,6 +27,9 @@ def set_plan(num_tests):

      def print_cnts():
+    if ksft_cnt['skip'] > 0:
+        print("# Skipped tests detected. Consider enabling relevant config options to improve coverage.") +
      print(
          f"# Totals: pass:{ksft_cnt['pass']} fail:{ksft_cnt['fail']} xfail:0 xpass:0 skip:{ksft_cnt['skip']} error:0" )

tools/testing/selftests/kselftest/ktap_helpers.sh +4 -0
index 79a125eb24c2..a4211221ccd6 100644
@@ -107,5 +107,9 @@ ktap_finished() {
   }
     ktap_print_totals() {
+    if [ "$KTAP_CNT_SKIP" -gt 0 ]; then
+        echo "# Skipped tests detected. " \
+            "Consider enabling relevant config options to improve coverage."
+    fi
Quoted 2 lines

      echo "# Totals: pass:$KTAP_CNT_PASS fail:$KTAP_CNT_FAIL xfail:0 xpass:0 skip:$KTAP_CNT_SKIP error:0" }

thanks,
-- Shuah

Signature · 2 lines
BR,
Muhammad Usama Anjum
author
#3 lore raw

Hi Shuah and Usama,

Quoted 23 lines · Muhammad Usama Anjum

Hi Laura,

Thank you for making change.

Quoted 18 lines · Shuah
Quoted 17 lines · Laura Nao

Update the functions that print the test totals at the end of a selftest to include a warning message when skipped tests are detected. The message advises users that skipped tests may indicate missing configuration options and suggests enabling them to improve coverage.

---
This patch follows up on a previous discussion[1] and aims to highlight skipped tests for the user's attention.

[1] https://lore.kernel.org/lkml/[email protected]/

---
   tools/testing/selftests/kselftest.h               | 4 ++++
   tools/testing/selftests/kselftest/ksft.py         | 3 +++
   tools/testing/selftests/kselftest/ktap_helpers.sh | 4 ++++
   3 files changed, 11 insertions(+)
Quoted 14 lines
Quoted 10 lines

tools/testing/selftests/kselftest.h static inline void ksft_set_plan(unsigned int plan) · line 151

Quoted 10 lines
tools/testing/selftests/kselftest.h +3 -0
index 29fedf609611..d3f64b333acd 100644
@@ -147,6 +147,10 @@ static inline void ksft_set_plan(unsigned int plan)
     static inline void ksft_print_cnts(void)
   {
+    if (ksft_cnt.ksft_xskip > 0)
+        printf(
+            "# Skipped tests detected. Consider enabling relevant config options to improve coverage.\n"

Looks good. Printing the number of skipped tests would be an improvement. I'm thinking about a case where some tests got failed and some skipped. Would this warning be useful in that case?

I believe the warning remains useful, as it helps users identify possible gaps in their configuration - I think that's valuable regardless of the results of other tests.

Quoted 6 lines
Quoted 6 lines

I like this. How about printing the number of skipped tests in this message also to make it easy to parse.

Same comment on other print messages,

Sure, that makes sense. I'll submit a v2 to include the number of skipped tests.

Quoted 25 lines
Quoted 25 lines
Quoted 25 lines
tools/testing/selftests/kselftest.h +1 -0
+        );
       if (ksft_plan != ksft_test_num())
           printf("# Planned tests != run tests (%u != %u)\n",
               ksft_plan, ksft_test_num());
tools/testing/selftests/kselftest/ksft.py +3 -0
index bf215790a89d..7675a15a1264 100644
@@ -27,6 +27,9 @@ def set_plan(num_tests):
       def print_cnts():
+    if ksft_cnt['skip'] > 0:
+        print("# Skipped tests detected. Consider enabling relevant config options to improve coverage.")
+
       print(
           f"# Totals: pass:{ksft_cnt['pass']} fail:{ksft_cnt['fail']} xfail:0 xpass:0 skip:{ksft_cnt['skip']} error:0"
       )
tools/testing/selftests/kselftest/ktap_helpers.sh +2 -0
index 79a125eb24c2..a4211221ccd6 100644
@@ -107,5 +107,9 @@ ktap_finished() {
   }
     ktap_print_totals() {
+    if [ "$KTAP_CNT_SKIP" -gt 0 ]; then
+        echo "# Skipped tests detected. " \
Quoted 9 lines
Quoted 8 lines

tools/testing/selftests/kselftest/ktap_helpers.sh ktap_finished() { · line 115

Quoted 4 lines
tools/testing/selftests/kselftest/ktap_helpers.sh +2 -0
+            "Consider enabling relevant config options to improve coverage."
+    fi
       echo "# Totals: pass:$KTAP_CNT_PASS fail:$KTAP_CNT_FAIL xfail:0 xpass:0 skip:$KTAP_CNT_SKIP error:0"
   }

thanks,
-- Shuah

Thanks,

Laura