diff options
author | Andy Shaw <qt-info@nokia.com> | 2010-04-19 06:58:24 (GMT) |
---|---|---|
committer | Andy Shaw <qt-info@nokia.com> | 2010-04-19 06:58:24 (GMT) |
commit | 73a1291a3f097787f00d79d0d27bd75219bf8e3d (patch) | |
tree | 6e9a633e916d72408581e21d2d088d5534964389 /tests | |
parent | ee6483a76e62a69641530f36ad35f1f686914442 (diff) | |
download | Qt-73a1291a3f097787f00d79d0d27bd75219bf8e3d.zip Qt-73a1291a3f097787f00d79d0d27bd75219bf8e3d.tar.gz Qt-73a1291a3f097787f00d79d0d27bd75219bf8e3d.tar.bz2 |
Report the error as being AlreadyExists if this is why it fails
On Windows it would never report this error, and on Unix it would
report a different error ulimately instead as it tried to obtain the
semaphore a second time which could cause a different error to what
should be reported.
Task-number: QTBUG-9610
Reviewed-by: Frans Englich
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/qtipc/qsystemsemaphore/tst_qsystemsemaphore.cpp | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/auto/qtipc/qsystemsemaphore/tst_qsystemsemaphore.cpp b/tests/auto/qtipc/qsystemsemaphore/tst_qsystemsemaphore.cpp index eb82fd4..0dc9c99 100644 --- a/tests/auto/qtipc/qsystemsemaphore/tst_qsystemsemaphore.cpp +++ b/tests/auto/qtipc/qsystemsemaphore/tst_qsystemsemaphore.cpp @@ -76,6 +76,8 @@ private slots: void undo(); void initialValue(); + void exists(); + private: QSystemSemaphore *existingLock; @@ -297,6 +299,29 @@ void tst_QSystemSemaphore::initialValue() release.waitForFinished(LACKYWAITTIME); QVERIFY(acquire.state()== QProcess::NotRunning); } + +void tst_QSystemSemaphore::exists() +{ + QSystemSemaphore sem("store", 1, QSystemSemaphore::Create); + QVERIFY(sem.error() == QSystemSemaphore::NoError); + QVERIFY(sem.acquire()); + QVERIFY(sem.error() == QSystemSemaphore::NoError); + + { + QSystemSemaphore dupSem("store", 1, QSystemSemaphore::Create); + QVERIFY(dupSem.error() == QSystemSemaphore::AlreadyExists); + } +#ifndef Q_OS_UNIX + // The rest of the test does not make sense on Unix because open will + // actually succeed anyway (see QSystemSemaphore docs) + QSystemSemaphore anotherSem("store", 1, QSystemSemaphore::Open); + QVERIFY(anotherSem.error() == QSystemSemaphore::AlreadyExists); + QVERIFY(sem.release()); + QVERIFY(anotherSem.acquire()); + QVERIFY(anotherSem.release()); +#endif +} + QTEST_MAIN(tst_QSystemSemaphore) #include "tst_qsystemsemaphore.moc" |