]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
tests: (refactor) add ts_skip_config, a new helper function
authorMasatake YAMATO <yamato@redhat.com>
Fri, 9 Jan 2026 03:44:00 +0000 (12:44 +0900)
committerMasatake YAMATO <yamato@redhat.com>
Mon, 12 Jan 2026 18:26:33 +0000 (03:26 +0900)
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
tests/functions.sh
tests/ts/cal/color
tests/ts/cal/colorw
tests/ts/cal/weekarg

index 4e163692789dfb9d891fcedc415ea395b698dd18..4a00463a80475d942731ee83a2ae03b16ca702bd 100644 (file)
@@ -1164,15 +1164,6 @@ function ts_init_socket_to_file {
        fi
 }
 
-function ts_has_ncurses_support {
-       grep -q '#define HAVE_LIBNCURSES' ${top_builddir}/config.h
-       if [ $? == 0 ]; then
-               echo "yes"
-       else
-               echo "no"
-       fi
-}
-
 # Get path to the ASan runtime DSO the given binary was compiled with
 function ts_get_asan_rt_path {
        local binary="${1?}"
@@ -1232,6 +1223,15 @@ function ts_check_ipv6 {
        fi
 }
 
+# ts_skip_config CONFIG SKIP_DESC
+function ts_skip_config {
+       grep -q "#define $1" ${top_builddir}/config.h || ts_skip "$2"
+}
+
+function ts_skip_ncurses {
+       ts_skip_config HAVE_LIBNCURSES "without-ncurses"
+}
+
 function ts_skip_netns {
-       grep -q '#define HAVE_LINUX_NET_NAMESPACE_H' ${top_builddir}/config.h || ts_skip "no netns support"
+       ts_skip_config HAVE_LINUX_NET_NAMESPACE_H "no netns support"
 }
index 2dffefed38ebf5e36bc39f6d1c1654ac5685014e..359f6a8f495ede38ec1c0d269cbd084be3d8eaea 100755 (executable)
@@ -23,10 +23,7 @@ ts_init "$*"
 ts_check_test_command "$TS_CMD_CAL"
 ts_inhibit_custom_colorscheme
 
-has_ncurses=$( ts_has_ncurses_support )
-if [ "$has_ncurses" != "yes" ]; then
-       ts_skip "without-ncurses"
-fi
+ts_skip_ncurses
 
 # --color output depends on terminal type
 export TERM=linux
index 541e2f44546b8bdf833495874e3ab61e14eb00cc..96da748c622d5800d489dae3eb5708544011dd9d 100755 (executable)
@@ -23,10 +23,7 @@ ts_init "$*"
 ts_check_test_command "$TS_CMD_CAL"
 ts_inhibit_custom_colorscheme
 
-has_ncurses=$( ts_has_ncurses_support )
-if [ "$has_ncurses" != "yes" ]; then
-       ts_skip "without-ncurses"
-fi
+ts_skip_ncurses
 
 # --color output depends on terminal type
 export TERM=linux
index 477cbd5dfd1ce7092c8f1648204d543228a237ec..006b03d693b58d2706a1799c02846d3cdab7cd2c 100755 (executable)
@@ -24,10 +24,7 @@ ts_init "$*"
 ts_check_test_command "$TS_CMD_CAL"
 ts_inhibit_custom_colorscheme
 
-has_ncurses=$( ts_has_ncurses_support )
-if [ "$has_ncurses" != "yes" ]; then
-       ts_skip "without-ncurses"
-fi
+ts_skip_ncurses
 
 export TERM=linux