Skip to contentSkip to conversation

selftests: openat2: don't print total number of tests and then skip

PATCH In review Muhammad Usama Anjum 3 participants 9 messages Jul 31, 2024 – Aug 2, 2024 Kselftest

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 selftests: openat2: don't print total number of tests and then skip

Don't print that 88 sub-tests are going to be executed, but then skip. This is against TAP compliance. Instead check pre-requisites first before printing total number of tests.

Old non-tap compliant output:
TAP version 13
1..88
ok 2 # SKIP all tests require euid == 0
# Planned tests != run tests (88 != 1)
# Totals: pass:0 fail:0 xfail:0 xpass:0 skip:1 error:0

New and correct output:
TAP version 13
1..0 # SKIP all tests require euid == 0

---
Changes since v1:
- Remove simplifying if condition lines
- Update the patch message

---
 tools/testing/selftests/openat2/resolve_test.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
tools/testing/selftests/openat2/resolve_test.c +2 -1
index bbafad440893c..85a4c64ee950d 100644
@@ -508,12 +508,13 @@ void test_openat2_opath_tests(void)
 int main(int argc, char **argv)
 {
 	ksft_print_header();
-	ksft_set_plan(NUM_TESTS);
 
 	/* NOTE: We should be checking for CAP_SYS_ADMIN here... */
 	if (geteuid() != 0)
 		ksft_exit_skip("all tests require euid == 0\n");
 
+	ksft_set_plan(NUM_TESTS);
+
 	test_openat2_opath_tests();
 
 	if (ksft_get_fail_cnt() + ksft_get_error_cnt() > 0)
Signature · 1 line
2.39.2
Reviewed-by on v2 1/1
#1 lore raw
Quoted 15 lines · Muhammad Usama Anjum

Don't print that 88 sub-tests are going to be executed, but then skip. This is against TAP compliance. Instead check pre-requisites first before printing total number of tests.

Old non-tap compliant output:
TAP version 13
1..88
ok 2 # SKIP all tests require euid == 0
# Planned tests != run tests (88 != 1)
# Totals: pass:0 fail:0 xfail:0 xpass:0 skip:1 error:0

New and correct output:
TAP version 13
1..0 # SKIP all tests require euid == 0

Quoted 5 lines

---
Changes since v1:
- Remove simplifying if condition lines
- Update the patch message

Feel free to take my

Quoted 26 lines
---
 tools/testing/selftests/openat2/resolve_test.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
tools/testing/selftests/openat2/resolve_test.c +2 -1
index bbafad440893c..85a4c64ee950d 100644
@@ -508,12 +508,13 @@ void test_openat2_opath_tests(void)
 int main(int argc, char **argv)
 {
 	ksft_print_header();
-	ksft_set_plan(NUM_TESTS);
 
 	/* NOTE: We should be checking for CAP_SYS_ADMIN here... */
 	if (geteuid() != 0)
 		ksft_exit_skip("all tests require euid == 0\n");
 
+	ksft_set_plan(NUM_TESTS);
+
 	test_openat2_opath_tests();
 
 	if (ksft_get_fail_cnt() + ksft_get_error_cnt() > 0)
Signature · 1 line
2.39.2
Signature · 4 lines
Aleksa Sarai
Senior Software Engineer (Containers)
SUSE Linux GmbH
<https://www.cyphar.com/>
maintainer
#2 lore raw
In reply to Muhammad Usama Anjum
Quoted 3 lines · Muhammad Usama Anjum

Don't print that 88 sub-tests are going to be executed, but then skip. This is against TAP compliance. Instead check pre-requisites first before printing total number of tests.

Does TAP clearly mention this?

Quoted 11 lines

Old non-tap compliant output:

   TAP version 13
   1..88
   ok 2 # SKIP all tests require euid == 0
   # Planned tests != run tests (88 != 1)
   # Totals: pass:0 fail:0 xfail:0 xpass:0 skip:1 error:0

New and correct output:
TAP version 13
1..0 # SKIP all tests require euid == 0

The problem is that this new output doesn't show how many tests are in this test suite that could be run.

I am not use if this is better for communicating coverage information even if meets the TAP compliance.

Quoted 19 lines

---
Changes since v1:
- Remove simplifying if condition lines
- Update the patch message

---
  tools/testing/selftests/openat2/resolve_test.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
tools/testing/selftests/openat2/resolve_test.c +0 -1
index bbafad440893c..85a4c64ee950d 100644
@@ -508,12 +508,13 @@ void test_openat2_opath_tests(void)
  int main(int argc, char **argv)
  {
  	ksft_print_header();
-	ksft_set_plan(NUM_TESTS);

tools/testing/selftests/openat2/resolve_test.c void test_openat2_opath_tests(void) · line 520

Quoted 10 lines
tools/testing/selftests/openat2/resolve_test.c +2 -0
 
  	/* NOTE: We should be checking for CAP_SYS_ADMIN here... */
  	if (geteuid() != 0)
  		ksft_exit_skip("all tests require euid == 0\n");
 
+	ksft_set_plan(NUM_TESTS);
+
  	test_openat2_opath_tests();
 
  	if (ksft_get_fail_cnt() + ksft_get_error_cnt() > 0)

thanks,
-- Shuah

#3 lore raw
Quoted 6 lines · Shuah Khan
Quoted 3 lines · Muhammad Usama Anjum

Don't print that 88 sub-tests are going to be executed, but then skip. This is against TAP compliance. Instead check pre-requisites first before printing total number of tests.

Does TAP clearly mention this?

Yes from https://testanything.org/tap-version-13-specification.html

Skipping everything
This listing shows that the entire listing is a skip. No tests were run.

TAP version 13
1..0 # skip because English-to-French translator isn't installed

We can see above that we need to print 1..0 and skip without printing the total number of tests to be executed as they are going to be skipped.

Quoted 13 lines
Quoted 9 lines

Old non-tap compliant output:
   TAP version 13
   1..88
   ok 2 # SKIP all tests require euid == 0
   # Planned tests != run tests (88 != 1)
   # Totals: pass:0 fail:0 xfail:0 xpass:0 skip:1 error:0

Quoted 3 lines

New and correct output:
   TAP version 13
   1..0 # SKIP all tests require euid == 0

Quoted 5 lines

The problem is that this new output doesn't show how many tests are in this test suite that could be run.

I am not use if this is better for communicating coverage information even if meets the TAP compliance.

I think the number of tests represents the number of planned tests. If we don't plan to run X number of tests, we shouldn't print it.

Quoted 33 lines
Quoted 18 lines

---
Changes since v1:
- Remove simplifying if condition lines
- Update the patch message
---
  tools/testing/selftests/openat2/resolve_test.c | 3 ++-

  1 file changed, 2 insertions(+), 1 deletion(-)
tools/testing/selftests/openat2/resolve_test.c +0 -0
index bbafad440893c..85a4c64ee950d 100644
@@ -508,12 +508,13 @@ void test_openat2_opath_tests(void)
   int main(int argc, char **argv)

tools/testing/selftests/openat2/resolve_test.c void test_openat2_opath_tests(void) · line 517

Quoted 10 lines
tools/testing/selftests/openat2/resolve_test.c +1 -1
   {
       ksft_print_header();
-    ksft_set_plan(NUM_TESTS);
         /* NOTE: We should be checking for CAP_SYS_ADMIN here... */
       if (geteuid() != 0)
           ksft_exit_skip("all tests require euid == 0\n");
   +    ksft_set_plan(NUM_TESTS);
+
       test_openat2_opath_tests();
         if (ksft_get_fail_cnt() + ksft_get_error_cnt() > 0)

thanks,
-- Shuah

Signature · 2 lines
BR,
Muhammad Usama Anjum
maintainer
#4 lore raw
Quoted 6 lines · Muhammad Usama Anjum
Quoted 5 lines · Shuah Khan
Quoted 3 lines · Muhammad Usama Anjum

Don't print that 88 sub-tests are going to be executed, but then skip. This is against TAP compliance. Instead check pre-requisites first before printing total number of tests.

Quoted 8 lines
Quoted 1 line

Does TAP clearly mention this?

Yes from https://testanything.org/tap-version-13-specification.html

Skipping everything
This listing shows that the entire listing is a skip. No tests were run.

TAP version 13
1..0 # skip because English-to-French translator isn't installed

I don't see how this is applicable to the current scenario. The user needs to have root privilege to run the test.

It is important to mention how many tests could have been run. As mentioned before, this information is important for users and testers.

I would like to see this information in the output.

Quoted 16 lines

We can see above that we need to print 1..0 and skip without printing the total number of tests to be executed as they are going to be skipped.

Quoted 12 lines
Quoted 11 lines

Old non-tap compliant output:
   TAP version 13
   1..88
   ok 2 # SKIP all tests require euid == 0
   # Planned tests != run tests (88 != 1)>>>    # Totals: pass:0 fail:0 xfail:0 xpass:0 skip:1 error:0

New and correct output:
   TAP version 13
   1..0 # SKIP all tests require euid == 0

Quoted 7 lines
Quoted 5 lines

The problem is that this new output doesn't show how many tests are in this test suite that could be run.

I am not use if this is better for communicating coverage information even if meets the TAP compliance.

I think the number of tests represents the number of planned tests. If we don't plan to run X number of tests, we shouldn't print it.

88 tests are planned to be run except for the fact the first check failed.

Planned tests could not be run because of user privileges. So these tests are all skips because of unmet dependencies.

So the a good report would show that 88 tests could have been run. You can meet the specification and still make it work for us. When we adapt TAP 13 we didn't require 100% compliance.

There are cases where you can comply and still provide how many test could be run.

I think you are applying the spec strictly thereby removing useful information from the report.

Can you tell me what would fail because of this "non-compliance"?

thanks,
-- Shuah

maintainer
#5 lore raw
Quoted 7 lines · Shuah Khan
Quoted 6 lines · Muhammad Usama Anjum
Quoted 5 lines · Shuah Khan
Quoted 3 lines · Muhammad Usama Anjum

Don't print that 88 sub-tests are going to be executed, but then skip. This is against TAP compliance. Instead check pre-requisites first before printing total number of tests.

Quoted 9 lines
Quoted 8 lines
Quoted 1 line

Does TAP clearly mention this?

Yes from https://testanything.org/tap-version-13-specification.html

Skipping everything
This listing shows that the entire listing is a skip. No tests were run.

TAP version 13
1..0 # skip because English-to-French translator isn't installed

One more thing on TAP compliance - we don't strive to be TAP compliant as it doesn't meet our special needs.

It is important to keep the how many tests could be run to improve testing coverage.

Refer to: https://www.kernel.org/doc/html/latest/dev-tools/ktap.html

"The Linux Kernel largely uses TAP output for test results. However, Kernel testing frameworks have special needs for test results which don’t align with the original TAP specification. Thus, a “Kernel TAP” (KTAP) format is specified to extend and alter TAP to support these use-cases. This specification describes the generally accepted format of KTAP as it is currently used in the kernel."

I appreciate the effort you are putting into improving the reports. I request that you refer to the above document and also keep in mind what would help us improve our testing over focusing just on reports and compliance.

thanks,
-- Shuah

#6 lore raw
Quoted 34 lines · Shuah Khan
Quoted 7 lines · Shuah Khan
Quoted 6 lines · Muhammad Usama Anjum
Quoted 5 lines · Shuah Khan
Quoted 3 lines · Muhammad Usama Anjum

Don't print that 88 sub-tests are going to be executed, but then skip. This is against TAP compliance. Instead check pre-requisites first before printing total number of tests.

Quoted 9 lines
Quoted 8 lines
Quoted 1 line

Does TAP clearly mention this?

Yes from https://testanything.org/tap-version-13-specification.html

Skipping everything
This listing shows that the entire listing is a skip. No tests were run.

TAP version 13
1..0 # skip because English-to-French translator isn't installed

One more thing on TAP compliance - we don't strive to be TAP compliant as it doesn't meet our special needs.

It is important to keep the how many tests could be run to improve testing coverage.

Refer to: https://www.kernel.org/doc/html/latest/dev-tools/ktap.html

"The Linux Kernel largely uses TAP output for test results. However, Kernel testing frameworks have special needs for test results which don’t align with the original TAP specification. Thus, a “Kernel TAP” (KTAP) format is specified
to extend and alter TAP to support these use-cases. This specification describes
the generally accepted format of KTAP as it is currently used in the kernel."

Quoted 3 lines

I appreciate the effort you are putting into improving the reports. I request that you refer to the above document and also keep in mind what would help us improve our testing over focusing just on reports and compliance.

That makes sense. I'll work on improving the testing going forward.

Quoted 4 lines

thanks,
-- Shuah

Signature · 2 lines
BR,
Muhammad Usama Anjum
#7 lore raw
In reply to Shuah Khan
Quoted 46 lines · Shuah Khan
Quoted 6 lines · Muhammad Usama Anjum
Quoted 5 lines · Shuah Khan
Quoted 3 lines · Muhammad Usama Anjum

Don't print that 88 sub-tests are going to be executed, but then skip. This is against TAP compliance. Instead check pre-requisites first before printing total number of tests.

Quoted 8 lines
Quoted 1 line

Does TAP clearly mention this?

Yes from https://testanything.org/tap-version-13-specification.html

Skipping everything
This listing shows that the entire listing is a skip. No tests were run.

TAP version 13
1..0 # skip because English-to-French translator isn't installed

I don't see how this is applicable to the current scenario. The user needs to have root privilege to run the test.

It is important to mention how many tests could have been run. As mentioned before, this information is important for users and testers.

I would like to see this information in the output.

Quoted 22 lines

We can see above that we need to print 1..0 and skip without printing the total number of tests to be executed as they are going to be skipped.

Quoted 18 lines
Quoted 9 lines

Old non-tap compliant output:
    TAP version 13
    1..88
    ok 2 # SKIP all tests require euid == 0
    # Planned tests != run tests (88 != 1)>>>     # Totals: pass:0 fail:0 xfail:0 xpass:0 skip:1 error:0

Quoted 3 lines

New and correct output:
    TAP version 13
    1..0 # SKIP all tests require euid == 0

The problem is that this new output doesn't show how many tests are in this test suite that could be run.

I am not use if this is better for communicating coverage information even if meets the TAP compliance.

Quoted 8 lines
Quoted 2 lines

I think the number of tests represents the number of planned tests. If we don't plan to run X number of tests, we shouldn't print it.

88 tests are planned to be run except for the fact the first check failed.

Planned tests could not be run because of user privileges. So these tests are all skips because of unmet dependencies.

Agreed.

Quoted 5 lines

So the a good report would show that 88 tests could have been run. You can meet the specification and still make it work for us. When we adapt TAP 13 we didn't require 100% compliance.

Quoted 7 lines

There are cases where you can comply and still provide how many test could be run.

I think you are applying the spec strictly thereby removing useful information from the report.

Can you tell me what would fail because of this "non-compliance"?

Some months ago, someone had reported for one of my test that it says it is going to execute X number of tests. But then it just skips saying it couldn't run X tests and final footer of tests also didn't had the correct number of tests in it.

Quoted 2 lines

TAP version 13
1..88

This gives information that 88 tests are going to be executed.

Quoted 1 line

ok 2 # SKIP all tests require euid == 0

Why not ok 1 here?

Quoted 1 line

# Planned tests != run tests (88 != 1)

This gives a error occured signal instead of telling us that preconditions failed.

Quoted 1 line

# Totals: pass:0 fail:0 xfail:0 xpass:0 skip:1 error:0

The tests exit with KSFT_FAIL instead of KSFT_SKIP. This was the biggest concern from the report.

Quoted 8 lines

thanks,
-- Shuah

Signature · 2 lines
BR,
Muhammad Usama Anjum
maintainer
#8 lore raw
Quoted 69 lines · Muhammad Usama Anjum
Quoted 46 lines · Shuah Khan
Quoted 6 lines · Muhammad Usama Anjum
Quoted 5 lines · Shuah Khan
Quoted 3 lines · Muhammad Usama Anjum

Don't print that 88 sub-tests are going to be executed, but then skip. This is against TAP compliance. Instead check pre-requisites first before printing total number of tests.

Quoted 8 lines
Quoted 1 line

Does TAP clearly mention this?

Yes from https://testanything.org/tap-version-13-specification.html

Skipping everything
This listing shows that the entire listing is a skip. No tests were run.

TAP version 13
1..0 # skip because English-to-French translator isn't installed

I don't see how this is applicable to the current scenario. The user needs to have root privilege to run the test.

It is important to mention how many tests could have been run. As mentioned before, this information is important for users and testers.

I would like to see this information in the output.

Quoted 22 lines

We can see above that we need to print 1..0 and skip without printing the total number of tests to be executed as they are going to be skipped.

Quoted 18 lines
Quoted 9 lines

Old non-tap compliant output:
    TAP version 13
    1..88
    ok 2 # SKIP all tests require euid == 0
    # Planned tests != run tests (88 != 1)>>>     # Totals: pass:0
fail:0 xfail:0 xpass:0 skip:1 error:0

Quoted 3 lines

New and correct output:
    TAP version 13
    1..0 # SKIP all tests require euid == 0

The problem is that this new output doesn't show how many tests are in this test suite that could be run.

I am not use if this is better for communicating coverage information even if meets the TAP compliance.

Quoted 8 lines
Quoted 2 lines

I think the number of tests represents the number of planned tests. If we don't plan to run X number of tests, we shouldn't print it.

88 tests are planned to be run except for the fact the first check failed.

Planned tests could not be run because of user privileges. So these tests are all skips because of unmet dependencies.

Agreed.

Quoted 5 lines

So the a good report would show that 88 tests could have been run. You can meet the specification and still make it work for us. When we adapt TAP 13 we didn't require 100% compliance.

Quoted 7 lines

There are cases where you can comply and still provide how many test could be run.

I think you are applying the spec strictly thereby removing useful information from the report.

Can you tell me what would fail because of this "non-compliance"?

Quoted 9 lines

Some months ago, someone had reported for one of my test that it says it is going to execute X number of tests. But then it just skips saying it couldn't run X tests and final footer of tests also didn't had the correct number of tests in it.

Quoted 2 lines

TAP version 13
1..88

This gives information that 88 tests are going to be executed.

Quoted 1 line

ok 2 # SKIP all tests require euid == 0

I agree this should be 1 if we ran just one test.

Quoted 4 lines

Why not ok 1 here?

Quoted 1 line

# Planned tests != run tests (88 != 1)

This gives a error occured signal instead of telling us that preconditions failed.

This is correct. We report skip and don't fail when dependencies aren't met. If we did that it would be reporting false failures since tests couldn't run tests.

I have asked Laura to see if we can add a message to tell the user that we couldn't run tests that could have run so they can look at the config and make changes as needed to increase coverage of testing.

Quoted 1 line
Quoted 1 line

# Totals: pass:0 fail:0 xfail:0 xpass:0 skip:1 error:0

This is correct - it shows 1 skip and rest are zero.

Quoted 3 lines

The tests exit with KSFT_FAIL instead of KSFT_SKIP. This was the biggest concern from the report.

Exiting with KSFT_FAIL is the real problem that needs to be fixed. Please take a look to see why this is and send me the fix.

thanks,
-- Shuah