[LTP] [PATCH v6 2/4] fw_load: rewrite test using new LTP API
Cyril Hrubis
chrubis@suse.cz
Mon Jun 15 13:33:00 CEST 2026
Hi!
> +static void run(void)
> {
> - setup(argc, argv);
> + struct fw_data *fw;
> + int result = 0;
> + int fail, offset;
>
> - test_run();
> + SAFE_FILE_PRINTF(DEV_FWNUM, "%d", fw_count);
> + SAFE_FILE_SCANF(DEV_RESULT, "%d", &result);
>
> - cleanup();
> + for (int i = 0; i < fw_count; i++) {
> + fw = &firmware[i];
>
> - tst_exit();
> -}
> + fail = (result & (1 << i)) == 0 && !fw->fake;
> + offset = fw->dir[0] ? strlen(fw->dir) : 0;
>
> -static void help(void)
> -{
> - printf(" -n x Write x bytes to firmware file, default is %d\n",
> - fw_size);
> - printf(" -s Skip cleanup\n");
> - printf(" -v Verbose\n");
> + if (fw->fake) {
> + tst_res(result & (1 << i) ? TFAIL : TPASS,
> + "Firmware '%s' correctly not loaded",
> + fw->file + offset);
> + } else {
> + tst_res(fail ? TFAIL : TPASS,
> + "Firmware '%s' loaded",
> + fw->file + offset);
> + }
If you are splitting the tst_res() by the fw->fake then do it right. We
should drop the && !fw->fake from the fail above and use a variable
only to get the right bit from the result:
int pass = result && (1<<i);
if (fw->fake)
tst_res(pass ? TFAIL : TPASS, ...)
else
tst_res(pass ? TPASS : TFAIL, ...)
> + }
> }
>
> -void setup(int argc, char *argv[])
> +static void setup(void)
> {
> - if (tst_lockdown_enabled() > 0 || tst_secureboot_enabled() > 0)
> - tst_brkm(TCONF, NULL, "Cannot load unsigned modules in Lockdown/Secure Boot");
I assume that we dropped this because we have
tst_requires_module_signature_disabled() later in the setup() right?
The rest looks good.
--
Cyril Hrubis
chrubis@suse.cz
More information about the ltp
mailing list