[PATCH] selftest: Fix timestamps on FreeBSD 11
Michael Adam
obnox at samba.org
Wed Nov 23 14:11:30 UTC 2016
On 2016-11-23 at 14:07 +0100, Volker Lendecke wrote:
> Hi!
>
> Review appreciated!
>
> Thanks, Volker
> From 899974db282be8db505430a35e0167ec6ca78af4 Mon Sep 17 00:00:00 2001
> From: Volker Lendecke <vl at samba.org>
> Date: Wed, 23 Nov 2016 13:54:39 +0100
> Subject: [PATCH] selftest: Fix timestamps on FreeBSD 11
>
> FreeBSD's date does not print the %, and \? does not catch that
I think \? does catch this, but the rest of the pattern is incomplete:
the \. is missing before and the possible digit (6) after the
possible % is also missing.... ;-)
> Tested this manually:
>
> $ echo 'time: 2016-11-23 12:52:19.123456Z'| sed 's/\..*NZ$/.000000Z/'
> time: 2016-11-23 12:52:19.123456Z
> $ echo 'time: 2016-11-23 12:52:19.%6NZ'| sed 's/\..*NZ$/.000000Z/'
> time: 2016-11-23 12:52:19.000000Z
> $ echo 'time: 2016-11-23 12:52:19.6NZ'| sed 's/\..*NZ$/.000000Z/'
> time: 2016-11-23 12:52:19.000000Z
> $
addition: this variant works as well:
$ echo 'time: 2016-11-23 12:52:19.NZ'| sed 's/\..*NZ$/.000000Z/'
time: 2016-11-23 12:52:19.000000Z
Since there is no other "." character in the date string,
your pattern is safe.
Nice!
Reviewed-by: me.
pushing to autobuild
Michael
> Signed-off-by: Volker Lendecke <vl at samba.org>
> ---
> testprogs/blackbox/subunit.sh | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/testprogs/blackbox/subunit.sh b/testprogs/blackbox/subunit.sh
> index 70fe2d7..0791d77 100755
> --- a/testprogs/blackbox/subunit.sh
> +++ b/testprogs/blackbox/subunit.sh
> @@ -22,7 +22,7 @@ timestamp() {
> # mark the start time. With Gnu date, you get nanoseconds from %N
> # (here truncated to microseconds with %6N), but not on BSDs,
> # Solaris, etc, which will apparently leave either %N or N at the end.
> - date -u +'time: %Y-%m-%d %H:%M:%S.%6NZ' | sed 's/%\?NZ$/000000Z/'
> + date -u +'time: %Y-%m-%d %H:%M:%S.%6NZ' | sed 's/\..*NZ$/.000000Z/'
> }
>
> subunit_start_test () {
> --
> 2.1.4
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 163 bytes
Desc: not available
URL: <http://lists.samba.org/pipermail/samba-technical/attachments/20161123/e6e2e0d5/signature.sig>
More information about the samba-technical
mailing list