diff mbox series

[net-next,1/4] selftests: kselftest_harness: pass step via shared memory

Message ID 20240213154416.422739-2-kuba@kernel.org (mailing list archive)
State New
Headers show
Series selftests: kselftest_harness: support using xfail | expand

Commit Message

Jakub Kicinski Feb. 13, 2024, 3:44 p.m. UTC
Commit 0ef67a888375 ("selftests/harness: Report skip reason")
added shared memory to communicate between harness and test.
Use that instead of exit codes to send the failing step back
to the harness. The exit codes are limited and because of
the step passing we can't use the full range of KSFT_* exit
codes.

Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
 tools/testing/selftests/kselftest_harness.h | 21 ++++++++++-----------
 1 file changed, 10 insertions(+), 11 deletions(-)

Comments

Kees Cook Feb. 13, 2024, 5:54 p.m. UTC | #1
On Tue, Feb 13, 2024 at 07:44:13AM -0800, Jakub Kicinski wrote:
> Commit 0ef67a888375 ("selftests/harness: Report skip reason")
> added shared memory to communicate between harness and test.
> Use that instead of exit codes to send the failing step back
> to the harness. The exit codes are limited and because of
> the step passing we can't use the full range of KSFT_* exit
> codes.
> 
> Signed-off-by: Jakub Kicinski <kuba@kernel.org>

Ah, very nice! Good idea.

Acked-by: Kees Cook <keescook@chromium.org>
kernel test robot Feb. 19, 2024, 2:21 a.m. UTC | #2
Hi Jakub,

kernel test robot noticed the following build errors:

[auto build test ERROR on net-next/main]

url:    https://github.com/intel-lab-lkp/linux/commits/Jakub-Kicinski/selftests-kselftest_harness-pass-step-via-shared-memory/20240213-234644
base:   net-next/main
patch link:    https://lore.kernel.org/r/20240213154416.422739-2-kuba%40kernel.org
patch subject: [PATCH net-next 1/4] selftests: kselftest_harness: pass step via shared memory
compiler: gcc-12 (Debian 12.2.0-14) 12.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240219/202402191034.76fuePpP-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202402191034.76fuePpP-lkp@intel.com/

All errors (new ones prefixed by >>):

   In file included from fs_test.c:26:
   fs_test.c: In function 'layout1_no_restriction':
>> common.h:52:40: error: 'struct __test_metadata' has no member named 'step'
      52 |                         _exit(_metadata->step); \
         |                                        ^~
   fs_test.c:403:1: note: in expansion of macro 'TEST_F_FORK'
     403 | TEST_F_FORK(layout1, no_restriction)
         | ^~~~~~~~~~~
   common.h:58:34: error: 'struct __test_metadata' has no member named 'step'
      58 |                         _metadata->step = 1; \
         |                                  ^~
   fs_test.c:403:1: note: in expansion of macro 'TEST_F_FORK'
     403 | TEST_F_FORK(layout1, no_restriction)
         | ^~~~~~~~~~~
   common.h:71:34: error: 'struct __test_metadata' has no member named 'step'
      71 |                         _metadata->step = WEXITSTATUS(status); \
         |                                  ^~
   fs_test.c:403:1: note: in expansion of macro 'TEST_F_FORK'
     403 | TEST_F_FORK(layout1, no_restriction)
         | ^~~~~~~~~~~
   fs_test.c: In function 'layout1_inval':
>> common.h:52:40: error: 'struct __test_metadata' has no member named 'step'
      52 |                         _exit(_metadata->step); \
         |                                        ^~
   fs_test.c:426:1: note: in expansion of macro 'TEST_F_FORK'
     426 | TEST_F_FORK(layout1, inval)
         | ^~~~~~~~~~~
   common.h:58:34: error: 'struct __test_metadata' has no member named 'step'
      58 |                         _metadata->step = 1; \
         |                                  ^~
   fs_test.c:426:1: note: in expansion of macro 'TEST_F_FORK'
     426 | TEST_F_FORK(layout1, inval)
         | ^~~~~~~~~~~
   common.h:71:34: error: 'struct __test_metadata' has no member named 'step'
      71 |                         _metadata->step = WEXITSTATUS(status); \
         |                                  ^~
   fs_test.c:426:1: note: in expansion of macro 'TEST_F_FORK'
     426 | TEST_F_FORK(layout1, inval)
         | ^~~~~~~~~~~
   fs_test.c: In function 'layout1_file_and_dir_access_rights':
>> common.h:52:40: error: 'struct __test_metadata' has no member named 'step'
      52 |                         _exit(_metadata->step); \
         |                                        ^~
   fs_test.c:548:1: note: in expansion of macro 'TEST_F_FORK'
     548 | TEST_F_FORK(layout1, file_and_dir_access_rights)
         | ^~~~~~~~~~~
   common.h:58:34: error: 'struct __test_metadata' has no member named 'step'
      58 |                         _metadata->step = 1; \
         |                                  ^~
   fs_test.c:548:1: note: in expansion of macro 'TEST_F_FORK'
     548 | TEST_F_FORK(layout1, file_and_dir_access_rights)
         | ^~~~~~~~~~~
   common.h:71:34: error: 'struct __test_metadata' has no member named 'step'
      71 |                         _metadata->step = WEXITSTATUS(status); \
         |                                  ^~
   fs_test.c:548:1: note: in expansion of macro 'TEST_F_FORK'
     548 | TEST_F_FORK(layout1, file_and_dir_access_rights)
         | ^~~~~~~~~~~
   fs_test.c: In function 'layout0_ruleset_with_unknown_access':
>> common.h:52:40: error: 'struct __test_metadata' has no member named 'step'
      52 |                         _exit(_metadata->step); \
         |                                        ^~
   fs_test.c:592:1: note: in expansion of macro 'TEST_F_FORK'
     592 | TEST_F_FORK(layout0, ruleset_with_unknown_access)
         | ^~~~~~~~~~~
   common.h:58:34: error: 'struct __test_metadata' has no member named 'step'
      58 |                         _metadata->step = 1; \
         |                                  ^~
   fs_test.c:592:1: note: in expansion of macro 'TEST_F_FORK'
     592 | TEST_F_FORK(layout0, ruleset_with_unknown_access)
         | ^~~~~~~~~~~
   common.h:71:34: error: 'struct __test_metadata' has no member named 'step'
      71 |                         _metadata->step = WEXITSTATUS(status); \
         |                                  ^~
   fs_test.c:592:1: note: in expansion of macro 'TEST_F_FORK'
     592 | TEST_F_FORK(layout0, ruleset_with_unknown_access)
         | ^~~~~~~~~~~
   fs_test.c: In function 'layout0_rule_with_unknown_access':
>> common.h:52:40: error: 'struct __test_metadata' has no member named 'step'
      52 |                         _exit(_metadata->step); \
         |                                        ^~
   fs_test.c:608:1: note: in expansion of macro 'TEST_F_FORK'
     608 | TEST_F_FORK(layout0, rule_with_unknown_access)
         | ^~~~~~~~~~~
   common.h:58:34: error: 'struct __test_metadata' has no member named 'step'
      58 |                         _metadata->step = 1; \
         |                                  ^~
   fs_test.c:608:1: note: in expansion of macro 'TEST_F_FORK'
     608 | TEST_F_FORK(layout0, rule_with_unknown_access)
         | ^~~~~~~~~~~
   common.h:71:34: error: 'struct __test_metadata' has no member named 'step'
      71 |                         _metadata->step = WEXITSTATUS(status); \
         |                                  ^~
   fs_test.c:608:1: note: in expansion of macro 'TEST_F_FORK'
     608 | TEST_F_FORK(layout0, rule_with_unknown_access)
         | ^~~~~~~~~~~
   fs_test.c: In function 'layout1_rule_with_unhandled_access':
>> common.h:52:40: error: 'struct __test_metadata' has no member named 'step'
      52 |                         _exit(_metadata->step); \
         |                                        ^~
   fs_test.c:635:1: note: in expansion of macro 'TEST_F_FORK'
     635 | TEST_F_FORK(layout1, rule_with_unhandled_access)
         | ^~~~~~~~~~~
   common.h:58:34: error: 'struct __test_metadata' has no member named 'step'
      58 |                         _metadata->step = 1; \
         |                                  ^~
   fs_test.c:635:1: note: in expansion of macro 'TEST_F_FORK'
     635 | TEST_F_FORK(layout1, rule_with_unhandled_access)
         | ^~~~~~~~~~~
   common.h:71:34: error: 'struct __test_metadata' has no member named 'step'
      71 |                         _metadata->step = WEXITSTATUS(status); \
         |                                  ^~
   fs_test.c:635:1: note: in expansion of macro 'TEST_F_FORK'
     635 | TEST_F_FORK(layout1, rule_with_unhandled_access)
         | ^~~~~~~~~~~
   fs_test.c: In function 'layout0_proc_nsfs':
>> common.h:52:40: error: 'struct __test_metadata' has no member named 'step'
      52 |                         _exit(_metadata->step); \
         |                                        ^~
   fs_test.c:741:1: note: in expansion of macro 'TEST_F_FORK'
     741 | TEST_F_FORK(layout0, proc_nsfs)
         | ^~~~~~~~~~~
   common.h:58:34: error: 'struct __test_metadata' has no member named 'step'
      58 |                         _metadata->step = 1; \
         |                                  ^~
   fs_test.c:741:1: note: in expansion of macro 'TEST_F_FORK'
     741 | TEST_F_FORK(layout0, proc_nsfs)
         | ^~~~~~~~~~~
   common.h:71:34: error: 'struct __test_metadata' has no member named 'step'
      71 |                         _metadata->step = WEXITSTATUS(status); \
         |                                  ^~
   fs_test.c:741:1: note: in expansion of macro 'TEST_F_FORK'
     741 | TEST_F_FORK(layout0, proc_nsfs)
         | ^~~~~~~~~~~
   fs_test.c: In function 'layout0_unpriv':
>> common.h:52:40: error: 'struct __test_metadata' has no member named 'step'
      52 |                         _exit(_metadata->step); \
         |                                        ^~
   fs_test.c:790:1: note: in expansion of macro 'TEST_F_FORK'
     790 | TEST_F_FORK(layout0, unpriv)
         | ^~~~~~~~~~~
   common.h:58:34: error: 'struct __test_metadata' has no member named 'step'
      58 |                         _metadata->step = 1; \
         |                                  ^~
   fs_test.c:790:1: note: in expansion of macro 'TEST_F_FORK'
     790 | TEST_F_FORK(layout0, unpriv)
         | ^~~~~~~~~~~
   common.h:71:34: error: 'struct __test_metadata' has no member named 'step'
      71 |                         _metadata->step = WEXITSTATUS(status); \
         |                                  ^~
   fs_test.c:790:1: note: in expansion of macro 'TEST_F_FORK'
     790 | TEST_F_FORK(layout0, unpriv)
         | ^~~~~~~~~~~
   fs_test.c: In function 'layout1_effective_access':
>> common.h:52:40: error: 'struct __test_metadata' has no member named 'step'
      52 |                         _exit(_metadata->step); \
         |                                        ^~
   fs_test.c:813:1: note: in expansion of macro 'TEST_F_FORK'
     813 | TEST_F_FORK(layout1, effective_access)
         | ^~~~~~~~~~~
   common.h:58:34: error: 'struct __test_metadata' has no member named 'step'
      58 |                         _metadata->step = 1; \
         |                                  ^~
   fs_test.c:813:1: note: in expansion of macro 'TEST_F_FORK'
     813 | TEST_F_FORK(layout1, effective_access)
         | ^~~~~~~~~~~
   common.h:71:34: error: 'struct __test_metadata' has no member named 'step'
      71 |                         _metadata->step = WEXITSTATUS(status); \
         |                                  ^~
   fs_test.c:813:1: note: in expansion of macro 'TEST_F_FORK'
     813 | TEST_F_FORK(layout1, effective_access)
         | ^~~~~~~~~~~
   fs_test.c: In function 'layout1_unhandled_access':
>> common.h:52:40: error: 'struct __test_metadata' has no member named 'step'
      52 |                         _exit(_metadata->step); \
         |                                        ^~
   fs_test.c:871:1: note: in expansion of macro 'TEST_F_FORK'
     871 | TEST_F_FORK(layout1, unhandled_access)
         | ^~~~~~~~~~~
   common.h:58:34: error: 'struct __test_metadata' has no member named 'step'
      58 |                         _metadata->step = 1; \
         |                                  ^~
   fs_test.c:871:1: note: in expansion of macro 'TEST_F_FORK'
     871 | TEST_F_FORK(layout1, unhandled_access)
         | ^~~~~~~~~~~
   common.h:71:34: error: 'struct __test_metadata' has no member named 'step'
      71 |                         _metadata->step = WEXITSTATUS(status); \
         |                                  ^~
   fs_test.c:871:1: note: in expansion of macro 'TEST_F_FORK'
     871 | TEST_F_FORK(layout1, unhandled_access)
         | ^~~~~~~~~~~
   fs_test.c: In function 'layout1_ruleset_overlap':
>> common.h:52:40: error: 'struct __test_metadata' has no member named 'step'
      52 |                         _exit(_metadata->step); \
         |                                        ^~
   fs_test.c:898:1: note: in expansion of macro 'TEST_F_FORK'
     898 | TEST_F_FORK(layout1, ruleset_overlap)
         | ^~~~~~~~~~~
   common.h:58:34: error: 'struct __test_metadata' has no member named 'step'
      58 |                         _metadata->step = 1; \
         |                                  ^~
   fs_test.c:898:1: note: in expansion of macro 'TEST_F_FORK'
     898 | TEST_F_FORK(layout1, ruleset_overlap)
         | ^~~~~~~~~~~
   common.h:71:34: error: 'struct __test_metadata' has no member named 'step'
      71 |                         _metadata->step = WEXITSTATUS(status); \
         |                                  ^~
   fs_test.c:898:1: note: in expansion of macro 'TEST_F_FORK'
     898 | TEST_F_FORK(layout1, ruleset_overlap)
         | ^~~~~~~~~~~
   fs_test.c: In function 'layout1_layer_rule_unions':
>> common.h:52:40: error: 'struct __test_metadata' has no member named 'step'
      52 |                         _exit(_metadata->step); \
         |                                        ^~
   fs_test.c:939:1: note: in expansion of macro 'TEST_F_FORK'
     939 | TEST_F_FORK(layout1, layer_rule_unions)
         | ^~~~~~~~~~~
   common.h:58:34: error: 'struct __test_metadata' has no member named 'step'
      58 |                         _metadata->step = 1; \
         |                                  ^~
   fs_test.c:939:1: note: in expansion of macro 'TEST_F_FORK'
     939 | TEST_F_FORK(layout1, layer_rule_unions)
         | ^~~~~~~~~~~
   common.h:71:34: error: 'struct __test_metadata' has no member named 'step'
      71 |                         _metadata->step = WEXITSTATUS(status); \
         |                                  ^~
   fs_test.c:939:1: note: in expansion of macro 'TEST_F_FORK'
     939 | TEST_F_FORK(layout1, layer_rule_unions)
         | ^~~~~~~~~~~
   fs_test.c: In function 'layout1_non_overlapping_accesses':
>> common.h:52:40: error: 'struct __test_metadata' has no member named 'step'
      52 |                         _exit(_metadata->step); \
         |                                        ^~
   fs_test.c:1046:1: note: in expansion of macro 'TEST_F_FORK'
    1046 | TEST_F_FORK(layout1, non_overlapping_accesses)
         | ^~~~~~~~~~~
   common.h:58:34: error: 'struct __test_metadata' has no member named 'step'
      58 |                         _metadata->step = 1; \
         |                                  ^~
   fs_test.c:1046:1: note: in expansion of macro 'TEST_F_FORK'
    1046 | TEST_F_FORK(layout1, non_overlapping_accesses)
         | ^~~~~~~~~~~
   common.h:71:34: error: 'struct __test_metadata' has no member named 'step'
      71 |                         _metadata->step = WEXITSTATUS(status); \
         |                                  ^~
   fs_test.c:1046:1: note: in expansion of macro 'TEST_F_FORK'
    1046 | TEST_F_FORK(layout1, non_overlapping_accesses)
         | ^~~~~~~~~~~
   fs_test.c: In function 'layout1_interleaved_masked_accesses':
>> common.h:52:40: error: 'struct __test_metadata' has no member named 'step'
      52 |                         _exit(_metadata->step); \
         |                                        ^~
   fs_test.c:1095:1: note: in expansion of macro 'TEST_F_FORK'
    1095 | TEST_F_FORK(layout1, interleaved_masked_accesses)
         | ^~~~~~~~~~~
   common.h:58:34: error: 'struct __test_metadata' has no member named 'step'
      58 |                         _metadata->step = 1; \
         |                                  ^~
   fs_test.c:1095:1: note: in expansion of macro 'TEST_F_FORK'
    1095 | TEST_F_FORK(layout1, interleaved_masked_accesses)
         | ^~~~~~~~~~~
   common.h:71:34: error: 'struct __test_metadata' has no member named 'step'
      71 |                         _metadata->step = WEXITSTATUS(status); \
         |                                  ^~
   fs_test.c:1095:1: note: in expansion of macro 'TEST_F_FORK'
    1095 | TEST_F_FORK(layout1, interleaved_masked_accesses)
         | ^~~~~~~~~~~
   fs_test.c: In function 'layout1_inherit_subset':
>> common.h:52:40: error: 'struct __test_metadata' has no member named 'step'
      52 |                         _exit(_metadata->step); \
         |                                        ^~
   fs_test.c:1280:1: note: in expansion of macro 'TEST_F_FORK'
    1280 | TEST_F_FORK(layout1, inherit_subset)
         | ^~~~~~~~~~~
   common.h:58:34: error: 'struct __test_metadata' has no member named 'step'
      58 |                         _metadata->step = 1; \
         |                                  ^~
   fs_test.c:1280:1: note: in expansion of macro 'TEST_F_FORK'
    1280 | TEST_F_FORK(layout1, inherit_subset)
         | ^~~~~~~~~~~
   common.h:71:34: error: 'struct __test_metadata' has no member named 'step'
      71 |                         _metadata->step = WEXITSTATUS(status); \
         |                                  ^~
   fs_test.c:1280:1: note: in expansion of macro 'TEST_F_FORK'
    1280 | TEST_F_FORK(layout1, inherit_subset)
         | ^~~~~~~~~~~
   fs_test.c: In function 'layout1_inherit_superset':
>> common.h:52:40: error: 'struct __test_metadata' has no member named 'step'
      52 |                         _exit(_metadata->step); \
         |                                        ^~
   fs_test.c:1397:1: note: in expansion of macro 'TEST_F_FORK'
    1397 | TEST_F_FORK(layout1, inherit_superset)
         | ^~~~~~~~~~~
   common.h:58:34: error: 'struct __test_metadata' has no member named 'step'
      58 |                         _metadata->step = 1; \
         |                                  ^~
   fs_test.c:1397:1: note: in expansion of macro 'TEST_F_FORK'
    1397 | TEST_F_FORK(layout1, inherit_superset)
         | ^~~~~~~~~~~
   common.h:71:34: error: 'struct __test_metadata' has no member named 'step'
      71 |                         _metadata->step = WEXITSTATUS(status); \
         |                                  ^~
   fs_test.c:1397:1: note: in expansion of macro 'TEST_F_FORK'
    1397 | TEST_F_FORK(layout1, inherit_superset)
         | ^~~~~~~~~~~
   fs_test.c: In function 'layout0_max_layers':
>> common.h:52:40: error: 'struct __test_metadata' has no member named 'step'
      52 |                         _exit(_metadata->step); \
         |                                        ^~
   fs_test.c:1434:1: note: in expansion of macro 'TEST_F_FORK'
    1434 | TEST_F_FORK(layout0, max_layers)
         | ^~~~~~~~~~~
   common.h:58:34: error: 'struct __test_metadata' has no member named 'step'
      58 |                         _metadata->step = 1; \
         |                                  ^~
   fs_test.c:1434:1: note: in expansion of macro 'TEST_F_FORK'
    1434 | TEST_F_FORK(layout0, max_layers)
         | ^~~~~~~~~~~
   common.h:71:34: error: 'struct __test_metadata' has no member named 'step'
      71 |                         _metadata->step = WEXITSTATUS(status); \
         |                                  ^~
   fs_test.c:1434:1: note: in expansion of macro 'TEST_F_FORK'
    1434 | TEST_F_FORK(layout0, max_layers)
         | ^~~~~~~~~~~
   fs_test.c: In function 'layout1_empty_or_same_ruleset':
>> common.h:52:40: error: 'struct __test_metadata' has no member named 'step'
      52 |                         _exit(_metadata->step); \
         |                                        ^~
   fs_test.c:1458:1: note: in expansion of macro 'TEST_F_FORK'
    1458 | TEST_F_FORK(layout1, empty_or_same_ruleset)
         | ^~~~~~~~~~~
   common.h:58:34: error: 'struct __test_metadata' has no member named 'step'
      58 |                         _metadata->step = 1; \
         |                                  ^~
   fs_test.c:1458:1: note: in expansion of macro 'TEST_F_FORK'
    1458 | TEST_F_FORK(layout1, empty_or_same_ruleset)
         | ^~~~~~~~~~~
   common.h:71:34: error: 'struct __test_metadata' has no member named 'step'
      71 |                         _metadata->step = WEXITSTATUS(status); \
         |                                  ^~
   fs_test.c:1458:1: note: in expansion of macro 'TEST_F_FORK'
    1458 | TEST_F_FORK(layout1, empty_or_same_ruleset)
         | ^~~~~~~~~~~
   fs_test.c: In function 'layout1_rule_on_mountpoint':
>> common.h:52:40: error: 'struct __test_metadata' has no member named 'step'
      52 |                         _exit(_metadata->step); \
         |                                        ^~
   fs_test.c:1492:1: note: in expansion of macro 'TEST_F_FORK'
    1492 | TEST_F_FORK(layout1, rule_on_mountpoint)
         | ^~~~~~~~~~~
   common.h:58:34: error: 'struct __test_metadata' has no member named 'step'
      58 |                         _metadata->step = 1; \
         |                                  ^~
   fs_test.c:1492:1: note: in expansion of macro 'TEST_F_FORK'
    1492 | TEST_F_FORK(layout1, rule_on_mountpoint)
         | ^~~~~~~~~~~
   common.h:71:34: error: 'struct __test_metadata' has no member named 'step'
      71 |                         _metadata->step = WEXITSTATUS(status); \
         |                                  ^~
   fs_test.c:1492:1: note: in expansion of macro 'TEST_F_FORK'
    1492 | TEST_F_FORK(layout1, rule_on_mountpoint)
         | ^~~~~~~~~~~
   fs_test.c: In function 'layout1_rule_over_mountpoint':
>> common.h:52:40: error: 'struct __test_metadata' has no member named 'step'
      52 |                         _exit(_metadata->step); \
         |                                        ^~
   fs_test.c:1521:1: note: in expansion of macro 'TEST_F_FORK'
    1521 | TEST_F_FORK(layout1, rule_over_mountpoint)
         | ^~~~~~~~~~~
   common.h:58:34: error: 'struct __test_metadata' has no member named 'step'
      58 |                         _metadata->step = 1; \
         |                                  ^~
   fs_test.c:1521:1: note: in expansion of macro 'TEST_F_FORK'
    1521 | TEST_F_FORK(layout1, rule_over_mountpoint)
         | ^~~~~~~~~~~
   common.h:71:34: error: 'struct __test_metadata' has no member named 'step'
      71 |                         _metadata->step = WEXITSTATUS(status); \
         |                                  ^~
   fs_test.c:1521:1: note: in expansion of macro 'TEST_F_FORK'
    1521 | TEST_F_FORK(layout1, rule_over_mountpoint)
         | ^~~~~~~~~~~
   fs_test.c: In function 'layout1_rule_over_root_allow_then_deny':
   common.h:52:40: error: 'struct __test_metadata' has no member named 'step'
      52 |                         _exit(_metadata->step); \
         |                                        ^~
   fs_test.c:1554:1: note: in expansion of macro 'TEST_F_FORK'
    1554 | TEST_F_FORK(layout1, rule_over_root_allow_then_deny)
         | ^~~~~~~~~~~
   common.h:58:34: error: 'struct __test_metadata' has no member named 'step'
      58 |                         _metadata->step = 1; \
         |                                  ^~
   fs_test.c:1554:1: note: in expansion of macro 'TEST_F_FORK'
    1554 | TEST_F_FORK(layout1, rule_over_root_allow_then_deny)
         | ^~~~~~~~~~~
   common.h:71:34: error: 'struct __test_metadata' has no member named 'step'
      71 |                         _metadata->step = WEXITSTATUS(status); \
         |                                  ^~
   fs_test.c:1554:1: note: in expansion of macro 'TEST_F_FORK'
    1554 | TEST_F_FORK(layout1, rule_over_root_allow_then_deny)
         | ^~~~~~~~~~~
   fs_test.c: In function 'layout1_rule_over_root_deny':
   common.h:52:40: error: 'struct __test_metadata' has no member named 'step'
      52 |                         _exit(_metadata->step); \
         |                                        ^~
   fs_test.c:1584:1: note: in expansion of macro 'TEST_F_FORK'
    1584 | TEST_F_FORK(layout1, rule_over_root_deny)
         | ^~~~~~~~~~~
   common.h:58:34: error: 'struct __test_metadata' has no member named 'step'
      58 |                         _metadata->step = 1; \
         |                                  ^~
   fs_test.c:1584:1: note: in expansion of macro 'TEST_F_FORK'
    1584 | TEST_F_FORK(layout1, rule_over_root_deny)
         | ^~~~~~~~~~~
   common.h:71:34: error: 'struct __test_metadata' has no member named 'step'
      71 |                         _metadata->step = WEXITSTATUS(status); \
         |                                  ^~
   fs_test.c:1584:1: note: in expansion of macro 'TEST_F_FORK'
    1584 | TEST_F_FORK(layout1, rule_over_root_deny)
         | ^~~~~~~~~~~
   fs_test.c: In function 'layout1_rule_inside_mount_ns':
   common.h:52:40: error: 'struct __test_metadata' has no member named 'step'
      52 |                         _exit(_metadata->step); \
         |                                        ^~
   fs_test.c:1604:1: note: in expansion of macro 'TEST_F_FORK'
    1604 | TEST_F_FORK(layout1, rule_inside_mount_ns)
         | ^~~~~~~~~~~
   common.h:58:34: error: 'struct __test_metadata' has no member named 'step'
      58 |                         _metadata->step = 1; \
         |                                  ^~
   fs_test.c:1604:1: note: in expansion of macro 'TEST_F_FORK'
    1604 | TEST_F_FORK(layout1, rule_inside_mount_ns)
         | ^~~~~~~~~~~
   common.h:71:34: error: 'struct __test_metadata' has no member named 'step'
      71 |                         _metadata->step = WEXITSTATUS(status); \
         |                                  ^~
   fs_test.c:1604:1: note: in expansion of macro 'TEST_F_FORK'
    1604 | TEST_F_FORK(layout1, rule_inside_mount_ns)
         | ^~~~~~~~~~~
   fs_test.c: In function 'layout1_mount_and_pivot':
   common.h:52:40: error: 'struct __test_metadata' has no member named 'step'
      52 |                         _exit(_metadata->step); \
         |                                        ^~
   fs_test.c:1632:1: note: in expansion of macro 'TEST_F_FORK'
    1632 | TEST_F_FORK(layout1, mount_and_pivot)
         | ^~~~~~~~~~~
   common.h:58:34: error: 'struct __test_metadata' has no member named 'step'
      58 |                         _metadata->step = 1; \
         |                                  ^~
   fs_test.c:1632:1: note: in expansion of macro 'TEST_F_FORK'
    1632 | TEST_F_FORK(layout1, mount_and_pivot)
         | ^~~~~~~~~~~
   common.h:71:34: error: 'struct __test_metadata' has no member named 'step'
      71 |                         _metadata->step = WEXITSTATUS(status); \
         |                                  ^~
   fs_test.c:1632:1: note: in expansion of macro 'TEST_F_FORK'
    1632 | TEST_F_FORK(layout1, mount_and_pivot)
         | ^~~~~~~~~~~
   fs_test.c: In function 'layout1_move_mount':
   common.h:52:40: error: 'struct __test_metadata' has no member named 'step'
      52 |                         _exit(_metadata->step); \
         |                                        ^~
   fs_test.c:1655:1: note: in expansion of macro 'TEST_F_FORK'
    1655 | TEST_F_FORK(layout1, move_mount)
         | ^~~~~~~~~~~
diff mbox series

Patch

diff --git a/tools/testing/selftests/kselftest_harness.h b/tools/testing/selftests/kselftest_harness.h
index e05ac8261046..98bdedf9a53a 100644
--- a/tools/testing/selftests/kselftest_harness.h
+++ b/tools/testing/selftests/kselftest_harness.h
@@ -101,8 +101,8 @@ 
  * ASSERT_* number for which the test failed.  This behavior can be enabled by
  * writing `_metadata->no_print = true;` before the check sequence that is
  * unable to print.  When an error occur, instead of printing an error message
- * and calling `abort(3)`, the test process call `_exit(2)` with the assert
- * number as argument, which is then printed by the parent process.
+ * and calling `abort(3)`, the test process call `_exit(2)` and pass the error
+ * to be printed to the parent process via shared memory.
  */
 #define TH_LOG(fmt, ...) do { \
 	if (TH_LOG_ENABLED) \
@@ -695,9 +695,8 @@ 
 			__bail(_assert, _metadata))
 
 #define __INC_STEP(_metadata) \
-	/* Keep "step" below 255 (which is used for "SKIP" reporting). */	\
-	if (_metadata->passed && _metadata->step < 253) \
-		_metadata->step++;
+	if (_metadata->passed) \
+		_metadata->results->step++;
 
 #define is_signed_type(var)       (!!(((__typeof__(var))(-1)) < (__typeof__(var))1))
 
@@ -784,6 +783,7 @@ 
 
 struct __test_results {
 	char reason[1024];	/* Reason for test result */
+	unsigned int step;	/* Test step reached without failure */
 };
 
 struct __test_metadata;
@@ -837,7 +837,6 @@  struct __test_metadata {
 	int trigger; /* extra handler after the evaluation */
 	int timeout;	/* seconds to wait for test timeout */
 	bool timed_out;	/* did this test timeout instead of exiting? */
-	__u8 step;
 	bool no_print; /* manual trigger when TH_LOG_STREAM is not available */
 	bool aborted;	/* stopped test due to failed ASSERT */
 	bool setup_completed; /* did setup finish? */
@@ -875,7 +874,7 @@  static inline void __test_check_assert(struct __test_metadata *t)
 {
 	if (t->aborted) {
 		if (t->no_print)
-			_exit(t->step);
+			_exit(1);
 		abort();
 	}
 }
@@ -960,7 +959,7 @@  void __wait_for_test(struct __test_metadata *t)
 				fprintf(TH_LOG_STREAM,
 					"# %s: Test failed at step #%d\n",
 					t->name,
-					WEXITSTATUS(status));
+					t->results->step);
 			}
 		}
 	} else if (WIFSIGNALED(status)) {
@@ -1114,9 +1113,9 @@  void __run_test(struct __fixture_metadata *f,
 	t->passed = 1;
 	t->skip = 0;
 	t->trigger = 0;
-	t->step = 1;
 	t->no_print = 0;
 	memset(t->results->reason, 0, sizeof(t->results->reason));
+	t->results->step = 1;
 
 	ksft_print_msg(" RUN           %s%s%s.%s ...\n",
 	       f->name, variant->name[0] ? "." : "", variant->name, t->name);
@@ -1137,8 +1136,8 @@  void __run_test(struct __fixture_metadata *f,
 		/* Pass is exit 0 */
 		if (t->passed)
 			_exit(0);
-		/* Something else happened, report the step. */
-		_exit(t->step);
+		/* Something else happened. */
+		_exit(1);
 	} else {
 		__wait_for_test(t);
 	}