Skip to contentSkip to conversation

Rewrite fw_load test using new API

PATCH Superseded Andrea Cervesato 2 participants 5 messages Jun 10

v1 of 7 Superseded Latest is v7 →

lore
Share & tools
lore
#0 lore raw

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)

---
Andrea Cervesato (3):
fw_load: Modernize ltp_fw_load kernel module 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 +
 testcases/kernel/firmware/fw_load/Makefile         |  25 +++
 testcases/kernel/firmware/fw_load/fw_load.h        |  17 ++
 testcases/kernel/firmware/fw_load/fw_load01.c      | 162 ++++++++++++++++
 testcases/kernel/firmware/fw_load/fw_load02.c      | 144 ++++++++++++++
 testcases/kernel/firmware/fw_load/ltp_fw_load.c    | 178 +++++++++++++++++
 testcases/kernel/firmware/fw_load_kernel/Makefile  |  35 ----
 testcases/kernel/firmware/fw_load_kernel/README    |  16 --
 .../kernel/firmware/fw_load_kernel/ltp_fw_load.c   | 164 ----------------
 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 ---------------------
 14 files changed, 530 insertions(+), 461 deletions(-)

---
base-commit: c1b71bf7ebb6a58507e4998faf5c74154f595f96
change-id: 20260609-fw_load-2882088bec8e

Best regards,

Signature · 5 lines
Andrea Cervesato <[email protected]>


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#1 lore raw

PATCH 1/3 fw_load: Modernize ltp_fw_load kernel module

From: Andrea Cervesato <[email protected]>

Fix VLA (banned since kernel v4.20), replace sscanf() with kstrtoint(), reset test_result between invocations, make the loop variable local and pass expected data explicitly.

Update license headers, fix brace style, drop obsolete README in favour of the in-source documentation.

---
 testcases/kernel/firmware/fw_load_kernel/Makefile  |  16 +--
 testcases/kernel/firmware/fw_load_kernel/README    |  16 ---
 .../kernel/firmware/fw_load_kernel/ltp_fw_load.c   | 114 ++++++++++++---------
 3 files changed, 66 insertions(+), 80 deletions(-)
testcases/kernel/firmware/fw_load_kernel/Makefile +2 -14
index 73996996f3397fb0a7f4616457168213587e654f..e81b300faaa6b4056d4b5f3d1417c381a000256d 100644
@@ -1,18 +1,6 @@
 # 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
+# Copyright (c) Linux Test Project, 2026
+# SPDX-License-Identifier: GPL-2.0-or-later
 
 ifneq ($(KERNELRELEASE),)
 
testcases/kernel/firmware/fw_load_kernel/README deleted +0 -16
deleted file mode 100644
index 97507fd99aa3bead708cd4bf599f4abf9ec6e2da..0000000000000000000000000000000000000000
@@ -1,16 +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 a kernel module, which is a part of the device firmware loading test.
-It allows to call request_firmware kernel function with specified parameters.
-Template firmware file name and expected firmware file's data size are passed
-as the insmod command line parameters. Then, the number of firmware test files
-should be written to sysfs file 'fwnum' (the maximum number is 32). This write
-will initiate request firmware procedure. In the end, results can be read from
-'result' device sysfs file. Also, some information regarding module loading,
-can be obtained by looking at kernel log file.
-
-It is automatically used by userspace part of the test.
testcases/kernel/firmware/fw_load_kernel/ltp_fw_load.c +64 -50

203 lines not on this page · raw message

Signature · 5 lines
2.51.0


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#2 lore raw

Re: [LTP] fw_load: Modernize ltp_fw_load kernel module

Hi Andrea,

Quoted 1 line · Andrea Cervesato

fw_load: Modernize ltp_fw_load kernel module

--- [PATCH 1/3] ---

testcases/kernel/firmware/fw_load_kernel/Makefile line 3

Quoted 7 lines
testcases/kernel/firmware/fw_load_kernel/Makefile +2 -0
 # 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

The SPDX tag must be the first line of the Makefile, before the Copyright lines.

--- [PATCH 2/3] ---

testcases/kernel/firmware/fw_load/fw_load.h

Quoted 5 lines
testcases/kernel/firmware/fw_load/fw_load.h +3 -0
+#ifndef FW_LOAD_H
+
+#define MNAME_KO "ltp_fw_load.ko"

Missing #define FW_LOAD_H after the #ifndef. Without it the include guard is non-functional.

Verdict: Needs revision

---
Note:

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

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#3 lore raw

PATCH 2/3 firmware/fw_load: rewrite firmware loading test using new LTP API

In reply to Andrea Cervesato

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  |   6 +-
 testcases/kernel/firmware/fw_load/fw_load.h        |  17 ++
 testcases/kernel/firmware/fw_load/fw_load01.c      | 162 ++++++++++++++++
 .../{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, 185 insertions(+), 248 deletions(-)
runtest/kernel_misc +1 -1
index 78f00d305fea10367fb4fd2845f25dd151a833ea..19caee1d81da9cf0503088138ecfda13436b96cf 100644
@@ -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
similarity index 90%
rename from testcases/kernel/firmware/fw_load_kernel/.gitignore
rename to testcases/kernel/firmware/fw_load/.gitignore
index 6fc82952c7f5406c04195e1064375d0c2bd53909..53c4b4634684ec7ea6deccedec34b214af4cd3a3 100644
@@ -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 +4 -2
similarity index 81%
rename from testcases/kernel/firmware/fw_load_kernel/Makefile
rename to testcases/kernel/firmware/fw_load/Makefile
index e81b300faaa6b4056d4b5f3d1417c381a000256d..4f1624c41a1bd6ba8db83c73f3a26916542fb204 100644
@@ -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 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_load.h new file +17 -0
new file mode 100644
index 0000000000000000000000000000000000000000..b72b4dfa9b4021bbc4003e53ea6ea3362ec1b21a
@@ -0,0 +1,17 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (c) 2026 SUSE LLC Andrea Cervesato <[email protected]>
+ */
+
+#ifndef 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 +162 -0

162 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
similarity index 100%
rename from testcases/kernel/firmware/fw_load_kernel/ltp_fw_load.c
rename to testcases/kernel/firmware/fw_load/ltp_fw_load.c
testcases/kernel/firmware/fw_load_user/.gitignore deleted +0 -1
deleted file mode 100644
index 1d0814980660f34b64bd49ba16c25dc1d99e9d07..0000000000000000000000000000000000000000
@@ -1 +0,0 @@
-/fw_load
testcases/kernel/firmware/fw_load_user/Makefile deleted +0 -20
deleted file mode 100644
index effd5dae5c05e9115c391093af523ab36ebfc8d6..0000000000000000000000000000000000000000
@@ -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
deleted file mode 100644
index 702fac90a2ccb41612ea8dc1010b468588cd3446..0000000000000000000000000000000000000000
@@ -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
#4 lore raw

PATCH 3/3 firmware/fw_load: add fw_load02 for custom firmware path

In reply to Andrea Cervesato

From: 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/fw_load02.c | 144 ++++++++++++++++++++++++++
 3 files changed, 146 insertions(+)
runtest/kernel_misc +1 -0
index 19caee1d81da9cf0503088138ecfda13436b96cf..cc3562cb78cfa9b657692fcbd8fb732f2879092e 100644
@@ -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
index 53c4b4634684ec7ea6deccedec34b214af4cd3a3..206028a8b2111d0db4dda5c2d5bb18e51c95760d 100644
@@ -6,3 +6,4 @@
 /.tmp_versions/
 modules.livepatch
 /fw_load01
+/fw_load02
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