]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
tests: utmpdump add subsecond accuracy test
authorSami Kerola <kerolasa@iki.fi>
Sun, 15 May 2016 09:55:54 +0000 (10:55 +0100)
committerSami Kerola <kerolasa@iki.fi>
Mon, 27 Jun 2016 18:57:29 +0000 (19:57 +0100)
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
tests/expected/utmp/utmpdump-subsecond [new file with mode: 0644]
tests/ts/utmp/subsec [new file with mode: 0644]
tests/ts/utmp/utmpdump-subsecond [new file with mode: 0755]

diff --git a/tests/expected/utmp/utmpdump-subsecond b/tests/expected/utmp/utmpdump-subsecond
new file mode 100644 (file)
index 0000000..9ec40da
--- /dev/null
@@ -0,0 +1,5 @@
+last 9 is expected to disappear in conversion
+3c3
+< [0] [00000] [ts/0] [nonvalid] [foo         ] [zero                ] [0.0.0.0        ] [2013-08-28T12:00:00,123456789+0000]
+---
+> [0] [00000] [ts/0] [nonvalid] [foo         ] [zero                ] [0.0.0.0        ] [2013-08-28T12:00:00,12345678+0000]
diff --git a/tests/ts/utmp/subsec b/tests/ts/utmp/subsec
new file mode 100644 (file)
index 0000000..4881e7c
--- /dev/null
@@ -0,0 +1,3 @@
+[7] [00010] [ipv6] [IPv6    ] [root        ] [dns-server          ] [2001:503:ba3e::2:30] [2013-08-28T20:30:40,123456+0000]
+[8] [00011] [ipv6] [IPv6    ] [root        ] [dns-server          ] [2001:503:ba3e::2:30] [2013-08-28T20:40:50,999999+0000]
+[0] [00000] [ts/0] [nonvalid] [foo         ] [zero                ] [0.0.0.0        ] [2013-08-28T12:00:00,123456789+0000]
diff --git a/tests/ts/utmp/utmpdump-subsecond b/tests/ts/utmp/utmpdump-subsecond
new file mode 100755 (executable)
index 0000000..f753a6d
--- /dev/null
@@ -0,0 +1,34 @@
+#!/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="subsecond"
+
+. $TS_TOPDIR/functions.sh
+ts_init "$*"
+
+# this test is arch independent, no need for utmp_functions.sh
+ts_check_test_command "$TS_CMD_UTMPDUMP"
+
+OUT_BIN=${TS_OUTDIR}/${TS_TESTNAME}.bin
+OUT_TXT=${TS_OUTDIR}/${TS_TESTNAME}.txt
+
+echo "last 9 is expected to disappear in conversion" > $TS_OUTPUT
+$TS_CMD_UTMPDUMP -r $TS_SELF/subsec > $OUT_BIN 2>/dev/null
+$TS_CMD_UTMPDUMP $OUT_BIN > $OUT_TXT 2>/dev/null
+diff $TS_SELF/subsec $OUT_TXT >> $TS_OUTPUT 2>&1
+
+rm -f "$OUT_BIN" "$OUT_TXT"
+
+ts_finalize