osbuild/PR1541.patch
Paweł Poławski 56f6146b16 Tests: Backport upstream unit tests fixes
After recent upstream rebase few tests were failing:
* test_libc_futimes_works FAILED
* test_exports_normal FAILED
* test_exports_with_force_no_preserve_owner FAILED
* test_fat FAILED

Patches fixing those issues has been presented upstream shortly after
rebasing has been completed. This commit adds backport those fixes.

Resolves: RHEL-1770
2024-01-17 18:12:03 +01:00

44 lines
1.6 KiB
Diff

From 78fc821803ce62d7f2846cb7c581d68c2be74c73 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)