[LTP] [PATCH v8] power_management: rewrite runpwtests04.sh in C
Jan Stancek
jstancek@redhat.com
Thu Aug 6 10:36:44 CEST 2026
On Wed, Aug 5, 2026 at 5:48 PM Petr Vorel <pvorel@suse.cz> 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
>
More information about the ltp
mailing list