[LTP] power_management: rewrite runpwtests04.sh in C

linuxtestproject.agent@gmail.com linuxtestproject.agent@gmail.com
Sun May 24 19:05:59 CEST 2026


Hi Jinseok,

On Mon, 25 May 2026 00:42:20 +0900, Jinseok Kim wrote:
> power_management: rewrite runpwtests04.sh in C

[...]

> +static void verify_cpuidle(unsigned int i)
> +{
> +	int fd;
> +	char path[PATH_MAX];
> +	char buf[32];
> +
> +	snprintf(path, sizeof(path), "%s/%s", CPUIDLE_PATH, tcases[i].name);
> +
> +	fd = SAFE_OPEN(path, O_RDONLY);

SAFE_OPEN() on a non-existent file aborts the test with TBROK.  The
files `current_governor_ro` and `current_driver` may not exist on every
system that has a cpuidle directory (e.g. no cpuidle driver loaded, or
kernel lacks CONFIG_CPU_IDLE_GOV_*).  Use open() directly and convert
ENOENT to TCONF:

    fd = open(path, O_RDONLY);
    if (fd < 0) {
        if (errno == ENOENT)
            tst_res(TCONF, "%s not available", path);
        else
            tst_res(TFAIL | TERRNO, "open(%s) failed", path);
        return;
    }

> +static struct tcases {
> +	const char *name;
> +} tcases[] = {

Tag and variable share the same name.  LTP convention uses the singular
for the struct tag: `struct tcase { ... } tcases[] = {`.

[...]

The new test is named `pwtests01` while the shell test it replaces was
`runpwtests04`.  The commit message does not explain the rename.  If
`pwtests01` is intentional (e.g. start of a new naming series), please
document it briefly.

---
Note:

Our agent completed the review of the patch. The full review can be
found at: https://github.com/linux-test-project/ltp/actions

The agent can sometimes produce false positives although often its
findings are genuine. If you find issues with the review, please
comment this email or ignore the suggestions.

Regards,
LTP AI Reviewer


More information about the ltp mailing list