summaryrefslogtreecommitdiffstats
path: root/tests/auto/qdatetime
diff options
context:
space:
mode:
authorRohan McGovern <rohan.mcgovern@nokia.com>2010-07-28 23:16:30 (GMT)
committerRohan McGovern <rohan.mcgovern@nokia.com>2010-07-28 23:18:16 (GMT)
commit63e010a09d53e0269182902a17dd2e79738f2e23 (patch)
treeb83ad1e3bd5e1117c46620d835581915e9dfcacf /tests/auto/qdatetime
parent953e91c582cd396082250748e4c4d8424292c1de (diff)
downloadQt-63e010a09d53e0269182902a17dd2e79738f2e23.zip
Qt-63e010a09d53e0269182902a17dd2e79738f2e23.tar.gz
Qt-63e010a09d53e0269182902a17dd2e79738f2e23.tar.bz2
Fixed instability of tst_qdatetime::currentDateTime(Utc) on Linux
It's possible for the second to tick over in gettimeofday() earlier than time() (verified with strace). So this test needs an extra second of leeway.
Diffstat (limited to 'tests/auto/qdatetime')
-rw-r--r--tests/auto/qdatetime/tst_qdatetime.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/tests/auto/qdatetime/tst_qdatetime.cpp b/tests/auto/qdatetime/tst_qdatetime.cpp
index 1a82a4c..1841487 100644
--- a/tests/auto/qdatetime/tst_qdatetime.cpp
+++ b/tests/auto/qdatetime/tst_qdatetime.cpp
@@ -959,7 +959,9 @@ void tst_QDateTime::currentDateTime()
#endif
QDateTime upperBound;
upperBound.setTime_t(buf2);
- upperBound = upperBound.addSecs(1);
+ // Note we must add 2 seconds here because time() may return up to
+ // 1 second difference from the more accurate method used by QDateTime::currentDateTime()
+ upperBound = upperBound.addSecs(2);
QString details = QString("\n"
"lowerBound: %1\n"
@@ -1010,7 +1012,9 @@ void tst_QDateTime::currentDateTimeUtc()
#endif
QDateTime upperBound;
upperBound.setTime_t(buf2);
- upperBound = upperBound.addSecs(1);
+ // Note we must add 2 seconds here because time() may return up to
+ // 1 second difference from the more accurate method used by QDateTime::currentDateTime()
+ upperBound = upperBound.addSecs(2);
QString details = QString("\n"
"lowerBound: %1\n"