From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 6FD19C28B28 for ; Tue, 18 Mar 2025 09:54:34 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 150D910E360; Tue, 18 Mar 2025 09:54:34 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="J0bAQ5B9"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.18]) by gabe.freedesktop.org (Postfix) with ESMTPS id A183010E0A4 for ; Tue, 18 Mar 2025 09:54:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1742291672; x=1773827672; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=FfXjj5INS06dojWjzxfpPpMCuTJxdXPSbyG/ovhcTpQ=; b=J0bAQ5B9azli6HtVTIv7sRzlHlQFmH4Or8mVSskUzFFkGiMdmF0nQT1q YL9IoV6pDOGylZ0W10KX+HborPi6BSrHFIbTZMI76CTVvj5ahqwER2Mch aSVMPc5y+2MdZh39oIq2N38iR8zZxYRBWMDvqJ6IIqRCFkPlbP0slD8GA ltEwpcrKewLCwhiLtNuT2xTnFlVdO09eL9mf4zYDWMaH1t2ZBjSC3464N nRUGJ9GVkct979Ni4cPDogybbt8i3I4PKJ46DLsWqxiWUn/qaxmv+gpYg ndv0gVTyWzCtRo0HeLU0Zzze7mtFFaoDVkhbvyL5OeDE5jWR/RQ9skAwp w==; X-CSE-ConnectionGUID: GwXVzmRBSqCdXw5JqwjKYw== X-CSE-MsgGUID: kfugE4ZpRQayBMnBJ+24OQ== X-IronPort-AV: E=McAfee;i="6700,10204,11376"; a="42671275" X-IronPort-AV: E=Sophos;i="6.14,256,1736841600"; d="scan'208";a="42671275" Received: from orviesa009.jf.intel.com ([10.64.159.149]) by fmvoesa112.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Mar 2025 02:54:32 -0700 X-CSE-ConnectionGUID: aSvTa1RCQi69JWXUIYkfsw== X-CSE-MsgGUID: ghscRFY8SU6K/80xz2A6zw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.14,256,1736841600"; d="scan'208";a="121944398" Received: from unknown (HELO friendship7-home.clients.intel.com) ([10.245.252.104]) by orviesa009-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Mar 2025 02:54:30 -0700 From: Peter Senna Tschudin To: igt-dev@lists.freedesktop.org Cc: Peter Senna Tschudin , rodrigo.vivi@intel.com, katarzyna.piecielska@intel.com Subject: [PATCH i-g-t 1/1] tests/intel/xe_debugfs: Add tests to read all debugfs and sysfs files Date: Tue, 18 Mar 2025 10:53:50 +0100 Message-Id: <20250318095350.57133-2-peter.senna@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250318095350.57133-1-peter.senna@linux.intel.com> References: <20250318095350.57133-1-peter.senna@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: igt-dev@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development mailing list for IGT GPU Tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: igt-dev-bounces@lists.freedesktop.org Sender: "igt-dev" The existing tests/intel/debugfs_test.c scans and reads all relevant files from sysfs and debugfs, but it is specific to i915, leaving a gap for Xe. A similar test exists for Xe in tests/intel/xe_debugfs.c, but it has two gaps compared to the i915 counterpart: - It lacks sysfs file testing. - It does not attempt to read all debugfs files. This commit addresses these gaps by adding two new tests to tests/intel/xe_debugfs.c: - sysfs_read_all_entries - debugfs_read_all_entries Both tests use the function read_and_discard_sysfs_entries(), which was copied from tests/intel/debugfs_test.c. Cc: rodrigo.vivi@intel.com Cc: katarzyna.piecielska@intel.com Signed-off-by: Peter Senna Tschudin --- tests/intel/xe_debugfs.c | 88 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 87 insertions(+), 1 deletion(-) diff --git a/tests/intel/xe_debugfs.c b/tests/intel/xe_debugfs.c index ec8b0d0b5..0b468c4d4 100644 --- a/tests/intel/xe_debugfs.c +++ b/tests/intel/xe_debugfs.c @@ -235,15 +235,90 @@ static int opt_handler(int option, int option_index, void *input) return IGT_OPT_HANDLER_SUCCESS; } +/** + * SUBTEST: sysfs_read_all_entries + * Description: Read all entries from sysfs path. + * + * SUBTEST: debugfs_read_all_entries + * Description: Read all entries from debugfs path. + */ +static void read_and_discard_sysfs_entries(int path_fd, int indent) +{ + struct dirent *dirent; + DIR *dir; + char tabs[8]; + int i; + + igt_assert(indent < sizeof(tabs) - 1); + + for (i = 0; i < indent; i++) + tabs[i] = '\t'; + tabs[i] = '\0'; + + dir = fdopendir(path_fd); + if (!dir) + return; + + while ((dirent = readdir(dir))) { + if (!strcmp(dirent->d_name, ".") || + !strcmp(dirent->d_name, "..")) + continue; + + if (dirent->d_type == DT_DIR) { + int sub_fd; + + sub_fd = openat(path_fd, dirent->d_name, + O_RDONLY | O_DIRECTORY); + if (sub_fd < 0) + continue; + + igt_debug("%sEntering subdir %s\n", tabs, dirent->d_name); + read_and_discard_sysfs_entries(sub_fd, indent + 1); + close(sub_fd); + } else if (dirent->d_type == DT_REG) { + char buf[512]; + int sub_fd; + ssize_t ret; + + igt_kmsg(KMSG_DEBUG "Reading file \"%s\"\n", dirent->d_name); + igt_debug("%sReading file \"%s\"\n", tabs, dirent->d_name); + igt_set_timeout(5, "reading sysfs entry"); + + sub_fd = openat(path_fd, dirent->d_name, O_RDONLY | O_NONBLOCK); + if (sub_fd == -1) { + igt_debug("%sCould not open file \"%s\" with error: %m\n", + tabs, dirent->d_name); + continue; + } + + do { + ret = read(sub_fd, buf, sizeof(buf)); + } while (ret == sizeof(buf)); + + if (ret == -1) + igt_debug("%sCould not read file \"%s\" with error: %m\n", + tabs, dirent->d_name); + + igt_reset_timeout(); + close(sub_fd); + } + } + closedir(dir); +} + igt_main_args("", long_options, help_str, opt_handler, NULL) { char devnode[PATH_MAX]; int fd; int gt; + int debugfs; + int sysfs; igt_fixture { fd = drm_open_driver(DRIVER_XE); __igt_debugfs_dump(fd, "info", IGT_LOG_INFO); + debugfs = igt_debugfs_dir(fd); + sysfs = igt_sysfs_open(fd); } igt_subtest("base") { @@ -263,6 +338,17 @@ igt_main_args("", long_options, help_str, opt_handler, NULL) test_forcewake(fd); } - igt_fixture + igt_describe("Read all entries from sysfs path."); + igt_subtest("sysfs_read_all_entries") + read_and_discard_sysfs_entries(sysfs, 0); + + igt_describe("Read all entries from debugfs path."); + igt_subtest("debugfs_read_all_entries") + read_and_discard_sysfs_entries(debugfs, 0); + + igt_fixture { + close(sysfs); + close(debugfs); drm_close_driver(fd); + } } -- 2.34.1