From: Peter Senna Tschudin <peter.senna@linux.intel.com>
To: "Zbigniew Kempczyński" <zbigniew.kempczynski@intel.com>
Cc: igt-dev@lists.freedesktop.org, marcin.bernatowicz@intel.com,
himanshu.girotra@intel.com, aditya.chauhan@intel.com,
pravalika.gurram@intel.com, sai.gowtham.ch@intel.com,
ramadevi.gandi@intel.com, lucas.demarchi@intel.com,
rodrigo.vivi@intel.com, kamil.konieczny@linux.intel.com,
katarzyna.piecielska@intel.com
Subject: Re: [RFC i-g-t 2/5] lib/igt_dir_explorer: Add function to recursively read all files in a directory
Date: Thu, 15 May 2025 18:40:09 +0200 [thread overview]
Message-ID: <21e8b10e-f47e-455f-b6be-306e7eb2eb33@linux.intel.com> (raw)
In-Reply-To: <ogha6otctbafhcqe5pokhjszogz6rzm2h7cdpxjssvvpiyf5md@xygjmjrvzcgd>
On 5/15/2025 10:51 AM, Zbigniew Kempczyński wrote:
> On Wed, May 14, 2025 at 07:51:34PM +0200, Peter Senna Tschudin wrote:
>> Introduces igt_dir_explorer_read_and_discard_all(), a function that
>> performs a recursive scan of all files within a directory. Each file is
>> read, and its content is discarded.
>>
>> This functionality is utilized in the following tests:
>> - core_debugfs
>> - core_debugfs_display_on_off
>> - core_sysfs
>>
>> This addition enhances the ability to efficiently handle directory
>> traversal and file processing in tests.
>>
>> Cc: marcin.bernatowicz@intel.com
>> Cc: himanshu.girotra@intel.com
>> Cc: aditya.chauhan@intel.com
>> Cc: pravalika.gurram@intel.com
>> Cc: sai.gowtham.ch@intel.com
>> Cc: ramadevi.gandi@intel.com
>> Cc: lucas.demarchi@intel.com
>> Cc: rodrigo.vivi@intel.com
>> Cc: kamil.konieczny@linux.intel.com
>> Cc: katarzyna.piecielska@intel.com
>> Signed-off-by: Peter Senna Tschudin <peter.senna@linux.intel.com>
>> ---
>> lib/igt_dir_explorer.c | 72 ++++++++++++++++++++++++++++++++++++++++++
>> lib/igt_dir_explorer.h | 10 ++++++
>> lib/meson.build | 1 +
>> 3 files changed, 83 insertions(+)
>> create mode 100644 lib/igt_dir_explorer.c
>> create mode 100644 lib/igt_dir_explorer.h
>>
>> diff --git a/lib/igt_dir_explorer.c b/lib/igt_dir_explorer.c
>> new file mode 100644
>> index 000000000..d47e08535
>> --- /dev/null
>> +++ b/lib/igt_dir_explorer.c
>> @@ -0,0 +1,72 @@
>> +// SPDX-License-Identifier: MIT
>> +/*
>> + * Copyright © 2025 Intel Corporation
>> + */
>> +
>> +#include <dirent.h>
>> +#include <fcntl.h>
>> +
>> +#include "igt.h"
>> +#include "igt_dir_explorer.h"
>> +
>> +void igt_dir_explorer_read_and_discard_all(int path_fd, int indent)
>
> Just loose thought - if you're doing recursive directory traversal,
> wouldn't be better to pass function (kind of callback) which would be
> called for each file/dir entry? I mean single traversal code, and
> multiple callbacks for different use cases.
What about?
/* Callback function type for processing files. I guess we should make
* it blocking. Wait for the function to return before starting the next
* file.
*/
typedef int (*igt_dir_exp_file_callback)(int filefd);
/* reading order */
typedef enum {
SCAN_ORDER_SEQUENTIAL,
SCAN_ORDER_RANDOM
} igt_dir_exp_scan_order_t;
/* Struct to hold the library interface */
typedef struct {
int dirfd; /* File descriptor of the directory to scan */
igt_dir_exp_file_callback callback; /* Callback function for file operations. If null defaults
* to read and discard */
const char *include_pattern; /* Pattern to match files to include (glob or regex) */
const char *exclude_pattern; /* Pattern to match files to exclude (glob or regex) */
uint32_t concurrency; /* Number of threads, default is 1 */
size_t max_depth; /* Maximum directory depth to scan. -1 no limit */
size_t max_files; /* Maximum number of files to process. -1 no limit */
size_t max_bytes; /* Maximum bytes to read on each file. -1 no limit */
scan_order_t reading_order; /* Reading order (sequential or random) */
} igt_dir_exp_file_scan_config_t;
/* Function prototype for the library function */
int igt_dir_exp_scan_directory(const igt_dir_exp_file_scan_config_t *config);
next prev parent reply other threads:[~2025-05-15 16:40 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-14 17:51 [RFC i-g-t 0/5] Replace intel_sysfs_debugfs Peter Senna Tschudin
2025-05-14 17:51 ` [RFC i-g-t 1/5] Remove tests/intel/intel_sysfs_debugfs Peter Senna Tschudin
2025-05-14 17:51 ` [RFC i-g-t 2/5] lib/igt_dir_explorer: Add function to recursively read all files in a directory Peter Senna Tschudin
2025-05-15 8:51 ` Zbigniew Kempczyński
2025-05-15 9:04 ` Peter Senna Tschudin
2025-05-16 5:35 ` Zbigniew Kempczyński
2025-05-15 16:40 ` Peter Senna Tschudin [this message]
2025-05-16 5:46 ` Zbigniew Kempczyński
2025-05-14 17:51 ` [RFC i-g-t 3/5] Add tests: core_debugfs and core_debugfs_display_on_off Peter Senna Tschudin
2025-05-14 17:51 ` [RFC i-g-t 4/5] tests/core_sysfs: Add GPU-agnostic sysfs testing Peter Senna Tschudin
2025-05-14 17:51 ` [RFC i-g-t 5/5] tests/intel/xe_debugfs: Add Xe-specific debugfs testing Peter Senna Tschudin
2025-05-14 19:24 ` ✗ Xe.CI.BAT: failure for Replace intel_sysfs_debugfs Patchwork
2025-05-14 19:44 ` ✗ i915.CI.BAT: " Patchwork
2025-05-15 2:40 ` ✗ Xe.CI.Full: " Patchwork
2025-05-20 19:29 ` [RFC v2 i-g-t 0/5] " Peter Senna Tschudin
2025-05-20 19:29 ` [RFC v2 i-g-t 1/5] Remove tests/intel/intel_sysfs_debugfs Peter Senna Tschudin
2025-05-20 19:29 ` [RFC v2 i-g-t 2/5] lib/igt_dir: Directory processing and flexible file handling Peter Senna Tschudin
2025-05-20 19:29 ` [RFC v2 i-g-t 3/5] Add tests: core_debugfs and core_debugfs_display_on_off Peter Senna Tschudin
2025-05-20 19:29 ` [RFC v2 i-g-t 4/5] tests/core_sysfs: Add GPU-agnostic sysfs testing Peter Senna Tschudin
2025-05-20 19:29 ` [RFC v2 i-g-t 5/5] tests/intel/xe_debugfs: Add Xe-specific debugfs testing Peter Senna Tschudin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=21e8b10e-f47e-455f-b6be-306e7eb2eb33@linux.intel.com \
--to=peter.senna@linux.intel.com \
--cc=aditya.chauhan@intel.com \
--cc=himanshu.girotra@intel.com \
--cc=igt-dev@lists.freedesktop.org \
--cc=kamil.konieczny@linux.intel.com \
--cc=katarzyna.piecielska@intel.com \
--cc=lucas.demarchi@intel.com \
--cc=marcin.bernatowicz@intel.com \
--cc=pravalika.gurram@intel.com \
--cc=ramadevi.gandi@intel.com \
--cc=rodrigo.vivi@intel.com \
--cc=sai.gowtham.ch@intel.com \
--cc=zbigniew.kempczynski@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.