~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/tools/testing/selftests/kselftest/ksft.py

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /tools/testing/selftests/kselftest/ksft.py (Architecture ppc) and /tools/testing/selftests/kselftest/ksft.py (Architecture sparc64)


  1 # SPDX-License-Identifier: GPL-2.0                  1 # SPDX-License-Identifier: GPL-2.0
  2 #                                                   2 #
  3 # Copyright (c) 2023 Collabora Ltd                  3 # Copyright (c) 2023 Collabora Ltd
  4 #                                                   4 #
  5 # Kselftest helpers for outputting in KTAP for      5 # Kselftest helpers for outputting in KTAP format. Based on kselftest.h.
  6 #                                                   6 #
  7                                                     7 
  8 import sys                                          8 import sys
  9                                                     9 
 10 ksft_cnt = {"pass": 0, "fail": 0, "skip": 0}       10 ksft_cnt = {"pass": 0, "fail": 0, "skip": 0}
 11 ksft_num_tests = 0                                 11 ksft_num_tests = 0
 12 ksft_test_number = 1                               12 ksft_test_number = 1
 13                                                    13 
 14 KSFT_PASS = 0                                      14 KSFT_PASS = 0
 15 KSFT_FAIL = 1                                      15 KSFT_FAIL = 1
 16 KSFT_SKIP = 4                                      16 KSFT_SKIP = 4
 17                                                    17 
 18                                                    18 
 19 def print_header():                                19 def print_header():
 20     print("TAP version 13")                        20     print("TAP version 13")
 21                                                    21 
 22                                                    22 
 23 def set_plan(num_tests):                           23 def set_plan(num_tests):
 24     global ksft_num_tests                          24     global ksft_num_tests
 25     ksft_num_tests = num_tests                     25     ksft_num_tests = num_tests
 26     print("1..{}".format(num_tests))               26     print("1..{}".format(num_tests))
 27                                                    27 
 28                                                    28 
 29 def print_cnts():                                  29 def print_cnts():
 30     print(                                         30     print(
 31         f"# Totals: pass:{ksft_cnt['pass']} fa     31         f"# Totals: pass:{ksft_cnt['pass']} fail:{ksft_cnt['fail']} xfail:0 xpass:0 skip:{ksft_cnt['skip']} error:0"
 32     )                                              32     )
 33                                                    33 
 34                                                    34 
 35 def print_msg(msg):                                35 def print_msg(msg):
 36     print(f"# {msg}")                              36     print(f"# {msg}")
 37                                                    37 
 38                                                    38 
 39 def _test_print(result, description, directive     39 def _test_print(result, description, directive=None):
 40     if directive:                                  40     if directive:
 41         directive_str = f"# {directive}"           41         directive_str = f"# {directive}"
 42     else:                                          42     else:
 43         directive_str = ""                         43         directive_str = ""
 44                                                    44 
 45     global ksft_test_number                        45     global ksft_test_number
 46     print(f"{result} {ksft_test_number} {descr     46     print(f"{result} {ksft_test_number} {description} {directive_str}")
 47     ksft_test_number += 1                          47     ksft_test_number += 1
 48                                                    48 
 49                                                    49 
 50 def test_result_pass(description):                 50 def test_result_pass(description):
 51     _test_print("ok", description)                 51     _test_print("ok", description)
 52     ksft_cnt["pass"] += 1                          52     ksft_cnt["pass"] += 1
 53                                                    53 
 54                                                    54 
 55 def test_result_fail(description):                 55 def test_result_fail(description):
 56     _test_print("not ok", description)             56     _test_print("not ok", description)
 57     ksft_cnt["fail"] += 1                          57     ksft_cnt["fail"] += 1
 58                                                    58 
 59                                                    59 
 60 def test_result_skip(description):                 60 def test_result_skip(description):
 61     _test_print("ok", description, "SKIP")         61     _test_print("ok", description, "SKIP")
 62     ksft_cnt["skip"] += 1                          62     ksft_cnt["skip"] += 1
 63                                                    63 
 64                                                    64 
 65 def test_result(condition, description=""):        65 def test_result(condition, description=""):
 66     if condition:                                  66     if condition:
 67         test_result_pass(description)              67         test_result_pass(description)
 68     else:                                          68     else:
 69         test_result_fail(description)              69         test_result_fail(description)
 70                                                    70 
 71                                                    71 
 72 def finished():                                    72 def finished():
 73     if ksft_cnt["pass"] + ksft_cnt["skip"] ==      73     if ksft_cnt["pass"] + ksft_cnt["skip"] == ksft_num_tests:
 74         exit_code = KSFT_PASS                      74         exit_code = KSFT_PASS
 75     else:                                          75     else:
 76         exit_code = KSFT_FAIL                      76         exit_code = KSFT_FAIL
 77                                                    77 
 78     print_cnts()                                   78     print_cnts()
 79                                                    79 
 80     sys.exit(exit_code)                            80     sys.exit(exit_code)
 81                                                    81 
 82                                                    82 
 83 def exit_fail():                                   83 def exit_fail():
 84     print_cnts()                                   84     print_cnts()
 85     sys.exit(KSFT_FAIL)                            85     sys.exit(KSFT_FAIL)
 86                                                    86 
 87                                                    87 
 88 def exit_pass():                                   88 def exit_pass():
 89     print_cnts()                                   89     print_cnts()
 90     sys.exit(KSFT_PASS)                            90     sys.exit(KSFT_PASS)
                                                      

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php