Fix test-runner on FreeBSD

CLOCK_MONOTONIC_RAW is only a thing on Linux and macOS. I'm not
actually sure why the previous hardcoding of a constant didn't
error out, but when we removed it, it sure does now.

Reviewed-by: Alexander Motin <mav@FreeBSD.org>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Co-authored-by: Rich Ercolani <rincebrain@gmail.com>
Signed-off-by: Rich Ercolani <rincebrain@gmail.com>
Closes #12995
This commit is contained in:
наб 2022-01-22 00:37:46 +01:00 committed by GitHub
parent 063daa8350
commit 17b2ae0b24
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -32,7 +32,7 @@ from select import select
from subprocess import PIPE from subprocess import PIPE
from subprocess import Popen from subprocess import Popen
from threading import Timer from threading import Timer
from time import time, CLOCK_MONOTONIC_RAW from time import time, CLOCK_MONOTONIC
BASEDIR = '/var/tmp/test_results' BASEDIR = '/var/tmp/test_results'
TESTDIR = '/usr/share/zfs/' TESTDIR = '/usr/share/zfs/'
@ -59,7 +59,7 @@ clock_gettime.argtypes = [ctypes.c_int, ctypes.POINTER(timespec)]
def monotonic_time(): def monotonic_time():
t = timespec() t = timespec()
if clock_gettime(CLOCK_MONOTONIC_RAW, ctypes.pointer(t)) != 0: if clock_gettime(CLOCK_MONOTONIC, ctypes.pointer(t)) != 0:
errno_ = ctypes.get_errno() errno_ = ctypes.get_errno()
raise OSError(errno_, os.strerror(errno_)) raise OSError(errno_, os.strerror(errno_))
return t.tv_sec + t.tv_nsec * 1e-9 return t.tv_sec + t.tv_nsec * 1e-9