test: fix test_libc_futimes_works
The test_libc_futimes_works() is failing under RHEL/Centos right now. To make it more robust a tiny sleep and rounding of the timestamps is introduced to ensure that we are not run into floating point comaparison funnines. The second part of the fix is to open the stamp_file in read-only mode to ensure that the mtime is not modified by the open itself which is what lead to the actual test failure.
This commit is contained in:
parent
94d8a1357f
commit
fd2079be60
1 changed files with 4 additions and 2 deletions
|
|
@ -6,6 +6,7 @@ import ctypes
|
|||
import os
|
||||
import subprocess
|
||||
import tempfile
|
||||
import time
|
||||
|
||||
import pytest
|
||||
|
||||
|
|
@ -255,10 +256,11 @@ def test_libc_futimes_works(tmpdir):
|
|||
with open(stamp_file, "wb") as fp:
|
||||
fp.write(b"meep")
|
||||
mtime1 = os.stat(stamp_file).st_mtime
|
||||
with open(stamp_file, "wb") as fp:
|
||||
time.sleep(0.1)
|
||||
with open(stamp_file, "rb") as fp:
|
||||
libc.futimens(fp.fileno(), ctypes.byref(linux.c_timespec_times2(
|
||||
atime=linux.c_timespec(tv_sec=3, tv_nsec=300 * 1000 * 1000),
|
||||
mtime=linux.c_timespec(tv_sec=0, tv_nsec=libc.UTIME_OMIT),
|
||||
)))
|
||||
assert os.stat(stamp_file).st_atime == 3.3
|
||||
assert os.stat(stamp_file).st_mtime == mtime1
|
||||
assert round(os.stat(stamp_file).st_mtime, 3) == round(mtime1, 3)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue