All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/11] pull: add timestamp printing to libcommon
@ 2016-05-15 17:30 Sami Kerola
  2016-05-15 17:30 ` [PATCH 01/11] lib: add timestamp helpers to libcommon.la Sami Kerola
                   ` (11 more replies)
  0 siblings, 12 replies; 13+ messages in thread
From: Sami Kerola @ 2016-05-15 17:30 UTC (permalink / raw)
  To: util-linux; +Cc: Sami Kerola

Hello,

This is reponse to earlier thread 'hwclock --show format':

http://www.spinics.net/lists/util-linux-ng/index.html#12326

At the time when hwclock discussion happen release of v2.28 was about to
happen, and major changes were not welcome - so the timestamp stuff was
added to TODO that this pull request attempts to sort out.

The hwclock(8) and logger(1) are left alone in this pull.  They are rather
special.  Most of the changes should be reasonable, and hopefully easy to
review.  Placed at the very end of the changes there are updates to
utmpdump(1) that are a little bit more intrusive than the other changes by
what I mean the utmpdump text output format will change.

As usual feedback and comments are welcome from all.

----------------------------------------------------------------
The following changes since commit 40c9c3a6b7e6c4cda627d76edb14e92e823451c3:
  libfdisk: add API for work with labelitems (2016-05-12 14:37:29 +0200)
are available in the git repository at:
  git://github.com/kerolasa/lelux-utiliteetit.git timestamp
for you to fetch changes up to bdd2dd1730c7bd83d0eb3ed29247d04731be312e:
  tests: utmpdump add subsecond accuracy test (2016-05-15 11:00:28 +0100)
----------------------------------------------------------------

Sami Kerola (11):
  lib: add timestamp helpers to libcommon.la
  last: use timestamp helpers
  lslogins: use timestamp helpers
  lsipc: use timestamp helpers
  dmesg: use timestamp helpers
  docs: remove timestamp TODO item
  utmpdump: use always UTC-0 timezone in textual output
  utmpdump: use iso-8601 timestamp format with subsecond accuracy
  tests: fix utmpdump timestamps to be in iso format
  tests: remove utmpdump localization go-arounds
  tests: utmpdump add subsecond accuracy test

 Documentation/TODO                      |   2 -
 include/Makemodule.am                   |   1 +
 include/timestamps.h                    |  20 +++++
 lib/Makemodule.am                       |   1 +
 lib/timestamps.c                        | 125 ++++++++++++++++++++++++++++++++
 login-utils/Makemodule.am               |   1 +
 login-utils/last.c                      |  42 +++++------
 login-utils/lslogins.c                  |  43 +++--------
 login-utils/utmpdump.c                  |  61 ++++++++++------
 sys-utils/dmesg.c                       |  62 +++++-----------
 sys-utils/lsipc.c                       |  39 +++-------
 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 -
 27 files changed, 371 insertions(+), 203 deletions(-)
 create mode 100644 include/timestamps.h
 create mode 100644 lib/timestamps.c
 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.8.2


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

* [PATCH 01/11] lib: add timestamp helpers to libcommon.la
  2016-05-15 17:30 [PATCH 00/11] pull: add timestamp printing to libcommon Sami Kerola
@ 2016-05-15 17:30 ` Sami Kerola
  2016-05-15 17:30 ` [PATCH 02/11] last: use timestamp helpers Sami Kerola
                   ` (10 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Sami Kerola @ 2016-05-15 17:30 UTC (permalink / raw)
  To: util-linux; +Cc: Sami Kerola

The following programs have local timestamp creation facilities.  Aim is to
retire local implementations and share functions that will work for all
cases below.

login-utils/last.c
login-utils/lslogins.c
sys-utils/dmesg.c
sys-utils/lsipc.c

Notably misc-utils/logger.c is not in the list.  The logger(1) has pretty
special timestamp requirements, so it is best to keep it as-is.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
 include/Makemodule.am |   1 +
 include/timestamps.h  |  20 ++++++++
 lib/Makemodule.am     |   1 +
 lib/timestamps.c      | 125 ++++++++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 147 insertions(+)
 create mode 100644 include/timestamps.h
 create mode 100644 lib/timestamps.c

diff --git a/include/Makemodule.am b/include/Makemodule.am
index d4ae10c..5c9a216 100644
--- a/include/Makemodule.am
+++ b/include/Makemodule.am
@@ -50,6 +50,7 @@ dist_noinst_HEADERS += \
 	include/swapprober.h \
 	include/sysfs.h \
 	include/timer.h \
+	include/timestamps.h \
 	include/timeutils.h \
 	include/ttyutils.h \
 	include/widechar.h \
diff --git a/include/timestamps.h b/include/timestamps.h
new file mode 100644
index 0000000..8fd006f
--- /dev/null
+++ b/include/timestamps.h
@@ -0,0 +1,20 @@
+#ifndef UTIL_LINUX_TIMESTAMPS
+#define UTIL_LINUX_TIMESTAMPS
+
+struct ul_time {
+	struct tm *tm;
+	long microseconds;
+	char *buf;
+	size_t bufsz;
+};
+
+int ul_timestamp_hours_minutes(const struct ul_time *t);
+int ul_timestamp_iso_full(const struct ul_time *t);
+int ul_timestamp_iso_ms(const struct ul_time *t);
+int ul_timestamp_iso_short(const struct ul_time *t);
+int ul_timestamp_ctime_full(const struct ul_time *t);
+int ul_timestamp_ctime_short_date(const struct ul_time *t, const char date,
+				  const char divider);
+int ul_timestamp_ctime_short(const struct ul_time *t);
+
+#endif /* UTIL_LINUX_TIMESTAMPS */
diff --git a/lib/Makemodule.am b/lib/Makemodule.am
index 092d54e..672c169 100644
--- a/lib/Makemodule.am
+++ b/lib/Makemodule.am
@@ -19,6 +19,7 @@ libcommon_la_SOURCES = \
 	lib/randutils.c \
 	lib/setproctitle.c \
 	lib/strutils.c \
+	lib/timestamps.c \
 	lib/timeutils.c \
 	lib/ttyutils.c \
 	lib/exec_shell.c \
diff --git a/lib/timestamps.c b/lib/timestamps.c
new file mode 100644
index 0000000..b8a59be
--- /dev/null
+++ b/lib/timestamps.c
@@ -0,0 +1,125 @@
+/*
+ * Copyright (C) 2016 Sami Kerola <kerolasa@iki.fi>
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/time.h>
+#include <time.h>
+
+#include "timestamps.h"
+
+int ul_timestamp_hours_minutes(const struct ul_time *t)
+{
+	if (!strftime(t->buf, t->bufsz, "%H:%M", t->tm))
+		return -1;
+	return 0;
+}
+
+static int ul_timestamp_iso_internal(const struct ul_time *t,
+				     int add_microseconds)
+{
+	size_t len;
+
+	if (!strftime(t->buf, t->bufsz, "%Y-%m-%dT%H:%M:%S", t->tm))
+		return -1;
+	len = strlen(t->buf);
+	if (add_microseconds) {
+		snprintf(t->buf + len, t->bufsz - len, ",%06ld",
+			 t->microseconds);
+		len = strlen(t->buf);
+	}
+	if (!strftime(t->buf + len, t->bufsz - len, "%z", t->tm))
+		return -1;
+	return 0;
+}
+
+int ul_timestamp_iso_full(const struct ul_time *t)
+{
+	return ul_timestamp_iso_internal(t, 0);
+}
+
+int ul_timestamp_iso_ms(const struct ul_time *t)
+{
+	return ul_timestamp_iso_internal(t, 1);
+}
+
+int ul_timestamp_iso_short(const struct ul_time *t)
+{
+	if (!strftime(t->buf, t->bufsz, "%Y-%m-%d", t->tm))
+		return -1;
+	return 0;
+}
+
+int ul_timestamp_ctime_full(const struct ul_time *t)
+{
+	/* same format as asctime() without trailing \n */
+	static const char wday_name[7][4] = {
+		"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
+	};
+	static const char mon_name[12][4] = {
+		"Jan", "Feb", "Mar", "Apr", "May", "Jun",
+		"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
+	};
+	size_t len;
+
+	len = snprintf(t->buf, t->bufsz, "%s %s ", wday_name[t->tm->tm_wday],
+		       mon_name[t->tm->tm_mon]);
+	if (!len)
+		return -1;
+	if (!strftime(t->buf + len, t->bufsz - len, "%e %T %Y", t->tm))
+		return -1;
+	return 0;
+}
+
+typedef enum {
+	DATE_IS_TODAY,
+	DATE_IS_THIS_YEAR,
+	DATE_IS_OLDER
+} ul_time_whence;
+
+static ul_time_whence date_is(const struct tm *tm)
+{
+	const time_t time = timelocal((struct tm *)tm);
+	struct timeval now;
+
+	gettimeofday(&now, NULL);
+	if ((time / (3600 * 24)) == (now.tv_sec / (3600 * 24)))
+		return DATE_IS_TODAY;
+	if ((time / (3600 * 24 * 365)) == (now.tv_sec / (3600 * 24 * 365)))
+		return DATE_IS_THIS_YEAR;
+	return DATE_IS_OLDER;
+}
+
+int ul_timestamp_ctime_short_date(const struct ul_time *t, const char date,
+				  const char divider)
+{
+	char fmt[11];
+
+	sprintf(fmt, "%%b%%%c%c%%H:%%M", date, divider);
+	if (!strftime(t->buf, t->bufsz, fmt, t->tm))
+		return -1;
+	return 0;
+}
+
+int ul_timestamp_ctime_short(const struct ul_time *t)
+{
+	switch (date_is(t->tm)) {
+	case DATE_IS_TODAY:
+		if (!strftime(t->buf, t->bufsz, "%T", t->tm))
+			return -1;
+		break;
+	case DATE_IS_THIS_YEAR:
+		ul_timestamp_ctime_short_date(t, 'd', '/');
+		break;
+	case DATE_IS_OLDER:
+		if (!strftime(t->buf, t->bufsz, "%Y-%b%d", t->tm))
+			return -1;
+		break;
+	default:
+		/* drop core when impossible happens */
+		abort();
+	}
+	return 0;
+}
-- 
2.8.2


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

* [PATCH 02/11] last: use timestamp helpers
  2016-05-15 17:30 [PATCH 00/11] pull: add timestamp printing to libcommon Sami Kerola
  2016-05-15 17:30 ` [PATCH 01/11] lib: add timestamp helpers to libcommon.la Sami Kerola
@ 2016-05-15 17:30 ` Sami Kerola
  2016-05-15 17:30 ` [PATCH 03/11] lslogins: " Sami Kerola
                   ` (9 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Sami Kerola @ 2016-05-15 17:30 UTC (permalink / raw)
  To: util-linux; +Cc: Sami Kerola

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
 login-utils/last.c | 42 +++++++++++++++++++++---------------------
 1 file changed, 21 insertions(+), 21 deletions(-)

diff --git a/login-utils/last.c b/login-utils/last.c
index b8c4b83..06708c6 100644
--- a/login-utils/last.c
+++ b/login-utils/last.c
@@ -49,6 +49,7 @@
 #include "closestream.h"
 #include "carefulputc.h"
 #include "strutils.h"
+#include "timestamps.h"
 #include "timeutils.h"
 #include "monotonic.h"
 
@@ -315,35 +316,34 @@ static int dns_lookup(char *result, int size, int useip, int32_t *a)
 static int time_formatter(const struct last_control *ctl, char *dst,
 			  size_t dlen, time_t *when, int pos)
 {
-	struct tm *tm;
 	int ret = 0;
+	struct ul_time t = { 0 };
+	struct tm tm;
 
+	if (ctl->time_fmt == LAST_TIMEFTM_NONE) {
+		*dst = '\0';
+		return 0;
+	}
+	t.tm = localtime_r(when, &tm);
+	if (pos) {
+		ret = snprintf(dst, dlen, "- ");
+		if (ret == 0)
+			return -1;
+	}
+	t.buf = dst + ret;
+	t.bufsz = dlen - ret;
 	switch (ctl->time_fmt) {
-	case LAST_TIMEFTM_NONE:
-		*dst = 0;
-		break;
 	case LAST_TIMEFTM_SHORT_CTIME:
-		if (pos == 0)
-			ret = sprintf(dst, "%s", ctime(when));
-		else {
-			tm = localtime(when);
-			if (!strftime(dst, dlen, "- %H:%M", tm))
-				ret = -1;
-		}
+		if (pos)
+			ret = ul_timestamp_hours_minutes(&t);
+		else
+			ret = ul_timestamp_ctime_full(&t);
 		break;
 	case LAST_TIMEFTM_FULL_CTIME:
-		if (pos == 0)
-			ret = sprintf(dst, "%s", ctime(when));
-		else
-			ret = sprintf(dst, "- %s", ctime(when));
+		ret = ul_timestamp_ctime_full(&t);
 		break;
 	case LAST_TIMEFTM_ISO8601:
-		tm = localtime(when);
-		if (pos == 0) {
-			if (!strftime(dst, dlen, "%Y-%m-%dT%H:%M:%S%z", tm))
-				ret = -1;
-		} else if (!strftime(dst, dlen, "- %Y-%m-%dT%H:%M:%S%z", tm))
-			ret = -1;
+		ret = ul_timestamp_iso_full(&t);
 		break;
 	default:
 		abort();
-- 
2.8.2


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

* [PATCH 03/11] lslogins: use timestamp helpers
  2016-05-15 17:30 [PATCH 00/11] pull: add timestamp printing to libcommon Sami Kerola
  2016-05-15 17:30 ` [PATCH 01/11] lib: add timestamp helpers to libcommon.la Sami Kerola
  2016-05-15 17:30 ` [PATCH 02/11] last: use timestamp helpers Sami Kerola
@ 2016-05-15 17:30 ` Sami Kerola
  2016-05-15 17:30 ` [PATCH 04/11] lsipc: " Sami Kerola
                   ` (8 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Sami Kerola @ 2016-05-15 17:30 UTC (permalink / raw)
  To: util-linux; +Cc: Sami Kerola

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
 login-utils/lslogins.c | 43 +++++++++++--------------------------------
 1 file changed, 11 insertions(+), 32 deletions(-)

diff --git a/login-utils/lslogins.c b/login-utils/lslogins.c
index 40a1343..9e80b25 100644
--- a/login-utils/lslogins.c
+++ b/login-utils/lslogins.c
@@ -56,6 +56,7 @@
 #include "pathnames.h"
 #include "logindefs.h"
 #include "procutils.h"
+#include "timestamps.h"
 
 /*
  * column description
@@ -293,22 +294,6 @@ static inline size_t err_columns_index(size_t arysz, size_t idx)
 #define add_column(ary, n, id)	\
 		((ary)[ err_columns_index(ARRAY_SIZE(ary), (n)) ] = (id))
 
-static struct timeval now;
-
-static int date_is_today(time_t t)
-{
-	if (now.tv_sec == 0)
-		gettimeofday(&now, NULL);
-	return t / (3600 * 24) == now.tv_sec / (3600 * 24);
-}
-
-static int date_is_thisyear(time_t t)
-{
-	if (now.tv_sec == 0)
-		gettimeofday(&now, NULL);
-	return t / (3600 * 24 * 365) == now.tv_sec / (3600 * 24 * 365);
-}
-
 static int column_name_to_id(const char *name, size_t namesz)
 {
 	size_t i;
@@ -325,31 +310,26 @@ static int column_name_to_id(const char *name, size_t namesz)
 
 static char *make_time(int mode, time_t time)
 {
-	char *s;
 	struct tm tm;
-	char buf[64] = {0};
+	char buf[64] = { 0 };
+	struct ul_time t = { 0 };
 
-	localtime_r(&time, &tm);
+	t.tm = localtime_r(&time, &tm);
+	t.buf = buf;
+	t.bufsz = sizeof(buf);
 
-	switch(mode) {
+	switch (mode) {
 	case TIME_FULL:
-		asctime_r(&tm, buf);
-		if (*(s = buf + strlen(buf) - 1) == '\n')
-			*s = '\0';
+		ul_timestamp_ctime_full(&t);
 		break;
 	case TIME_SHORT:
-		if (date_is_today(time))
-			strftime(buf, sizeof(buf), "%H:%M:%S", &tm);
-		else if (date_is_thisyear(time))
-			strftime(buf, sizeof(buf), "%b%d/%H:%M", &tm);
-		else
-			strftime(buf, sizeof(buf), "%Y-%b%d", &tm);
+		ul_timestamp_ctime_short(&t);
 		break;
 	case TIME_ISO:
-		strftime(buf, sizeof(buf), "%Y-%m-%dT%H:%M:%S%z", &tm);
+		ul_timestamp_iso_full(&t);
 		break;
 	case TIME_ISO_SHORT:
-		strftime(buf, sizeof(buf), "%Y-%m-%d", &tm);
+		ul_timestamp_iso_short(&t);
 		break;
 	default:
 		errx(EXIT_FAILURE, _("unsupported time type"));
@@ -357,7 +337,6 @@ static char *make_time(int mode, time_t time)
 	return xstrdup(buf);
 }
 
-
 static char *uidtostr(uid_t uid)
 {
 	char *str_uid = NULL;
-- 
2.8.2


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

* [PATCH 04/11] lsipc: use timestamp helpers
  2016-05-15 17:30 [PATCH 00/11] pull: add timestamp printing to libcommon Sami Kerola
                   ` (2 preceding siblings ...)
  2016-05-15 17:30 ` [PATCH 03/11] lslogins: " Sami Kerola
@ 2016-05-15 17:30 ` Sami Kerola
  2016-05-15 17:30 ` [PATCH 05/11] dmesg: " Sami Kerola
                   ` (7 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Sami Kerola @ 2016-05-15 17:30 UTC (permalink / raw)
  To: util-linux; +Cc: Sami Kerola

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
 sys-utils/lsipc.c | 39 ++++++++++-----------------------------
 1 file changed, 10 insertions(+), 29 deletions(-)

diff --git a/sys-utils/lsipc.c b/sys-utils/lsipc.c
index 195ee15..c1d4f1c 100644
--- a/sys-utils/lsipc.c
+++ b/sys-utils/lsipc.c
@@ -39,6 +39,7 @@
 #include "xalloc.h"
 #include "procutils.h"
 #include "ipcutils.h"
+#include "timestamps.h"
 
 /*
  * time modes
@@ -427,46 +428,26 @@ static int print_table(struct lsipc_control *ctl, struct libscols_table *tb)
 		scols_print_table(tb);
 	return 0;
 }
-static struct timeval now;
-
-static int date_is_today(time_t t)
-{
-	if (now.tv_sec == 0)
-		gettimeofday(&now, NULL);
-	return t / (3600 * 24) == now.tv_sec / (3600 * 24);
-}
-
-static int date_is_thisyear(time_t t)
-{
-	if (now.tv_sec == 0)
-		gettimeofday(&now, NULL);
-	return t / (3600 * 24 * 365) == now.tv_sec / (3600 * 24 * 365);
-}
 
 static char *make_time(int mode, time_t time)
 {
-	char *s;
 	struct tm tm;
-	char buf[64] = {0};
+	char buf[64] = { 0 };
+	struct ul_time t = { 0 };
 
-	localtime_r(&time, &tm);
+	t.tm = localtime_r(&time, &tm);
+	t.buf = buf;
+	t.bufsz = sizeof(buf);
 
-	switch(mode) {
+	switch (mode) {
 	case TIME_FULL:
-		asctime_r(&tm, buf);
-		if (*(s = buf + strlen(buf) - 1) == '\n')
-			*s = '\0';
+		ul_timestamp_ctime_full(&t);
 		break;
 	case TIME_SHORT:
-		if (date_is_today(time))
-			strftime(buf, sizeof(buf), "%H:%M", &tm);
-		else if (date_is_thisyear(time))
-			strftime(buf, sizeof(buf), "%b%d", &tm);
-		else
-			strftime(buf, sizeof(buf), "%Y-%b%d", &tm);
+		ul_timestamp_ctime_short(&t);
 		break;
 	case TIME_ISO:
-		strftime(buf, sizeof(buf), "%Y-%m-%dT%H:%M:%S%z", &tm);
+		ul_timestamp_iso_full(&t);
 		break;
 	default:
 		errx(EXIT_FAILURE, _("unsupported time type"));
-- 
2.8.2


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

* [PATCH 05/11] dmesg: use timestamp helpers
  2016-05-15 17:30 [PATCH 00/11] pull: add timestamp printing to libcommon Sami Kerola
                   ` (3 preceding siblings ...)
  2016-05-15 17:30 ` [PATCH 04/11] lsipc: " Sami Kerola
@ 2016-05-15 17:30 ` Sami Kerola
  2016-05-15 17:30 ` [PATCH 06/11] docs: remove timestamp TODO item Sami Kerola
                   ` (6 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Sami Kerola @ 2016-05-15 17:30 UTC (permalink / raw)
  To: util-linux; +Cc: Sami Kerola

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
 sys-utils/dmesg.c | 62 ++++++++++++++++++-------------------------------------
 1 file changed, 20 insertions(+), 42 deletions(-)

diff --git a/sys-utils/dmesg.c b/sys-utils/dmesg.c
index cf93331..94381da 100644
--- a/sys-utils/dmesg.c
+++ b/sys-utils/dmesg.c
@@ -32,6 +32,7 @@
 #include "bitops.h"
 #include "closestream.h"
 #include "optutils.h"
+#include "timestamps.h"
 #include "timeutils.h"
 #include "monotonic.h"
 #include "mangle.h"
@@ -804,43 +805,6 @@ static struct tm *record_localtime(struct dmesg_control *ctl,
 	return localtime_r(&t, tm);
 }
 
-static char *record_ctime(struct dmesg_control *ctl,
-			  struct dmesg_record *rec,
-			  char *buf, size_t bufsiz)
-{
-	struct tm tm;
-
-	record_localtime(ctl, rec, &tm);
-
-	if (strftime(buf, bufsiz, "%a %b %e %H:%M:%S %Y", &tm) == 0)
-		*buf = '\0';
-	return buf;
-}
-
-static char *short_ctime(struct tm *tm, char *buf, size_t bufsiz)
-{
-	if (strftime(buf, bufsiz, "%b%e %H:%M", tm) == 0)
-		*buf = '\0';
-	return buf;
-}
-
-static char *iso_8601_time(struct dmesg_control *ctl, struct dmesg_record *rec,
-			   char *buf, size_t bufsiz)
-{
-	struct tm tm;
-	size_t len;
-	record_localtime(ctl, rec, &tm);
-	if (strftime(buf, bufsiz, "%Y-%m-%dT%H:%M:%S", &tm) == 0) {
-		*buf = '\0';
-		return buf;
-	}
-	len = strlen(buf);
-	snprintf(buf + len, bufsiz - len, ",%06ld", (long)rec->tv.tv_usec);
-	len = strlen(buf);
-	strftime(buf + len, bufsiz - len, "%z", &tm);
-	return buf;
-}
-
 static double record_count_delta(struct dmesg_control *ctl,
 				 struct dmesg_record *rec)
 {
@@ -880,6 +844,12 @@ static void print_record(struct dmesg_control *ctl,
 	const char *mesg;
 	size_t mesg_size;
 	int indent = 0;
+	struct tm tm;
+	struct ul_time t = { 0 };
+
+	t.buf = buf;
+	t.bufsz = sizeof(buf);
+	t.tm = &tm;
 
 	if (!accept_record(ctl, rec))
 		return;
@@ -921,24 +891,29 @@ static void print_record(struct dmesg_control *ctl,
 		ctl->indent = 0;
 		break;
 	case DMESG_TIMEFTM_CTIME:
-		ctl->indent = printf("[%s] ", record_ctime(ctl, rec, buf, sizeof(buf)));
+		record_localtime(ctl, rec, &tm);
+		ul_timestamp_ctime_full(&t);
+		ctl->indent = printf("[%s] ", buf);
 		break;
 	case DMESG_TIMEFTM_CTIME_DELTA:
-		ctl->indent = printf("[%s <%12.06f>] ",
-		       		     record_ctime(ctl, rec, buf, sizeof(buf)),
+		record_localtime(ctl, rec, &tm);
+		ul_timestamp_ctime_full(&t);
+		ctl->indent = printf("[%s <%12.06f>] ", buf,
 		       		     record_count_delta(ctl, rec));
 		break;
 	case DMESG_TIMEFTM_DELTA:
 		ctl->indent = printf("[<%12.06f>] ", record_count_delta(ctl, rec));
 		break;
 	case DMESG_TIMEFTM_RELTIME:
+		t.tm = &cur;
 		record_localtime(ctl, rec, &cur);
 		delta = record_count_delta(ctl, rec);
 		if (cur.tm_min != ctl->lasttm.tm_min ||
 		    cur.tm_hour != ctl->lasttm.tm_hour ||
 		    cur.tm_yday != ctl->lasttm.tm_yday) {
 			dmesg_enable_color(DMESG_COLOR_TIMEBREAK);
-			ctl->indent = printf("[%s] ", short_ctime(&cur, buf, sizeof(buf)));
+			ul_timestamp_ctime_short_date(&t, 'e', ' ');
+			ctl->indent = printf("[%s] ", buf);
 		} else {
 			if (delta < 10)
 				ctl->indent = printf("[  %+8.06f] ", delta);
@@ -956,7 +931,10 @@ static void print_record(struct dmesg_control *ctl,
 		               (long)rec->tv.tv_usec, record_count_delta(ctl, rec));
 		break;
 	case DMESG_TIMEFTM_ISO8601:
-		ctl->indent = printf("%s ", iso_8601_time(ctl, rec, buf, sizeof(buf)));
+		record_localtime(ctl, rec, &tm);
+		t.microseconds = (long)rec->tv.tv_usec;
+		ul_timestamp_iso_ms(&t);
+		ctl->indent = printf("%s ", buf);
 		break;
 	default:
 		abort();
-- 
2.8.2


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

* [PATCH 06/11] docs: remove timestamp TODO item
  2016-05-15 17:30 [PATCH 00/11] pull: add timestamp printing to libcommon Sami Kerola
                   ` (4 preceding siblings ...)
  2016-05-15 17:30 ` [PATCH 05/11] dmesg: " Sami Kerola
@ 2016-05-15 17:30 ` Sami Kerola
  2016-05-15 17:30 ` [PATCH 07/11] utmpdump: use always UTC-0 timezone in textual output Sami Kerola
                   ` (5 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Sami Kerola @ 2016-05-15 17:30 UTC (permalink / raw)
  To: util-linux; +Cc: Sami Kerola

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
 Documentation/TODO | 2 --
 1 file changed, 2 deletions(-)

diff --git a/Documentation/TODO b/Documentation/TODO
index af00ab3..416aaed 100644
--- a/Documentation/TODO
+++ b/Documentation/TODO
@@ -1,8 +1,6 @@
 
  Note that items with (!) have high priority.
 
-- add functions strtime_short(), strtime_iso(), strtime_ctime(), ...
-
 - cleanup lib/path.c:
    - always return rc from all functions
    - introduce control struct and use openat() from top-level path 
-- 
2.8.2


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

* [PATCH 07/11] utmpdump: use always UTC-0 timezone in textual output
  2016-05-15 17:30 [PATCH 00/11] pull: add timestamp printing to libcommon Sami Kerola
                   ` (5 preceding siblings ...)
  2016-05-15 17:30 ` [PATCH 06/11] docs: remove timestamp TODO item Sami Kerola
@ 2016-05-15 17:30 ` Sami Kerola
  2016-05-15 17:30 ` [PATCH 08/11] utmpdump: use iso-8601 timestamp format with subsecond accuracy Sami Kerola
                   ` (4 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Sami Kerola @ 2016-05-15 17:30 UTC (permalink / raw)
  To: util-linux; +Cc: Sami Kerola

Converting a time structure from text format that has timezone markup is
impossible.  See reference links for more information.  This leads to
situation where utmpdump(1) conversions from binary to text and back make
timestamps to shift amount of timezone offset, assuming user does not by
chance usingn UTC-0 locale at a time of conversions.

Easiest way to make multiple conversions to work is to be to ensure the
textual format is always using UTC-0 timezone, without daylight saving
shifts.  Unfortunately these timestamps are almost certainly less readable
to users altough they are more correct.

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.8.2


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

* [PATCH 08/11] utmpdump: use iso-8601 timestamp format with subsecond accuracy
  2016-05-15 17:30 [PATCH 00/11] pull: add timestamp printing to libcommon Sami Kerola
                   ` (6 preceding siblings ...)
  2016-05-15 17:30 ` [PATCH 07/11] utmpdump: use always UTC-0 timezone in textual output Sami Kerola
@ 2016-05-15 17:30 ` Sami Kerola
  2016-05-15 17:30 ` [PATCH 09/11] tests: fix utmpdump timestamps to be in iso format Sami Kerola
                   ` (3 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Sami Kerola @ 2016-05-15 17:30 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 old textual formats back
to binary.  Just converting from binary to textual format that does not use
ISO timestamps is no longer available.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
 login-utils/Makemodule.am |  1 +
 login-utils/utmpdump.c    | 61 +++++++++++++++++++++++++++++------------------
 2 files changed, 39 insertions(+), 23 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..f8deef5 100644
--- a/login-utils/utmpdump.c
+++ b/login-utils/utmpdump.c
@@ -42,22 +42,10 @@
 
 #include "c.h"
 #include "nls.h"
+#include "timestamps.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,8 +91,14 @@ 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];
+	time_t epoc;
+	struct ul_time t = { 0 };
+	char time_string[40];
+
+	t.buf = time_string;
+	t.bufsz = sizeof(time_string);
 
 	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));
@@ -95,17 +106,20 @@ static void print_utline(struct utmp *ut, FILE *out)
 		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);
+	epoc = ut->ut_tv.tv_sec;
+	t.microseconds = ut->ut_tv.tv_usec;
 #else
-	time_string = timetostr((time_t)ut->ut_time);	/* ut_time is not always a time_t */
+	epoc = ut->ut_time;
 #endif
+	t.tm = gmtime(&epoc);
+	ul_timestamp_iso_ms(&t);
 	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 +293,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.8.2


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

* [PATCH 09/11] tests: fix utmpdump timestamps to be in iso format
  2016-05-15 17:30 [PATCH 00/11] pull: add timestamp printing to libcommon Sami Kerola
                   ` (7 preceding siblings ...)
  2016-05-15 17:30 ` [PATCH 08/11] utmpdump: use iso-8601 timestamp format with subsecond accuracy Sami Kerola
@ 2016-05-15 17:30 ` Sami Kerola
  2016-05-15 17:30 ` [PATCH 10/11] tests: remove utmpdump localization go-arounds Sami Kerola
                   ` (2 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Sami Kerola @ 2016-05-15 17:30 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.8.2


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

* [PATCH 10/11] tests: remove utmpdump localization go-arounds
  2016-05-15 17:30 [PATCH 00/11] pull: add timestamp printing to libcommon Sami Kerola
                   ` (8 preceding siblings ...)
  2016-05-15 17:30 ` [PATCH 09/11] tests: fix utmpdump timestamps to be in iso format Sami Kerola
@ 2016-05-15 17:30 ` Sami Kerola
  2016-05-15 17:30 ` [PATCH 11/11] tests: utmpdump add subsecond accuracy test Sami Kerola
  2016-05-16  8:51 ` [PATCH 00/11] pull: add timestamp printing to libcommon Karel Zak
  11 siblings, 0 replies; 13+ messages in thread
From: Sami Kerola @ 2016-05-15 17:30 UTC (permalink / raw)
  To: util-linux; +Cc: Sami Kerola

The utmpdump is using unambigous timestamp format that is forced to use
UTC-0 timezone.  This deprecates need to enforce localization in tests.

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.8.2


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

* [PATCH 11/11] tests: utmpdump add subsecond accuracy test
  2016-05-15 17:30 [PATCH 00/11] pull: add timestamp printing to libcommon Sami Kerola
                   ` (9 preceding siblings ...)
  2016-05-15 17:30 ` [PATCH 10/11] tests: remove utmpdump localization go-arounds Sami Kerola
@ 2016-05-15 17:30 ` Sami Kerola
  2016-05-16  8:51 ` [PATCH 00/11] pull: add timestamp printing to libcommon Karel Zak
  11 siblings, 0 replies; 13+ messages in thread
From: Sami Kerola @ 2016-05-15 17:30 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..db94805
--- /dev/null
+++ b/tests/expected/utmp/utmpdump-subsecond
@@ -0,0 +1,5 @@
+invalid should diff by last subsecond digit
+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..dba233e
--- /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 "invalid should diff by last subsecond digit" > $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.8.2


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

* Re: [PATCH 00/11] pull: add timestamp printing to libcommon
  2016-05-15 17:30 [PATCH 00/11] pull: add timestamp printing to libcommon Sami Kerola
                   ` (10 preceding siblings ...)
  2016-05-15 17:30 ` [PATCH 11/11] tests: utmpdump add subsecond accuracy test Sami Kerola
@ 2016-05-16  8:51 ` Karel Zak
  11 siblings, 0 replies; 13+ messages in thread
From: Karel Zak @ 2016-05-16  8:51 UTC (permalink / raw)
  To: Sami Kerola; +Cc: util-linux

On Sun, May 15, 2016 at 06:30:46PM +0100, Sami Kerola wrote:
> Hello,
> 
> This is reponse to earlier thread 'hwclock --show format':
> 
> http://www.spinics.net/lists/util-linux-ng/index.html#12326
> 
> At the time when hwclock discussion happen release of v2.28 was about to

Hmm.. I already started work on this :-)

    https://github.com/karelzak/util-linux/commit/3c201431ee26c85b5c7fbcd85856c1df84065d64

I'll try to merge it with your changes.

    Karel

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

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

end of thread, other threads:[~2016-05-16  8:52 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-05-15 17:30 [PATCH 00/11] pull: add timestamp printing to libcommon Sami Kerola
2016-05-15 17:30 ` [PATCH 01/11] lib: add timestamp helpers to libcommon.la Sami Kerola
2016-05-15 17:30 ` [PATCH 02/11] last: use timestamp helpers Sami Kerola
2016-05-15 17:30 ` [PATCH 03/11] lslogins: " Sami Kerola
2016-05-15 17:30 ` [PATCH 04/11] lsipc: " Sami Kerola
2016-05-15 17:30 ` [PATCH 05/11] dmesg: " Sami Kerola
2016-05-15 17:30 ` [PATCH 06/11] docs: remove timestamp TODO item Sami Kerola
2016-05-15 17:30 ` [PATCH 07/11] utmpdump: use always UTC-0 timezone in textual output Sami Kerola
2016-05-15 17:30 ` [PATCH 08/11] utmpdump: use iso-8601 timestamp format with subsecond accuracy Sami Kerola
2016-05-15 17:30 ` [PATCH 09/11] tests: fix utmpdump timestamps to be in iso format Sami Kerola
2016-05-15 17:30 ` [PATCH 10/11] tests: remove utmpdump localization go-arounds Sami Kerola
2016-05-15 17:30 ` [PATCH 11/11] tests: utmpdump add subsecond accuracy test Sami Kerola
2016-05-16  8:51 ` [PATCH 00/11] pull: add timestamp printing to libcommon 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.