From: Alessandro Ratti Date: Sun, 28 Dec 2025 18:12:08 +0000 (+0100) Subject: tests: add regression test for repeated termreduce printing X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=aadd29107c43f04a34968a23ca8ee0435acdb783;p=thirdparty%2Futil-linux.git tests: add regression test for repeated termreduce printing Add a regression test that verifies repeated printing of the same libsmartcols table produces identical output when termreduce is used. Before the fix, the effective output width would shrink on each print, resulting in progressively truncated output. The test guards against future regressions by ensuring printing remains stable across invocations. Signed-off-by: Alessandro Ratti --- diff --git a/tests/commands.sh b/tests/commands.sh index 19f51529ca..dc9c714a48 100644 --- a/tests/commands.sh +++ b/tests/commands.sh @@ -66,6 +66,7 @@ TS_HELPER_BLKID_FUZZ="${ts_helpersdir}test_blkid_fuzz" TS_HELPER_PROCFS="${ts_helpersdir}test_procfs" TS_HELPER_TIMEUTILS="${ts_helpersdir}test_timeutils" TS_HELPER_KILL_PIDFDINO="${ts_helpersdir}test_kill_pidfdino" +TS_HELPER_SCOLS_TERMREDUCE="${ts_helpersdir}test_scols_termreduce" # paths to commands TS_CMD_ADDPART=${TS_CMD_ADDPART:-"${ts_commandsdir}addpart"} diff --git a/tests/expected/libsmartcols/termreduce-loop b/tests/expected/libsmartcols/termreduce-loop new file mode 100644 index 0000000000..0a8a309e4e --- /dev/null +++ b/tests/expected/libsmartcols/termreduce-loop @@ -0,0 +1,6 @@ +DATA +THIS-IS-A-VERY-LONG-STRING-THAT-WOUL +DATA +THIS-IS-A-VERY-LONG-STRING-THAT-WOUL +DATA +THIS-IS-A-VERY-LONG-STRING-THAT-WOUL diff --git a/tests/ts/libsmartcols/termreduce-loop b/tests/ts/libsmartcols/termreduce-loop new file mode 100755 index 0000000000..a34e523dc3 --- /dev/null +++ b/tests/ts/libsmartcols/termreduce-loop @@ -0,0 +1,30 @@ +#!/bin/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. +# +# + +TS_TOPDIR="${0%/*}/../.." +TS_DESC="termreduce-loop" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +TESTPROG="$TS_HELPER_SCOLS_TERMREDUCE" +ts_check_test_command "$TESTPROG" + +# Single-shot test: output must match expected file exactly. +ts_run $TESTPROG >> $TS_OUTPUT 2>> $TS_ERRLOG + +ts_finalize +