get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 2218256,
    "url": "http://patchwork.ozlabs.org/api/patches/2218256/?format=api",
    "web_url": "http://patchwork.ozlabs.org/project/kvm-riscv/patch/20260331194202.1722082-5-vipinsh@google.com/",
    "project": {
        "id": 70,
        "url": "http://patchwork.ozlabs.org/api/projects/70/?format=api",
        "name": "Linux KVM RISC-V",
        "link_name": "kvm-riscv",
        "list_id": "kvm-riscv.lists.infradead.org",
        "list_email": "kvm-riscv@lists.infradead.org",
        "web_url": "",
        "scm_url": "",
        "webscm_url": "",
        "list_archive_url": "http://lists.infradead.org/pipermail/kvm-riscv/",
        "list_archive_url_format": "",
        "commit_url_format": ""
    },
    "msgid": "<20260331194202.1722082-5-vipinsh@google.com>",
    "list_archive_url": null,
    "date": "2026-03-31T19:41:57",
    "name": "[v4,4/9] KVM: selftests: Add option to save selftest runner output to a directory",
    "commit_ref": null,
    "pull_url": null,
    "state": "new",
    "archived": false,
    "hash": "808857bb200c134030ab42622d88205153ba9113",
    "submitter": {
        "id": 86282,
        "url": "http://patchwork.ozlabs.org/api/people/86282/?format=api",
        "name": "Vipin Sharma",
        "email": "vipinsh@google.com"
    },
    "delegate": null,
    "mbox": "http://patchwork.ozlabs.org/project/kvm-riscv/patch/20260331194202.1722082-5-vipinsh@google.com/mbox/",
    "series": [
        {
            "id": 498244,
            "url": "http://patchwork.ozlabs.org/api/series/498244/?format=api",
            "web_url": "http://patchwork.ozlabs.org/project/kvm-riscv/list/?series=498244",
            "date": "2026-03-31T19:41:53",
            "name": "KVM: selftests: Create KVM selftests runner",
            "version": 4,
            "mbox": "http://patchwork.ozlabs.org/series/498244/mbox/"
        }
    ],
    "comments": "http://patchwork.ozlabs.org/api/patches/2218256/comments/",
    "check": "pending",
    "checks": "http://patchwork.ozlabs.org/api/patches/2218256/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "\n <kvm-riscv-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org>",
        "X-Original-To": "incoming@patchwork.ozlabs.org",
        "Delivered-To": "patchwork-incoming@legolas.ozlabs.org",
        "Authentication-Results": [
            "legolas.ozlabs.org;\n\tdkim=pass (2048-bit key;\n secure) header.d=lists.infradead.org header.i=@lists.infradead.org\n header.a=rsa-sha256 header.s=bombadil.20210309 header.b=sOr2xerJ;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n unprotected) header.d=google.com header.i=@google.com header.a=rsa-sha256\n header.s=20251104 header.b=m9AYZPGp;\n\tdkim-atps=neutral",
            "legolas.ozlabs.org;\n spf=none (no SPF record) smtp.mailfrom=lists.infradead.org\n (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org;\n envelope-from=kvm-riscv-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org;\n receiver=patchwork.ozlabs.org)"
        ],
        "Received": [
            "from bombadil.infradead.org (bombadil.infradead.org\n [IPv6:2607:7c80:54:3::133])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519 server-signature ECDSA (secp384r1) server-digest SHA384)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4fldmy1TtDz1yGw\n\tfor <incoming@patchwork.ozlabs.org>; Wed, 01 Apr 2026 06:42:26 +1100 (AEDT)",
            "from localhost ([::1] helo=bombadil.infradead.org)\n\tby bombadil.infradead.org with esmtp (Exim 4.98.2 #2 (Red Hat Linux))\n\tid 1w7eym-0000000DUQA-2kMz;\n\tTue, 31 Mar 2026 19:42:24 +0000",
            "from mail-pj1-x104a.google.com ([2607:f8b0:4864:20::104a])\n\tby bombadil.infradead.org with esmtps (Exim 4.98.2 #2 (Red Hat Linux))\n\tid 1w7eyj-0000000DUO0-1a4j\n\tfor kvm-riscv@lists.infradead.org;\n\tTue, 31 Mar 2026 19:42:22 +0000",
            "by mail-pj1-x104a.google.com with SMTP id\n 98e67ed59e1d1-35da86144daso2790453a91.3\n        for <kvm-riscv@lists.infradead.org>;\n Tue, 31 Mar 2026 12:42:20 -0700 (PDT)"
        ],
        "DKIM-Signature": [
            "v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed;\n\td=lists.infradead.org; s=bombadil.20210309; h=Sender:\n\tContent-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post:\n\tList-Archive:List-Unsubscribe:List-Id:Cc:To:From:Subject:Message-ID:\n\tReferences:Mime-Version:In-Reply-To:Date:Reply-To:Content-ID:\n\tContent-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc\n\t:Resent-Message-ID:List-Owner;\n\tbh=hNh4Xs0AucfkIhmM5nww+AGOLdzkoQA1D4Bnpt8evlU=; b=sOr2xerJO660IUTRbe9o8c3w19\n\teJz8CLKJ8eq1ZDoopOSaU8EheRUvTwuIIpZcaA2Yuah6YcHHPNZZMv4HHGnLHNI202P1iPALnLMTl\n\tpeTrBH/OHN49vvpNSeqhZxda8iL0SrVroy1blyhG3XYZmcKDi5zNwsuYpPfWT8aGItvGT59W6f7jZ\n\toVFvlICdTWhR3uMqKtU4I3+ZQs7C4POu+KFQW52lXg33G28cyYtKhkdmo7m2wS7IhSNVkiba3FM7N\n\tZTG7ZQgdB/PFhiXGlIAV1XXUfR2KDNxdti2f1DkF/ybKHB3uBNL1O45v8hEWRKTsuqS0FH0brW3Pz\n\tMk0du0YQ==;",
            "v=1; a=rsa-sha256; c=relaxed/relaxed;\n        d=google.com; s=20251104; t=1774986140; x=1775590940;\n darn=lists.infradead.org;\n        h=cc:to:from:subject:message-id:references:mime-version:in-reply-to\n         :date:from:to:cc:subject:date:message-id:reply-to;\n        bh=ka0uEckvF83qn5GmvpHw9HtNOmToQnEieGf8Vdd2qVw=;\n        b=m9AYZPGpS2iy8rSnRh2PoMJqsui9xQ9P079wLFLObfCoEE3by0sGQ5dbM4dE8df7lD\n         6LUSR+Z//Xq3WWgeSsMdb2aZdZULwqh0xGiuvyENt/uTjpc2vPrGWs0+PF8q7qsm65H3\n         uiHEKlcGWJINbjSZ35JNMZCz9lDhoZPnilPeIrEd3hrf0IJc8UOUdQQaPLsy0rIeU1hI\n         ze74LTdImc9IMCkf3aTZYA8dFu9neQbd98sFOLseouFNYmS+ZNiHlaowpCs+AbDih6Df\n         16wliqPs0345bQO7tm+PkX/BWzbtTidr0q9O56DNe5/Z1ASV+zw/G/WPfZfxGZh+A0ij\n         JtnQ=="
        ],
        "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n        d=1e100.net; s=20251104; t=1774986140; x=1775590940;\n        h=cc:to:from:subject:message-id:references:mime-version:in-reply-to\n         :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to;\n        bh=ka0uEckvF83qn5GmvpHw9HtNOmToQnEieGf8Vdd2qVw=;\n        b=qh+i9TTr5ZZci7YD3jC+2SL4qrifXJg5CnW8uJk3xgtXcPTmAq2L0Y3pt7arI1E4lr\n         K6EBhGwqkkWor0GZnKQcvsIYrM05RmTqoUuJ54og+0IXLRfqz7wFzUW6MxOdnHGrG9Hh\n         5w0H+SQ3Xu7FjVnXUDAzEzVO81qPCwqG77ILpn0I2c2zCe7oHHxX4utBBJjWF1LnYFdf\n         e6OgjTdZSU0R5Z8TsKM11PFiJsA8ghhODsHoDTZ1PGGR40OnFwdUEOLITTS6GdU1uyMn\n         oJ7ZmkOYIey0JUIHzeN1QUGBy6r3MKneWcjee6mdxtvg6E9UAJTxHgEQUWTMgEioV/2M\n         uiYw==",
        "X-Forwarded-Encrypted": "i=1;\n AJvYcCUSBQrz99agIxiJyTc1jAPQAvEvFjulYVaIZS+E1G3kih5r2CNzHtw5HEtQmvWeQTY0p7uekddrP5g=@lists.infradead.org",
        "X-Gm-Message-State": "AOJu0YzyPA/CyAhTs/FOyRalu0BbBZvK1zDEWtf+YqbCu8Xzf5WT32wF\n\totkm2fPZSPz5X4TF3iRweWcSQa0TdUnHBZUo9HuGesykejvfVfbBw5O+lmgfMWeJk9QPh9upqIv\n\tH6kcOkO6rbQ==",
        "X-Received": "from pjblp17.prod.google.com\n ([2002:a17:90b:4a91:b0:35d:a80b:8d43])\n (user=vipinsh job=prod-delivery.src-stubby-dispatcher) by\n 2002:a17:90b:4cc2:b0:35b:e554:53a6\n with SMTP id 98e67ed59e1d1-35dc6ea1153mr570258a91.11.1774986139702; Tue, 31\n Mar 2026 12:42:19 -0700 (PDT)",
        "Date": "Tue, 31 Mar 2026 12:41:57 -0700",
        "In-Reply-To": "<20260331194202.1722082-1-vipinsh@google.com>",
        "Mime-Version": "1.0",
        "References": "<20260331194202.1722082-1-vipinsh@google.com>",
        "X-Mailer": "git-send-email 2.53.0.1118.gaef5881109-goog",
        "Message-ID": "<20260331194202.1722082-5-vipinsh@google.com>",
        "Subject": "[PATCH v4 4/9] KVM: selftests: Add option to save selftest runner\n output to a directory",
        "From": "Vipin Sharma <vipinsh@google.com>",
        "To": "kvm@vger.kernel.org, kvmarm@lists.linux.dev, kvm-riscv@lists.infradead.org",
        "Cc": "seanjc@google.com, pbonzini@redhat.com, borntraeger@linux.ibm.com,\n\tfrankja@linux.ibm.com, imbrenda@linux.ibm.com, anup@brainfault.org,\n\tatish.patra@linux.dev, zhaotianrui@loongson.cn, maobibo@loongson.cn,\n\tchenhuacai@kernel.org, maz@kernel.org, oliver.upton@linux.dev,\n\tajones@ventanamicro.com, Vipin Sharma <vipinsh@google.com>",
        "X-CRM114-Version": "20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 ",
        "X-CRM114-CacheID": "sfid-20260331_124221_424533_A635E3E4 ",
        "X-CRM114-Status": "GOOD (  12.57  )",
        "X-Spam-Score": "-9.5 (---------)",
        "X-Spam-Report": "Spam detection software,\n running on the system \"bombadil.infradead.org\",\n has NOT identified this incoming email as spam.  The original\n message has been attached to this so you can view it or label\n similar future email.  If you have any questions, see\n the administrator of that system for details.\n Content preview:  Add a command line flag, -o/--output,\n to selftest runner which\n    enables it to save individual tests output (stdout & stderr) stream to a\n   directory in a hierarchical way. Create folder hierarchy same as [...]\n Content analysis details:   (-9.5 points, 5.0 required)\n  pts rule name              description\n ---- ----------------------\n --------------------------------------------------\n -0.0 RCVD_IN_DNSWL_NONE     RBL: Sender listed at https://www.dnswl.org/, no\n                             trust\n                             [2607:f8b0:4864:20:0:0:0:104a listed in]\n                             [list.dnswl.org]\n -7.5 USER_IN_DEF_DKIM_WL    From: address is in the default DKIM welcome-list\n  0.0 SPF_HELO_NONE          SPF: HELO does not publish an SPF Record\n -0.0 SPF_PASS               SPF: sender matches SPF record\n  0.1 DKIM_SIGNED            Message has a DKIM or DK signature,\n not necessarily valid\n -0.1 DKIM_VALID_AU          Message has a valid DKIM or DK signature from\n author's\n                             domain\n -0.1 DKIM_VALID             Message has at least one valid DKIM or DK\n signature\n -1.9 BAYES_00               BODY: Bayes spam probability is 0 to 1%\n                             [score: 0.0000]\n -0.0 DKIMWL_WL_MED          DKIMwl.org - Medium trust sender",
        "X-BeenThere": "kvm-riscv@lists.infradead.org",
        "X-Mailman-Version": "2.1.34",
        "Precedence": "list",
        "List-Id": "<kvm-riscv.lists.infradead.org>",
        "List-Unsubscribe": "<http://lists.infradead.org/mailman/options/kvm-riscv>,\n <mailto:kvm-riscv-request@lists.infradead.org?subject=unsubscribe>",
        "List-Archive": "<http://lists.infradead.org/pipermail/kvm-riscv/>",
        "List-Post": "<mailto:kvm-riscv@lists.infradead.org>",
        "List-Help": "<mailto:kvm-riscv-request@lists.infradead.org?subject=help>",
        "List-Subscribe": "<http://lists.infradead.org/mailman/listinfo/kvm-riscv>,\n <mailto:kvm-riscv-request@lists.infradead.org?subject=subscribe>",
        "Content-Type": "text/plain; charset=\"us-ascii\"",
        "Content-Transfer-Encoding": "7bit",
        "Sender": "\"kvm-riscv\" <kvm-riscv-bounces@lists.infradead.org>",
        "Errors-To": "kvm-riscv-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org"
    },
    "content": "Add a command line flag, -o/--output, to selftest runner which enables\nit to save individual tests output (stdout & stderr) stream to a\ndirectory in a hierarchical way. Create folder hierarchy same as tests\nhieararcy given by --testcases and --dirs.\n\nAlso, add a command line flag, --append-output-time, which will append\ntimestamp (format YYYY.M.DD.HH.MM.SS) to the directory name given in\n--output flag.\n\nExample:\n  python3 runner --dirs test -o test_result --append_output_time\n\nThis will create test_result.2025.06.06.08.45.57 directory.\n\nSigned-off-by: Vipin Sharma <vipinsh@google.com>\n---\n .../testing/selftests/kvm/runner/__main__.py  | 34 +++++++++++++++--\n .../testing/selftests/kvm/runner/selftest.py  | 38 ++++++++++++++++---\n .../selftests/kvm/runner/test_runner.py       |  4 +-\n 3 files changed, 65 insertions(+), 11 deletions(-)",
    "diff": "diff --git a/tools/testing/selftests/kvm/runner/__main__.py b/tools/testing/selftests/kvm/runner/__main__.py\nindex 82c543d11c34..5ea5ee8957c4 100644\n--- a/tools/testing/selftests/kvm/runner/__main__.py\n+++ b/tools/testing/selftests/kvm/runner/__main__.py\n@@ -7,6 +7,8 @@ import argparse\n import logging\n import os\n import sys\n+import datetime\n+import pathlib\n \n from test_runner import TestRunner\n from selftest import SelftestStatus\n@@ -42,10 +44,20 @@ def cli():\n                         type=int,\n                         help=\"Timeout, in seconds, before runner kills the running test. (Default: 120 seconds)\")\n \n+    parser.add_argument(\"-o\",\n+                        \"--output\",\n+                        nargs='?',\n+                        help=\"Dumps test runner output which includes each test execution result, their stdouts and stderrs hierarchically in the given directory.\")\n+\n+    parser.add_argument(\"--append-output-time\",\n+                        action=\"store_true\",\n+                        default=False,\n+                        help=\"Appends timestamp to the output directory.\")\n+\n     return parser.parse_args()\n \n \n-def setup_logging():\n+def setup_logging(args):\n     class TerminalColorFormatter(logging.Formatter):\n         reset = \"\\033[0m\"\n         red_bold = \"\\033[31;1m\"\n@@ -72,12 +84,26 @@ def setup_logging():\n     logger = logging.getLogger(\"runner\")\n     logger.setLevel(logging.INFO)\n \n+    formatter_args = {\n+        \"fmt\": \"%(asctime)s | %(message)s\",\n+        \"datefmt\": \"%H:%M:%S\"\n+    }\n+\n     ch = logging.StreamHandler()\n-    ch_formatter = TerminalColorFormatter(fmt=\"%(asctime)s | %(message)s\",\n-                                          datefmt=\"%H:%M:%S\")\n+    ch_formatter = TerminalColorFormatter(**formatter_args)\n     ch.setFormatter(ch_formatter)\n     logger.addHandler(ch)\n \n+    if args.output != None:\n+        if (args.append_output_time):\n+            args.output += datetime.datetime.now().strftime(\".%Y.%m.%d.%H.%M.%S\")\n+        pathlib.Path(args.output).mkdir(parents=True, exist_ok=True)\n+        logging_file = os.path.join(args.output, \"log\")\n+        fh = logging.FileHandler(logging_file)\n+        fh_formatter = logging.Formatter(**formatter_args)\n+        fh.setFormatter(fh_formatter)\n+        logger.addHandler(fh)\n+\n \n def fetch_testcases_in_dirs(dirs):\n     testcases = []\n@@ -98,7 +124,7 @@ def fetch_testcases(args):\n \n def main():\n     args = cli()\n-    setup_logging()\n+    setup_logging(args)\n     testcases = fetch_testcases(args)\n     return TestRunner(testcases, args).start()\n \ndiff --git a/tools/testing/selftests/kvm/runner/selftest.py b/tools/testing/selftests/kvm/runner/selftest.py\nindex e3924ee40ab3..76c3e6d463ee 100644\n--- a/tools/testing/selftests/kvm/runner/selftest.py\n+++ b/tools/testing/selftests/kvm/runner/selftest.py\n@@ -7,6 +7,7 @@ import pathlib\n import enum\n import os\n import subprocess\n+import contextlib\n \n class SelftestStatus(enum.IntEnum):\n     \"\"\"\n@@ -29,7 +30,7 @@ class Selftest:\n     Extract the test execution command from test file and executes it.\n     \"\"\"\n \n-    def __init__(self, test_path, path, timeout):\n+    def __init__(self, test_path, path, timeout, output_dir):\n         test_command = pathlib.Path(test_path).read_text().strip()\n         if not test_command:\n             raise ValueError(\"Empty test command in \" + test_path)\n@@ -39,15 +40,14 @@ class Selftest:\n         self.test_path = test_path\n         self.command = test_command\n         self.timeout = timeout\n+        if output_dir is not None:\n+            output_dir = os.path.join(output_dir, test_path.lstrip(\"./\"))\n+        self.output_dir = output_dir\n         self.status = SelftestStatus.NO_RUN\n         self.stdout = \"\"\n         self.stderr = \"\"\n \n-    def run(self):\n-        if not self.exists:\n-            self.stderr = \"File doesn't exist.\"\n-            return\n-\n+    def _run(self, output=None, error=None):\n         run_args = {\n             \"universal_newlines\": True,\n             \"shell\": True,\n@@ -70,4 +70,30 @@ class Selftest:\n             out, err = e.stdout, e.stderr\n \n         self.stdout = out.decode(\"utf-8\", \"replace\") if isinstance(out, bytes) else (out or \"\")\n+        if output is not None:\n+            output.write(self.stdout)\n+\n         self.stderr = err.decode(\"utf-8\", \"replace\") if isinstance(err, bytes) else (err or \"\")\n+        if error is not None:\n+            error.write(self.stderr)\n+\n+    def run(self):\n+        if not self.exists:\n+            self.stderr = \"File doesn't exist.\"\n+            return\n+\n+        if self.output_dir is not None:\n+            pathlib.Path(self.output_dir).mkdir(parents=True, exist_ok=True)\n+\n+        output = None\n+        error = None\n+        with contextlib.ExitStack() as stack:\n+            if self.output_dir is not None:\n+                output_path = os.path.join(self.output_dir, \"stdout\")\n+                output = stack.enter_context(\n+                    open(output_path, encoding=\"utf-8\", mode=\"w\"))\n+\n+                error_path = os.path.join(self.output_dir, \"stderr\")\n+                error = stack.enter_context(\n+                    open(error_path, encoding=\"utf-8\", mode=\"w\"))\n+            return self._run(output, error)\ndiff --git a/tools/testing/selftests/kvm/runner/test_runner.py b/tools/testing/selftests/kvm/runner/test_runner.py\nindex bea82c6239cd..b9101f0e0432 100644\n--- a/tools/testing/selftests/kvm/runner/test_runner.py\n+++ b/tools/testing/selftests/kvm/runner/test_runner.py\n@@ -13,9 +13,11 @@ logger = logging.getLogger(\"runner\")\n class TestRunner:\n     def __init__(self, testcases, args):\n         self.tests = []\n+        self.output_dir = args.output\n \n         for testcase in testcases:\n-            self.tests.append(Selftest(testcase, args.path, args.timeout))\n+            self.tests.append(Selftest(testcase, args.path, args.timeout,\n+                                       args.output))\n \n     def _log_result(self, test_result):\n         logger.info(\"*** stdout ***\\n\" + test_result.stdout)\n",
    "prefixes": [
        "v4",
        "4/9"
    ]
}