summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/io/qlockfile
diff options
context:
space:
mode:
authorAhmad Samir <a.samirh78@gmail.com>2023-03-02 00:24:21 +0200
committerAhmad Samir <a.samirh78@gmail.com>2023-03-03 21:36:01 +0200
commit855a6cb6767a7759f00f52acf501fabb38bc1243 (patch)
treeffcdc1ede2fff708affc68bc5ff47f72062fb7fb /tests/auto/corelib/io/qlockfile
parentd48dbafeb24ee82ad6b97e8e5e9c9fcaa5f8a2d4 (diff)
Use utimensat instead of utimes
From the manual page: Note: modern applications may prefer to use the interfaces described in utimensat(2). Change-Id: Ib20d8b9b50626233852ca351452ce90841a39603 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'tests/auto/corelib/io/qlockfile')
-rw-r--r--tests/auto/corelib/io/qlockfile/tst_qlockfile.cpp15
1 files changed, 9 insertions, 6 deletions
diff --git a/tests/auto/corelib/io/qlockfile/tst_qlockfile.cpp b/tests/auto/corelib/io/qlockfile/tst_qlockfile.cpp
index f36334db02..aa40353c99 100644
--- a/tests/auto/corelib/io/qlockfile/tst_qlockfile.cpp
+++ b/tests/auto/corelib/io/qlockfile/tst_qlockfile.cpp
@@ -16,6 +16,8 @@
#include <qsysinfo.h>
#if defined(Q_OS_UNIX) && !defined(Q_OS_VXWORKS)
#include <unistd.h>
+
+#include <sys/stat.h> // utimensat
#include <sys/time.h>
#elif defined(Q_OS_WIN)
# include <qt_windows.h>
@@ -516,7 +518,7 @@ void tst_QLockFile::corruptedLockFile()
void tst_QLockFile::corruptedLockFileInTheFuture()
{
#if !defined(Q_OS_UNIX)
- QSKIP("This tests needs utimes");
+ QSKIP("This test needs utimensat");
#else
// This test is the same as the previous one, but the corruption was so there is a corrupted
// .rmlock whose timestamp is in the future
@@ -528,11 +530,12 @@ void tst_QLockFile::corruptedLockFileInTheFuture()
QVERIFY(file.open(QFile::WriteOnly));
}
- struct timeval times[2];
- gettimeofday(times, 0);
- times[1].tv_sec = (times[0].tv_sec += 600);
- times[1].tv_usec = times[0].tv_usec;
- utimes(fileName.toLocal8Bit(), times);
+ struct timespec times[2];
+ clock_gettime(CLOCK_REALTIME, times);
+ times[0].tv_sec += 600;
+ times[1].tv_sec = times[0].tv_sec;
+ times[1].tv_nsec = times[0].tv_nsec;
+ utimensat(0 /* ignored */, fileName.toLocal8Bit(), times, 0);
QTest::ignoreMessage(QtInfoMsg, "QLockFile: Lock file '" + fileName.toUtf8() + "' has a modification time in the future");
corruptedLockFile();