IPC: clean up #ifdef in tst_qsharedmemory.cpp

Change-Id: I12a088d1ae424825abd3fffd171db0debf823a12
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
This commit is contained in:
Thiago Macieira 2022-11-02 08:55:33 -07:00
parent bdaf3c458c
commit 6bc3a89c90

View File

@ -53,20 +53,14 @@ private slots:
void lock(); void lock();
// custom edge cases // custom edge cases
#ifndef Q_OS_HPUX
void removeWhileAttached(); void removeWhileAttached();
#endif
void emptyMemory(); void emptyMemory();
#if !defined(Q_OS_WIN)
void readOnly(); void readOnly();
#endif
// basics all together // basics all together
#ifndef Q_OS_HPUX
void simpleProducerConsumer_data(); void simpleProducerConsumer_data();
void simpleProducerConsumer(); void simpleProducerConsumer();
void simpleDoubleProducerConsumer(); void simpleDoubleProducerConsumer();
#endif
// with threads // with threads
void simpleThreadedProducerConsumer_data(); void simpleThreadedProducerConsumer_data();
@ -78,9 +72,7 @@ private slots:
// extreme cases // extreme cases
void useTooMuchMemory(); void useTooMuchMemory();
#if !defined(Q_OS_HPUX)
void attachTooMuch(); void attachTooMuch();
#endif
// unique keys // unique keys
void uniqueKey_data(); void uniqueKey_data();
@ -429,7 +421,6 @@ void tst_QSharedMemory::lock()
but new shared memory are not allowed to attach after a remove. but new shared memory are not allowed to attach after a remove.
*/ */
// HPUX doesn't allow for multiple attaches per process. // HPUX doesn't allow for multiple attaches per process.
#ifndef Q_OS_HPUX
void tst_QSharedMemory::removeWhileAttached() void tst_QSharedMemory::removeWhileAttached()
{ {
rememberKey("one"); rememberKey("one");
@ -459,7 +450,6 @@ void tst_QSharedMemory::removeWhileAttached()
QVERIFY(!smThree.attach()); QVERIFY(!smThree.attach());
QCOMPARE(smThree.error(), QSharedMemory::NotFound); QCOMPARE(smThree.error(), QSharedMemory::NotFound);
} }
#endif
/*! /*!
The memory should be set to 0 after created. The memory should be set to 0 after created.
@ -479,14 +469,14 @@ void tst_QSharedMemory::emptyMemory()
Verify that attach with ReadOnly is actually read only Verify that attach with ReadOnly is actually read only
by writing to data and causing a segfault. by writing to data and causing a segfault.
*/ */
// This test opens a crash dialog on Windows.
#if !defined(Q_OS_WIN)
void tst_QSharedMemory::readOnly() void tst_QSharedMemory::readOnly()
{ {
#if !QT_CONFIG(process) #if !QT_CONFIG(process)
QSKIP("No qprocess support", SkipAll); QSKIP("No qprocess support", SkipAll);
#elif defined(Q_OS_MACOS) #elif defined(Q_OS_MACOS)
QSKIP("QTBUG-59936: Times out on macOS", SkipAll); QSKIP("QTBUG-59936: Times out on macOS", SkipAll);
#elif defined(Q_OS_WIN)
QSKIP("This test opens a crash dialog on Windows.");
#elif defined(__SANITIZE_ADDRESS__) || __has_feature(address_sanitizer) #elif defined(__SANITIZE_ADDRESS__) || __has_feature(address_sanitizer)
QSKIP("ASan prevents the crash this test is looking for.", SkipAll); QSKIP("ASan prevents the crash this test is looking for.", SkipAll);
#else #else
@ -500,7 +490,6 @@ void tst_QSharedMemory::readOnly()
QCOMPARE(p.error(), QProcess::Crashed); QCOMPARE(p.error(), QProcess::Crashed);
#endif #endif
} }
#endif
/*! /*!
Keep making shared memory until the kernel stops us. Keep making shared memory until the kernel stops us.
@ -549,8 +538,6 @@ void tst_QSharedMemory::useTooMuchMemory()
Create one shared memory (government) and see how many other shared memories (wars) we can Create one shared memory (government) and see how many other shared memories (wars) we can
attach before the system runs out of resources. attach before the system runs out of resources.
*/ */
// HPUX doesn't allow for multiple attaches per process.
#if !defined(Q_OS_HPUX)
void tst_QSharedMemory::attachTooMuch() void tst_QSharedMemory::attachTooMuch()
{ {
QSKIP("disabled"); QSKIP("disabled");
@ -575,10 +562,7 @@ void tst_QSharedMemory::attachTooMuch()
} }
} }
} }
#endif
// HPUX doesn't allow for multiple attaches per process.
#ifndef Q_OS_HPUX
void tst_QSharedMemory::simpleProducerConsumer_data() void tst_QSharedMemory::simpleProducerConsumer_data()
{ {
QTest::addColumn<QSharedMemory::AccessMode>("mode"); QTest::addColumn<QSharedMemory::AccessMode>("mode");
@ -616,10 +600,7 @@ void tst_QSharedMemory::simpleProducerConsumer()
} }
QVERIFY(consumer.detach()); QVERIFY(consumer.detach());
} }
#endif
// HPUX doesn't allow for multiple attaches per process.
#ifndef Q_OS_HPUX
void tst_QSharedMemory::simpleDoubleProducerConsumer() void tst_QSharedMemory::simpleDoubleProducerConsumer()
{ {
QNativeIpcKey nativeKey = rememberKey(QLatin1String("market")); QNativeIpcKey nativeKey = rememberKey(QLatin1String("market"));
@ -640,7 +621,6 @@ void tst_QSharedMemory::simpleDoubleProducerConsumer()
QVERIFY(consumer.attach()); QVERIFY(consumer.attach());
} }
} }
#endif
class Consumer : public QThread class Consumer : public QThread
{ {