Re: [PATCH v4 1/7] selftests/cgroup: skip test_zswap if zswap is globally disabled

Yosry Ahmed
2026-03-24T00:13:31Z

> diff --git a/tools/testing/selftests/cgroup/test_zswap.c b/tools/testing/selftests/cgroup/test_zswap.c
> index 64ebc3f3f203..e69d845d3592 100644
> --- a/tools/testing/selftests/cgroup/test_zswap.c
> +++ b/tools/testing/selftests/cgroup/test_zswap.c
> @@ -589,9 +589,21 @@ struct zswap_test {
> };
> #undef T
>
> -static bool zswap_configured(void)
> +static void check_zswap_enabled(void)
> {
> - return access("/sys/module/zswap", F_OK) == 0;
> + char value[2];
> +
> + if (access("/sys/module/zswap", F_OK))
> + ksft_exit_skip("zswap isn't configured\n");
> +
> + if (read_text("/sys/module/zswap/parameters/enabled", value,
> + sizeof(value)) <= 0)
> + ksft_exit_fail_msg("Failed to read "
> + "/sys/module/zswap/parameters/enabled\n");
> +
> + if (value[0] == 'N')
> + ksft_exit_skip("zswap is disabled (hint: echo 1 > "
> + "/sys/module/zswap/parameters/enabled)\n");
> }

In the next version please put "/sys/module/zswap" and
"/sys/module/zswap/parameters/enabled" in macros to avoid all the line
breaks here.