Rewrite fw_load test using new API
v5 cover Rewrite fw_load test using new API
Support immutable distribution by splitting test in two:
- fw_load01 triggers request_firmware on /lib/firmware (read-only on immutable distributions) and it doesn't support read-only filesystems
- fw_load02 triggers request_firmware on custom path (always supported by any distribution)
---
Changes in v5:
- rebase since apply is failing
- Link to v4: https://lore.kernel.org/r/[email protected]
Changes in v4:
- verify /lib/firmware/update was created by our test
- fix algorithm op order in fw_load02
- Link to v3: https://lore.kernel.org/r/[email protected]
Changes in v3:
- fix bisecting
- fix algorithm op order
- Link to v2: https://lore.kernel.org/r/[email protected]
Changes in v2:
- fix fw_load.h define
- fix Makefile copyright position
- fix year in the firmware file
- Link to v1: https://lore.kernel.org/r/[email protected]
---
Andrea Cervesato (2):
firmware/fw_load: rewrite firmware loading test using new LTP API firmware/fw_load: add fw_load02 for custom firmware path
runtest/kernel_misc | 3 +-
.../{fw_load_kernel => fw_load}/.gitignore | 2 +
.../firmware/{fw_load_kernel => fw_load}/Makefile | 8 +-
testcases/kernel/firmware/fw_load/fw_load.h | 18 ++
testcases/kernel/firmware/fw_load/fw_load01.c | 165 ++++++++++++++++
testcases/kernel/firmware/fw_load/fw_load02.c | 144 ++++++++++++++
.../{fw_load_kernel => fw_load}/ltp_fw_load.c | 0
testcases/kernel/firmware/fw_load_user/.gitignore | 1 -
testcases/kernel/firmware/fw_load_user/Makefile | 20 --
testcases/kernel/firmware/fw_load_user/README | 11 --
testcases/kernel/firmware/fw_load_user/fw_load.c | 213 ---------------------
11 files changed, 336 insertions(+), 249 deletions(-)---
base-commit: 515ec02cfb33a5b7594aa90c8d300fbdc6878f35
change-id: 20260609-fw_load-2882088bec8e
Best regards,
Signature · 5 lines
Andrea Cervesato <[email protected]> -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH v5 1/2 firmware/fw_load: rewrite firmware loading test using new LTP API
From: Andrea Cervesato <[email protected]>
Consolidate the firmware loading tests into a single fw_load directory:
- Convert the kernel-module based test to the new LTP API as fw_load01, with shared definitions moved to fw_load.h.
- Rename fw_load_kernel to fw_load and keep the ltp_fw_load helper module.
- Remove the obsolete user-helper based fw_load_user test.
---
runtest/kernel_misc | 2 +-
.../{fw_load_kernel => fw_load}/.gitignore | 1 +
.../firmware/{fw_load_kernel => fw_load}/Makefile | 8 +-
testcases/kernel/firmware/fw_load/fw_load.h | 18 ++
testcases/kernel/firmware/fw_load/fw_load01.c | 165 ++++++++++++++++
.../{fw_load_kernel => fw_load}/ltp_fw_load.c | 0
testcases/kernel/firmware/fw_load_user/.gitignore | 1 -
testcases/kernel/firmware/fw_load_user/Makefile | 20 --
testcases/kernel/firmware/fw_load_user/README | 11 --
testcases/kernel/firmware/fw_load_user/fw_load.c | 213 ---------------------
10 files changed, 190 insertions(+), 249 deletions(-)runtest/kernel_misc +1 -1
@@ -1,6 +1,6 @@ cn_pec_sh cn_pec.sh kmsg01 kmsg01 -fw_load fw_load +fw_load01 fw_load01 rtc01 rtc01 rtc02 rtc02 block_dev block_dev
testcases/kernel/firmware/fw_load/.gitignore renamed from testcases/kernel/firmware/fw_load_kernel/.gitignore +1 -0
@@ -5,3 +5,4 @@ /ltp_fw_load.mod.c /.tmp_versions/ modules.livepatch +/fw_load01
testcases/kernel/firmware/fw_load/Makefile renamed from testcases/kernel/firmware/fw_load_kernel/Makefile +5 -3
@@ -1,6 +1,6 @@ +# SPDX-License-Identifier: GPL-2.0-or-later # Copyright (c) 2013 Oracle and/or its affiliates. All Rights Reserved. # Copyright (c) Linux Test Project, 2026 -# SPDX-License-Identifier: GPL-2.0-or-later ifneq ($(KERNELRELEASE),)
@@ -11,11 +11,13 @@ endif else top_srcdir ?= ../../../.. -include $(top_srcdir)/include/mk/env_pre.mk + +include $(top_srcdir)/include/mk/testcases.mk REQ_VERSION_MAJOR := 3 REQ_VERSION_PATCH := 7 -MAKE_TARGETS := ltp_fw_load.ko + +MAKE_TARGETS := fw_load01 ltp_fw_load.ko include $(top_srcdir)/include/mk/module.mk include $(top_srcdir)/include/mk/generic_leaf_target.mk
testcases/kernel/firmware/fw_load/fw_load.h new file +18 -0
@@ -0,0 +1,18 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* +* Copyright (c) 2026 SUSE LLC Andrea Cervesato <[email protected]> +*/ + +#ifndef FW_LOAD_H +#define FW_LOAD_H + +#define MNAME_KO "ltp_fw_load.ko" +#define FW_NAME "load_tst.fw" +#define FW_SIZE 0x1000 +#define FW_NUM 5 +#define FW_PATH "/sys/module/firmware_class/parameters/path" +#define DEV_FWNUM "/sys/devices/ltp_fw_load/fwnum" +#define DEV_RESULT "/sys/devices/ltp_fw_load/result" +#define LIB_PATH "/lib/firmware" + +#endif
testcases/kernel/firmware/fw_load/fw_load01.c new file +165 -0
165 lines not on this page · raw message
testcases/kernel/firmware/fw_load/ltp_fw_load.c renamed from testcases/kernel/firmware/fw_load_kernel/ltp_fw_load.c +0 -0
testcases/kernel/firmware/fw_load_user/.gitignore deleted +0 -1
@@ -1 +0,0 @@ -/fw_load
testcases/kernel/firmware/fw_load_user/Makefile deleted +0 -20
@@ -1,20 +0,0 @@ -# Copyright (c) 2013 Oracle and/or its affiliates. All Rights Reserved. -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as -# published by the Free Software Foundation; either version 2 of -# the License, or (at your option) any later version. -# -# This program is distributed in the hope that it would be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - -top_srcdir ?= ../../../.. - -include $(top_srcdir)/include/mk/testcases.mk -include $(top_srcdir)/include/mk/generic_leaf_target.mk
testcases/kernel/firmware/fw_load_user/README deleted +0 -11
@@ -1,11 +0,0 @@ -The aim of the test is to check device firmware loading. Since kernel 3.7 -firmware loading changed to direct loading (by-pass udev). The test consists -of the two parts: - - userspace part - - kernelspace part - -This is the userspace part, its tasks are: - - create firmware files in the standard firmware paths - - load the module and initiate firmware request procedure - - read device's result file and print final results - - unload the module.
testcases/kernel/firmware/fw_load_user/fw_load.c deleted +0 -213
213 lines not on this page · raw message
Signature · 5 lines
2.51.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH v5 1/2] firmware/fw_load: rewrite firmware loading test using new LTP API
Hi!
Quoted 11 lines
---
runtest/kernel_misc | 2 +-
.../{fw_load_kernel => fw_load}/.gitignore | 1 +
.../firmware/{fw_load_kernel => fw_load}/Makefile | 8 +-
testcases/kernel/firmware/fw_load/fw_load.h | 18 ++
testcases/kernel/firmware/fw_load/fw_load01.c | 165 ++++++++++++++++
.../{fw_load_kernel => fw_load}/ltp_fw_load.c | 0
testcases/kernel/firmware/fw_load_user/.gitignore | 1 -
testcases/kernel/firmware/fw_load_user/Makefile | 20 --
testcases/kernel/firmware/fw_load_user/README | 11 --
testcases/kernel/firmware/fw_load_user/fw_load.c | 213 ---------------------This is impossible to review. If you move/rename files it's usually done in a separate patch that does not change the content.
Signature · 5 lines
Cyril Hrubis [email protected] -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH v5 1/2] firmware/fw_load: rewrite firmware loading test using new LTP API
Hi Cyril,
Quoted 13 lines
Hi!
Quoted 11 lines
--- runtest/kernel_misc | 2 +- .../{fw_load_kernel => fw_load}/.gitignore | 1 + .../firmware/{fw_load_kernel => fw_load}/Makefile | 8 +- testcases/kernel/firmware/fw_load/fw_load.h | 18 ++ testcases/kernel/firmware/fw_load/fw_load01.c | 165 ++++++++++++++++ .../{fw_load_kernel => fw_load}/ltp_fw_load.c | 0 testcases/kernel/firmware/fw_load_user/.gitignore | 1 - testcases/kernel/firmware/fw_load_user/Makefile | 20 -- testcases/kernel/firmware/fw_load_user/README | 11 -- testcases/kernel/firmware/fw_load_user/fw_load.c | 213 ---------------------
Quoted 2 lines
This is impossible to review. If you move/rename files it's usually done in a separate patch that does not change the content.
I usually review with double column editor left=old, right=new :-) But I agree with you that diff is messed up. Should I send a new version?
--
Andrea Cervesato
SUSE QE Automation Engineer Linux
[email protected]
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH v5 1/2] firmware/fw_load: rewrite firmware loading test using new LTP API
Hi!
Quoted 11 lines
Quoted 11 lines
Quoted 10 lines
runtest/kernel_misc | 2 +- .../{fw_load_kernel => fw_load}/.gitignore | 1 + .../firmware/{fw_load_kernel => fw_load}/Makefile | 8 +- testcases/kernel/firmware/fw_load/fw_load.h | 18 ++ testcases/kernel/firmware/fw_load/fw_load01.c | 165 ++++++++++++++++ .../{fw_load_kernel => fw_load}/ltp_fw_load.c | 0 testcases/kernel/firmware/fw_load_user/.gitignore | 1 - testcases/kernel/firmware/fw_load_user/Makefile | 20 -- testcases/kernel/firmware/fw_load_user/README | 11 -- testcases/kernel/firmware/fw_load_user/fw_load.c | 213 ---------------------
Quoted 6 lines
Quoted 2 lines
This is impossible to review. If you move/rename files it's usually done in a separate patch that does not change the content.
I usually review with double column editor left=old, right=new :-) But I agree with you that diff is messed up. Should I send a new version?
Yes, please.
Signature · 5 lines
Cyril Hrubis [email protected] -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH v5 2/2 firmware/fw_load: add fw_load02 for custom firmware path
In reply to Andrea CervesatoFrom: Andrea Cervesato <[email protected]>
Add fw_load02 which points the kernel firmware loader at the writable LTP temporary directory via /sys/module/firmware_class/parameters/path. Unlike fw_load01, it does not rely on a writable /lib/firmware and so works on read-only and immutable root filesystems while still exercising request_firmware() for both successful loads and the not-found case.
--- runtest/kernel_misc | 1 + testcases/kernel/firmware/fw_load/.gitignore | 1 + testcases/kernel/firmware/fw_load/Makefile | 2 +- testcases/kernel/firmware/fw_load/fw_load02.c | 144 ++++++++++++++++++++++++++ 4 files changed, 147 insertions(+), 1 deletion(-)
runtest/kernel_misc +1 -0
@@ -1,6 +1,7 @@ cn_pec_sh cn_pec.sh kmsg01 kmsg01 fw_load01 fw_load01 +fw_load02 fw_load02 rtc01 rtc01 rtc02 rtc02 block_dev block_dev
testcases/kernel/firmware/fw_load/.gitignore +1 -0
@@ -6,3 +6,4 @@ /.tmp_versions/ modules.livepatch /fw_load01 +/fw_load02
testcases/kernel/firmware/fw_load/Makefile +1 -1
@@ -17,7 +17,7 @@ include $(top_srcdir)/include/mk/testcases.mk REQ_VERSION_MAJOR := 3 REQ_VERSION_PATCH := 7 -MAKE_TARGETS := fw_load01 ltp_fw_load.ko +MAKE_TARGETS := fw_load01 fw_load02 ltp_fw_load.ko include $(top_srcdir)/include/mk/module.mk include $(top_srcdir)/include/mk/generic_leaf_target.mk
testcases/kernel/firmware/fw_load/fw_load02.c new file +144 -0
144 lines not on this page · raw message
Signature · 5 lines
2.51.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH v5 2/2] firmware/fw_load: add fw_load02 for custom firmware path
Hi!
Quoted 8 lines
testcases/kernel/firmware/fw_load/fw_load02.c new file +8
-0+static void setup (void ) +{ +char fw_size_param[32 ]; +char *tmpdir =tst_tmpdir_path (); +struct tst_path_val fw_path = { + .path =FW_PATH , + .val = tmpdir, + .flags =TST_SR_TCONF ,
testcases/kernel/firmware/fw_load/fw_load02.c line 110
Quoted 10 lines
testcases/kernel/firmware/fw_load/fw_load02.c new file +10
-0+ }; + +tst_requires_module_signature_disabled (); + +/* +* Point the kernel firmware loader at our writable tmpdir so the +* test does not depend on a writable /lib/firmware. The previous +* value is restored automatically during cleanup. +*/ +tst_sys_conf_save (&fw_path);
I would say that it's cleaner to add the save_restore to the tst_test structure without the tmpdir value and use SAFE_FILE_PRINTF(FW_PATH, "%s", tmpdir) in the test setup. Since if the test crashes the test library will still restore the FW_PATH
Signature · 5 lines
Cyril Hrubis [email protected] -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH v5 2/2] firmware/fw_load: add fw_load02 for custom firmware path
Hi Cyril,
Quoted 11 lines
testcases/kernel/firmware/fw_load/fw_load02.c line 110
Quoted 6 lines
testcases/kernel/firmware/fw_load/fw_load02.c new file +6
-0+/* +* Point the kernel firmware loader at our writable tmpdir so the +* test does not depend on a writable /lib/firmware. The previous +* value is restored automatically during cleanup. +*/ +tst_sys_conf_save (&fw_path);I would say that it's cleaner to add the
save_restoreto thetst_teststructure without the tmpdir value and useSAFE_FILE_PRINTF(FW_PATH, "%s", tmpdir)in the test setup. Since if the test crashes the test library will still restore theFW_PATH
The problem here is that we have to use the tmpdir for the custom folder, because on immutable distribution fw_path will be read-only.
Regards,
--
Andrea Cervesato
SUSE QE Automation Engineer Linux
[email protected]
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH v5 2/2] firmware/fw_load: add fw_load02 for custom firmware path
Hi!
Quoted 7 lines
Quoted 4 lines
I would say that it's cleaner to add the
save_restoreto thetst_teststructure without the tmpdir value and useSAFE_FILE_PRINTF(FW_PATH, "%s", tmpdir)in the test setup. Since if the test crashes the test library will still restore theFW_PATHThe problem here is that we have to use the tmpdir for the custom folder, because on immutable distribution
fw_pathwill be read-only.
And I do ask to split the part where we ask the library to save and restore the value and the part where we set it so that we can have the save restore in the tst_test structure.
Signature · 5 lines
Cyril Hrubis [email protected] -- Mailing list info: https://lists.linux.it/listinfo/ltp