]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
tests: add regression test for repeated termreduce printing
authorAlessandro Ratti <alessandro@0x65c.net>
Sun, 28 Dec 2025 18:12:08 +0000 (19:12 +0100)
committerAlessandro Ratti <alessandro@0x65c.net>
Wed, 7 Jan 2026 13:52:24 +0000 (14:52 +0100)
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 <alessandro@0x65c.net>
tests/commands.sh
tests/expected/libsmartcols/termreduce-loop [new file with mode: 0644]
tests/ts/libsmartcols/termreduce-loop [new file with mode: 0755]

index 19f51529ca543dbeb93480d1a2aebb152c2d830e..dc9c714a4849a8b7ea2f4384a64c70443ee4e916 100644 (file)
@@ -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 (file)
index 0000000..0a8a309
--- /dev/null
@@ -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 (executable)
index 0000000..a34e523
--- /dev/null
@@ -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
+