From fee6b63275c821fe89c279d88526e7fb6ffc07a9 Mon Sep 17 00:00:00 2001 From: Tobias Klauser Date: Wed, 13 Nov 2019 10:39:24 +0100 Subject: [PATCH] =?UTF-8?q?unix:=20accept=20time.Now()=C2=B11=20as=20valid?= =?UTF-8?q?=20in=20TestTime?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes golang/go#33200 Change-Id: I7e6e62f09174f0b214e7d021a31f1ad2166f9db5 Reviewed-on: https://go-review.googlesource.com/c/sys/+/206861 Run-TryBot: Tobias Klauser TryBot-Result: Gobot Gobot Reviewed-by: Ian Lance Taylor --- unix/syscall_aix_test.go | 6 +++--- unix/syscall_linux_test.go | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/unix/syscall_aix_test.go b/unix/syscall_aix_test.go index 6787643b..7563dc2f 100644 --- a/unix/syscall_aix_test.go +++ b/unix/syscall_aix_test.go @@ -49,13 +49,13 @@ func TestTime(t *testing.T) { } now = time.Now() - - if int64(ut) == now.Unix() { + diff := int64(ut) - now.Unix() + if -1 <= diff && diff <= 1 { return } } - t.Errorf("Time: return value %v should be nearly equal to time.Now().Unix() %v", ut, now.Unix()) + t.Errorf("Time: return value %v should be nearly equal to time.Now().Unix() %v±1", ut, now.Unix()) } func TestUtime(t *testing.T) { diff --git a/unix/syscall_linux_test.go b/unix/syscall_linux_test.go index adc59b12..d3f2bc3e 100644 --- a/unix/syscall_linux_test.go +++ b/unix/syscall_linux_test.go @@ -125,13 +125,13 @@ func TestTime(t *testing.T) { } now = time.Now() - - if int64(ut) == now.Unix() { + diff := int64(ut) - now.Unix() + if -1 <= diff && diff <= 1 { return } } - t.Errorf("Time: return value %v should be nearly equal to time.Now().Unix() %v", ut, now.Unix()) + t.Errorf("Time: return value %v should be nearly equal to time.Now().Unix() %v±1", ut, now.Unix()) } func TestUtime(t *testing.T) {