get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

GET /api/patches/137669/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 137669,
    "url": "http://patches.dpdk.org/api/patches/137669/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/20240301105522.79870-5-juraj.linkes@pantheon.tech/",
    "project": {
        "id": 1,
        "url": "http://patches.dpdk.org/api/projects/1/?format=api",
        "name": "DPDK",
        "link_name": "dpdk",
        "list_id": "dev.dpdk.org",
        "list_email": "dev@dpdk.org",
        "web_url": "http://core.dpdk.org",
        "scm_url": "git://dpdk.org/dpdk",
        "webscm_url": "http://git.dpdk.org/dpdk",
        "list_archive_url": "https://inbox.dpdk.org/dev",
        "list_archive_url_format": "https://inbox.dpdk.org/dev/{}",
        "commit_url_format": ""
    },
    "msgid": "<20240301105522.79870-5-juraj.linkes@pantheon.tech>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20240301105522.79870-5-juraj.linkes@pantheon.tech",
    "date": "2024-03-01T10:55:19",
    "name": "[v4,4/7] dts: reorganize test result",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": true,
    "hash": "d430c78cf13c05c8e43896d07e7684e4f408957e",
    "submitter": {
        "id": 1626,
        "url": "http://patches.dpdk.org/api/people/1626/?format=api",
        "name": "Juraj Linkeš",
        "email": "juraj.linkes@pantheon.tech"
    },
    "delegate": {
        "id": 1,
        "url": "http://patches.dpdk.org/api/users/1/?format=api",
        "username": "tmonjalo",
        "first_name": "Thomas",
        "last_name": "Monjalon",
        "email": "thomas@monjalon.net"
    },
    "mbox": "http://patches.dpdk.org/project/dpdk/patch/20240301105522.79870-5-juraj.linkes@pantheon.tech/mbox/",
    "series": [
        {
            "id": 31329,
            "url": "http://patches.dpdk.org/api/series/31329/?format=api",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=31329",
            "date": "2024-03-01T10:55:15",
            "name": "test case blocking and logging",
            "version": 4,
            "mbox": "http://patches.dpdk.org/series/31329/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/137669/comments/",
    "check": "success",
    "checks": "http://patches.dpdk.org/api/patches/137669/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<dev-bounces@dpdk.org>",
        "X-Original-To": "patchwork@inbox.dpdk.org",
        "Delivered-To": "patchwork@inbox.dpdk.org",
        "Received": [
            "from mails.dpdk.org (mails.dpdk.org [217.70.189.124])\n\tby inbox.dpdk.org (Postfix) with ESMTP id 1D03C43BB1;\n\tFri,  1 Mar 2024 11:55:59 +0100 (CET)",
            "from mails.dpdk.org (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id E09A9433DC;\n\tFri,  1 Mar 2024 11:55:32 +0100 (CET)",
            "from mail-ed1-f54.google.com (mail-ed1-f54.google.com\n [209.85.208.54]) by mails.dpdk.org (Postfix) with ESMTP id 2C85C433CE\n for <dev@dpdk.org>; Fri,  1 Mar 2024 11:55:30 +0100 (CET)",
            "by mail-ed1-f54.google.com with SMTP id\n 4fb4d7f45d1cf-5656e5754ccso2643493a12.0\n for <dev@dpdk.org>; Fri, 01 Mar 2024 02:55:30 -0800 (PST)",
            "from jlinkes-PT-Latitude-5530.pantheon.local ([84.245.120.62])\n by smtp.gmail.com with ESMTPSA id\n f12-20020a056402194c00b0056661ec3f24sm1461734edz.81.2024.03.01.02.55.28\n (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n Fri, 01 Mar 2024 02:55:28 -0800 (PST)"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=pantheon.tech; s=google; t=1709290530; x=1709895330; darn=dpdk.org;\n h=content-transfer-encoding:mime-version:references:in-reply-to\n :message-id:date:subject:cc:to:from:from:to:cc:subject:date\n :message-id:reply-to;\n bh=Xl86siJVlDGlX5Wkzr/K/eUz6vp6W3gCEYpA70LynMk=;\n b=NQH26d9nANOMoFkfPp2dj+9ILBhYnOqeS3oHO4UIDMYsMAKxOpF9E/PqqnviC2yAy+\n MQzxvQYyE5FrXGQ1vE36pn9aOEShRwcT0hfQeLO7cD1qTmWUuByP1CPifbD9p4U1z1du\n l/KYpcE3uktTmWpKRJDBXavPuLrckfvrmAP0GDn/MiTWdthiwt8/ER3WyCMnO/kpd2Qh\n bCfUWtxVqCVzXGNMnlCnQhi1UXXN/sdhmLzZ7DOujjwowUfkmAz5hZNYnU4S3rNf3i+z\n 8KlguDC8XgvgQHSzJsobGAondryQiPXjg5P9fQ9sJJKAuzjqxUAB8kiXCGh/vzEgDR9r\n BlAg==",
        "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20230601; t=1709290530; x=1709895330;\n h=content-transfer-encoding:mime-version:references:in-reply-to\n :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc\n :subject:date:message-id:reply-to;\n bh=Xl86siJVlDGlX5Wkzr/K/eUz6vp6W3gCEYpA70LynMk=;\n b=ISlivYuP3T5D3FGdC9wkKz7ylFzsCtGNsPYZuEFpmTUBOXE3PE6ignA6gZYh9/CN9v\n ErPu8LNPSqGt8xS+oww5j7oshf48NuMGQBPa7YpSb5z2d+gAPNACHDTLBHV7qjxtk/ZA\n B+l8v34/n5+J9PxMQFpu7uKQI14T0pBq/8Ey2BI8J174eiNFbRT5jUanyW962+gzuivH\n 2iNFwG7oPDWSNvDrY6i2mBF/jgiRj9/Ic2Sr6gnSVLFiOglpwgyc0MKEuQaSaLvBDzq0\n VWvOBpO3Jp2P5KHqmoWZa6gkC2XnBGlN7ZDOq8wSEPB3k2kqA+nk9H42MULYGL1tEQCD\n WnRQ==",
        "X-Gm-Message-State": "AOJu0YyfL2bcX5ciqV3td9Y5WUIl2e7bDBz3lAiRgw6KIDxYA6y2YKlh\n ZVpo3eDrcoRGdFnRCv6nvYnUA+1rSd38XEOdjq/UUq/DelyepJjvhTkp6TtHXJKjBKeDYBknMLN\n fe6Y=",
        "X-Google-Smtp-Source": "\n AGHT+IEOZ3POxRf8++2Vhsr3lZCupdpgba85rdDG6nKUbGfQX2IwhH1PNcBRlbHE7VGHvMr0tH2CvA==",
        "X-Received": "by 2002:a50:d6d7:0:b0:566:1952:694c with SMTP id\n l23-20020a50d6d7000000b005661952694cmr1120236edj.20.1709290529483;\n Fri, 01 Mar 2024 02:55:29 -0800 (PST)",
        "From": "=?utf-8?q?Juraj_Linke=C5=A1?= <juraj.linkes@pantheon.tech>",
        "To": "thomas@monjalon.net, Honnappa.Nagarahalli@arm.com, jspewock@iol.unh.edu,\n probb@iol.unh.edu, paul.szczepanek@arm.com, Luca.Vizzarro@arm.com,\n npratte@iol.unh.edu",
        "Cc": "dev@dpdk.org, =?utf-8?q?Juraj_Linke=C5=A1?= <juraj.linkes@pantheon.tech>",
        "Subject": "[PATCH v4 4/7] dts: reorganize test result",
        "Date": "Fri,  1 Mar 2024 11:55:19 +0100",
        "Message-Id": "<20240301105522.79870-5-juraj.linkes@pantheon.tech>",
        "X-Mailer": "git-send-email 2.34.1",
        "In-Reply-To": "<20240301105522.79870-1-juraj.linkes@pantheon.tech>",
        "References": "<20231220103331.60888-1-juraj.linkes@pantheon.tech>\n <20240301105522.79870-1-juraj.linkes@pantheon.tech>",
        "MIME-Version": "1.0",
        "Content-Type": "text/plain; charset=UTF-8",
        "Content-Transfer-Encoding": "8bit",
        "X-BeenThere": "dev@dpdk.org",
        "X-Mailman-Version": "2.1.29",
        "Precedence": "list",
        "List-Id": "DPDK patches and discussions <dev.dpdk.org>",
        "List-Unsubscribe": "<https://mails.dpdk.org/options/dev>,\n <mailto:dev-request@dpdk.org?subject=unsubscribe>",
        "List-Archive": "<http://mails.dpdk.org/archives/dev/>",
        "List-Post": "<mailto:dev@dpdk.org>",
        "List-Help": "<mailto:dev-request@dpdk.org?subject=help>",
        "List-Subscribe": "<https://mails.dpdk.org/listinfo/dev>,\n <mailto:dev-request@dpdk.org?subject=subscribe>",
        "Errors-To": "dev-bounces@dpdk.org"
    },
    "content": "The current order of Result classes in the test_suite.py module is\nguided by the needs of type hints, which is not as intuitively readable\nas ordering them by the occurrences in code. The order goes from the\ntopmost level to lowermost:\nBaseResult\nDTSResult\nExecutionResult\nBuildTargetResult\nTestSuiteResult\nTestCaseResult\n\nThis is the same order as they're used in the runner module and they're\nalso used in the same order between themselves in the test_result\nmodule.\n\nSigned-off-by: Juraj Linkeš <juraj.linkes@pantheon.tech>\n---\n dts/framework/test_result.py | 411 ++++++++++++++++++-----------------\n 1 file changed, 206 insertions(+), 205 deletions(-)",
    "diff": "diff --git a/dts/framework/test_result.py b/dts/framework/test_result.py\nindex 075195fd5b..abdbafab10 100644\n--- a/dts/framework/test_result.py\n+++ b/dts/framework/test_result.py\n@@ -28,6 +28,7 @@\n from dataclasses import dataclass\n from enum import Enum, auto\n from types import MethodType\n+from typing import Union\n \n from .config import (\n     OS,\n@@ -129,58 +130,6 @@ def __bool__(self) -> bool:\n         return bool(self.result)\n \n \n-class Statistics(dict):\n-    \"\"\"How many test cases ended in which result state along some other basic information.\n-\n-    Subclassing :class:`dict` provides a convenient way to format the data.\n-\n-    The data are stored in the following keys:\n-\n-    * **PASS RATE** (:class:`int`) -- The FAIL/PASS ratio of all test cases.\n-    * **DPDK VERSION** (:class:`str`) -- The tested DPDK version.\n-    \"\"\"\n-\n-    def __init__(self, dpdk_version: str | None):\n-        \"\"\"Extend the constructor with keys in which the data are stored.\n-\n-        Args:\n-            dpdk_version: The version of tested DPDK.\n-        \"\"\"\n-        super(Statistics, self).__init__()\n-        for result in Result:\n-            self[result.name] = 0\n-        self[\"PASS RATE\"] = 0.0\n-        self[\"DPDK VERSION\"] = dpdk_version\n-\n-    def __iadd__(self, other: Result) -> \"Statistics\":\n-        \"\"\"Add a Result to the final count.\n-\n-        Example:\n-            stats: Statistics = Statistics()  # empty Statistics\n-            stats += Result.PASS  # add a Result to `stats`\n-\n-        Args:\n-            other: The Result to add to this statistics object.\n-\n-        Returns:\n-            The modified statistics object.\n-        \"\"\"\n-        self[other.name] += 1\n-        self[\"PASS RATE\"] = (\n-            float(self[Result.PASS.name]) * 100 / sum(self[result.name] for result in Result)\n-        )\n-        return self\n-\n-    def __str__(self) -> str:\n-        \"\"\"Each line contains the formatted key = value pair.\"\"\"\n-        stats_str = \"\"\n-        for key, value in self.items():\n-            stats_str += f\"{key:<12} = {value}\\n\"\n-            # according to docs, we should use \\n when writing to text files\n-            # on all platforms\n-        return stats_str\n-\n-\n class BaseResult(object):\n     \"\"\"Common data and behavior of DTS results.\n \n@@ -245,7 +194,7 @@ def get_errors(self) -> list[Exception]:\n         \"\"\"\n         return self._get_setup_teardown_errors() + self._get_inner_errors()\n \n-    def add_stats(self, statistics: Statistics) -> None:\n+    def add_stats(self, statistics: \"Statistics\") -> None:\n         \"\"\"Collate stats from the whole result hierarchy.\n \n         Args:\n@@ -255,91 +204,149 @@ def add_stats(self, statistics: Statistics) -> None:\n             inner_result.add_stats(statistics)\n \n \n-class TestCaseResult(BaseResult, FixtureResult):\n-    r\"\"\"The test case specific result.\n+class DTSResult(BaseResult):\n+    \"\"\"Stores environment information and test results from a DTS run.\n \n-    Stores the result of the actual test case. This is done by adding an extra superclass\n-    in :class:`FixtureResult`. The setup and teardown results are :class:`FixtureResult`\\s and\n-    the class is itself a record of the test case.\n+        * Execution level information, such as testbed and the test suite list,\n+        * Build target level information, such as compiler, target OS and cpu,\n+        * Test suite and test case results,\n+        * All errors that are caught and recorded during DTS execution.\n+\n+    The information is stored hierarchically. This is the first level of the hierarchy\n+    and as such is where the data form the whole hierarchy is collated or processed.\n+\n+    The internal list stores the results of all executions.\n \n     Attributes:\n-        test_case_name: The test case name.\n+        dpdk_version: The DPDK version to record.\n     \"\"\"\n \n-    test_case_name: str\n+    dpdk_version: str | None\n+    _logger: DTSLOG\n+    _errors: list[Exception]\n+    _return_code: ErrorSeverity\n+    _stats_result: Union[\"Statistics\", None]\n+    _stats_filename: str\n \n-    def __init__(self, test_case_name: str):\n-        \"\"\"Extend the constructor with `test_case_name`.\n+    def __init__(self, logger: DTSLOG):\n+        \"\"\"Extend the constructor with top-level specifics.\n \n         Args:\n-            test_case_name: The test case's name.\n+            logger: The logger instance the whole result will use.\n         \"\"\"\n-        super(TestCaseResult, self).__init__()\n-        self.test_case_name = test_case_name\n+        super(DTSResult, self).__init__()\n+        self.dpdk_version = None\n+        self._logger = logger\n+        self._errors = []\n+        self._return_code = ErrorSeverity.NO_ERR\n+        self._stats_result = None\n+        self._stats_filename = os.path.join(SETTINGS.output_dir, \"statistics.txt\")\n \n-    def update(self, result: Result, error: Exception | None = None) -> None:\n-        \"\"\"Update the test case result.\n+    def add_execution(self, sut_node: NodeConfiguration) -> \"ExecutionResult\":\n+        \"\"\"Add and return the inner result (execution).\n \n-        This updates the result of the test case itself and doesn't affect\n-        the results of the setup and teardown steps in any way.\n+        Args:\n+            sut_node: The SUT node's test run configuration.\n+\n+        Returns:\n+            The execution's result.\n+        \"\"\"\n+        execution_result = ExecutionResult(sut_node)\n+        self._inner_results.append(execution_result)\n+        return execution_result\n+\n+    def add_error(self, error: Exception) -> None:\n+        \"\"\"Record an error that occurred outside any execution.\n \n         Args:\n-            result: The result of the test case.\n-            error: The error that occurred in case of a failure.\n+            error: The exception to record.\n         \"\"\"\n-        self.result = result\n-        self.error = error\n+        self._errors.append(error)\n \n-    def _get_inner_errors(self) -> list[Exception]:\n-        if self.error:\n-            return [self.error]\n-        return []\n+    def process(self) -> None:\n+        \"\"\"Process the data after a whole DTS run.\n \n-    def add_stats(self, statistics: Statistics) -> None:\n-        r\"\"\"Add the test case result to statistics.\n+        The data is added to inner objects during runtime and this object is not updated\n+        at that time. This requires us to process the inner data after it's all been gathered.\n \n-        The base method goes through the hierarchy recursively and this method is here to stop\n-        the recursion, as the :class:`TestCaseResult`\\s are the leaves of the hierarchy tree.\n+        The processing gathers all errors and the statistics of test case results.\n+        \"\"\"\n+        self._errors += self.get_errors()\n+        if self._errors and self._logger:\n+            self._logger.debug(\"Summary of errors:\")\n+            for error in self._errors:\n+                self._logger.debug(repr(error))\n \n-        Args:\n-            statistics: The :class:`Statistics` object where the stats will be added.\n+        self._stats_result = Statistics(self.dpdk_version)\n+        self.add_stats(self._stats_result)\n+        with open(self._stats_filename, \"w+\") as stats_file:\n+            stats_file.write(str(self._stats_result))\n+\n+    def get_return_code(self) -> int:\n+        \"\"\"Go through all stored Exceptions and return the final DTS error code.\n+\n+        Returns:\n+            The highest error code found.\n         \"\"\"\n-        statistics += self.result\n+        for error in self._errors:\n+            error_return_code = ErrorSeverity.GENERIC_ERR\n+            if isinstance(error, DTSError):\n+                error_return_code = error.severity\n \n-    def __bool__(self) -> bool:\n-        \"\"\"The test case passed only if setup, teardown and the test case itself passed.\"\"\"\n-        return bool(self.setup_result) and bool(self.teardown_result) and bool(self.result)\n+            if error_return_code > self._return_code:\n+                self._return_code = error_return_code\n \n+        return int(self._return_code)\n \n-class TestSuiteResult(BaseResult):\n-    \"\"\"The test suite specific result.\n \n-    The internal list stores the results of all test cases in a given test suite.\n+class ExecutionResult(BaseResult):\n+    \"\"\"The execution specific result.\n+\n+    The internal list stores the results of all build targets in a given execution.\n \n     Attributes:\n-        suite_name: The test suite name.\n+        sut_node: The SUT node used in the execution.\n+        sut_os_name: The operating system of the SUT node.\n+        sut_os_version: The operating system version of the SUT node.\n+        sut_kernel_version: The operating system kernel version of the SUT node.\n     \"\"\"\n \n-    suite_name: str\n+    sut_node: NodeConfiguration\n+    sut_os_name: str\n+    sut_os_version: str\n+    sut_kernel_version: str\n \n-    def __init__(self, suite_name: str):\n-        \"\"\"Extend the constructor with `suite_name`.\n+    def __init__(self, sut_node: NodeConfiguration):\n+        \"\"\"Extend the constructor with the `sut_node`'s config.\n \n         Args:\n-            suite_name: The test suite's name.\n+            sut_node: The SUT node's test run configuration used in the execution.\n         \"\"\"\n-        super(TestSuiteResult, self).__init__()\n-        self.suite_name = suite_name\n+        super(ExecutionResult, self).__init__()\n+        self.sut_node = sut_node\n \n-    def add_test_case(self, test_case_name: str) -> TestCaseResult:\n-        \"\"\"Add and return the inner result (test case).\n+    def add_build_target(self, build_target: BuildTargetConfiguration) -> \"BuildTargetResult\":\n+        \"\"\"Add and return the inner result (build target).\n+\n+        Args:\n+            build_target: The build target's test run configuration.\n \n         Returns:\n-            The test case's result.\n+            The build target's result.\n         \"\"\"\n-        test_case_result = TestCaseResult(test_case_name)\n-        self._inner_results.append(test_case_result)\n-        return test_case_result\n+        build_target_result = BuildTargetResult(build_target)\n+        self._inner_results.append(build_target_result)\n+        return build_target_result\n+\n+    def add_sut_info(self, sut_info: NodeInfo) -> None:\n+        \"\"\"Add SUT information gathered at runtime.\n+\n+        Args:\n+            sut_info: The additional SUT node information.\n+        \"\"\"\n+        self.sut_os_name = sut_info.os_name\n+        self.sut_os_version = sut_info.os_version\n+        self.sut_kernel_version = sut_info.kernel_version\n \n \n class BuildTargetResult(BaseResult):\n@@ -386,7 +393,7 @@ def add_build_target_info(self, versions: BuildTargetInfo) -> None:\n         self.compiler_version = versions.compiler_version\n         self.dpdk_version = versions.dpdk_version\n \n-    def add_test_suite(self, test_suite_name: str) -> TestSuiteResult:\n+    def add_test_suite(self, test_suite_name: str) -> \"TestSuiteResult\":\n         \"\"\"Add and return the inner result (test suite).\n \n         Returns:\n@@ -397,146 +404,140 @@ def add_test_suite(self, test_suite_name: str) -> TestSuiteResult:\n         return test_suite_result\n \n \n-class ExecutionResult(BaseResult):\n-    \"\"\"The execution specific result.\n+class TestSuiteResult(BaseResult):\n+    \"\"\"The test suite specific result.\n \n-    The internal list stores the results of all build targets in a given execution.\n+    The internal list stores the results of all test cases in a given test suite.\n \n     Attributes:\n-        sut_node: The SUT node used in the execution.\n-        sut_os_name: The operating system of the SUT node.\n-        sut_os_version: The operating system version of the SUT node.\n-        sut_kernel_version: The operating system kernel version of the SUT node.\n+        suite_name: The test suite name.\n     \"\"\"\n \n-    sut_node: NodeConfiguration\n-    sut_os_name: str\n-    sut_os_version: str\n-    sut_kernel_version: str\n+    suite_name: str\n \n-    def __init__(self, sut_node: NodeConfiguration):\n-        \"\"\"Extend the constructor with the `sut_node`'s config.\n+    def __init__(self, suite_name: str):\n+        \"\"\"Extend the constructor with `suite_name`.\n \n         Args:\n-            sut_node: The SUT node's test run configuration used in the execution.\n+            suite_name: The test suite's name.\n         \"\"\"\n-        super(ExecutionResult, self).__init__()\n-        self.sut_node = sut_node\n-\n-    def add_build_target(self, build_target: BuildTargetConfiguration) -> BuildTargetResult:\n-        \"\"\"Add and return the inner result (build target).\n+        super(TestSuiteResult, self).__init__()\n+        self.suite_name = suite_name\n \n-        Args:\n-            build_target: The build target's test run configuration.\n+    def add_test_case(self, test_case_name: str) -> \"TestCaseResult\":\n+        \"\"\"Add and return the inner result (test case).\n \n         Returns:\n-            The build target's result.\n-        \"\"\"\n-        build_target_result = BuildTargetResult(build_target)\n-        self._inner_results.append(build_target_result)\n-        return build_target_result\n-\n-    def add_sut_info(self, sut_info: NodeInfo) -> None:\n-        \"\"\"Add SUT information gathered at runtime.\n-\n-        Args:\n-            sut_info: The additional SUT node information.\n+            The test case's result.\n         \"\"\"\n-        self.sut_os_name = sut_info.os_name\n-        self.sut_os_version = sut_info.os_version\n-        self.sut_kernel_version = sut_info.kernel_version\n+        test_case_result = TestCaseResult(test_case_name)\n+        self._inner_results.append(test_case_result)\n+        return test_case_result\n \n \n-class DTSResult(BaseResult):\n-    \"\"\"Stores environment information and test results from a DTS run.\n-\n-        * Execution level information, such as testbed and the test suite list,\n-        * Build target level information, such as compiler, target OS and cpu,\n-        * Test suite and test case results,\n-        * All errors that are caught and recorded during DTS execution.\n-\n-    The information is stored hierarchically. This is the first level of the hierarchy\n-    and as such is where the data form the whole hierarchy is collated or processed.\n+class TestCaseResult(BaseResult, FixtureResult):\n+    r\"\"\"The test case specific result.\n \n-    The internal list stores the results of all executions.\n+    Stores the result of the actual test case. This is done by adding an extra superclass\n+    in :class:`FixtureResult`. The setup and teardown results are :class:`FixtureResult`\\s and\n+    the class is itself a record of the test case.\n \n     Attributes:\n-        dpdk_version: The DPDK version to record.\n+        test_case_name: The test case name.\n     \"\"\"\n \n-    dpdk_version: str | None\n-    _logger: DTSLOG\n-    _errors: list[Exception]\n-    _return_code: ErrorSeverity\n-    _stats_result: Statistics | None\n-    _stats_filename: str\n+    test_case_name: str\n \n-    def __init__(self, logger: DTSLOG):\n-        \"\"\"Extend the constructor with top-level specifics.\n+    def __init__(self, test_case_name: str):\n+        \"\"\"Extend the constructor with `test_case_name`.\n \n         Args:\n-            logger: The logger instance the whole result will use.\n+            test_case_name: The test case's name.\n         \"\"\"\n-        super(DTSResult, self).__init__()\n-        self.dpdk_version = None\n-        self._logger = logger\n-        self._errors = []\n-        self._return_code = ErrorSeverity.NO_ERR\n-        self._stats_result = None\n-        self._stats_filename = os.path.join(SETTINGS.output_dir, \"statistics.txt\")\n+        super(TestCaseResult, self).__init__()\n+        self.test_case_name = test_case_name\n \n-    def add_execution(self, sut_node: NodeConfiguration) -> ExecutionResult:\n-        \"\"\"Add and return the inner result (execution).\n+    def update(self, result: Result, error: Exception | None = None) -> None:\n+        \"\"\"Update the test case result.\n \n-        Args:\n-            sut_node: The SUT node's test run configuration.\n+        This updates the result of the test case itself and doesn't affect\n+        the results of the setup and teardown steps in any way.\n \n-        Returns:\n-            The execution's result.\n+        Args:\n+            result: The result of the test case.\n+            error: The error that occurred in case of a failure.\n         \"\"\"\n-        execution_result = ExecutionResult(sut_node)\n-        self._inner_results.append(execution_result)\n-        return execution_result\n+        self.result = result\n+        self.error = error\n \n-    def add_error(self, error: Exception) -> None:\n-        \"\"\"Record an error that occurred outside any execution.\n+    def _get_inner_errors(self) -> list[Exception]:\n+        if self.error:\n+            return [self.error]\n+        return []\n+\n+    def add_stats(self, statistics: \"Statistics\") -> None:\n+        r\"\"\"Add the test case result to statistics.\n+\n+        The base method goes through the hierarchy recursively and this method is here to stop\n+        the recursion, as the :class:`TestCaseResult`\\s are the leaves of the hierarchy tree.\n \n         Args:\n-            error: The exception to record.\n+            statistics: The :class:`Statistics` object where the stats will be added.\n         \"\"\"\n-        self._errors.append(error)\n+        statistics += self.result\n \n-    def process(self) -> None:\n-        \"\"\"Process the data after a whole DTS run.\n+    def __bool__(self) -> bool:\n+        \"\"\"The test case passed only if setup, teardown and the test case itself passed.\"\"\"\n+        return bool(self.setup_result) and bool(self.teardown_result) and bool(self.result)\n \n-        The data is added to inner objects during runtime and this object is not updated\n-        at that time. This requires us to process the inner data after it's all been gathered.\n \n-        The processing gathers all errors and the statistics of test case results.\n+class Statistics(dict):\n+    \"\"\"How many test cases ended in which result state along some other basic information.\n+\n+    Subclassing :class:`dict` provides a convenient way to format the data.\n+\n+    The data are stored in the following keys:\n+\n+    * **PASS RATE** (:class:`int`) -- The FAIL/PASS ratio of all test cases.\n+    * **DPDK VERSION** (:class:`str`) -- The tested DPDK version.\n+    \"\"\"\n+\n+    def __init__(self, dpdk_version: str | None):\n+        \"\"\"Extend the constructor with keys in which the data are stored.\n+\n+        Args:\n+            dpdk_version: The version of tested DPDK.\n         \"\"\"\n-        self._errors += self.get_errors()\n-        if self._errors and self._logger:\n-            self._logger.debug(\"Summary of errors:\")\n-            for error in self._errors:\n-                self._logger.debug(repr(error))\n+        super(Statistics, self).__init__()\n+        for result in Result:\n+            self[result.name] = 0\n+        self[\"PASS RATE\"] = 0.0\n+        self[\"DPDK VERSION\"] = dpdk_version\n \n-        self._stats_result = Statistics(self.dpdk_version)\n-        self.add_stats(self._stats_result)\n-        with open(self._stats_filename, \"w+\") as stats_file:\n-            stats_file.write(str(self._stats_result))\n+    def __iadd__(self, other: Result) -> \"Statistics\":\n+        \"\"\"Add a Result to the final count.\n \n-    def get_return_code(self) -> int:\n-        \"\"\"Go through all stored Exceptions and return the final DTS error code.\n+        Example:\n+            stats: Statistics = Statistics()  # empty Statistics\n+            stats += Result.PASS  # add a Result to `stats`\n+\n+        Args:\n+            other: The Result to add to this statistics object.\n \n         Returns:\n-            The highest error code found.\n+            The modified statistics object.\n         \"\"\"\n-        for error in self._errors:\n-            error_return_code = ErrorSeverity.GENERIC_ERR\n-            if isinstance(error, DTSError):\n-                error_return_code = error.severity\n-\n-            if error_return_code > self._return_code:\n-                self._return_code = error_return_code\n+        self[other.name] += 1\n+        self[\"PASS RATE\"] = (\n+            float(self[Result.PASS.name]) * 100 / sum(self[result.name] for result in Result)\n+        )\n+        return self\n \n-        return int(self._return_code)\n+    def __str__(self) -> str:\n+        \"\"\"Each line contains the formatted key = value pair.\"\"\"\n+        stats_str = \"\"\n+        for key, value in self.items():\n+            stats_str += f\"{key:<12} = {value}\\n\"\n+            # according to docs, we should use \\n when writing to text files\n+            # on all platforms\n+        return stats_str\n",
    "prefixes": [
        "v4",
        "4/7"
    ]
}