public inbox for util-linux@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 18/21] last: never restrict session time
@ 2013-08-28 18:55 Sami Kerola
  2013-08-28 18:55 ` [PATCH 19/21] tests: add last(1) test Sami Kerola
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Sami Kerola @ 2013-08-28 18:55 UTC (permalink / raw)
  To: util-linux; +Cc: kerolasa

When a session time will reach whopping 10000 days the last round bracket
is unnecessarily removed from output.

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

diff --git a/login-utils/last.c b/login-utils/last.c
index 4733c64..23cc8aa 100644
--- a/login-utils/last.c
+++ b/login-utils/last.c
@@ -462,7 +462,7 @@ static int list(const struct last_control *ctl, struct utmp *p, time_t t, int wh
 	if (ctl->showhost) {
 		if (!ctl->altlist) {
 			len = snprintf(final, sizeof(final),
-				"%-8.*s %-12.12s %-16.*s %-*.*s %-*.*s %-12.12s\n",
+				"%-8.*s %-12.12s %-16.*s %-*.*s %-*.*s %s\n",
 				ctl->name_len, p->ut_name, utline,
 				ctl->domain_len, domain,
 				tftl[ctl->time_fmt].in, tftl[ctl->time_fmt].in, logintime,
@@ -478,7 +478,7 @@ static int list(const struct last_control *ctl, struct utmp *p, time_t t, int wh
 		}
 	} else
 		len = snprintf(final, sizeof(final),
-			"%-8.*s %-12.12s %-*.*s %-*.*s %-12.12s\n",
+			"%-8.*s %-12.12s %-*.*s %-*.*s %s\n",
 			ctl->name_len, p->ut_name, utline,
 			tftl[ctl->time_fmt].in, tftl[ctl->time_fmt].in, logintime,
 			tftl[ctl->time_fmt].out, tftl[ctl->time_fmt].out, logouttime,
-- 
1.8.4


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

* [PATCH 19/21] tests: add last(1) test
  2013-08-28 18:55 [PATCH 18/21] last: never restrict session time Sami Kerola
@ 2013-08-28 18:55 ` Sami Kerola
  2013-08-28 18:55 ` [PATCH 20/21] last: trim trailing white spaces Sami Kerola
  2013-08-28 18:55 ` [PATCH 21/21] last: tell verbally system is still running Sami Kerola
  2 siblings, 0 replies; 4+ messages in thread
From: Sami Kerola @ 2013-08-28 18:55 UTC (permalink / raw)
  To: util-linux; +Cc: kerolasa

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
 tests/commands.sh        |   1 +
 tests/expected/last/last | 121 +++++++++++++++++++++++++++++++++++++++++++++++
 tests/ts/last/last       |  62 ++++++++++++++++++++++++
 tests/ts/last/wtmp       | Bin 0 -> 7296 bytes
 4 files changed, 184 insertions(+)
 create mode 100644 tests/expected/last/last
 create mode 100755 tests/ts/last/last
 create mode 100644 tests/ts/last/wtmp

diff --git a/tests/commands.sh b/tests/commands.sh
index 84da400..fcd74dc 100644
--- a/tests/commands.sh
+++ b/tests/commands.sh
@@ -47,6 +47,7 @@ TS_CMD_IPCMK=${TS_CMD_IPCMK-"$top_builddir/ipcmk"}
 TS_CMD_IPCRM=${TS_CMD_IPCRM-"$top_builddir/ipcrm"}
 TS_CMD_IPCS=${TS_CMD_IPCS:-"$top_builddir/ipcs"}
 TS_CMD_ISOSIZE=${TS_CMD_ISOSIZE-"$top_builddir/isosize"}
+TS_CMD_LAST=${TS_CMD_LAST-"$top_builddir/last"}
 TS_CMD_LINE=${TS_CMD_LINE-"$top_builddir/line"}
 TS_CMD_LOOK=${TS_CMD_LOOK-"$top_builddir/look"}
 TS_CMD_LOSETUP=${TS_CMD_LOSETUP:-"$top_builddir/losetup"}
diff --git a/tests/expected/last/last b/tests/expected/last/last
new file mode 100644
index 0000000..772a738
--- /dev/null
+++ b/tests/expected/last/last
@@ -0,0 +1,121 @@
+~~~ basic output ~~~
+rick     long         never-gonna-logo Thu Jan  1 00:00 - 03:14 (24855+03:14)
+torvalds linux        hobby            Mon Aug 26 00:57   still logged in
+reboot   system boot  system-name      Wed Aug 28 18:00 - 18:50  (00:50)
+reboot   system boot  system-name      Wed Aug 28 16:00 - 17:00  (01:00)
+IPv4     root         dns-server       Wed Aug 28 13:00 - 14:00  (01:00)
+nonvalid foo          zero             Wed Aug 28 12:00 - down   (03:00)
+runlevel foo          one              Wed Aug 28 11:00 - 12:00  (01:00)
+sysboot  foo          two              Wed Aug 28 10:00 - 11:00  (01:00)
+newtime  foo          three            Wed Aug 28 09:00 - 10:00  (01:00)
+oldtime  foo          four             Wed Aug 28 08:00 - 09:00  (01:00)
+init     foo          five             Wed Aug 28 07:00 - 08:00  (01:00)
+login    foo          six              Wed Aug 28 06:00 - 07:00  (01:00)
+user_pro foo          seven            Wed Aug 28 05:00 - 06:00  (01:00)
+accounti foo          nine             Wed Aug 28 03:00 - 04:00  (01:00)
+
+wtmp begins Wed Aug 28 03:00:00 2013
+~~~ include system ~~~
+rick     long         never-gonna-logo Thu Jan  1 00:00 - 03:14 (24855+03:14)
+torvalds linux        hobby            Mon Aug 26 00:57   still logged in
+reboot   system boot  system-name      Wed Aug 28 18:00 - 18:50  (00:50)
+shutdown system down  system-name      Wed Aug 28 17:00 - 18:00  (01:00)
+reboot   system boot  system-name      Wed Aug 28 16:00 - 17:00  (01:00)
+shutdown system down  system-name      Wed Aug 28 15:00 - 16:00  (01:00)
+IPv4     root         dns-server       Wed Aug 28 13:00 - 14:00  (01:00)
+nonvalid foo          zero             Wed Aug 28 12:00 - down   (03:00)
+runlevel foo          one              Wed Aug 28 11:00 - 12:00  (01:00)
+sysboot  foo          two              Wed Aug 28 10:00 - 11:00  (01:00)
+newtime  foo          three            Wed Aug 28 09:00 - 10:00  (01:00)
+oldtime  foo          four             Wed Aug 28 08:00 - 09:00  (01:00)
+init     foo          five             Wed Aug 28 07:00 - 08:00  (01:00)
+login    foo          six              Wed Aug 28 06:00 - 07:00  (01:00)
+user_pro foo          seven            Wed Aug 28 05:00 - 06:00  (01:00)
+accounti foo          nine             Wed Aug 28 03:00 - 04:00  (01:00)
+
+wtmp begins Wed Aug 28 03:00:00 2013
+~~~ dns short ~~~
+IPv4     root         a.root-servers.n Wed Aug 28 13:00 - 14:00  (01:00)
+
+wtmp begins Wed Aug 28 03:00:00 2013
+~~~ dns long ~~~
+IPv4     root         a.root-servers.net Wed Aug 28 13:00 - 14:00  (01:00)
+
+wtmp begins Wed Aug 28 03:00:00 2013
+~~~ dns host last ~~~
+IPv4     root         Wed Aug 28 13:00 - 14:00  (01:00)     a.root-servers.net
+
+wtmp begins Wed Aug 28 03:00:00 2013
+~~~ show ip ~~~
+torvalds linux        128.214.205.14   Mon Aug 26 00:57   still logged in
+
+wtmp begins Wed Aug 28 03:00:00 2013
+~~~ no host ~~~
+torvalds linux        Mon Aug 26 00:57   still logged in
+
+wtmp begins Wed Aug 28 03:00:00 2013
+~~~ full times ~~~
+rick     long         never-gonna-logo Thu Jan  1 00:00:00 1970 - Tue Jan 19 03:14:07 2038 (24855+03:14)
+torvalds linux        hobby            Mon Aug 26 00:57:08 1991   still logged in          
+reboot   system boot  system-name      Wed Aug 28 18:00:00 2013 - Wed Aug 28 18:50:27 2013  (00:50)
+reboot   system boot  system-name      Wed Aug 28 16:00:00 2013 - Wed Aug 28 17:00:00 2013  (01:00)
+IPv4     root         dns-server       Wed Aug 28 13:00:00 2013 - Wed Aug 28 14:00:00 2013  (01:00)
+nonvalid foo          zero             Wed Aug 28 12:00:00 2013 - down                      (03:00)
+runlevel foo          one              Wed Aug 28 11:00:00 2013 - Wed Aug 28 12:00:00 2013  (01:00)
+sysboot  foo          two              Wed Aug 28 10:00:00 2013 - Wed Aug 28 11:00:00 2013  (01:00)
+newtime  foo          three            Wed Aug 28 09:00:00 2013 - Wed Aug 28 10:00:00 2013  (01:00)
+oldtime  foo          four             Wed Aug 28 08:00:00 2013 - Wed Aug 28 09:00:00 2013  (01:00)
+init     foo          five             Wed Aug 28 07:00:00 2013 - Wed Aug 28 08:00:00 2013  (01:00)
+login    foo          six              Wed Aug 28 06:00:00 2013 - Wed Aug 28 07:00:00 2013  (01:00)
+user_pro foo          seven            Wed Aug 28 05:00:00 2013 - Wed Aug 28 06:00:00 2013  (01:00)
+accounti foo          nine             Wed Aug 28 03:00:00 2013 - Wed Aug 28 04:00:00 2013  (01:00)
+
+wtmp begins Wed Aug 28 03:00:00 2013
+~~~ no time ~~~
+rick     long         never-gonna-logo   (24855+03:14)
+torvalds linux        hobby              logged in
+reboot   system boot  system-name         (00:50)
+reboot   system boot  system-name         (01:00)
+IPv4     root         dns-server          (01:00)
+nonvalid foo          zero                (03:00)
+runlevel foo          one                 (01:00)
+sysboot  foo          two                 (01:00)
+newtime  foo          three               (01:00)
+oldtime  foo          four                (01:00)
+init     foo          five                (01:00)
+login    foo          six                 (01:00)
+user_pro foo          seven               (01:00)
+accounti foo          nine                (01:00)
+
+wtmp begins Wed Aug 28 03:00:00 2013
+~~~ iso-8601 time ~~~
+rick     long         never-gonna-logout 1970-01-01T00:00:00+0000 - 2038-01-19T03:14:07+0000 (24855+03:14)
+torvalds linux        hobby            1991-08-26T00:57:08+0000   still logged in          
+reboot   system boot  system-name      2013-08-28T18:00:00+0000 - 2013-08-28T18:50:27+0000  (00:50)
+reboot   system boot  system-name      2013-08-28T16:00:00+0000 - 2013-08-28T17:00:00+0000  (01:00)
+IPv4     root         dns-server       2013-08-28T13:00:00+0000 - 2013-08-28T14:00:00+0000  (01:00)
+nonvalid foo          zero             2013-08-28T12:00:00+0000 - down                      (03:00)
+runlevel foo          one              2013-08-28T11:00:00+0000 - 2013-08-28T12:00:00+0000  (01:00)
+sysboot  foo          two              2013-08-28T10:00:00+0000 - 2013-08-28T11:00:00+0000  (01:00)
+newtime  foo          three            2013-08-28T09:00:00+0000 - 2013-08-28T10:00:00+0000  (01:00)
+oldtime  foo          four             2013-08-28T08:00:00+0000 - 2013-08-28T09:00:00+0000  (01:00)
+init     foo          five             2013-08-28T07:00:00+0000 - 2013-08-28T08:00:00+0000  (01:00)
+login    foo          six              2013-08-28T06:00:00+0000 - 2013-08-28T07:00:00+0000  (01:00)
+user_process foo          seven            2013-08-28T05:00:00+0000 - 2013-08-28T06:00:00+0000  (01:00)
+accounting foo          nine             2013-08-28T03:00:00+0000 - 2013-08-28T04:00:00+0000  (01:00)
+
+wtmp begins Wed Aug 28 03:00:00 2013
+~~~ since and until ~~~
+oldtime  foo          four             Wed Aug 28 08:00    gone - no logout
+init     foo          five             Wed Aug 28 07:00 - 08:00  (01:00)
+login    foo          six              Wed Aug 28 06:00 - 07:00  (01:00)
+user_pro foo          seven            Wed Aug 28 05:00 - 06:00  (01:00)
+accounti foo          nine             Wed Aug 28 03:00 - 04:00  (01:00)
+
+wtmp begins Wed Aug 28 03:00:00 2013
+~~~ present ~~~
+rick     long         never-gonna-logo Thu Jan  1 00:00 - 03:14 (24855+03:14)
+torvalds linux        hobby            Mon Aug 26 00:57   still logged in
+runlevel foo          one              Wed Aug 28 11:00 - 12:00  (01:00)
+
+wtmp begins Wed Aug 28 03:00:00 2013
diff --git a/tests/ts/last/last b/tests/ts/last/last
new file mode 100755
index 0000000..4ad38cb
--- /dev/null
+++ b/tests/ts/last/last
@@ -0,0 +1,62 @@
+#!/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="$(dirname $0)/../.."
+TS_DESC="last"
+
+. $TS_TOPDIR/functions.sh
+ts_init "$*"
+
+export LANG=C
+export TZ=GMT
+
+>| $TS_OUTPUT
+
+ts_log "~~~ basic output ~~~"
+$TS_CMD_LAST -f $TS_SELF/wtmp >> $TS_OUTPUT 2>/dev/null
+
+ts_log "~~~ include system ~~~"
+$TS_CMD_LAST -f $TS_SELF/wtmp -x >> $TS_OUTPUT 2>/dev/null
+
+ts_log "~~~ dns short ~~~"
+$TS_CMD_LAST -f $TS_SELF/wtmp -d root >> $TS_OUTPUT 2>/dev/null
+
+ts_log "~~~ dns long ~~~"
+$TS_CMD_LAST -f $TS_SELF/wtmp -w -d root >> $TS_OUTPUT 2>/dev/null
+
+ts_log "~~~ dns host last ~~~"
+$TS_CMD_LAST -f $TS_SELF/wtmp -a -d root >> $TS_OUTPUT 2>/dev/null
+
+ts_log "~~~ show ip ~~~"
+$TS_CMD_LAST -f $TS_SELF/wtmp -i torvalds >> $TS_OUTPUT 2>/dev/null
+
+ts_log "~~~ no host ~~~"
+$TS_CMD_LAST -f $TS_SELF/wtmp -R torvalds >> $TS_OUTPUT 2>/dev/null
+
+ts_log "~~~ full times ~~~"
+$TS_CMD_LAST -f $TS_SELF/wtmp -F >> $TS_OUTPUT 2>/dev/null
+
+ts_log "~~~ no time ~~~"
+$TS_CMD_LAST -f $TS_SELF/wtmp --time-format=notime >> $TS_OUTPUT 2>/dev/null
+
+ts_log "~~~ iso-8601 time ~~~"
+$TS_CMD_LAST -f $TS_SELF/wtmp --time-format=iso -w >> $TS_OUTPUT 2>/dev/null
+
+ts_log "~~~ since and until ~~~"
+$TS_CMD_LAST -f $TS_SELF/wtmp -s "2013-08-28 02:20" -t "2013-08-28 08:20" >> $TS_OUTPUT 2>/dev/null
+
+ts_log "~~~ present ~~~"
+$TS_CMD_LAST -f $TS_SELF/wtmp -p "2013-08-28 11:20" >> $TS_OUTPUT 2>/dev/null
+
+ts_finalize
diff --git a/tests/ts/last/wtmp b/tests/ts/last/wtmp
new file mode 100644
index 0000000000000000000000000000000000000000..f66bb20a101790e61ee4a09a2da9bdede96f73d6
GIT binary patch
literal 7296
zcmeI1y-pl45XUd%3-TpiAn3|O$|*oD;iF1R2YG>H@7A|xW$~PB?;cPbNW1_%0eJ#M
zNkKuCB2uJOh%!Z#Iz{@+%$;bWwQrE9ur2-fR-U=p_0L}K*gI3J)n-r~06e;jHLq8a
zb{h(1rOK-PlvJYH5?1X=_WT34#nb3WV(?#1MUsB(X=n>$s^SZob#0X)u)6bt&;KE^
zAu;$b6-H<ue<Mnv0%Kj(+#maV{tqw!iNXI}4w>}vHFB%!c7m(>dC2E~AL)=7{NG9?
zz0*ramT~?^mVb`;{O_SZiNU`Kd1~dR8*v8;jiF*W=JUUcv`7s8Z<OeJ`P;4*?%oNf
zTV~Jr{HG8LiNSx-Y?~H<dkV6Be-0Z;57fW$`QJe(BnJNlU8o#WoZQ6`V){QqGk?kF
zf5no)e_nwqlU$}(|M~xSN9gzfAe8sN`TQyOe}vM$i3RPlS2owy%O;*WOR7u*mk6Z@
z{4Koxcg+9m%Ta3M<V6Nr`#wfR{zT(u%BQKh(f$L6Kh6D5P=g7V9t`Sr(=BWYediJk
z-_KTTHdNxtQ72sHR+xLUWB#1RQ0~L!uZ1`LsYU){;(K#^{&D<sM(Oo@4qoy3$MJtX
zwjA#-t9<^H|2#$IQWd`4Gu;1Qu%I#jOe^=E>At$qYHia=;N{oG=?g-zck%t%BoxG-
yoN{n|RT)PhyO!<GzIX~3XS$JrQb_~%N}+Hsm3?7?vQhpS`QL1p4~N5DZp44z^2EFV

literal 0
HcmV?d00001

-- 
1.8.4


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

* [PATCH 20/21] last: trim trailing white spaces
  2013-08-28 18:55 [PATCH 18/21] last: never restrict session time Sami Kerola
  2013-08-28 18:55 ` [PATCH 19/21] tests: add last(1) test Sami Kerola
@ 2013-08-28 18:55 ` Sami Kerola
  2013-08-28 18:55 ` [PATCH 21/21] last: tell verbally system is still running Sami Kerola
  2 siblings, 0 replies; 4+ messages in thread
From: Sami Kerola @ 2013-08-28 18:55 UTC (permalink / raw)
  To: util-linux; +Cc: kerolasa

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
 login-utils/last.c       | 18 ++++++++++++++++++
 tests/expected/last/last |  4 ++--
 2 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/login-utils/last.c b/login-utils/last.c
index 23cc8aa..b800cee 100644
--- a/login-utils/last.c
+++ b/login-utils/last.c
@@ -349,6 +349,23 @@ static int time_formatter(const struct last_control *ctl, char *dst,
 }
 
 /*
+ *	Remove trailing spaces from a string.
+ */
+static void trim_trailing_spaces(char *s)
+{
+	char *p;
+
+	for (p = s; *p; ++p)
+		continue;
+	while (p > s && isspace(*--p))
+		continue;
+	if (p > s)
+		++p;
+	*p++ = '\n';
+	*p = '\0';
+}
+
+/*
  *	Show one line of information on screen
  */
 static int list(const struct last_control *ctl, struct utmp *p, time_t t, int what)
@@ -490,6 +507,7 @@ static int list(const struct last_control *ctl, struct utmp *p, time_t t, int wh
 #  endif
 #endif
 
+	trim_trailing_spaces(final);
 	/*
 	 *	Print out "final" string safely.
 	 */
diff --git a/tests/expected/last/last b/tests/expected/last/last
index 772a738..baa6ebc 100644
--- a/tests/expected/last/last
+++ b/tests/expected/last/last
@@ -56,7 +56,7 @@ torvalds linux        Mon Aug 26 00:57   still logged in
 wtmp begins Wed Aug 28 03:00:00 2013
 ~~~ full times ~~~
 rick     long         never-gonna-logo Thu Jan  1 00:00:00 1970 - Tue Jan 19 03:14:07 2038 (24855+03:14)
-torvalds linux        hobby            Mon Aug 26 00:57:08 1991   still logged in          
+torvalds linux        hobby            Mon Aug 26 00:57:08 1991   still logged in
 reboot   system boot  system-name      Wed Aug 28 18:00:00 2013 - Wed Aug 28 18:50:27 2013  (00:50)
 reboot   system boot  system-name      Wed Aug 28 16:00:00 2013 - Wed Aug 28 17:00:00 2013  (01:00)
 IPv4     root         dns-server       Wed Aug 28 13:00:00 2013 - Wed Aug 28 14:00:00 2013  (01:00)
@@ -90,7 +90,7 @@ accounti foo          nine                (01:00)
 wtmp begins Wed Aug 28 03:00:00 2013
 ~~~ iso-8601 time ~~~
 rick     long         never-gonna-logout 1970-01-01T00:00:00+0000 - 2038-01-19T03:14:07+0000 (24855+03:14)
-torvalds linux        hobby            1991-08-26T00:57:08+0000   still logged in          
+torvalds linux        hobby            1991-08-26T00:57:08+0000   still logged in
 reboot   system boot  system-name      2013-08-28T18:00:00+0000 - 2013-08-28T18:50:27+0000  (00:50)
 reboot   system boot  system-name      2013-08-28T16:00:00+0000 - 2013-08-28T17:00:00+0000  (01:00)
 IPv4     root         dns-server       2013-08-28T13:00:00+0000 - 2013-08-28T14:00:00+0000  (01:00)
-- 
1.8.4


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

* [PATCH 21/21] last: tell verbally system is still running
  2013-08-28 18:55 [PATCH 18/21] last: never restrict session time Sami Kerola
  2013-08-28 18:55 ` [PATCH 19/21] tests: add last(1) test Sami Kerola
  2013-08-28 18:55 ` [PATCH 20/21] last: trim trailing white spaces Sami Kerola
@ 2013-08-28 18:55 ` Sami Kerola
  2 siblings, 0 replies; 4+ messages in thread
From: Sami Kerola @ 2013-08-28 18:55 UTC (permalink / raw)
  To: util-linux; +Cc: kerolasa

Use of uptime time stamp as previous boot login time makes the output not
constant, which is rather difficult to test.  Verbal message 'system is
still running' makes testing easy, and noticing which boot is still
running clear to a person.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
 login-utils/last.c       | 13 +++++++++++--
 tests/expected/last/last | 10 +++++-----
 2 files changed, 16 insertions(+), 7 deletions(-)

diff --git a/login-utils/last.c b/login-utils/last.c
index b800cee..21adf2a 100644
--- a/login-utils/last.c
+++ b/login-utils/last.c
@@ -370,7 +370,7 @@ static void trim_trailing_spaces(char *s)
  */
 static int list(const struct last_control *ctl, struct utmp *p, time_t t, int what)
 {
-	time_t		secs, tmp;
+	time_t		secs, tmp, epoch;
 	char		logintime[LAST_TIMESTAMP_LEN];
 	char		logouttime[LAST_TIMESTAMP_LEN];
 	char		length[LAST_TIMESTAMP_LEN];
@@ -421,7 +421,16 @@ static int list(const struct last_control *ctl, struct utmp *p, time_t t, int wh
 	mins  = (secs / 60) % 60;
 	hours = (secs / 3600) % 24;
 	days  = secs / 86400;
-	if (days)
+
+	epoch = time(NULL);
+	if (t == epoch) {
+		if (ctl->fulltime)
+			sprintf(logouttime, "  still running");
+		else {
+			sprintf(logouttime, "  still");
+			sprintf(length, "running");
+		}
+	} else if (days)
 		sprintf(length, "(%d+%02d:%02d)", days, hours, mins);
 	else
 		sprintf(length, " (%02d:%02d)", hours, mins);
diff --git a/tests/expected/last/last b/tests/expected/last/last
index baa6ebc..2ff5cc1 100644
--- a/tests/expected/last/last
+++ b/tests/expected/last/last
@@ -1,7 +1,7 @@
 ~~~ basic output ~~~
 rick     long         never-gonna-logo Thu Jan  1 00:00 - 03:14 (24855+03:14)
 torvalds linux        hobby            Mon Aug 26 00:57   still logged in
-reboot   system boot  system-name      Wed Aug 28 18:00 - 18:50  (00:50)
+reboot   system boot  system-name      Wed Aug 28 18:00   still running
 reboot   system boot  system-name      Wed Aug 28 16:00 - 17:00  (01:00)
 IPv4     root         dns-server       Wed Aug 28 13:00 - 14:00  (01:00)
 nonvalid foo          zero             Wed Aug 28 12:00 - down   (03:00)
@@ -18,7 +18,7 @@ wtmp begins Wed Aug 28 03:00:00 2013
 ~~~ include system ~~~
 rick     long         never-gonna-logo Thu Jan  1 00:00 - 03:14 (24855+03:14)
 torvalds linux        hobby            Mon Aug 26 00:57   still logged in
-reboot   system boot  system-name      Wed Aug 28 18:00 - 18:50  (00:50)
+reboot   system boot  system-name      Wed Aug 28 18:00   still running
 shutdown system down  system-name      Wed Aug 28 17:00 - 18:00  (01:00)
 reboot   system boot  system-name      Wed Aug 28 16:00 - 17:00  (01:00)
 shutdown system down  system-name      Wed Aug 28 15:00 - 16:00  (01:00)
@@ -57,7 +57,7 @@ wtmp begins Wed Aug 28 03:00:00 2013
 ~~~ full times ~~~
 rick     long         never-gonna-logo Thu Jan  1 00:00:00 1970 - Tue Jan 19 03:14:07 2038 (24855+03:14)
 torvalds linux        hobby            Mon Aug 26 00:57:08 1991   still logged in
-reboot   system boot  system-name      Wed Aug 28 18:00:00 2013 - Wed Aug 28 18:50:27 2013  (00:50)
+reboot   system boot  system-name      Wed Aug 28 18:00:00 2013   still running
 reboot   system boot  system-name      Wed Aug 28 16:00:00 2013 - Wed Aug 28 17:00:00 2013  (01:00)
 IPv4     root         dns-server       Wed Aug 28 13:00:00 2013 - Wed Aug 28 14:00:00 2013  (01:00)
 nonvalid foo          zero             Wed Aug 28 12:00:00 2013 - down                      (03:00)
@@ -74,7 +74,7 @@ wtmp begins Wed Aug 28 03:00:00 2013
 ~~~ no time ~~~
 rick     long         never-gonna-logo   (24855+03:14)
 torvalds linux        hobby              logged in
-reboot   system boot  system-name         (00:50)
+reboot   system boot  system-name        running
 reboot   system boot  system-name         (01:00)
 IPv4     root         dns-server          (01:00)
 nonvalid foo          zero                (03:00)
@@ -91,7 +91,7 @@ wtmp begins Wed Aug 28 03:00:00 2013
 ~~~ iso-8601 time ~~~
 rick     long         never-gonna-logout 1970-01-01T00:00:00+0000 - 2038-01-19T03:14:07+0000 (24855+03:14)
 torvalds linux        hobby            1991-08-26T00:57:08+0000   still logged in
-reboot   system boot  system-name      2013-08-28T18:00:00+0000 - 2013-08-28T18:50:27+0000  (00:50)
+reboot   system boot  system-name      2013-08-28T18:00:00+0000   still running
 reboot   system boot  system-name      2013-08-28T16:00:00+0000 - 2013-08-28T17:00:00+0000  (01:00)
 IPv4     root         dns-server       2013-08-28T13:00:00+0000 - 2013-08-28T14:00:00+0000  (01:00)
 nonvalid foo          zero             2013-08-28T12:00:00+0000 - down                      (03:00)
-- 
1.8.4


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

end of thread, other threads:[~2013-08-28 18:55 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-08-28 18:55 [PATCH 18/21] last: never restrict session time Sami Kerola
2013-08-28 18:55 ` [PATCH 19/21] tests: add last(1) test Sami Kerola
2013-08-28 18:55 ` [PATCH 20/21] last: trim trailing white spaces Sami Kerola
2013-08-28 18:55 ` [PATCH 21/21] last: tell verbally system is still running Sami Kerola

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox