summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sys-utils/Makemodule.am4
-rw-r--r--sys-utils/dmesg.c5
-rw-r--r--tests/commands.sh2
-rwxr-xr-xtests/ts/dmesg/console-levels4
-rwxr-xr-xtests/ts/dmesg/decode4
-rwxr-xr-xtests/ts/dmesg/delta4
-rwxr-xr-xtests/ts/dmesg/facilities4
-rwxr-xr-xtests/ts/dmesg/indentation10
8 files changed, 23 insertions, 14 deletions
diff --git a/sys-utils/Makemodule.am b/sys-utils/Makemodule.am
index d538cdad7..a1dc042d6 100644
--- a/sys-utils/Makemodule.am
+++ b/sys-utils/Makemodule.am
@@ -75,6 +75,10 @@ dist_man_MANS += sys-utils/dmesg.1
dmesg_SOURCES = sys-utils/dmesg.c lib/monotonic.c
dmesg_LDADD = $(LDADD) libcommon.la libtcolors.la $(REALTIME_LIBS)
dmesg_CFLAGS = $(AM_CFLAGS)
+check_PROGRAMS += test_dmesg
+test_dmesg_SOURCES = $(dmesg_SOURCES)
+test_dmesg_LDADD = $(dmesg_LDADD)
+test_dmesg_CFLAGS = -DTEST_DMESG $(dmesg_CFLAGS)
endif
if BUILD_CTRLALTDEL
diff --git a/sys-utils/dmesg.c b/sys-utils/dmesg.c
index b56199f36..a17cc70af 100644
--- a/sys-utils/dmesg.c
+++ b/sys-utils/dmesg.c
@@ -1378,8 +1378,13 @@ int main(int argc, char *argv[])
is_timefmt(&ctl, CTIME) ||
is_timefmt(&ctl, ISO8601)) {
+#ifdef TEST_DMESG
+ ctl.boot_time.tv_sec = 1234567890;
+ ctl.boot_time.tv_usec = 123456;
+#else
if (get_boot_time(&ctl.boot_time) != 0)
ctl.time_fmt = DMESG_TIMEFTM_NONE;
+#endif
}
if (delta)
diff --git a/tests/commands.sh b/tests/commands.sh
index 420feb9ae..e3ac43394 100644
--- a/tests/commands.sh
+++ b/tests/commands.sh
@@ -4,6 +4,7 @@ TS_TESTUSER=${TS_TESTUSER:-"nobody"}
# helpers
TS_HELPER_BYTESWAP="$top_builddir/test_byteswap"
TS_HELPER_CPUSET="$top_builddir/test_cpuset"
+TS_HELPER_DMESG="$top_builddir/test_dmesg"
TS_HELPER_ISLOCAL="$top_builddir/test_islocal"
TS_HELPER_ISMOUNTED="$top_builddir/test_ismounted"
TS_HELPER_LIBMOUNT_CONTEXT="$top_builddir/test_mount_context"
@@ -36,7 +37,6 @@ TS_CMD_CAL=${TS_CMD_CAL-"$top_builddir/cal"}
TS_CMD_COLRM=${TS_CMD_COLRM:-"$top_builddir/colrm"}
TS_CMD_COL=${TS_CMD_COL:-"$top_builddir/col"}
TS_CMD_COLUMN=${TS_CMD_COLUMN:-"$top_builddir/column"}
-TS_CMD_DMESG=${TS_CMD_DMESG-"$top_builddir/dmesg"}
TS_CMD_EJECT=${TS_CMD_EJECT-"$top_builddir/eject"}
TS_CMD_FALLOCATE=${TS_CMD_FALLOCATE-"$top_builddir/fallocate"}
TS_CMD_FDISK=${TS_CMD_FDISK-"$top_builddir/fdisk"}
diff --git a/tests/ts/dmesg/console-levels b/tests/ts/dmesg/console-levels
index 14c69c980..9abd5b285 100755
--- a/tests/ts/dmesg/console-levels
+++ b/tests/ts/dmesg/console-levels
@@ -18,10 +18,10 @@ TS_DESC="levels"
. $TS_TOPDIR/functions.sh
ts_init "$*"
-ts_check_test_command "$TS_CMD_DMESG"
+ts_check_test_command "$TS_HELPER_DMESG"
for I in {-1..8}; do
- $TS_CMD_DMESG -F $TS_SELF/input -l $I >> $TS_OUTPUT 2>/dev/null
+ $TS_HELPER_DMESG -F $TS_SELF/input -l $I >> $TS_OUTPUT 2>/dev/null
done
ts_finalize
diff --git a/tests/ts/dmesg/decode b/tests/ts/dmesg/decode
index 63f3c5c47..4725208d5 100755
--- a/tests/ts/dmesg/decode
+++ b/tests/ts/dmesg/decode
@@ -18,8 +18,8 @@ TS_DESC="decode"
. $TS_TOPDIR/functions.sh
ts_init "$*"
-ts_check_test_command "$TS_CMD_DMESG"
+ts_check_test_command "$TS_HELPER_DMESG"
-$TS_CMD_DMESG -x -F $TS_SELF/input >> $TS_OUTPUT 2>/dev/null
+$TS_HELPER_DMESG -x -F $TS_SELF/input >> $TS_OUTPUT 2>/dev/null
ts_finalize
diff --git a/tests/ts/dmesg/delta b/tests/ts/dmesg/delta
index da480421d..4b55bf636 100755
--- a/tests/ts/dmesg/delta
+++ b/tests/ts/dmesg/delta
@@ -18,8 +18,8 @@ TS_DESC="delta"
. $TS_TOPDIR/functions.sh
ts_init "$*"
-ts_check_test_command "$TS_CMD_DMESG"
+ts_check_test_command "$TS_HELPER_DMESG"
-$TS_CMD_DMESG -d -F $TS_SELF/input >> $TS_OUTPUT 2>/dev/null
+$TS_HELPER_DMESG -d -F $TS_SELF/input >> $TS_OUTPUT 2>/dev/null
ts_finalize
diff --git a/tests/ts/dmesg/facilities b/tests/ts/dmesg/facilities
index 7066ae58e..bc44c2546 100755
--- a/tests/ts/dmesg/facilities
+++ b/tests/ts/dmesg/facilities
@@ -18,10 +18,10 @@ TS_DESC="facilities"
. $TS_TOPDIR/functions.sh
ts_init "$*"
-ts_check_test_command "$TS_CMD_DMESG"
+ts_check_test_command "$TS_HELPER_DMESG"
for I in {-1..12}; do
- $TS_CMD_DMESG -F $TS_SELF/input -f $I >> $TS_OUTPUT 2>/dev/null
+ $TS_HELPER_DMESG -F $TS_SELF/input -f $I >> $TS_OUTPUT 2>/dev/null
done
ts_finalize
diff --git a/tests/ts/dmesg/indentation b/tests/ts/dmesg/indentation
index 74198889b..624dd9b49 100755
--- a/tests/ts/dmesg/indentation
+++ b/tests/ts/dmesg/indentation
@@ -18,14 +18,14 @@ TS_DESC="indentation"
. $TS_TOPDIR/functions.sh
ts_init "$*"
-ts_check_test_command "$TS_CMD_DMESG"
+ts_check_test_command "$TS_HELPER_DMESG"
-$TS_CMD_DMESG -F $TS_SELF/newlines > $TS_OUTPUT 2>&1
+$TS_HELPER_DMESG -F $TS_SELF/newlines > $TS_OUTPUT 2>&1
-$TS_CMD_DMESG -F $TS_SELF/newlines -x >> $TS_OUTPUT 2>&1
+$TS_HELPER_DMESG -F $TS_SELF/newlines -x >> $TS_OUTPUT 2>&1
-$TS_CMD_DMESG --time-format=delta --file $TS_SELF/newlines >> $TS_OUTPUT 2>&1
+$TS_HELPER_DMESG --time-format=delta --file $TS_SELF/newlines >> $TS_OUTPUT 2>&1
-$TS_CMD_DMESG --time-format=notime --file $TS_SELF/newlines >> $TS_OUTPUT 2>&1
+$TS_HELPER_DMESG --time-format=notime --file $TS_SELF/newlines >> $TS_OUTPUT 2>&1
ts_finalize