get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 2229274,
    "url": "http://patchwork.ozlabs.org/api/1.1/patches/2229274/?format=api",
    "web_url": "http://patchwork.ozlabs.org/project/ltp/patch/20260429105114.710966-1-priyama2@linux.ibm.com/",
    "project": {
        "id": 59,
        "url": "http://patchwork.ozlabs.org/api/1.1/projects/59/?format=api",
        "name": "Linux Test Project development",
        "link_name": "ltp",
        "list_id": "ltp.lists.linux.it",
        "list_email": "ltp@lists.linux.it",
        "web_url": "",
        "scm_url": "",
        "webscm_url": ""
    },
    "msgid": "<20260429105114.710966-1-priyama2@linux.ibm.com>",
    "date": "2026-04-29T10:51:14",
    "name": "testcases/nvme: Add NVMe device discovery and identification test",
    "commit_ref": null,
    "pull_url": null,
    "state": "changes-requested",
    "archived": false,
    "hash": "6b13c1b043d651677ad38dba7491d34e886db3c0",
    "submitter": {
        "id": 93267,
        "url": "http://patchwork.ozlabs.org/api/1.1/people/93267/?format=api",
        "name": "priyama2",
        "email": "priyama2@linux.ibm.com"
    },
    "delegate": null,
    "mbox": "http://patchwork.ozlabs.org/project/ltp/patch/20260429105114.710966-1-priyama2@linux.ibm.com/mbox/",
    "series": [
        {
            "id": 501749,
            "url": "http://patchwork.ozlabs.org/api/1.1/series/501749/?format=api",
            "web_url": "http://patchwork.ozlabs.org/project/ltp/list/?series=501749",
            "date": "2026-04-29T10:51:14",
            "name": "testcases/nvme: Add NVMe device discovery and identification test",
            "version": 1,
            "mbox": "http://patchwork.ozlabs.org/series/501749/mbox/"
        }
    ],
    "comments": "http://patchwork.ozlabs.org/api/patches/2229274/comments/",
    "check": "warning",
    "checks": "http://patchwork.ozlabs.org/api/patches/2229274/checks/",
    "tags": {},
    "headers": {
        "Return-Path": "<ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it>",
        "X-Original-To": [
            "incoming@patchwork.ozlabs.org",
            "ltp@lists.linux.it"
        ],
        "Delivered-To": [
            "patchwork-incoming@legolas.ozlabs.org",
            "ltp@picard.linux.it"
        ],
        "Authentication-Results": [
            "legolas.ozlabs.org;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n unprotected) header.d=ibm.com header.i=@ibm.com header.a=rsa-sha256\n header.s=pp1 header.b=J5Zfswae;\n\tdkim-atps=neutral",
            "legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=lists.linux.it\n (client-ip=213.254.12.146; helo=picard.linux.it;\n envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it;\n receiver=patchwork.ozlabs.org)"
        ],
        "Received": [
            "from picard.linux.it (picard.linux.it [213.254.12.146])\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 4g4MGS621hz1xvV\n\tfor <incoming@patchwork.ozlabs.org>; Tue, 28 Apr 2026 10:47:26 +1000 (AEST)",
            "from picard.linux.it (localhost [IPv6:::1])\n\tby picard.linux.it (Postfix) with ESMTP id 82CF83E28AE\n\tfor <incoming@patchwork.ozlabs.org>; Tue, 28 Apr 2026 02:47:23 +0200 (CEST)",
            "from in-4.smtp.seeweb.it (in-4.smtp.seeweb.it [217.194.8.4])\n (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n key-exchange X25519 server-signature ECDSA (secp384r1))\n (No client certificate requested)\n by picard.linux.it (Postfix) with ESMTPS id 0A9553C7A5F\n for <ltp@lists.linux.it>; Tue, 28 Apr 2026 02:47:19 +0200 (CEST)",
            "from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com\n [148.163.156.1])\n (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest\n SHA256)\n (No client certificate requested)\n by in-4.smtp.seeweb.it (Postfix) with ESMTPS id B8FD410000E7\n for <ltp@lists.linux.it>; Tue, 28 Apr 2026 02:47:18 +0200 (CEST)",
            "from pps.filterd (m0353729.ppops.net [127.0.0.1])\n by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id\n 63RCOIPT2327619\n for <ltp@lists.linux.it>; Tue, 28 Apr 2026 00:47:16 GMT",
            "from ppma22.wdc07v.mail.ibm.com\n (5c.69.3da9.ip4.static.sl-reverse.com [169.61.105.92])\n by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4drn9r334q-1\n (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT)\n for <ltp@lists.linux.it>; Tue, 28 Apr 2026 00:47:16 +0000 (GMT)",
            "from pps.filterd (ppma22.wdc07v.mail.ibm.com [127.0.0.1])\n by ppma22.wdc07v.mail.ibm.com (8.18.1.7/8.18.1.7) with ESMTP id\n 63S0ckN7003806\n for <ltp@lists.linux.it>; Tue, 28 Apr 2026 00:47:15 GMT",
            "from smtprelay03.dal12v.mail.ibm.com ([172.16.1.5])\n by ppma22.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4ds8avqm1m-1\n (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT)\n for <ltp@lists.linux.it>; Tue, 28 Apr 2026 00:47:15 +0000 (GMT)",
            "from smtpav02.dal12v.mail.ibm.com (smtpav02.dal12v.mail.ibm.com\n [10.241.53.101])\n by smtprelay03.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id\n 63S0lEvr19727090\n (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK);\n Tue, 28 Apr 2026 00:47:14 GMT",
            "from smtpav02.dal12v.mail.ibm.com (unknown [127.0.0.1])\n by IMSVA (Postfix) with ESMTP id F17785805A;\n Tue, 28 Apr 2026 00:47:13 +0000 (GMT)",
            "from smtpav02.dal12v.mail.ibm.com (unknown [127.0.0.1])\n by IMSVA (Postfix) with ESMTP id BFA0A58051;\n Tue, 28 Apr 2026 00:47:13 +0000 (GMT)",
            "from botlp69.isst.tadn.ibm.com (unknown [9.5.7.36])\n by smtpav02.dal12v.mail.ibm.com (Postfix) with ESMTP;\n Tue, 28 Apr 2026 00:47:13 +0000 (GMT)"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc\n :content-transfer-encoding:date:from:message-id:mime-version\n :subject:to; s=pp1; bh=wXaNcLIm6BwrYfgwydZwm8R8bU2hVQ0zIL0dIyk/j\n HY=; b=J5ZfswaejP0PrUbOpYI3GYw9FjGKOPUn1QyrDFMG09NOo6Rv6bMQgil3u\n 3Fr9/JOFHOEorY0Yr5mYxwVgJkQElebBOH0N3g4MrTkum72qQuoA4Jm5LkXpCHgv\n YjA9am7L5BopnmSJ22CNMeGCnHPuy1rmHqwdc6VGP5Is9dbnFc79LMTbEkIoJg/K\n kaTrOXrPFYY91M1yRTKpoFkUuGAerPrIIuulsQWq5ZYlZSyKTrp2h6d0kO6WRuTU\n /Md5/HNfG5cNxMkQpYVcjHpJzRuY6q5BrFkPpqqJz/IKPFBFKlazoqoXsohZuI/A\n LT5054uO6QbwRpKs9CP7JfjX/mWHw==",
        "From": "priyama2 <priyama2@linux.ibm.com>",
        "To": "ltp@lists.linux.it",
        "Date": "Wed, 29 Apr 2026 10:51:14 +0000",
        "Message-ID": "<20260429105114.710966-1-priyama2@linux.ibm.com>",
        "X-Mailer": "git-send-email 2.52.0",
        "MIME-Version": "1.0",
        "X-TM-AS-GCONF": "00",
        "X-Proofpoint-GUID": "z-SJd-fnAaj4l94hPm2UIVMXx0tGvQGy",
        "X-Proofpoint-Spam-Details-Enc": "AW1haW4tMjYwNDI4MDAwMSBTYWx0ZWRfX1OOjAlfv1Vu/\n DYrh2En39bt+0PfZpe4LYrmzI0oy0ZOw8bf1WuixHvekZJs4YmZEf41JfZxo+mfvh6FHlFQIV79\n tavSpu4QRbClYyptQlQSyR9VVtDC42maDx2PFgRhW/MusPIUWEoq+1QuSAtrP4uFCywdWN0T/cb\n Kg6cQE0885RVnGIpK5dM0xOAYcr9auszPJ1Uj15F8tLL8gNBCp8zQB7MQ4FjVVraWYVIjTpEU9f\n iglHuEMk4agfsBcJ75datth0IiF7d7MW7LaDxi+wwstKG5e4eCknNwBfkrFABn/Kz/sXnoLD4Gl\n LYLIVyBzMfVItM0koPDNTsvH4o2Eq6WfbLBnko+ALZiwvU/qGnCGg4aDn+YiK7kiPbD59LTApbU\n 3kpHq3ZLTL24xj1gkkA/aEtjcvcaDvNwloceYty9qS2hKdyEnpM9Y0NB33RYQyh3iTckZUjZiSM\n EU6hUNdImewakYGaU3g==",
        "X-Authority-Analysis": "v=2.4 cv=Kc7idwYD c=1 sm=1 tr=0 ts=69f00394 cx=c_pps\n a=5BHTudwdYE3Te8bg5FgnPg==:117 a=5BHTudwdYE3Te8bg5FgnPg==:17\n a=A5OVakUREuEA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22\n a=uAbxVGIbfxUO_5tXvNgY:22 a=pNaSbsGRAAAA:8 a=NEAV23lmAAAA:8 a=2vtMdsJAAAAA:8\n a=VnNF1IyMAAAA:8 a=fWpSmyuFXFEm1FXd86wA:9 a=qcg49hLlgF0N60+LroqrWnV/Vu4=:19\n a=cz0TccRYsqG1oLvFGeGV:22 a=MdDwjtskJbVj7SMrG5yS:22",
        "X-Proofpoint-ORIG-GUID": "z-SJd-fnAaj4l94hPm2UIVMXx0tGvQGy",
        "X-Proofpoint-Virus-Version": "vendor=baseguard\n engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49\n definitions=2026-04-27_04,2026-04-21_02,2025-10-01_01",
        "X-Proofpoint-Spam-Details": "rule=outbound_notspam policy=outbound score=0\n clxscore=1015 phishscore=0 bulkscore=0 adultscore=0 spamscore=0\n malwarescore=0 impostorscore=0 priorityscore=1501 lowpriorityscore=0\n suspectscore=0 classifier=typeunknown authscore=0 authtc= authcc=\n route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2604200000\n definitions=main-2604280001",
        "X-Spam-Status": "No, score=1.3 required=7.0 tests=DATE_IN_FUTURE_24_48,\n DKIM_SIGNED,DKIM_VALID,SPF_HELO_NONE,SPF_PASS shortcircuit=no\n autolearn=disabled version=4.0.1",
        "X-Spam-Level": "*",
        "X-Spam-Checker-Version": "SpamAssassin 4.0.1 (2024-03-25) on in-4.smtp.seeweb.it",
        "X-Virus-Scanned": "clamav-milter 1.0.9 at in-4.smtp.seeweb.it",
        "X-Virus-Status": "Clean",
        "Subject": "[LTP] [PATCH] testcases/nvme: Add NVMe device discovery and\n identification test",
        "X-BeenThere": "ltp@lists.linux.it",
        "X-Mailman-Version": "2.1.29",
        "Precedence": "list",
        "List-Id": "Linux Test Project <ltp.lists.linux.it>",
        "List-Unsubscribe": "<https://lists.linux.it/options/ltp>,\n <mailto:ltp-request@lists.linux.it?subject=unsubscribe>",
        "List-Archive": "<http://lists.linux.it/pipermail/ltp/>",
        "List-Post": "<mailto:ltp@lists.linux.it>",
        "List-Help": "<mailto:ltp-request@lists.linux.it?subject=help>",
        "List-Subscribe": "<https://lists.linux.it/listinfo/ltp>,\n <mailto:ltp-request@lists.linux.it?subject=subscribe>",
        "Content-Type": "text/plain; charset=\"us-ascii\"",
        "Content-Transfer-Encoding": "7bit",
        "Errors-To": "ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it",
        "Sender": "\"ltp\" <ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it>"
    },
    "content": "This patch introduces the first test case (nvme01) for NVMe device\ntesting in LTP. The test verifies:\n\n- Detection of NVMe controllers in the system\n- Enumeration of NVMe namespaces\n- PCI bus enumeration verification\n- Driver binding validation\n\nThe test uses the LTP test framework (tst_test.h) and follows LTP\ncoding standards. It provides comprehensive coverage for basic NVMe\ndevice discovery functionality.\n\nTested on:\n- System: ppc64le, RHEL 10.2\n- Kernel: 6.12.0-210.el10.ppc64le\n- Hardware: Samsung PM1735a NVMe devices\n- Result: All 4 test cases passed\n\nThis is the first in a series of patches to add comprehensive NVMe\ntesting support to LTP.\n\nSigned-off-by: priyama2 <priyama2@linux.ibm.com>\n---\n testcases/kernel/device-drivers/nvme/Makefile |  42 ++++\n testcases/kernel/device-drivers/nvme/README   | 155 ++++++++++++\n testcases/kernel/device-drivers/nvme/nvme01.c | 236 ++++++++++++++++++\n 3 files changed, 433 insertions(+)\n create mode 100644 testcases/kernel/device-drivers/nvme/Makefile\n create mode 100644 testcases/kernel/device-drivers/nvme/README\n create mode 100644 testcases/kernel/device-drivers/nvme/nvme01.c",
    "diff": "diff --git a/testcases/kernel/device-drivers/nvme/Makefile b/testcases/kernel/device-drivers/nvme/Makefile\nnew file mode 100644\nindex 000000000..ace6696f6\n--- /dev/null\n+++ b/testcases/kernel/device-drivers/nvme/Makefile\n@@ -0,0 +1,42 @@\n+# SPDX-License-Identifier: GPL-2.0-or-later\n+# Copyright (c) 2024 IBM Corporation\n+#\n+# Standalone Makefile for NVMe LTP test suite\n+\n+# Compiler and flags\n+CC\t\t= gcc\n+CFLAGS\t\t= -Wall -O2 -I/opt/ltp/include\n+LDFLAGS\t\t= -L/opt/ltp/lib\n+LDLIBS\t\t= -lltp -lrt\n+\n+# Test binaries\n+TARGETS\t\t= nvme01 nvme02 nvme03 nvme04\n+\n+# Build all tests\n+all: $(TARGETS)\n+\n+nvme01: nvme01.c\n+\t$(CC) $(CFLAGS) -o $@ $< $(LDFLAGS) $(LDLIBS)\n+\n+nvme02: nvme02.c\n+\t$(CC) $(CFLAGS) -o $@ $< $(LDFLAGS) $(LDLIBS)\n+\n+nvme03: nvme03.c\n+\t$(CC) $(CFLAGS) -o $@ $< $(LDFLAGS) $(LDLIBS)\n+\n+nvme04: nvme04.c\n+\t$(CC) $(CFLAGS) -o $@ $< $(LDFLAGS) $(LDLIBS)\n+\n+# Install targets\n+install: $(TARGETS)\n+\t@mkdir -p /opt/ltp/testcases/bin\n+\t@for target in $(TARGETS); do \\\n+\t\tinstall -m 0755 $$target /opt/ltp/testcases/bin/; \\\n+\tdone\n+\t@echo \"Tests installed to /opt/ltp/testcases/bin/\"\n+\n+# Clean\n+clean:\n+\trm -f $(TARGETS) *.o\n+\n+.PHONY: all install clean\n\\ No newline at end of file\ndiff --git a/testcases/kernel/device-drivers/nvme/README b/testcases/kernel/device-drivers/nvme/README\nnew file mode 100644\nindex 000000000..6ee5796fe\n--- /dev/null\n+++ b/testcases/kernel/device-drivers/nvme/README\n@@ -0,0 +1,155 @@\n+NVMe Test Suite for Linux Test Project (LTP)\n+==============================================\n+\n+This directory contains test cases for NVMe (Non-Volatile Memory Express) \n+device functionality testing.\n+\n+Test Cases\n+----------\n+\n+1. nvme01 - Device Discovery & Identification\n+   Tests:\n+   - Detect NVMe controllers\n+   - Enumerate namespaces\n+   - Verify PCI enumeration\n+   - Check driver binding\n+\n+2. nvme02 - Namespace Management\n+   Tests:\n+   - Create namespaces (various sizes)\n+   - Delete namespaces\n+   - Attach/detach namespaces to controllers\n+   - Resize namespaces\n+   - Format namespaces (different block sizes: 512B, 4KB)\n+   - Namespace sharing across controllers\n+\n+3. nvme03 - I/O Operations\n+   Tests:\n+   - Sequential read/write operations\n+   - Random read/write operations\n+   - Mixed workloads\n+   - Different block sizes (512B, 4KB, 8KB)\n+   - Queue depth variations\n+   - Direct I/O vs buffered I/O\n+\n+4. nvme04 - Multipath & Redundancy\n+   Tests:\n+   - Path failover testing\n+   - Load balancing across paths\n+   - Path recovery\n+   - ANA (Asymmetric Namespace Access) states\n+   - Controller failover\n+\n+Requirements\n+------------\n+\n+Hardware:\n+- System with NVMe storage device(s)\n+- For multipath tests: NVMe device with multiple paths configured\n+\n+Software:\n+- Linux kernel with NVMe support (CONFIG_BLK_DEV_NVME=y)\n+- nvme-cli tools (for namespace management tests)\n+- Root/sudo privileges\n+\n+Building\n+--------\n+\n+From the LTP root directory:\n+  make -C testcases/kernel/device-drivers/nvme\n+\n+Or from this directory:\n+  make\n+\n+Running Tests\n+-------------\n+\n+Individual test execution:\n+  ./nvme01\n+  ./nvme02\n+  ./nvme03\n+  ./nvme04\n+\n+Using LTP runtest:\n+  runltp -f nvme\n+\n+Using runtest file:\n+  runltp -f /opt/ltp/runtest/nvme\n+\n+Test Results\n+------------\n+\n+Tests use standard LTP result codes:\n+- TPASS: Test passed\n+- TFAIL: Test failed\n+- TCONF: Test not configured (e.g., no NVMe device found)\n+- TBROK: Test broken (setup failure)\n+- TWARN: Test warning\n+\n+Notes\n+-----\n+\n+1. Some tests require specific hardware configurations:\n+   - nvme02: May require namespace management support\n+   - nvme04: Requires multipath configuration for full testing\n+\n+2. Destructive tests:\n+   - nvme02 includes namespace creation/deletion which may affect data\n+   - Always run on test systems or with proper backups\n+\n+3. Performance tests (nvme03):\n+   - Results vary based on hardware and system load\n+   - Tests measure relative performance, not absolute benchmarks\n+\n+4. Root privileges:\n+   - All tests require root access for device operations\n+\n+Test Coverage\n+-------------\n+\n+The test suite covers:\n+- Basic NVMe device detection and enumeration\n+- Namespace lifecycle management\n+- I/O performance characteristics\n+- Multipath and redundancy features\n+- Driver and controller state verification\n+\n+Known Limitations\n+-----------------\n+\n+1. Namespace management tests may not work on all NVMe devices\n+   (depends on controller capabilities)\n+\n+2. Multipath tests require specific hardware and kernel configuration\n+\n+3. Some tests are informational and may show TCONF on systems\n+   without full NVMe feature support\n+\n+Contributing\n+------------\n+\n+When adding new tests:\n+1. Follow LTP coding standards\n+2. Use tst_test.h framework\n+3. Include proper error handling\n+4. Document test purpose and requirements\n+5. Test on multiple NVMe device types if possible\n+\n+References\n+----------\n+\n+- NVMe Specification: https://nvmexpress.org/specifications/\n+- Linux NVMe Driver: Documentation/block/nvme.rst\n+- nvme-cli: https://github.com/linux-nvme/nvme-cli\n+- LTP Documentation: https://linux-test-project.github.io/\n+\n+Authors\n+-------\n+\n+Copyright (c) 2024 IBM Corporation\n+LTP NVMe Test Suite\n+\n+License\n+-------\n+\n+SPDX-License-Identifier: GPL-2.0-or-later\n\\ No newline at end of file\ndiff --git a/testcases/kernel/device-drivers/nvme/nvme01.c b/testcases/kernel/device-drivers/nvme/nvme01.c\nnew file mode 100644\nindex 000000000..82fbd315b\n--- /dev/null\n+++ b/testcases/kernel/device-drivers/nvme/nvme01.c\n@@ -0,0 +1,236 @@\n+// SPDX-License-Identifier: GPL-2.0-or-later\n+/*\n+ * Copyright (c) 2024 IBM Corporation\n+ * Author: LTP NVMe Test Suite\n+ *\n+ * Test: NVMe Device Discovery & Identification\n+ *\n+ * This test verifies:\n+ * - Detection of NVMe controllers\n+ * - Enumeration of namespaces\n+ * - PCI enumeration verification\n+ * - Driver binding check\n+ */\n+\n+#define _GNU_SOURCE\n+#include <stdio.h>\n+#include <stdlib.h>\n+#include <string.h>\n+#include <unistd.h>\n+#include <fcntl.h>\n+#include <sys/types.h>\n+#include <sys/stat.h>\n+#include <dirent.h>\n+#include <errno.h>\n+\n+#include \"tst_test.h\"\n+\n+#define NVME_DEV_PATH \"/dev\"\n+#define NVME_SYS_PATH \"/sys/class/nvme\"\n+#define PCI_DEVICES_PATH \"/sys/bus/pci/devices\"\n+\n+static int nvme_device_found = 0;\n+static char nvme_dev_name[256];\n+\n+/*\n+ * Test Case 1: Detect NVMe Controllers\n+ * Verifies that NVMe controllers are present in the system\n+ */\n+static void test_detect_nvme_controllers(void)\n+{\n+\tDIR *dir;\n+\tstruct dirent *entry;\n+\tint found = 0;\n+\n+\tdir = opendir(NVME_DEV_PATH);\n+\tif (!dir) {\n+\t\ttst_brk(TBROK | TERRNO, \"Failed to open %s\", NVME_DEV_PATH);\n+\t\treturn;\n+\t}\n+\n+\ttst_res(TINFO, \"Scanning for NVMe devices in %s\", NVME_DEV_PATH);\n+\n+\twhile ((entry = readdir(dir)) != NULL) {\n+\t\tif (strncmp(entry->d_name, \"nvme\", 4) == 0 &&\n+\t\t    strlen(entry->d_name) == 5) {  /* nvme0, nvme1, etc. */\n+\t\t\ttst_res(TINFO, \"Found NVMe controller: %s\", entry->d_name);\n+\t\t\tstrncpy(nvme_dev_name, entry->d_name, sizeof(nvme_dev_name) - 1);\n+\t\t\tfound = 1;\n+\t\t\tnvme_device_found = 1;\n+\t\t}\n+\t}\n+\n+\tclosedir(dir);\n+\n+\tif (found)\n+\t\ttst_res(TPASS, \"NVMe controller(s) detected successfully\");\n+\telse\n+\t\ttst_res(TCONF, \"No NVMe controllers found in system\");\n+}\n+\n+/*\n+ * Test Case 2: Enumerate Namespaces\n+ * Verifies that NVMe namespaces can be enumerated\n+ */\n+static void test_enumerate_namespaces(void)\n+{\n+\tDIR *dir;\n+\tstruct dirent *entry;\n+\tint ns_count = 0;\n+\tchar search_pattern[32];\n+\n+\tif (!nvme_device_found) {\n+\t\ttst_res(TCONF, \"No NVMe device found, skipping namespace enumeration\");\n+\t\treturn;\n+\t}\n+\n+\tsnprintf(search_pattern, sizeof(search_pattern), \"%sn\", nvme_dev_name);\n+\n+\tdir = opendir(NVME_DEV_PATH);\n+\tif (!dir) {\n+\t\ttst_brk(TBROK | TERRNO, \"Failed to open %s\", NVME_DEV_PATH);\n+\t\treturn;\n+\t}\n+\n+\ttst_res(TINFO, \"Enumerating namespaces for %s\", nvme_dev_name);\n+\n+\twhile ((entry = readdir(dir)) != NULL) {\n+\t\tif (strncmp(entry->d_name, search_pattern, strlen(search_pattern)) == 0) {\n+\t\t\ttst_res(TINFO, \"Found namespace: %s\", entry->d_name);\n+\t\t\tns_count++;\n+\t\t}\n+\t}\n+\n+\tclosedir(dir);\n+\n+\tif (ns_count > 0)\n+\t\ttst_res(TPASS, \"Enumerated %d namespace(s) successfully\", ns_count);\n+\telse\n+\t\ttst_res(TPASS, \"No namespaces found for %s (device may not have namespaces configured)\", nvme_dev_name);\n+}\n+\n+/*\n+ * Test Case 3: Verify PCI Enumeration\n+ * Checks if NVMe device is properly enumerated on PCI bus\n+ */\n+static void test_verify_pci_enumeration(void)\n+{\n+\tDIR *dir;\n+\tstruct dirent *entry;\n+\tint found = 0;\n+\tchar class_path[512];\n+\tFILE *fp;\n+\tchar class_id[16];\n+\n+\tif (!nvme_device_found) {\n+\t\ttst_res(TCONF, \"No NVMe device found, skipping PCI enumeration check\");\n+\t\treturn;\n+\t}\n+\n+\tdir = opendir(PCI_DEVICES_PATH);\n+\tif (!dir) {\n+\t\ttst_brk(TBROK | TERRNO, \"Failed to open %s\", PCI_DEVICES_PATH);\n+\t\treturn;\n+\t}\n+\n+\ttst_res(TINFO, \"Checking PCI enumeration for NVMe devices\");\n+\n+\twhile ((entry = readdir(dir)) != NULL) {\n+\t\tif (entry->d_name[0] == '.')\n+\t\t\tcontinue;\n+\n+\t\tsnprintf(class_path, sizeof(class_path), \"%s/%s/class\",\n+\t\t\t PCI_DEVICES_PATH, entry->d_name);\n+\n+\t\tfp = fopen(class_path, \"r\");\n+\t\tif (!fp)\n+\t\t\tcontinue;\n+\n+\t\tif (fgets(class_id, sizeof(class_id), fp)) {\n+\t\t\t/* NVMe class code is 0x010802 (Mass storage controller: NVM Express) */\n+\t\t\tif (strncmp(class_id, \"0x010802\", 8) == 0) {\n+\t\t\t\ttst_res(TINFO, \"Found NVMe PCI device: %s (class: %s)\",\n+\t\t\t\t\tentry->d_name, class_id);\n+\t\t\t\tfound = 1;\n+\t\t\t}\n+\t\t}\n+\t\tfclose(fp);\n+\t}\n+\n+\tclosedir(dir);\n+\n+\tif (found)\n+\t\ttst_res(TPASS, \"NVMe device properly enumerated on PCI bus\");\n+\telse\n+\t\ttst_res(TFAIL, \"NVMe device not found on PCI bus\");\n+}\n+\n+/*\n+ * Test Case 4: Check Driver Binding\n+ * Verifies that NVMe driver is properly bound to the device\n+ */\n+static void test_check_driver_binding(void)\n+{\n+\tchar driver_path[512];\n+\tchar driver_link[512];\n+\tssize_t len;\n+\n+\tif (!nvme_device_found) {\n+\t\ttst_res(TCONF, \"No NVMe device found, skipping driver binding check\");\n+\t\treturn;\n+\t}\n+\n+\tsnprintf(driver_path, sizeof(driver_path), \"%s/%s/device/driver\",\n+\t\t NVME_SYS_PATH, nvme_dev_name);\n+\n+\tlen = readlink(driver_path, driver_link, sizeof(driver_link) - 1);\n+\tif (len == -1) {\n+\t\ttst_res(TFAIL | TERRNO, \"Failed to read driver symlink for %s\", nvme_dev_name);\n+\t\treturn;\n+\t}\n+\n+\tdriver_link[len] = '\\0';\n+\n+\ttst_res(TINFO, \"Driver binding: %s\", driver_link);\n+\n+\tif (strstr(driver_link, \"nvme\") != NULL)\n+\t\ttst_res(TPASS, \"NVMe driver properly bound to device\");\n+\telse\n+\t\ttst_res(TFAIL, \"Unexpected driver bound to NVMe device: %s\", driver_link);\n+}\n+\n+static void setup(void)\n+{\n+\t/* Check if nvme module is loaded */\n+\tif (access(\"/sys/module/nvme\", F_OK) != 0)\n+\t\ttst_brk(TCONF, \"NVMe kernel module not loaded\");\n+\n+\ttst_res(TINFO, \"NVMe Device Discovery & Identification Test\");\n+}\n+\n+static void run(unsigned int n)\n+{\n+\tswitch (n) {\n+\tcase 0:\n+\t\ttest_detect_nvme_controllers();\n+\t\tbreak;\n+\tcase 1:\n+\t\ttest_enumerate_namespaces();\n+\t\tbreak;\n+\tcase 2:\n+\t\ttest_verify_pci_enumeration();\n+\t\tbreak;\n+\tcase 3:\n+\t\ttest_check_driver_binding();\n+\t\tbreak;\n+\t}\n+}\n+\n+static struct tst_test test = {\n+\t.test = run,\n+\t.tcnt = 4,\n+\t.setup = setup,\n+\t.needs_root = 1,\n+};\n+\n+// Made with Bob\n",
    "prefixes": []
}