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

TOMOYO Linux Cross Reference
Linux/tools/testing/kunit/kunit_json.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/kunit/kunit_json.py (Architecture sparc64) and /tools/testing/kunit/kunit_json.py (Architecture alpha)


  1 # SPDX-License-Identifier: GPL-2.0                  1 # SPDX-License-Identifier: GPL-2.0
  2 #                                                   2 #
  3 # Generates JSON from KUnit results according       3 # Generates JSON from KUnit results according to
  4 # KernelCI spec: https://github.com/kernelci/k      4 # KernelCI spec: https://github.com/kernelci/kernelci-doc/wiki/Test-API
  5 #                                                   5 #
  6 # Copyright (C) 2020, Google LLC.                   6 # Copyright (C) 2020, Google LLC.
  7 # Author: Heidi Fahim <heidifahim@google.com>        7 # Author: Heidi Fahim <heidifahim@google.com>
  8                                                     8 
  9 from dataclasses import dataclass                   9 from dataclasses import dataclass
 10 import json                                        10 import json
 11 from typing import Any, Dict                       11 from typing import Any, Dict
 12                                                    12 
 13 from kunit_parser import Test, TestStatus          13 from kunit_parser import Test, TestStatus
 14                                                    14 
 15 @dataclass                                         15 @dataclass
 16 class Metadata:                                    16 class Metadata:
 17         """Stores metadata about this run to i     17         """Stores metadata about this run to include in get_json_result()."""
 18         arch: str = ''                             18         arch: str = ''
 19         def_config: str = ''                       19         def_config: str = ''
 20         build_dir: str = ''                        20         build_dir: str = ''
 21                                                    21 
 22 JsonObj = Dict[str, Any]                           22 JsonObj = Dict[str, Any]
 23                                                    23 
 24 _status_map: Dict[TestStatus, str] = {             24 _status_map: Dict[TestStatus, str] = {
 25         TestStatus.SUCCESS: "PASS",                25         TestStatus.SUCCESS: "PASS",
 26         TestStatus.SKIPPED: "SKIP",                26         TestStatus.SKIPPED: "SKIP",
 27         TestStatus.TEST_CRASHED: "ERROR",          27         TestStatus.TEST_CRASHED: "ERROR",
 28 }                                                  28 }
 29                                                    29 
 30 def _get_group_json(test: Test, common_fields:     30 def _get_group_json(test: Test, common_fields: JsonObj) -> JsonObj:
 31         sub_groups = []  # List[JsonObj]           31         sub_groups = []  # List[JsonObj]
 32         test_cases = []  # List[JsonObj]           32         test_cases = []  # List[JsonObj]
 33                                                    33 
 34         for subtest in test.subtests:              34         for subtest in test.subtests:
 35                 if subtest.subtests:               35                 if subtest.subtests:
 36                         sub_group = _get_group     36                         sub_group = _get_group_json(subtest, common_fields)
 37                         sub_groups.append(sub_     37                         sub_groups.append(sub_group)
 38                         continue                   38                         continue
 39                 status = _status_map.get(subte     39                 status = _status_map.get(subtest.status, "FAIL")
 40                 test_cases.append({"name": sub     40                 test_cases.append({"name": subtest.name, "status": status})
 41                                                    41 
 42         test_group = {                             42         test_group = {
 43                 "name": test.name,                 43                 "name": test.name,
 44                 "sub_groups": sub_groups,          44                 "sub_groups": sub_groups,
 45                 "test_cases": test_cases,          45                 "test_cases": test_cases,
 46         }                                          46         }
 47         test_group.update(common_fields)           47         test_group.update(common_fields)
 48         return test_group                          48         return test_group
 49                                                    49 
 50 def get_json_result(test: Test, metadata: Meta     50 def get_json_result(test: Test, metadata: Metadata) -> str:
 51         common_fields = {                          51         common_fields = {
 52                 "arch": metadata.arch,             52                 "arch": metadata.arch,
 53                 "defconfig": metadata.def_conf     53                 "defconfig": metadata.def_config,
 54                 "build_environment": metadata.     54                 "build_environment": metadata.build_dir,
 55                 "lab_name": None,                  55                 "lab_name": None,
 56                 "kernel": None,                    56                 "kernel": None,
 57                 "job": None,                       57                 "job": None,
 58                 "git_branch": "kselftest",         58                 "git_branch": "kselftest",
 59         }                                          59         }
 60                                                    60 
 61         test_group = _get_group_json(test, com     61         test_group = _get_group_json(test, common_fields)
 62         test_group["name"] = "KUnit Test Group     62         test_group["name"] = "KUnit Test Group"
 63         return json.dumps(test_group, indent=4     63         return json.dumps(test_group, indent=4)
                                                      

~ [ 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