Skip to contentSkip to conversation

pull: add timestamp printing to libcommon

PATCH In review Sami Kerola 2 participants 13 messages May 15, 2016 – May 16, 2016

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover pull: add timestamp printing to libcommon

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
Signature · 1 line
2.8.2
#1 lore raw

PATCH 1/11 lib: add timestamp helpers to libcommon.la

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.

---
 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
include/Makemodule.am +1 -0
index d4ae10c..5c9a216 100644
@@ -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 \
include/timestamps.h new file +20 -0
new file mode 100644
index 0000000..8fd006f
@@ -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 */
lib/Makemodule.am +1 -0
index 092d54e..672c169 100644
@@ -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 \
lib/timestamps.c new file +125 -0

125 lines not on this page · raw message

Signature · 1 line
2.8.2
#2 lore raw

PATCH 2/11 last: use timestamp helpers

In reply to Sami Kerola
---
 login-utils/last.c | 42 +++++++++++++++++++++---------------------
 1 file changed, 21 insertions(+), 21 deletions(-)
login-utils/last.c +21 -21
index b8c4b83..06708c6 100644
@@ -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();
Signature · 1 line
2.8.2
#3 lore raw

PATCH 3/11 lslogins: use timestamp helpers

In reply to Sami Kerola
---
 login-utils/lslogins.c | 43 +++++++++++--------------------------------
 1 file changed, 11 insertions(+), 32 deletions(-)
login-utils/lslogins.c +11 -32
index 40a1343..9e80b25 100644
@@ -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;
Signature · 1 line
2.8.2
#4 lore raw

PATCH 4/11 lsipc: use timestamp helpers

In reply to Sami Kerola
---
 sys-utils/lsipc.c | 39 ++++++++++-----------------------------
 1 file changed, 10 insertions(+), 29 deletions(-)
sys-utils/lsipc.c +10 -29
index 195ee15..c1d4f1c 100644
@@ -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"));
Signature · 1 line
2.8.2
#5 lore raw

PATCH 5/11 dmesg: use timestamp helpers

In reply to Sami Kerola
---
 sys-utils/dmesg.c | 62 ++++++++++++++++++-------------------------------------
 1 file changed, 20 insertions(+), 42 deletions(-)
sys-utils/dmesg.c +20 -42
index cf93331..94381da 100644
@@ -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();
Signature · 1 line
2.8.2
#6 lore raw

PATCH 6/11 docs: remove timestamp TODO item

In reply to Sami Kerola
---
 Documentation/TODO | 2 --
 1 file changed, 2 deletions(-)
Documentation/TODO +0 -2
index af00ab3..416aaed 100644
@@ -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 
Signature · 1 line
2.8.2
#7 lore raw

PATCH 7/11 utmpdump: use always UTC-0 timezone in textual output

In reply to 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

---
 login-utils/utmpdump.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
login-utils/utmpdump.c +3 -3
index 03cf4a9..6eaf202 100644
@@ -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))
Signature · 1 line
2.8.2
#8 lore raw

PATCH 8/11 utmpdump: use iso-8601 timestamp format with subsecond accuracy

In reply to 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.

---
 login-utils/Makemodule.am |  1 +
 login-utils/utmpdump.c    | 61 +++++++++++++++++++++++++++++------------------
 2 files changed, 39 insertions(+), 23 deletions(-)
login-utils/Makemodule.am +1 -0
index 502ecd5..be07ace 100644
@@ -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
 
 
login-utils/utmpdump.c +38 -23

106 lines not on this page · raw message

Signature · 1 line
2.8.2
#9 lore raw

PATCH 9/11 tests: fix utmpdump timestamps to be in iso format

In reply to 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.

---
 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
tests/expected/utmp/utmpdump-totxt +10 -10
index 02fb22d..5deefde 100644
@@ -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]
tests/expected/utmp/utmpdump-totxt-ipv6 +2 -2
index 5cce150..5894144 100644
@@ -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]
tests/ts/utmp/txt-a +19 -19
index bc91d19..8501daa 100644
@@ -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]
tests/ts/utmp/txt-a-old new file +19 -0
new file mode 100644
index 0000000..bc91d19
@@ -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]
tests/ts/utmp/txt-b +10 -10
index 02fb22d..5deefde 100644
@@ -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]
tests/ts/utmp/txt-b-old new file +10 -0
new file mode 100644
index 0000000..02fb22d
@@ -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]
tests/ts/utmp/txt-ipv6 +2 -2
index 5cce150..5894144 100644
@@ -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]
tests/ts/utmp/txt-ipv6-old new file +2 -0
new file mode 100644
index 0000000..5cce150
@@ -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]
tests/ts/utmp/utmpdump-circle +7 -1
index cae2995..9663dba 100755
@@ -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 &&
Signature · 1 line
2.8.2
#10 lore raw

PATCH 10/11 tests: remove utmpdump localization go-arounds

In reply to 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.

---
 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(-)
tests/ts/utmp/utmpdump-circle +0 -2
index 9663dba..41d7de6 100755
@@ -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
tests/ts/utmp/utmpdump-tobin +0 -2
index 2f14bfc..4054952 100755
@@ -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
tests/ts/utmp/utmpdump-tobin-ipv6 +0 -2
index e0b19cd..3198d3c 100755
@@ -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
tests/ts/utmp/utmpdump-totxt +0 -2
index 37d376a..cde1f4c 100755
@@ -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
tests/ts/utmp/utmpdump-totxt-ipv6 +0 -2
index 1b21783..5fc3d9c 100755
@@ -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
Signature · 1 line
2.8.2
#11 lore raw

PATCH 11/11 tests: utmpdump add subsecond accuracy test

In reply to Sami Kerola
---
 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
tests/expected/utmp/utmpdump-subsecond new file +5 -0
new file mode 100644
index 0000000..db94805
@@ -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]
tests/ts/utmp/subsec new file +3 -0
new file mode 100644
index 0000000..4881e7c
@@ -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]
tests/ts/utmp/utmpdump-subsecond new file +34 -0
new file mode 100755
index 0000000..dba233e
@@ -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
Signature · 1 line
2.8.2
maintainer
#12 lore raw
In reply to Sami Kerola
Quoted 7 lines · 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

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

Signature · 2 lines
 Karel Zak  <[email protected]>
 http://karelzak.blogspot.com