Linux Kernel Selftest development
 help / color / mirror / Atom feed
* [PATCH v2] selftests: openat2: don't print total number of tests and then skip
@ 2024-07-31 13:39 Muhammad Usama Anjum
  2024-07-31 14:58 ` Aleksa Sarai
  2024-07-31 16:57 ` Shuah Khan
  0 siblings, 2 replies; 9+ messages in thread
From: Muhammad Usama Anjum @ 2024-07-31 13:39 UTC (permalink / raw)
  To: Shuah Khan, Muhammad Usama Anjum
  Cc: Aleksa Sarai, kernel, linux-kselftest, linux-kernel

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

Signed-off-by: Muhammad Usama Anjum <usama.anjum@collabora.com>
---
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(-)

diff --git a/tools/testing/selftests/openat2/resolve_test.c b/tools/testing/selftests/openat2/resolve_test.c
index bbafad440893c..85a4c64ee950d 100644
--- a/tools/testing/selftests/openat2/resolve_test.c
+++ b/tools/testing/selftests/openat2/resolve_test.c
@@ -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)
-- 
2.39.2


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

end of thread, other threads:[~2024-08-02 23:10 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-31 13:39 [PATCH v2] selftests: openat2: don't print total number of tests and then skip Muhammad Usama Anjum
2024-07-31 14:58 ` Aleksa Sarai
2024-07-31 16:57 ` Shuah Khan
2024-08-01  8:42   ` Muhammad Usama Anjum
2024-08-01 16:27     ` Shuah Khan
2024-08-01 17:27       ` Shuah Khan
2024-08-02  5:40         ` Muhammad Usama Anjum
2024-08-02  5:38       ` Muhammad Usama Anjum
2024-08-02 23:10         ` Shuah Khan

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