Re: [PATCH v8] power_management: rewrite runpwtests04.sh in C
Jan Stancek via ltp <[email protected]> Thu, 6 Aug 2026 10:36:44 +0200
| Newsgroups | gmane.linux.ltp |
|---|---|
| Message-ID | <CAASaF6yfmq8FPtVVzQjG3PFRNkJbJKdWUUM1GiXV-xaQdQwR8w@mail.gmail.com> |
On Wed, Aug 5, 2026 at 5:48 PM Petr Vorel <[email protected]> wrote: > > Hi Jinseok Kim, > > [Cc Jan ] CC mailing list > > > +/*\ > > + * Basic cpuidle sysfs smoke test. > > + * > > + * Verify that selected cpuidle sysfs files are readable and contain > > + * non-empty values. Also verify that current_governor rejects an > > + * invalid governor. > > + * > > + * Root privileges are required to write to current_governor. > > + */ > > + > > +#include <errno.h> > > +#include <fcntl.h> > > +#include <unistd.h> > > + > > +#include "tst_test.h" > > + > > +#define CPUIDLE_PATH "/sys/devices/system/cpu/cpuidle" > > +#define AVAILABLE_GOVERNORS CPUIDLE_PATH "/available_governors" > > +#define CURRENT_DRIVER CPUIDLE_PATH "/current_driver" > > +#define CURRENT_GOVERNOR CPUIDLE_PATH "/current_governor" > > +#define CURRENT_GOVERNOR_RO CPUIDLE_PATH "/current_governor_ro" > > + > > +static void verify_readable(const char *path) > > +{ > > + int ret; > > + char buf[32]; > > + > > + int fd = open(path, O_RDONLY); > > + > > + if (fd < 0) { > > + if (errno == ENOENT) > > + tst_res(TCONF, "%s is not available", path); > While this works, we have .save_restore, you would use it with TST_SR_TCONF_MISSING > https://linux-test-project.readthedocs.io/en/latest/developers/api_c_tests.html#saving-and-restoring-proc-sys-values > > But because that would skip whole testing if one of them is missing, maybe > instead each test function should check with tst_sys_conf_save(). > > @Jan Or something else would be more appropriate than lib/tst_sys_conf.c to just > detect path existence? tst_path_exists() + FILE_SCANF() perhaps, and you report again errors from FILE_SCANF() as TFAIL > > Kind regards, > Petr > -- Mailing list info: https://lists.linux.it/listinfo/ltp