From: Christian Goeschel Ndjomouo Date: Mon, 25 May 2026 20:55:38 +0000 (-0400) Subject: tests: (chmem) add tests for aarch64 16K 16G memory layout X-Git-Url: http://git.ipfire.org/index.cgi?a=commitdiff_plain;h=c3244a8a5c9df5a3b9f67f97b0ac1e3f7ef78841;p=thirdparty%2Futil-linux.git tests: (chmem) add tests for aarch64 16K 16G memory layout Signed-off-by: Christian Goeschel Ndjomouo --- diff --git a/tests/expected/chmem/aarch64_16k_16g-enable-disable-blocks b/tests/expected/chmem/aarch64_16k_16g-enable-disable-blocks new file mode 100644 index 000000000..d6558bddf --- /dev/null +++ b/tests/expected/chmem/aarch64_16k_16g-enable-disable-blocks @@ -0,0 +1,2 @@ +offline +online diff --git a/tests/expected/chmem/aarch64_16k_16g-enable-disable-zone b/tests/expected/chmem/aarch64_16k_16g-enable-disable-zone new file mode 100644 index 000000000..c2319f855 --- /dev/null +++ b/tests/expected/chmem/aarch64_16k_16g-enable-disable-zone @@ -0,0 +1,7 @@ +Memory Block 8195 (0x0000010018000000-0x000001001fffffff) disabled +offline +Memory Block 8195 (0x0000010018000000-0x000001001fffffff) enabled +online_movable +Memory Block 8195 (0x0000010018000000-0x000001001fffffff) already enabled + + diff --git a/tests/expected/chmem/aarch64_16k_16g-enable-disable-zone.err b/tests/expected/chmem/aarch64_16k_16g-enable-disable-zone.err new file mode 100644 index 000000000..86ad57220 --- /dev/null +++ b/tests/expected/chmem/aarch64_16k_16g-enable-disable-zone.err @@ -0,0 +1 @@ +chmem: Memory Block 8195 (0x0000010018000000-0x000001001fffffff) enable failed: Zone mismatch diff --git a/tests/ts/chmem/aarch64_16k_16g b/tests/ts/chmem/aarch64_16k_16g new file mode 100755 index 000000000..ad201e314 --- /dev/null +++ b/tests/ts/chmem/aarch64_16k_16g @@ -0,0 +1,105 @@ +#!/usr/bin/env bash + +# This file is part of util-linux. +# +# This file 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 file is distributed in the hope that it will 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. +# +# Copyright (C) 2026 Christian Goeschel Ndjomouo + +TS_TOPDIR="${0%/*}/../.." +TS_DESC="aarch64_16k_16g" + +. "$TS_TOPDIR/functions.sh" +ts_init "$*" + +ts_skip_nonroot + +ts_check_test_command "$TS_CMD_CHMEM" +ts_check_test_command "$TS_CMD_LSMEM" +ts_check_prog "bzip2" +ts_check_prog "tar" + +_PATH_SYS_MEM="/sys/devices/system/memory" + +DUMP_NAME="aarch64_16k_16g" +DUMP_FILENAME="$TS_SELF/sysfs-dumps/$DUMP_NAME.tar.bz2" +DUMP_DIR="$TS_OUTDIR/sysfs-dumps" + +mkdir -p "$DUMP_DIR" +tar -C "$DUMP_DIR" -jxf "$DUMP_FILENAME" + +do_chmem() { + "$TS_CMD_CHMEM" --sysroot "${DUMP_DIR}/${DUMP_NAME}" "${@}" >>"$TS_OUTPUT" 2>>"$TS_ERRLOG" +} + +# The tests below are primarily testing the reads and writes +# performed by chmem(8). Whether the performed actions have an +# effect on the memory block settings, can only be tested on a +# running Linux system. chmem(8) simply interacts with the kernel +# ABI through the sysfs, i.e. reads or writes to the provided interfaces. + +ts_init_subtest "enable-disable-blocks" + +do_chmem --disable --blocks 8193 +path_mem_state="${DUMP_DIR}/${DUMP_NAME}/${_PATH_SYS_MEM}/memory8193/state" +cat "$path_mem_state" >>"$TS_OUTPUT" +true >"$path_mem_state" +printf "\n" >>"$TS_OUTPUT" + +do_chmem --enable --blocks 8193 +cat "$path_mem_state" >>"$TS_OUTPUT" +printf "\n" >>"$TS_OUTPUT" + +ts_finalize_subtest + + +ts_init_subtest "enable-disable-zone" + +# We will enable memory block 8195 (memory8195) on the Movable zone, +# so let us make sure that it is disabled first. + +# In this subtest we will use a hexadecimal address range +index="8195" +range_str="$("$TS_CMD_LSMEM" --sysroot "${DUMP_DIR}/${DUMP_NAME}" \ + --all --output=BLOCK,RANGE --raw 2>>"$TS_ERRLOG" \ + | sed -n "s/\(^$index\) \(.*\)/\2/p" 2>>"$TS_ERRLOG" \ + )" +mem_block="memory${index}" + +# We need to enable the "Movable" zone on this block first +# otherwise chmem will complain about a zone mismatch +echo "Movable" >"${DUMP_DIR}/${DUMP_NAME}/${_PATH_SYS_MEM}/${mem_block}/valid_zones" + + +do_chmem --verbose --disable "$range_str" +path_mem_state="${DUMP_DIR}/${DUMP_NAME}/${_PATH_SYS_MEM}/${mem_block}/state" +cat "$path_mem_state" >>"$TS_OUTPUT" +true >"$path_mem_state" +printf "\n" >>"$TS_OUTPUT" + +do_chmem --verbose --enable --zone "Movable" "$range_str" +cat "$path_mem_state" >>"$TS_OUTPUT" +printf "\n" >>"$TS_OUTPUT" + +# Should report that it is already enabled +do_chmem --verbose --enable "$range_str" +true >"$path_mem_state" +printf "\n" >>"$TS_OUTPUT" + +# Should report a zone mismatch +do_chmem --verbose --enable --zone "Normal" "$range_str" +cat "$path_mem_state" >>"$TS_OUTPUT" +printf "\n" >>"$TS_OUTPUT" + +ts_finalize_subtest + + +ts_finalize diff --git a/tests/ts/chmem/sysfs-dumps/aarch64_16k_16g.tar.bz2 b/tests/ts/chmem/sysfs-dumps/aarch64_16k_16g.tar.bz2 new file mode 100644 index 000000000..a5de793c1 Binary files /dev/null and b/tests/ts/chmem/sysfs-dumps/aarch64_16k_16g.tar.bz2 differ