aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/color-names.c6
-rw-r--r--tests/commands.sh1
-rw-r--r--tests/expected/misc/colors22
-rwxr-xr-xtests/ts/misc/colors42
4 files changed, 68 insertions, 3 deletions
diff --git a/lib/color-names.c b/lib/color-names.c
index f7b1946090..88c4ef9577 100644
--- a/lib/color-names.c
+++ b/lib/color-names.c
@@ -43,7 +43,7 @@ const char *color_sequence_from_colorname(const char *str)
{ "halfbright", UL_COLOR_HALFBRIGHT },
{ "lightblue", UL_COLOR_BOLD_BLUE },
{ "lightcyan", UL_COLOR_BOLD_CYAN },
- { "lightgray,", UL_COLOR_GRAY },
+ { "lightgray", UL_COLOR_GRAY },
{ "lightgreen", UL_COLOR_BOLD_GREEN },
{ "lightmagenta", UL_COLOR_BOLD_MAGENTA },
{ "lightred", UL_COLOR_BOLD_RED },
@@ -51,8 +51,8 @@ const char *color_sequence_from_colorname(const char *str)
{ "red", UL_COLOR_RED },
{ "reset", UL_COLOR_RESET, },
{ "reverse", UL_COLOR_REVERSE },
- { "yellow", UL_COLOR_BOLD_YELLOW },
- { "white", UL_COLOR_WHITE }
+ { "white", UL_COLOR_WHITE },
+ { "yellow", UL_COLOR_BOLD_YELLOW }
};
struct ul_color_name key = { .name = str }, *res;
diff --git a/tests/commands.sh b/tests/commands.sh
index b79d7c650a..fe989a541a 100644
--- a/tests/commands.sh
+++ b/tests/commands.sh
@@ -4,6 +4,7 @@ TS_TESTUSER=${TS_TESTUSER:-"nobody"}
# helpers
TS_HELPER_BOILERPLATE="${ts_helpersdir}test_boilerplate"
TS_HELPER_BYTESWAP="${ts_helpersdir}test_byteswap"
+TS_HELPER_COLORS="${ts_helpersdir}test_colors"
TS_HELPER_CPUSET="${ts_helpersdir}test_cpuset"
TS_HELPER_CAP="${ts_helpersdir}test_cap"
TS_HELPER_DMESG="${ts_helpersdir}test_dmesg"
diff --git a/tests/expected/misc/colors b/tests/expected/misc/colors
new file mode 100644
index 0000000000..c6ae7ce93a
--- /dev/null
+++ b/tests/expected/misc/colors
@@ -0,0 +1,22 @@
+ black: Hello World!
+ blink: Hello World!
+ blue: Hello World!
+ bold: Hello World!
+ brown: Hello World!
+ cyan: Hello World!
+ darkgray: Hello World!
+ gray: Hello World!
+ green: Hello World!
+ halfbright: Hello World!
+ lightblue: Hello World!
+ lightcyan: Hello World!
+ lightgray: Hello World!
+ lightgreen: Hello World!
+ lightmagenta: Hello World!
+ lightred: Hello World!
+ magenta: Hello World!
+ red: Hello World!
+ reset: Hello World!
+ reverse: Hello World!
+ white: Hello World!
+ yellow: Hello World!
diff --git a/tests/ts/misc/colors b/tests/ts/misc/colors
new file mode 100755
index 0000000000..bae7599ace
--- /dev/null
+++ b/tests/ts/misc/colors
@@ -0,0 +1,42 @@
+#!/bin/bash
+
+#
+# SPDX-License-Identifier: GPL-2.0-or-later
+#
+# This program 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.
+#
+# Copyright (C) 2025 Karel Zak <kzak@redhat.com>
+#
+TS_TOPDIR="${0%/*}/../.."
+TS_DESC="colors"
+
+. "$TS_TOPDIR"/functions.sh
+ts_init "$*"
+
+ts_check_test_command "$TS_HELPER_COLORS"
+ts_cd "$TS_OUTDIR"
+
+SRC="${top_srcdir}/lib/color-names.c"
+
+COLOR_NAMES=$(awk '
+ /basic_schemes\[\]/ { in_array=1; next }
+ in_array && /};/ { exit }
+ in_array && /\{[[:space:]]*"/ {
+ sub(/.*\{[[:space:]]*"/, "")
+ if (match($0, /[^"]*/)) {
+ name = substr($0, RSTART, RLENGTH)
+ print name
+ }
+ }
+' "$SRC")
+
+for color in $COLOR_NAMES; do
+ printf "%15s: " "$color" >> $TS_OUTPUT
+ $TS_HELPER_COLORS --mode always --color "$color" >> $TS_OUTPUT 2>> $TS_ERRLOG
+done
+
+ts_finalize
+