From: Sami Kerola Date: Sun, 22 Mar 2015 23:05:28 +0000 (+0000) Subject: tests: add test_dmesg that has fixed boot time X-Git-Tag: v2.27-rc1~328 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5fac518cefdba5c06829be187cefa3e904a7e1b3;p=thirdparty%2Futil-linux.git tests: add test_dmesg that has fixed boot time This allows testing time stamp formats. Signed-off-by: Sami Kerola --- diff --git a/sys-utils/Makemodule.am b/sys-utils/Makemodule.am index d538cdad71..a1dc042d63 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 b56199f36b..a17cc70af2 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 420feb9aeb..e3ac43394d 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 14c69c9803..9abd5b285a 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 63f3c5c476..4725208d53 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 da480421d3..4b55bf636f 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 7066ae58ed..bc44c25465 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 74198889b7..624dd9b492 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