All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/6] pull: utmpdump iso-8601 format
@ 2016-06-20 20:40 Sami Kerola
  2016-06-20 20:40 ` [PATCH 1/6] utmpdump: use always UTC-0 timezone in textual output Sami Kerola
                   ` (6 more replies)
  0 siblings, 7 replies; 13+ messages in thread
From: Sami Kerola @ 2016-06-20 20:40 UTC (permalink / raw)
  To: util-linux; +Cc: Sami Kerola

Hello.

This pull request is re-implementation of iso-8601 timestamp format in
textual output using timeutils Karel made available as libcommon timeutils
functions.  The earlier submission was based on my version of timeutils,
that were not merged.

----------------------------------------------------------------
The following changes since commit 7f787ced5d401ccd56a82bb2b1202f1ea7164783:
  libblkid: don't check nonnull attributes for NULL [-Wnonnull-compare] (2016-06-14 14:39:16 +0200)
are available in the git repository at:
  git://github.com/kerolasa/lelux-utiliteetit.git utmpdump
for you to fetch changes up to 9997c0b13fffe7d198e7d056e4279727c2b0b3ad:
  tests: utmpdump add subsecond accuracy test (2016-06-20 21:31:18 +0100)
----------------------------------------------------------------

Sami Kerola (6):
  utmpdump: use always UTC-0 timezone in textual output
  libcommon: add ISO_8601_GMTIME that will print UTC-0 timestamps
  utmpdump: use iso-8601 timestamp format with subsecond accuracy
  tests: fix utmpdump timestamps to be in iso format
  tests: remove utmpdump localization go-around
  tests: utmpdump add subsecond accuracy test

 include/timeutils.h                     |  3 +-
 lib/timeutils.c                         | 14 ++++++--
 login-utils/Makemodule.am               |  1 +
 login-utils/utmpdump.c                  | 63 +++++++++++++++++++--------------
 tests/expected/utmp/utmpdump-subsecond  |  5 +++
 tests/expected/utmp/utmpdump-totxt      | 20 +++++------
 tests/expected/utmp/utmpdump-totxt-ipv6 |  4 +--
 tests/ts/utmp/subsec                    |  3 ++
 tests/ts/utmp/txt-a                     | 38 ++++++++++----------
 tests/ts/utmp/txt-a-old                 | 19 ++++++++++
 tests/ts/utmp/txt-b                     | 20 +++++------
 tests/ts/utmp/txt-b-old                 | 10 ++++++
 tests/ts/utmp/txt-ipv6                  |  4 +--
 tests/ts/utmp/txt-ipv6-old              |  2 ++
 tests/ts/utmp/utmpdump-circle           | 10 ++++--
 tests/ts/utmp/utmpdump-subsecond        | 34 ++++++++++++++++++
 tests/ts/utmp/utmpdump-tobin            |  2 --
 tests/ts/utmp/utmpdump-tobin-ipv6       |  2 --
 tests/ts/utmp/utmpdump-totxt            |  2 --
 tests/ts/utmp/utmpdump-totxt-ipv6       |  2 --
 20 files changed, 175 insertions(+), 83 deletions(-)
 create mode 100644 tests/expected/utmp/utmpdump-subsecond
 create mode 100644 tests/ts/utmp/subsec
 create mode 100644 tests/ts/utmp/txt-a-old
 create mode 100644 tests/ts/utmp/txt-b-old
 create mode 100644 tests/ts/utmp/txt-ipv6-old
 create mode 100755 tests/ts/utmp/utmpdump-subsecond

-- 
2.9.0


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH 1/6] utmpdump: use always UTC-0 timezone in textual output
  2016-06-20 20:40 [PATCH 0/6] pull: utmpdump iso-8601 format Sami Kerola
@ 2016-06-20 20:40 ` Sami Kerola
  2016-06-24  9:20   ` Karel Zak
  2016-06-20 20:40 ` [PATCH 2/6] libcommon: add ISO_8601_GMTIME that will print UTC-0 timestamps Sami Kerola
                   ` (5 subsequent siblings)
  6 siblings, 1 reply; 13+ messages in thread
From: Sami Kerola @ 2016-06-20 20:40 UTC (permalink / raw)
  To: util-linux; +Cc: Sami Kerola

Converting a time structure from text format that has timezone markup is
practically impossible.  See reference links for more information.  This
leads to situation where multiple utmpdump(1) conversions from binary to
text and back make timestamps to shift amount of timezone offset to UTC-0.

The easiest way to make multiple conversions to work without timeshifts is
to always use UTC-0 timezone.  Downside of this approach is that the textual
format is less human readable than local timestamps would be.

Reference: http://www.catb.org/esr/time-programming/#_strptime_3_and_getdate_3
Reference: http://man7.org/linux/man-pages/man3/strptime.3.html
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
 login-utils/utmpdump.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/login-utils/utmpdump.c b/login-utils/utmpdump.c
index 03cf4a9..6eaf202 100644
--- a/login-utils/utmpdump.c
+++ b/login-utils/utmpdump.c
@@ -47,10 +47,10 @@
 
 static char *timetostr(const time_t time)
 {
-	static char s[29];	/* [Sun Sep 01 00:00:00 1998 PST] */
+	static char s[29];	/* [Tue Sep 01 00:00:00 1998 GMT] */
 	struct tm *tmp;
 
-	if (time != 0 && (tmp = localtime(&time)))
+	if (time != 0 && (tmp = gmtime(&time)))
 		strftime(s, 29, "%a %b %d %T %Y %Z", tmp);
 	else
 		s[0] = '\0';
@@ -73,7 +73,7 @@ static time_t strtotime(const char *s_time)
 	if (s_time[26] == 'D')
 		tm.tm_isdst = 1;
 
-	return mktime(&tm);
+	return timegm(&tm);
 }
 
 #define cleanse(x) xcleanse(x, sizeof(x))
-- 
2.9.0


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 2/6] libcommon: add ISO_8601_GMTIME that will print UTC-0 timestamps
  2016-06-20 20:40 [PATCH 0/6] pull: utmpdump iso-8601 format Sami Kerola
  2016-06-20 20:40 ` [PATCH 1/6] utmpdump: use always UTC-0 timezone in textual output Sami Kerola
@ 2016-06-20 20:40 ` Sami Kerola
  2016-06-20 20:40 ` [PATCH 3/6] utmpdump: use iso-8601 timestamp format with subsecond accuracy Sami Kerola
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 13+ messages in thread
From: Sami Kerola @ 2016-06-20 20:40 UTC (permalink / raw)
  To: util-linux; +Cc: Sami Kerola

When timestamps are intented to be conversable back from string to binary it
is best to stick with UTC-0 timezone.  This is needed in utmpdump(1).

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
 include/timeutils.h |  3 ++-
 lib/timeutils.c     | 14 ++++++++++++--
 2 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/include/timeutils.h b/include/timeutils.h
index 265577f..00d1820 100644
--- a/include/timeutils.h
+++ b/include/timeutils.h
@@ -61,7 +61,8 @@ enum {
 	ISO_8601_DOTUSEC	= (1 << 3),
 	ISO_8601_COMMAUSEC	= (1 << 4),
 	ISO_8601_TIMEZONE	= (1 << 5),
-	ISO_8601_SPACE		= (1 << 6)
+	ISO_8601_SPACE		= (1 << 6),
+	ISO_8601_GMTIME		= (1 << 7)
 };
 
 #define ISO_8601_BUFSIZ	32
diff --git a/lib/timeutils.c b/lib/timeutils.c
index 25a163e..fd9aa3e 100644
--- a/lib/timeutils.c
+++ b/lib/timeutils.c
@@ -396,7 +396,12 @@ static int format_iso_time(struct tm *tm, suseconds_t usec, int flags, char *buf
 /* timeval to ISO 8601 */
 int strtimeval_iso(struct timeval *tv, int flags, char *buf, size_t bufsz)
 {
-	struct tm tm = *localtime(&tv->tv_sec);
+	struct tm tm;
+
+	if (flags & ISO_8601_GMTIME)
+		tm = *gmtime(&tv->tv_sec);
+	else
+		tm = *localtime(&tv->tv_sec);
 	return format_iso_time(&tm, tv->tv_usec, flags, buf, bufsz);
 }
 
@@ -409,7 +414,12 @@ int strtm_iso(struct tm *tm, int flags, char *buf, size_t bufsz)
 /* time_t to ISO 8601 */
 int strtime_iso(const time_t *t, int flags, char *buf, size_t bufsz)
 {
-	struct tm tm = *localtime(t);
+	struct tm tm;
+
+	if (flags & ISO_8601_GMTIME)
+		tm = *gmtime(t);
+	else
+		tm = *localtime(t);
 	return format_iso_time(&tm, 0, flags, buf, bufsz);
 }
 
-- 
2.9.0


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 3/6] utmpdump: use iso-8601 timestamp format with subsecond accuracy
  2016-06-20 20:40 [PATCH 0/6] pull: utmpdump iso-8601 format Sami Kerola
  2016-06-20 20:40 ` [PATCH 1/6] utmpdump: use always UTC-0 timezone in textual output Sami Kerola
  2016-06-20 20:40 ` [PATCH 2/6] libcommon: add ISO_8601_GMTIME that will print UTC-0 timestamps Sami Kerola
@ 2016-06-20 20:40 ` Sami Kerola
  2016-06-24  9:27   ` Karel Zak
  2016-06-20 20:40 ` [PATCH 4/6] tests: fix utmpdump timestamps to be in iso format Sami Kerola
                   ` (3 subsequent siblings)
  6 siblings, 1 reply; 13+ messages in thread
From: Sami Kerola @ 2016-06-20 20:40 UTC (permalink / raw)
  To: util-linux; +Cc: Sami Kerola

Newer 'struct utmp' is using 'struct timeval' to represent login and logout
times, so include the maximum accuracy to textual utmp format.  Notice that
this change does not remove support of converting earlier textual formats
back to binary.  But conversions from binary to former format will no longer
be available.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
 login-utils/Makemodule.am |  1 +
 login-utils/utmpdump.c    | 63 ++++++++++++++++++++++++++++-------------------
 2 files changed, 38 insertions(+), 26 deletions(-)

diff --git a/login-utils/Makemodule.am b/login-utils/Makemodule.am
index 502ecd5..be07ace 100644
--- a/login-utils/Makemodule.am
+++ b/login-utils/Makemodule.am
@@ -67,6 +67,7 @@ if BUILD_UTMPDUMP
 usrbin_exec_PROGRAMS += utmpdump
 dist_man_MANS += login-utils/utmpdump.1
 utmpdump_SOURCES = login-utils/utmpdump.c
+utmpdump_LDADD = $(LDADD) libcommon.la
 endif
 
 
diff --git a/login-utils/utmpdump.c b/login-utils/utmpdump.c
index 6eaf202..1849a4e 100644
--- a/login-utils/utmpdump.c
+++ b/login-utils/utmpdump.c
@@ -42,22 +42,10 @@
 
 #include "c.h"
 #include "nls.h"
+#include "timeutils.h"
 #include "xalloc.h"
 #include "closestream.h"
 
-static char *timetostr(const time_t time)
-{
-	static char s[29];	/* [Tue Sep 01 00:00:00 1998 GMT] */
-	struct tm *tmp;
-
-	if (time != 0 && (tmp = gmtime(&time)))
-		strftime(s, 29, "%a %b %d %T %Y %Z", tmp);
-	else
-		s[0] = '\0';
-
-	return s;
-}
-
 static time_t strtotime(const char *s_time)
 {
 	struct tm tm;
@@ -67,15 +55,32 @@ static time_t strtotime(const char *s_time)
 	if (s_time[0] == ' ' || s_time[0] == '\0')
 		return (time_t)0;
 
-	strptime(s_time, "%a %b %d %T %Y", &tm);
-
-	/* Cheesy way of checking for DST */
-	if (s_time[26] == 'D')
-		tm.tm_isdst = 1;
-
+	if (isdigit(s_time[0])) {
+		/* [1998-09-01T01:00:00,000000+00:00]
+		 * Subseconds are parsed with strtousec().  Timezone is
+		 * always UTC-0 */
+		strptime(s_time, "%Y-%m-%dT%H:%M:%S", &tm);
+	} else {
+		/* [Tue Sep 01 00:00:00 1998 GMT] */
+		strptime(s_time, "%a %b %d %T %Y", &tm);
+		/* Cheesy way of checking for DST.  This could be needed
+		 * with legacy dumps that used localtime(3).  */
+		if (s_time[26] == 'D')
+			tm.tm_isdst = 1;
+	}
 	return timegm(&tm);
 }
 
+#if defined(_HAVE_UT_TV)
+static suseconds_t strtousec(const char *s_time)
+{
+	const char *s = strchr(s_time, ',');
+	if (s)
+		return (suseconds_t) atoi(s + 1);
+	return 0;
+}
+#endif
+
 #define cleanse(x) xcleanse(x, sizeof(x))
 static void xcleanse(char *s, int len)
 {
@@ -86,26 +91,31 @@ static void xcleanse(char *s, int len)
 
 static void print_utline(struct utmp *ut, FILE *out)
 {
-	const char *addr_string, *time_string;
+	const char *addr_string;
 	char buffer[INET6_ADDRSTRLEN];
+	char time_string[40];
+	struct timeval tv;
 
 	if (ut->ut_addr_v6[1] || ut->ut_addr_v6[2] || ut->ut_addr_v6[3])
 		addr_string = inet_ntop(AF_INET6, &(ut->ut_addr_v6), buffer, sizeof(buffer));
 	else
 		addr_string = inet_ntop(AF_INET, &(ut->ut_addr_v6), buffer, sizeof(buffer));
 
-#if defined(_HAVE_UT_TV)
-	time_string = timetostr(ut->ut_tv.tv_sec);
-#else
-	time_string = timetostr((time_t)ut->ut_time);	/* ut_time is not always a time_t */
-#endif
+	tv.tv_sec = ut->ut_tv.tv_sec;
+	tv.tv_usec = ut->ut_tv.tv_usec;
+
+	if (strtimeval_iso(&tv,
+			   ISO_8601_DATE | ISO_8601_TIME | ISO_8601_COMMAUSEC |
+			   ISO_8601_TIMEZONE | ISO_8601_GMTIME, time_string,
+			   sizeof(time_string)) != 0)
+		return;
 	cleanse(ut->ut_id);
 	cleanse(ut->ut_user);
 	cleanse(ut->ut_line);
 	cleanse(ut->ut_host);
 
 	/*            pid    id       user     line     host     addr       time */
-	fprintf(out, "[%d] [%05d] [%-4.4s] [%-*.*s] [%-*.*s] [%-*.*s] [%-15s] [%-28.28s]\n",
+	fprintf(out, "[%d] [%05d] [%-4.4s] [%-*.*s] [%-*.*s] [%-*.*s] [%-15s] [%s]\n",
 	       ut->ut_type, ut->ut_pid, ut->ut_id, 8, UT_NAMESIZE, ut->ut_user,
 	       12, UT_LINESIZE, ut->ut_line, 20, UT_HOSTSIZE, ut->ut_host,
 	       addr_string, time_string);
@@ -279,6 +289,7 @@ static void undump(FILE *in, FILE *out)
 			inet_pton(AF_INET6, s_addr, &(ut.ut_addr_v6));
 #if defined(_HAVE_UT_TV)
 		ut.ut_tv.tv_sec = strtotime(s_time);
+		ut.ut_tv.tv_usec = strtousec(s_time);
 #else
 		ut.ut_time = strtotime(s_time);
 #endif
-- 
2.9.0


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 4/6] tests: fix utmpdump timestamps to be in iso format
  2016-06-20 20:40 [PATCH 0/6] pull: utmpdump iso-8601 format Sami Kerola
                   ` (2 preceding siblings ...)
  2016-06-20 20:40 ` [PATCH 3/6] utmpdump: use iso-8601 timestamp format with subsecond accuracy Sami Kerola
@ 2016-06-20 20:40 ` Sami Kerola
  2016-06-20 20:40 ` [PATCH 5/6] tests: remove utmpdump localization go-around Sami Kerola
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 13+ messages in thread
From: Sami Kerola @ 2016-06-20 20:40 UTC (permalink / raw)
  To: util-linux; +Cc: Sami Kerola

The utmpdump-circle is slightly modified to use old timestamp format as
basis of conversion and to do cyclic conversion via new format.  This is
better from test coverage point of view.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
 tests/expected/utmp/utmpdump-totxt      | 20 ++++++++---------
 tests/expected/utmp/utmpdump-totxt-ipv6 |  4 ++--
 tests/ts/utmp/txt-a                     | 38 ++++++++++++++++-----------------
 tests/ts/utmp/txt-a-old                 | 19 +++++++++++++++++
 tests/ts/utmp/txt-b                     | 20 ++++++++---------
 tests/ts/utmp/txt-b-old                 | 10 +++++++++
 tests/ts/utmp/txt-ipv6                  |  4 ++--
 tests/ts/utmp/txt-ipv6-old              |  2 ++
 tests/ts/utmp/utmpdump-circle           |  8 ++++++-
 9 files changed, 81 insertions(+), 44 deletions(-)
 create mode 100644 tests/ts/utmp/txt-a-old
 create mode 100644 tests/ts/utmp/txt-b-old
 create mode 100644 tests/ts/utmp/txt-ipv6-old

diff --git a/tests/expected/utmp/utmpdump-totxt b/tests/expected/utmp/utmpdump-totxt
index 02fb22d..5deefde 100644
--- a/tests/expected/utmp/utmpdump-totxt
+++ b/tests/expected/utmp/utmpdump-totxt
@@ -1,10 +1,10 @@
-[7] [17058] [ts/1] [kerolasa] [pts/1       ] [:0.0                ] [0.0.0.0        ] [Wed Jan 16 23:44:09 2013 GMT]
-[7] [22098] [ts/2] [kerolasa] [pts/2       ] [:0.0                ] [0.0.0.0        ] [Wed Jan 16 23:49:17 2013 GMT]
-[7] [24915] [ts/3] [kerolasa] [pts/3       ] [:0.0                ] [0.0.0.0        ] [Thu Jan 17 12:23:33 2013 GMT]
-[8] [24915] [ts/3] [kerolasa] [pts/3       ] [                    ] [0.0.0.0        ] [Thu Jan 17 12:24:49 2013 GMT]
-[7] [30629] [ts/3] [kerolasa] [pts/3       ] [:0.0                ] [0.0.0.0        ] [Thu Jan 17 13:12:39 2013 GMT]
-[8] [30629] [ts/3] [kerolasa] [pts/3       ] [                    ] [0.0.0.0        ] [Thu Jan 17 13:42:19 2013 GMT]
-[8] [22098] [ts/2] [kerolasa] [pts/2       ] [                    ] [0.0.0.0        ] [Thu Jan 17 13:42:48 2013 GMT]
-[8] [17058] [ts/1] [kerolasa] [pts/1       ] [                    ] [0.0.0.0        ] [Thu Jan 17 13:42:48 2013 GMT]
-[7] [31545] [ts/1] [kerolasa] [pts/1       ] [:0.0                ] [0.0.0.0        ] [Thu Jan 17 20:17:21 2013 GMT]
-[7] [28496] [ts/2] [kerolasa] [pts/2       ] [:0.0                ] [0.0.0.0        ] [Thu Jan 17 21:09:39 2013 GMT]
+[7] [17058] [ts/1] [kerolasa] [pts/1       ] [:0.0                ] [0.0.0.0        ] [2013-01-16T23:44:09,000000+0000]
+[7] [22098] [ts/2] [kerolasa] [pts/2       ] [:0.0                ] [0.0.0.0        ] [2013-01-16T23:49:17,000000+0000]
+[7] [24915] [ts/3] [kerolasa] [pts/3       ] [:0.0                ] [0.0.0.0        ] [2013-01-17T12:23:33,000000+0000]
+[8] [24915] [ts/3] [kerolasa] [pts/3       ] [                    ] [0.0.0.0        ] [2013-01-17T12:24:49,000000+0000]
+[7] [30629] [ts/3] [kerolasa] [pts/3       ] [:0.0                ] [0.0.0.0        ] [2013-01-17T13:12:39,000000+0000]
+[8] [30629] [ts/3] [kerolasa] [pts/3       ] [                    ] [0.0.0.0        ] [2013-01-17T13:42:19,000000+0000]
+[8] [22098] [ts/2] [kerolasa] [pts/2       ] [                    ] [0.0.0.0        ] [2013-01-17T13:42:48,000000+0000]
+[8] [17058] [ts/1] [kerolasa] [pts/1       ] [                    ] [0.0.0.0        ] [2013-01-17T13:42:48,000000+0000]
+[7] [31545] [ts/1] [kerolasa] [pts/1       ] [:0.0                ] [0.0.0.0        ] [2013-01-17T20:17:21,000000+0000]
+[7] [28496] [ts/2] [kerolasa] [pts/2       ] [:0.0                ] [0.0.0.0        ] [2013-01-17T21:09:39,000000+0000]
diff --git a/tests/expected/utmp/utmpdump-totxt-ipv6 b/tests/expected/utmp/utmpdump-totxt-ipv6
index 5cce150..5894144 100644
--- a/tests/expected/utmp/utmpdump-totxt-ipv6
+++ b/tests/expected/utmp/utmpdump-totxt-ipv6
@@ -1,2 +1,2 @@
-[7] [00010] [ipv6] [IPv6    ] [root        ] [dns-server          ] [2001:503:ba3e::2:30] [Wed Aug 28 20:30:40 2013 GMT]
-[8] [00011] [ipv6] [IPv6    ] [root        ] [dns-server          ] [2001:503:ba3e::2:30] [Wed Aug 28 20:40:50 2013 GMT]
+[7] [00010] [ipv6] [IPv6    ] [root        ] [dns-server          ] [2001:503:ba3e::2:30] [2013-08-28T20:30:40,000000+0000]
+[8] [00011] [ipv6] [IPv6    ] [root        ] [dns-server          ] [2001:503:ba3e::2:30] [2013-08-28T20:40:50,000000+0000]
diff --git a/tests/ts/utmp/txt-a b/tests/ts/utmp/txt-a
index bc91d19..8501daa 100644
--- a/tests/ts/utmp/txt-a
+++ b/tests/ts/utmp/txt-a
@@ -1,19 +1,19 @@
-[9] [00009] [ts/9] [accounting] [foo         ] [nine                ] [0.0.0.0        ] [Wed Aug 28 03:00:00 2013 GMT]
-[8] [00008] [ts/8] [dead_process] [foo         ] [eight               ] [0.0.0.0        ] [Wed Aug 28 04:00:00 2013 GMT]
-[7] [00007] [ts/7] [user_process] [foo         ] [seven               ] [0.0.0.0        ] [Wed Aug 28 05:00:00 2013 GMT]
-[6] [00006] [ts/6] [login   ] [foo         ] [six                 ] [0.0.0.0        ] [Wed Aug 28 06:00:00 2013 GMT]
-[5] [00005] [ts/5] [init    ] [foo         ] [five                ] [0.0.0.0        ] [Wed Aug 28 07:00:00 2013 GMT]
-[4] [00004] [ts/4] [oldtime ] [foo         ] [four                ] [0.0.0.0        ] [Wed Aug 28 08:00:00 2013 GMT]
-[3] [00003] [ts/3] [newtime ] [foo         ] [three               ] [0.0.0.0        ] [Wed Aug 28 09:00:00 2013 GMT]
-[2] [00002] [ts/2] [sysboot ] [foo         ] [two                 ] [0.0.0.0        ] [Wed Aug 28 10:00:00 2013 GMT]
-[1] [00001] [ts/1] [runlevel] [foo         ] [one                 ] [0.0.0.0        ] [Wed Aug 28 11:00:00 2013 GMT]
-[0] [00000] [ts/0] [nonvalid] [foo         ] [zero                ] [0.0.0.0        ] [Wed Aug 28 12:00:00 2013 GMT]
-[7] [00010] [ipv4] [IPv4    ] [root        ] [dns-server          ] [198.41.0.4     ] [Wed Aug 28 13:00:00 2013 GMT]
-[8] [00011] [ipv4] [IPv4    ] [root        ] [dns-server          ] [198.41.0.4     ] [Wed Aug 28 14:00:00 2013 GMT]
-[1] [00012] [~~  ] [shutdown] [~           ] [system-name         ] [0.0.0.0        ] [Wed Aug 28 15:00:00 2013 GMT]
-[2] [00012] [~~  ] [reboot  ] [~           ] [system-name         ] [0.0.0.0        ] [Wed Aug 28 16:00:00 2013 GMT]
-[1] [00012] [~~  ] [shutdown] [~           ] [system-name         ] [0.0.0.0        ] [Wed Aug 28 17:00:00 2013 GMT]
-[2] [00012] [~~  ] [reboot  ] [~           ] [system-name         ] [0.0.0.0        ] [Wed Aug 28 18:00:00 2013 GMT]
-[7] [00013] [ts/1] [torvalds] [linux       ] [hobby               ] [128.214.205.14 ] [Mon Aug 26 00:57:08 1991 GMT]
-[7] [00014] [long] [rick    ] [long        ] [never-gonna-logout  ] [0.0.0.0        ] [                            ]
-[8] [00014] [long] [rick    ] [long        ] [never-gonna-logout  ] [0.0.0.0        ] [Tue Jan 19 03:14:07 2038 GMT]
+[9] [00009] [ts/9] [accounting] [foo         ] [nine                ] [0.0.0.0        ] [2013-08-28T03:00:00,000000+0000]
+[8] [00008] [ts/8] [dead_process] [foo         ] [eight               ] [0.0.0.0        ] [2013-08-28T04:00:00,000000+0000]
+[7] [00007] [ts/7] [user_process] [foo         ] [seven               ] [0.0.0.0        ] [2013-08-28T05:00:00,000000+0000]
+[6] [00006] [ts/6] [login   ] [foo         ] [six                 ] [0.0.0.0        ] [2013-08-28T06:00:00,000000+0000]
+[5] [00005] [ts/5] [init    ] [foo         ] [five                ] [0.0.0.0        ] [2013-08-28T07:00:00,000000+0000]
+[4] [00004] [ts/4] [oldtime ] [foo         ] [four                ] [0.0.0.0        ] [2013-08-28T08:00:00,000000+0000]
+[3] [00003] [ts/3] [newtime ] [foo         ] [three               ] [0.0.0.0        ] [2013-08-28T09:00:00,000000+0000]
+[2] [00002] [ts/2] [sysboot ] [foo         ] [two                 ] [0.0.0.0        ] [2013-08-28T10:00:00,000000+0000]
+[1] [00001] [ts/1] [runlevel] [foo         ] [one                 ] [0.0.0.0        ] [2013-08-28T11:00:00,000000+0000]
+[0] [00000] [ts/0] [nonvalid] [foo         ] [zero                ] [0.0.0.0        ] [2013-08-28T12:00:00,000000+0000]
+[7] [00010] [ipv4] [IPv4    ] [root        ] [dns-server          ] [198.41.0.4     ] [2013-08-28T13:00:00,000000+0000]
+[8] [00011] [ipv4] [IPv4    ] [root        ] [dns-server          ] [198.41.0.4     ] [2013-08-28T14:00:00,000000+0000]
+[1] [00012] [~~  ] [shutdown] [~           ] [system-name         ] [0.0.0.0        ] [2013-08-28T15:00:00,000000+0000]
+[2] [00012] [~~  ] [reboot  ] [~           ] [system-name         ] [0.0.0.0        ] [2013-08-28T16:00:00,000000+0000]
+[1] [00012] [~~  ] [shutdown] [~           ] [system-name         ] [0.0.0.0        ] [2013-08-28T17:00:00,000000+0000]
+[2] [00012] [~~  ] [reboot  ] [~           ] [system-name         ] [0.0.0.0        ] [2013-08-28T18:00:00,000000+0000]
+[7] [00013] [ts/1] [torvalds] [linux       ] [hobby               ] [128.214.205.14 ] [1991-08-26T00:57:08,000000+0000]
+[7] [00014] [long] [rick    ] [long        ] [never-gonna-logout  ] [0.0.0.0        ] [1970-01-01T00:00:00,000000+0000]
+[8] [00014] [long] [rick    ] [long        ] [never-gonna-logout  ] [0.0.0.0        ] [2038-01-19T03:14:07,000000+0000]
diff --git a/tests/ts/utmp/txt-a-old b/tests/ts/utmp/txt-a-old
new file mode 100644
index 0000000..bc91d19
--- /dev/null
+++ b/tests/ts/utmp/txt-a-old
@@ -0,0 +1,19 @@
+[9] [00009] [ts/9] [accounting] [foo         ] [nine                ] [0.0.0.0        ] [Wed Aug 28 03:00:00 2013 GMT]
+[8] [00008] [ts/8] [dead_process] [foo         ] [eight               ] [0.0.0.0        ] [Wed Aug 28 04:00:00 2013 GMT]
+[7] [00007] [ts/7] [user_process] [foo         ] [seven               ] [0.0.0.0        ] [Wed Aug 28 05:00:00 2013 GMT]
+[6] [00006] [ts/6] [login   ] [foo         ] [six                 ] [0.0.0.0        ] [Wed Aug 28 06:00:00 2013 GMT]
+[5] [00005] [ts/5] [init    ] [foo         ] [five                ] [0.0.0.0        ] [Wed Aug 28 07:00:00 2013 GMT]
+[4] [00004] [ts/4] [oldtime ] [foo         ] [four                ] [0.0.0.0        ] [Wed Aug 28 08:00:00 2013 GMT]
+[3] [00003] [ts/3] [newtime ] [foo         ] [three               ] [0.0.0.0        ] [Wed Aug 28 09:00:00 2013 GMT]
+[2] [00002] [ts/2] [sysboot ] [foo         ] [two                 ] [0.0.0.0        ] [Wed Aug 28 10:00:00 2013 GMT]
+[1] [00001] [ts/1] [runlevel] [foo         ] [one                 ] [0.0.0.0        ] [Wed Aug 28 11:00:00 2013 GMT]
+[0] [00000] [ts/0] [nonvalid] [foo         ] [zero                ] [0.0.0.0        ] [Wed Aug 28 12:00:00 2013 GMT]
+[7] [00010] [ipv4] [IPv4    ] [root        ] [dns-server          ] [198.41.0.4     ] [Wed Aug 28 13:00:00 2013 GMT]
+[8] [00011] [ipv4] [IPv4    ] [root        ] [dns-server          ] [198.41.0.4     ] [Wed Aug 28 14:00:00 2013 GMT]
+[1] [00012] [~~  ] [shutdown] [~           ] [system-name         ] [0.0.0.0        ] [Wed Aug 28 15:00:00 2013 GMT]
+[2] [00012] [~~  ] [reboot  ] [~           ] [system-name         ] [0.0.0.0        ] [Wed Aug 28 16:00:00 2013 GMT]
+[1] [00012] [~~  ] [shutdown] [~           ] [system-name         ] [0.0.0.0        ] [Wed Aug 28 17:00:00 2013 GMT]
+[2] [00012] [~~  ] [reboot  ] [~           ] [system-name         ] [0.0.0.0        ] [Wed Aug 28 18:00:00 2013 GMT]
+[7] [00013] [ts/1] [torvalds] [linux       ] [hobby               ] [128.214.205.14 ] [Mon Aug 26 00:57:08 1991 GMT]
+[7] [00014] [long] [rick    ] [long        ] [never-gonna-logout  ] [0.0.0.0        ] [                            ]
+[8] [00014] [long] [rick    ] [long        ] [never-gonna-logout  ] [0.0.0.0        ] [Tue Jan 19 03:14:07 2038 GMT]
diff --git a/tests/ts/utmp/txt-b b/tests/ts/utmp/txt-b
index 02fb22d..5deefde 100644
--- a/tests/ts/utmp/txt-b
+++ b/tests/ts/utmp/txt-b
@@ -1,10 +1,10 @@
-[7] [17058] [ts/1] [kerolasa] [pts/1       ] [:0.0                ] [0.0.0.0        ] [Wed Jan 16 23:44:09 2013 GMT]
-[7] [22098] [ts/2] [kerolasa] [pts/2       ] [:0.0                ] [0.0.0.0        ] [Wed Jan 16 23:49:17 2013 GMT]
-[7] [24915] [ts/3] [kerolasa] [pts/3       ] [:0.0                ] [0.0.0.0        ] [Thu Jan 17 12:23:33 2013 GMT]
-[8] [24915] [ts/3] [kerolasa] [pts/3       ] [                    ] [0.0.0.0        ] [Thu Jan 17 12:24:49 2013 GMT]
-[7] [30629] [ts/3] [kerolasa] [pts/3       ] [:0.0                ] [0.0.0.0        ] [Thu Jan 17 13:12:39 2013 GMT]
-[8] [30629] [ts/3] [kerolasa] [pts/3       ] [                    ] [0.0.0.0        ] [Thu Jan 17 13:42:19 2013 GMT]
-[8] [22098] [ts/2] [kerolasa] [pts/2       ] [                    ] [0.0.0.0        ] [Thu Jan 17 13:42:48 2013 GMT]
-[8] [17058] [ts/1] [kerolasa] [pts/1       ] [                    ] [0.0.0.0        ] [Thu Jan 17 13:42:48 2013 GMT]
-[7] [31545] [ts/1] [kerolasa] [pts/1       ] [:0.0                ] [0.0.0.0        ] [Thu Jan 17 20:17:21 2013 GMT]
-[7] [28496] [ts/2] [kerolasa] [pts/2       ] [:0.0                ] [0.0.0.0        ] [Thu Jan 17 21:09:39 2013 GMT]
+[7] [17058] [ts/1] [kerolasa] [pts/1       ] [:0.0                ] [0.0.0.0        ] [2013-01-16T23:44:09,000000+0000]
+[7] [22098] [ts/2] [kerolasa] [pts/2       ] [:0.0                ] [0.0.0.0        ] [2013-01-16T23:49:17,000000+0000]
+[7] [24915] [ts/3] [kerolasa] [pts/3       ] [:0.0                ] [0.0.0.0        ] [2013-01-17T12:23:33,000000+0000]
+[8] [24915] [ts/3] [kerolasa] [pts/3       ] [                    ] [0.0.0.0        ] [2013-01-17T12:24:49,000000+0000]
+[7] [30629] [ts/3] [kerolasa] [pts/3       ] [:0.0                ] [0.0.0.0        ] [2013-01-17T13:12:39,000000+0000]
+[8] [30629] [ts/3] [kerolasa] [pts/3       ] [                    ] [0.0.0.0        ] [2013-01-17T13:42:19,000000+0000]
+[8] [22098] [ts/2] [kerolasa] [pts/2       ] [                    ] [0.0.0.0        ] [2013-01-17T13:42:48,000000+0000]
+[8] [17058] [ts/1] [kerolasa] [pts/1       ] [                    ] [0.0.0.0        ] [2013-01-17T13:42:48,000000+0000]
+[7] [31545] [ts/1] [kerolasa] [pts/1       ] [:0.0                ] [0.0.0.0        ] [2013-01-17T20:17:21,000000+0000]
+[7] [28496] [ts/2] [kerolasa] [pts/2       ] [:0.0                ] [0.0.0.0        ] [2013-01-17T21:09:39,000000+0000]
diff --git a/tests/ts/utmp/txt-b-old b/tests/ts/utmp/txt-b-old
new file mode 100644
index 0000000..02fb22d
--- /dev/null
+++ b/tests/ts/utmp/txt-b-old
@@ -0,0 +1,10 @@
+[7] [17058] [ts/1] [kerolasa] [pts/1       ] [:0.0                ] [0.0.0.0        ] [Wed Jan 16 23:44:09 2013 GMT]
+[7] [22098] [ts/2] [kerolasa] [pts/2       ] [:0.0                ] [0.0.0.0        ] [Wed Jan 16 23:49:17 2013 GMT]
+[7] [24915] [ts/3] [kerolasa] [pts/3       ] [:0.0                ] [0.0.0.0        ] [Thu Jan 17 12:23:33 2013 GMT]
+[8] [24915] [ts/3] [kerolasa] [pts/3       ] [                    ] [0.0.0.0        ] [Thu Jan 17 12:24:49 2013 GMT]
+[7] [30629] [ts/3] [kerolasa] [pts/3       ] [:0.0                ] [0.0.0.0        ] [Thu Jan 17 13:12:39 2013 GMT]
+[8] [30629] [ts/3] [kerolasa] [pts/3       ] [                    ] [0.0.0.0        ] [Thu Jan 17 13:42:19 2013 GMT]
+[8] [22098] [ts/2] [kerolasa] [pts/2       ] [                    ] [0.0.0.0        ] [Thu Jan 17 13:42:48 2013 GMT]
+[8] [17058] [ts/1] [kerolasa] [pts/1       ] [                    ] [0.0.0.0        ] [Thu Jan 17 13:42:48 2013 GMT]
+[7] [31545] [ts/1] [kerolasa] [pts/1       ] [:0.0                ] [0.0.0.0        ] [Thu Jan 17 20:17:21 2013 GMT]
+[7] [28496] [ts/2] [kerolasa] [pts/2       ] [:0.0                ] [0.0.0.0        ] [Thu Jan 17 21:09:39 2013 GMT]
diff --git a/tests/ts/utmp/txt-ipv6 b/tests/ts/utmp/txt-ipv6
index 5cce150..5894144 100644
--- a/tests/ts/utmp/txt-ipv6
+++ b/tests/ts/utmp/txt-ipv6
@@ -1,2 +1,2 @@
-[7] [00010] [ipv6] [IPv6    ] [root        ] [dns-server          ] [2001:503:ba3e::2:30] [Wed Aug 28 20:30:40 2013 GMT]
-[8] [00011] [ipv6] [IPv6    ] [root        ] [dns-server          ] [2001:503:ba3e::2:30] [Wed Aug 28 20:40:50 2013 GMT]
+[7] [00010] [ipv6] [IPv6    ] [root        ] [dns-server          ] [2001:503:ba3e::2:30] [2013-08-28T20:30:40,000000+0000]
+[8] [00011] [ipv6] [IPv6    ] [root        ] [dns-server          ] [2001:503:ba3e::2:30] [2013-08-28T20:40:50,000000+0000]
diff --git a/tests/ts/utmp/txt-ipv6-old b/tests/ts/utmp/txt-ipv6-old
new file mode 100644
index 0000000..5cce150
--- /dev/null
+++ b/tests/ts/utmp/txt-ipv6-old
@@ -0,0 +1,2 @@
+[7] [00010] [ipv6] [IPv6    ] [root        ] [dns-server          ] [2001:503:ba3e::2:30] [Wed Aug 28 20:30:40 2013 GMT]
+[8] [00011] [ipv6] [IPv6    ] [root        ] [dns-server          ] [2001:503:ba3e::2:30] [Wed Aug 28 20:40:50 2013 GMT]
diff --git a/tests/ts/utmp/utmpdump-circle b/tests/ts/utmp/utmpdump-circle
index cae2995..9663dba 100755
--- a/tests/ts/utmp/utmpdump-circle
+++ b/tests/ts/utmp/utmpdump-circle
@@ -27,9 +27,15 @@ OUT_BIN1=${TS_OUTDIR}/${TS_TESTNAME}.bin1
 OUT_BIN2=${TS_OUTDIR}/${TS_TESTNAME}.bin2
 OUT_TXT=${TS_OUTDIR}/${TS_TESTNAME}.txt
 
+# Files with -old extension are using timestamp format before utmpdump
+# started to use iso-8601 format.  This check is testing nothing is lost
+# when conversions performing following conversions.
+#
+# old text format -> binary -> new text format -> binary
+
 echo "no output expected" > $TS_OUTPUT
 for f in txt-a txt-b txt-ipv6; do
-	$TS_CMD_UTMPDUMP -r $TS_SELF/$f > $OUT_BIN1 2>/dev/null &&
+	$TS_CMD_UTMPDUMP -r $TS_SELF/$f-old > $OUT_BIN1 2>/dev/null &&
 	$TS_CMD_UTMPDUMP $OUT_BIN1 > $OUT_TXT 2>/dev/null &&
 	diff -u $TS_SELF/$f $OUT_TXT &&
 	$TS_CMD_UTMPDUMP -r $OUT_TXT > $OUT_BIN2 2>/dev/null &&
-- 
2.9.0


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 5/6] tests: remove utmpdump localization go-around
  2016-06-20 20:40 [PATCH 0/6] pull: utmpdump iso-8601 format Sami Kerola
                   ` (3 preceding siblings ...)
  2016-06-20 20:40 ` [PATCH 4/6] tests: fix utmpdump timestamps to be in iso format Sami Kerola
@ 2016-06-20 20:40 ` Sami Kerola
  2016-06-24  9:31   ` Karel Zak
  2016-06-20 20:40 ` [PATCH 6/6] tests: utmpdump add subsecond accuracy test Sami Kerola
  2016-07-01 11:52 ` [PATCH 0/6] pull: utmpdump iso-8601 format Karel Zak
  6 siblings, 1 reply; 13+ messages in thread
From: Sami Kerola @ 2016-06-20 20:40 UTC (permalink / raw)
  To: util-linux; +Cc: Sami Kerola

The utmpdump timestamps are unambiguous, so forcing locale environment is
never needed.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
 tests/ts/utmp/utmpdump-circle     | 2 --
 tests/ts/utmp/utmpdump-tobin      | 2 --
 tests/ts/utmp/utmpdump-tobin-ipv6 | 2 --
 tests/ts/utmp/utmpdump-totxt      | 2 --
 tests/ts/utmp/utmpdump-totxt-ipv6 | 2 --
 5 files changed, 10 deletions(-)

diff --git a/tests/ts/utmp/utmpdump-circle b/tests/ts/utmp/utmpdump-circle
index 9663dba..41d7de6 100755
--- a/tests/ts/utmp/utmpdump-circle
+++ b/tests/ts/utmp/utmpdump-circle
@@ -21,8 +21,6 @@ ts_init "$*"
 # this test is arch independent, no need for utmp_functions.sh
 ts_check_test_command "$TS_CMD_UTMPDUMP"
 
-export LANG=C
-export TZ=GMT
 OUT_BIN1=${TS_OUTDIR}/${TS_TESTNAME}.bin1
 OUT_BIN2=${TS_OUTDIR}/${TS_TESTNAME}.bin2
 OUT_TXT=${TS_OUTDIR}/${TS_TESTNAME}.txt
diff --git a/tests/ts/utmp/utmpdump-tobin b/tests/ts/utmp/utmpdump-tobin
index 2f14bfc..4054952 100755
--- a/tests/ts/utmp/utmpdump-tobin
+++ b/tests/ts/utmp/utmpdump-tobin
@@ -21,8 +21,6 @@ ts_init "$*"
 . "$TS_SELF/utmp_functions.sh"
 [ $SIZEOF_UTMP -eq 384 ] || ts_skip "utmp struct size $SIZEOF_UTMP"
 
-export LANG=C
-export TZ=GMT
 OUTFILE=${TS_OUTDIR}/${TS_TESTNAME}.file
 $TS_CMD_UTMPDUMP -r $TS_SELF/txt-b >| $OUTFILE 2>/dev/null
 if diff -q $TS_SELF/wtmp-b.$BYTE_ORDER $OUTFILE; then
diff --git a/tests/ts/utmp/utmpdump-tobin-ipv6 b/tests/ts/utmp/utmpdump-tobin-ipv6
index e0b19cd..3198d3c 100755
--- a/tests/ts/utmp/utmpdump-tobin-ipv6
+++ b/tests/ts/utmp/utmpdump-tobin-ipv6
@@ -21,8 +21,6 @@ ts_init "$*"
 . "$TS_SELF/utmp_functions.sh"
 [ $SIZEOF_UTMP -eq 384 ] || ts_skip "utmp struct size $SIZEOF_UTMP"
 
-export LANG=C
-export TZ=GMT
 OUTFILE=${TS_OUTDIR}/${TS_TESTNAME}.file
 $TS_CMD_UTMPDUMP -r $TS_SELF/txt-ipv6 >| $OUTFILE 2>/dev/null
 if diff -q $TS_SELF/wtmp-ipv6.$BYTE_ORDER $OUTFILE; then
diff --git a/tests/ts/utmp/utmpdump-totxt b/tests/ts/utmp/utmpdump-totxt
index 37d376a..cde1f4c 100755
--- a/tests/ts/utmp/utmpdump-totxt
+++ b/tests/ts/utmp/utmpdump-totxt
@@ -21,8 +21,6 @@ ts_init "$*"
 . "$TS_SELF/utmp_functions.sh"
 [ $SIZEOF_UTMP -eq 384 ] || ts_skip "utmp struct size $SIZEOF_UTMP"
 
-export LANG=C
-export TZ=GMT
 $TS_CMD_UTMPDUMP $TS_SELF/wtmp-b.$BYTE_ORDER >| $TS_OUTPUT 2>/dev/null
 
 ts_finalize
diff --git a/tests/ts/utmp/utmpdump-totxt-ipv6 b/tests/ts/utmp/utmpdump-totxt-ipv6
index 1b21783..5fc3d9c 100755
--- a/tests/ts/utmp/utmpdump-totxt-ipv6
+++ b/tests/ts/utmp/utmpdump-totxt-ipv6
@@ -21,8 +21,6 @@ ts_init "$*"
 . "$TS_SELF/utmp_functions.sh"
 [ $SIZEOF_UTMP -eq 384 ] || ts_skip "utmp struct size $SIZEOF_UTMP"
 
-export LANG=C
-export TZ=GMT
 $TS_CMD_UTMPDUMP $TS_SELF/wtmp-ipv6.$BYTE_ORDER >| $TS_OUTPUT 2>/dev/null
 
 ts_finalize
-- 
2.9.0


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 6/6] tests: utmpdump add subsecond accuracy test
  2016-06-20 20:40 [PATCH 0/6] pull: utmpdump iso-8601 format Sami Kerola
                   ` (4 preceding siblings ...)
  2016-06-20 20:40 ` [PATCH 5/6] tests: remove utmpdump localization go-around Sami Kerola
@ 2016-06-20 20:40 ` Sami Kerola
  2016-07-01 11:52 ` [PATCH 0/6] pull: utmpdump iso-8601 format Karel Zak
  6 siblings, 0 replies; 13+ messages in thread
From: Sami Kerola @ 2016-06-20 20:40 UTC (permalink / raw)
  To: util-linux; +Cc: Sami Kerola

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
 tests/expected/utmp/utmpdump-subsecond |  5 +++++
 tests/ts/utmp/subsec                   |  3 +++
 tests/ts/utmp/utmpdump-subsecond       | 34 ++++++++++++++++++++++++++++++++++
 3 files changed, 42 insertions(+)
 create mode 100644 tests/expected/utmp/utmpdump-subsecond
 create mode 100644 tests/ts/utmp/subsec
 create mode 100755 tests/ts/utmp/utmpdump-subsecond

diff --git a/tests/expected/utmp/utmpdump-subsecond b/tests/expected/utmp/utmpdump-subsecond
new file mode 100644
index 0000000..9ec40da
--- /dev/null
+++ b/tests/expected/utmp/utmpdump-subsecond
@@ -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
index 0000000..4881e7c
--- /dev/null
+++ b/tests/ts/utmp/subsec
@@ -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
index 0000000..f753a6d
--- /dev/null
+++ b/tests/ts/utmp/utmpdump-subsecond
@@ -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
-- 
2.9.0


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* Re: [PATCH 1/6] utmpdump: use always UTC-0 timezone in textual output
  2016-06-20 20:40 ` [PATCH 1/6] utmpdump: use always UTC-0 timezone in textual output Sami Kerola
@ 2016-06-24  9:20   ` Karel Zak
  0 siblings, 0 replies; 13+ messages in thread
From: Karel Zak @ 2016-06-24  9:20 UTC (permalink / raw)
  To: Sami Kerola; +Cc: util-linux

On Mon, Jun 20, 2016 at 09:40:32PM +0100, Sami Kerola wrote:
> Converting a time structure from text format that has timezone markup is
> practically impossible.  See reference links for more information.  This
> leads to situation where multiple utmpdump(1) conversions from binary to
> text and back make timestamps to shift amount of timezone offset to UTC-0.
> 
> The easiest way to make multiple conversions to work without timeshifts is
> to always use UTC-0 timezone.  Downside of this approach is that the textual
> format is less human readable than local timestamps would be.

Makes sense, but it would be nice to have big fat note in the man
page.

    Karel

-- 
 Karel Zak  <kzak@redhat.com>
 http://karelzak.blogspot.com

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 3/6] utmpdump: use iso-8601 timestamp format with subsecond accuracy
  2016-06-20 20:40 ` [PATCH 3/6] utmpdump: use iso-8601 timestamp format with subsecond accuracy Sami Kerola
@ 2016-06-24  9:27   ` Karel Zak
  2016-06-27 19:44     ` Sami Kerola
  0 siblings, 1 reply; 13+ messages in thread
From: Karel Zak @ 2016-06-24  9:27 UTC (permalink / raw)
  To: Sami Kerola; +Cc: util-linux

On Mon, Jun 20, 2016 at 09:40:34PM +0100, Sami Kerola wrote:
> Newer 'struct utmp' is using 'struct timeval' to represent login and logout
> times, so include the maximum accuracy to textual utmp format.  Notice that
> this change does not remove support of converting earlier textual formats
> back to binary.  But conversions from binary to former format will no longer
> be available.

It would be also nice to document that utmpdump is able to read
textual utmp format generated by the current utmpdump version only and
that we don't maintain any backward compatibility for the textual
output.

The only binary version of the utmp is standardized.

    Karel

-- 
 Karel Zak  <kzak@redhat.com>
 http://karelzak.blogspot.com

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 5/6] tests: remove utmpdump localization go-around
  2016-06-20 20:40 ` [PATCH 5/6] tests: remove utmpdump localization go-around Sami Kerola
@ 2016-06-24  9:31   ` Karel Zak
  2016-06-27 19:48     ` Sami Kerola
  0 siblings, 1 reply; 13+ messages in thread
From: Karel Zak @ 2016-06-24  9:31 UTC (permalink / raw)
  To: Sami Kerola; +Cc: util-linux

On Mon, Jun 20, 2016 at 09:40:36PM +0100, Sami Kerola wrote:
> The utmpdump timestamps are unambiguous, so forcing locale environment is
> never needed.

and what about strptime()?

I think it's fine to keep tests robust and in well know environment.

    Karel

-- 
 Karel Zak  <kzak@redhat.com>
 http://karelzak.blogspot.com

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 3/6] utmpdump: use iso-8601 timestamp format with subsecond accuracy
  2016-06-24  9:27   ` Karel Zak
@ 2016-06-27 19:44     ` Sami Kerola
  0 siblings, 0 replies; 13+ messages in thread
From: Sami Kerola @ 2016-06-27 19:44 UTC (permalink / raw)
  To: Karel Zak; +Cc: util-linux

On 24 June 2016 at 10:27, Karel Zak <kzak@redhat.com> wrote:
> On Mon, Jun 20, 2016 at 09:40:34PM +0100, Sami Kerola wrote:
>> Newer 'struct utmp' is using 'struct timeval' to represent login and logout
>> times, so include the maximum accuracy to textual utmp format.  Notice that
>> this change does not remove support of converting earlier textual formats
>> back to binary.  But conversions from binary to former format will no longer
>> be available.
>
> It would be also nice to document that utmpdump is able to read
> textual utmp format generated by the current utmpdump version only and
> that we don't maintain any backward compatibility for the textual
> output.
>
> The only binary version of the utmp is standardized.

Fair point. How about something like

https://github.com/kerolasa/lelux-utiliteetit/commit/3d47107de5d04fe2803827d3e24c227a18d1a4b0

-- 
Sami Kerola
http://www.iki.fi/kerolasa/

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 5/6] tests: remove utmpdump localization go-around
  2016-06-24  9:31   ` Karel Zak
@ 2016-06-27 19:48     ` Sami Kerola
  0 siblings, 0 replies; 13+ messages in thread
From: Sami Kerola @ 2016-06-27 19:48 UTC (permalink / raw)
  To: Karel Zak; +Cc: util-linux

On 24 June 2016 at 10:31, Karel Zak <kzak@redhat.com> wrote:
> On Mon, Jun 20, 2016 at 09:40:36PM +0100, Sami Kerola wrote:
>> The utmpdump timestamps are unambiguous, so forcing locale environment is
>> never needed.
>
> and what about strptime()?
>
> I think it's fine to keep tests robust and in well know environment.

strptime(3) is no longer expected to make timestamp to be localized.
Perhaps it would
be best to give strptime(3) wrong ideas about timezone, so that one can observe
gmtime(3) to do the right thing. To express same in form of change, here we go:

https://github.com/kerolasa/lelux-utiliteetit/commit/73f46aedc316efbb8e2a719c1c6c3aef364a5553

-- 
Sami Kerola
http://www.iki.fi/kerolasa/

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 0/6] pull: utmpdump iso-8601 format
  2016-06-20 20:40 [PATCH 0/6] pull: utmpdump iso-8601 format Sami Kerola
                   ` (5 preceding siblings ...)
  2016-06-20 20:40 ` [PATCH 6/6] tests: utmpdump add subsecond accuracy test Sami Kerola
@ 2016-07-01 11:52 ` Karel Zak
  6 siblings, 0 replies; 13+ messages in thread
From: Karel Zak @ 2016-07-01 11:52 UTC (permalink / raw)
  To: Sami Kerola; +Cc: util-linux

On Mon, Jun 20, 2016 at 09:40:31PM +0100, Sami Kerola wrote:
>   utmpdump: use always UTC-0 timezone in textual output
>   libcommon: add ISO_8601_GMTIME that will print UTC-0 timestamps
>   utmpdump: use iso-8601 timestamp format with subsecond accuracy
>   tests: fix utmpdump timestamps to be in iso format
>   tests: remove utmpdump localization go-around
>   tests: utmpdump add subsecond accuracy test

 Applied, thanks.

-- 
 Karel Zak  <kzak@redhat.com>
 http://karelzak.blogspot.com

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2016-07-01 11:52 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-20 20:40 [PATCH 0/6] pull: utmpdump iso-8601 format Sami Kerola
2016-06-20 20:40 ` [PATCH 1/6] utmpdump: use always UTC-0 timezone in textual output Sami Kerola
2016-06-24  9:20   ` Karel Zak
2016-06-20 20:40 ` [PATCH 2/6] libcommon: add ISO_8601_GMTIME that will print UTC-0 timestamps Sami Kerola
2016-06-20 20:40 ` [PATCH 3/6] utmpdump: use iso-8601 timestamp format with subsecond accuracy Sami Kerola
2016-06-24  9:27   ` Karel Zak
2016-06-27 19:44     ` Sami Kerola
2016-06-20 20:40 ` [PATCH 4/6] tests: fix utmpdump timestamps to be in iso format Sami Kerola
2016-06-20 20:40 ` [PATCH 5/6] tests: remove utmpdump localization go-around Sami Kerola
2016-06-24  9:31   ` Karel Zak
2016-06-27 19:48     ` Sami Kerola
2016-06-20 20:40 ` [PATCH 6/6] tests: utmpdump add subsecond accuracy test Sami Kerola
2016-07-01 11:52 ` [PATCH 0/6] pull: utmpdump iso-8601 format Karel Zak

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.