Hi. On Wed, Mar 11, 2026 at 07:05:19PM +0800, Li Wang <[email protected]> wrote: > +static bool disable_zswap(void) > +{ > + int st; > + char n[] = "N\n"; > + > + st = zswap_enabled_state(); > + if (st == 0) > + return true; > + if (st < 0) > + return false; > + > + if (write_text("/sys/module/zswap/parameters/enabled", n, strlen(n)) >= > 0) { > + if (zswap_enabled_state() == 0) > + return true; > + } > + > + ksft_print_msg("Failed to disable zswap\n");
Hm, so this can fail?
> + return false;
> +}
> +
> int main(int argc, char **argv)
> {
> char root[PATH_MAX];
> - int i;
> + int i, orig_zswap_state;
>
> ksft_print_header();
> ksft_set_plan(ARRAY_SIZE(tests));
> if (cg_find_unified_root(root, sizeof(root), NULL))
> ksft_exit_skip("cgroup v2 isn't mounted\n");
>
> - if (!zswap_configured())
> + orig_zswap_state = zswap_enabled_state();
> +
> + if (orig_zswap_state == -1)
> ksft_exit_skip("zswap isn't configured\n");
> + else if (orig_zswap_state == 0 && !enable_zswap())
> + ksft_exit_skip("zswap is disabled and cannot be enabled\n");
I should simply check the enablement state and skip if it's not
satisfactory (possibly printing an instructive message what to tweak).
(To keep the test dummy and leave it up to who's reponsible for the
environment.)
My 0.02€,
Michal
signature.asc
Description: PGP signature

