osbuild/PR1541.patch

44 lines
1.6 KiB
Diff

From 0cdf98b1008161e5c07b9a4c578c7cecda4050ca Mon Sep 17 00:00:00 2001
From: Michael Vogt <michael.vogt@gmail.com>
Date: Wed, 17 Jan 2024 09:29:26 +0100
Subject: [PATCH] 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.
---
test/mod/test_util_linux.py | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/test/mod/test_util_linux.py b/test/mod/test_util_linux.py
index be31723d3..518a4bfa2 100644
--- a/test/mod/test_util_linux.py
+++ b/test/mod/test_util_linux.py
@@ -6,6 +6,7 @@
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)