[PATCH] lsmem: correct memmap-on-memory test output

From: Sumanth Korikkar

Date: Mon Mar 02 2026 - 10:52:46 EST


* The "Memmap on memory parameter" line may show "yes", "no",
or may not appear at all if the feature is not supported.
Because this changes between systems, stop checking this line
in the tests.

* When --sysroot is used, do not read /sys/firmware/memory
(used on s390). This makes sure lsmem reads only the memory
directories inside the given sysroot, so the directory list
is correct.

Signed-off-by: Sumanth Korikkar <sumanthk@xxxxxxxxxxxxx>
---
sys-utils/lsmem.c | 2 +-
tests/expected/lsmem/lsmem-s390-zvm-6g | 7 -------
tests/expected/lsmem/lsmem-x86_64-16g | 7 -------
tests/ts/lsmem/lsmem | 2 ++
4 files changed, 3 insertions(+), 15 deletions(-)

diff --git a/sys-utils/lsmem.c b/sys-utils/lsmem.c
index c68f2317c..65b141c51 100644
--- a/sys-utils/lsmem.c
+++ b/sys-utils/lsmem.c
@@ -806,7 +806,7 @@ int main(int argc, char **argv)
err(EXIT_FAILURE, _("failed to initialize %s handler"), _PATH_SYS_MEMORY);
lsmem->sysmemconfig = ul_new_path(_PATH_SYS_MEMCONFIG);
/* Always check for the existence of /sys/firmware/memory/memory0 first */
- if (ul_path_access(lsmem->sysmemconfig, F_OK, "memory0") == 0)
+ if (!prefix && ul_path_access(lsmem->sysmemconfig, F_OK, "memory0") == 0)
lsmem->have_memconfig = 1;
if (!lsmem->sysmemconfig)
err(EXIT_FAILURE, _("failed to initialized %s handler"), _PATH_SYS_MEMCONFIG);
diff --git a/tests/expected/lsmem/lsmem-s390-zvm-6g b/tests/expected/lsmem/lsmem-s390-zvm-6g
index fe3892f6e..40dcfe982 100644
--- a/tests/expected/lsmem/lsmem-s390-zvm-6g
+++ b/tests/expected/lsmem/lsmem-s390-zvm-6g
@@ -17,7 +17,6 @@ RANGE SIZE STATE REMOVABLE BLOCK
Memory block size: 256M
Total online memory: 4.8G
Total offline memory: 1.3G
-Memmap on memory parameter: no

---

@@ -28,7 +27,6 @@ RANGE SIZE
Memory block size: 256M
Total online memory: 4.8G
Total offline memory: 1.3G
-Memmap on memory parameter: no

---

@@ -42,7 +40,6 @@ RANGE SIZE STATE
Memory block size: 256M
Total online memory: 4.8G
Total offline memory: 1.3G
-Memmap on memory parameter: no

---

@@ -76,7 +73,6 @@ RANGE SIZE STATE REMOVABLE BLOCK NODE
Memory block size: 256M
Total online memory: 4.8G
Total offline memory: 1.3G
-Memmap on memory parameter: no

---

@@ -220,7 +216,6 @@ RANGE SIZE STATE REMOVABLE BLOCK ZON
Memory block size: 256M
Total online memory: 4.8G
Total offline memory: 1.3G
-Memmap on memory parameter: no

---

@@ -242,7 +237,6 @@ RANGE SIZE STATE REMOVABLE BLOCK NODE
Memory block size: 256M
Total online memory: 4.8G
Total offline memory: 1.3G
-Memmap on memory parameter: no

---

@@ -262,4 +256,3 @@ RANGE SIZE STATE REMOVABLE BLOCK
Memory block size: 256M
Total online memory: 4.8G
Total offline memory: 1.3G
-Memmap on memory parameter: no
diff --git a/tests/expected/lsmem/lsmem-x86_64-16g b/tests/expected/lsmem/lsmem-x86_64-16g
index d3232470c..52975be9b 100644
--- a/tests/expected/lsmem/lsmem-x86_64-16g
+++ b/tests/expected/lsmem/lsmem-x86_64-16g
@@ -37,7 +37,6 @@ RANGE SIZE STATE REMOVABLE BLOCK
Memory block size: 128M
Total online memory: 16G
Total offline memory: 0B
-Memmap on memory parameter: no

---

@@ -49,7 +48,6 @@ RANGE SIZE
Memory block size: 128M
Total online memory: 16G
Total offline memory: 0B
-Memmap on memory parameter: no

---

@@ -61,7 +59,6 @@ RANGE SIZE STATE
Memory block size: 128M
Total online memory: 16G
Total offline memory: 0B
-Memmap on memory parameter: no

---

@@ -199,7 +196,6 @@ RANGE SIZE STATE REMOVABLE BLOCK NODE ZONES
Memory block size: 128M
Total online memory: 16G
Total offline memory: 0B
-Memmap on memory parameter: no

---

@@ -523,7 +519,6 @@ RANGE SIZE STATE REMOVABLE BLOCK ZONES
Memory block size: 128M
Total online memory: 16G
Total offline memory: 0B
-Memmap on memory parameter: no

---

@@ -563,7 +558,6 @@ RANGE SIZE STATE REMOVABLE BLOCK NODE ZONES
Memory block size: 128M
Total online memory: 16G
Total offline memory: 0B
-Memmap on memory parameter: no

---

@@ -603,4 +597,3 @@ RANGE SIZE STATE REMOVABLE BLOCK
Memory block size: 128M
Total online memory: 16G
Total offline memory: 0B
-Memmap on memory parameter: no
diff --git a/tests/ts/lsmem/lsmem b/tests/ts/lsmem/lsmem
index 179f0ef15..057a30fd5 100755
--- a/tests/ts/lsmem/lsmem
+++ b/tests/ts/lsmem/lsmem
@@ -34,6 +34,8 @@ function do_lsmem {
echo "\$ lsmem $opts" >>${TS_OUTPUT}
${TS_CMD_LSMEM} $opts --sysroot "${dumpdir}/${name}" >> $TS_OUTPUT 2>> $TS_ERRLOG

+ sed -i '/^Memmap on memory parameter:/d' ${TS_OUTPUT}
+
}

for dump in $(ls $TS_SELF/dumps/*.tar.bz2 | sort); do
--
2.53.0