OSDN Git Service

fix tst_QThread::setStackSize() test case
authorIvailo Monev <xakepa10@laimg.moc>
Mon, 30 Mar 2020 19:34:11 +0000 (19:34 +0000)
committerIvailo Monev <xakepa10@laimg.moc>
Mon, 30 Mar 2020 19:34:11 +0000 (19:34 +0000)
also fixes a regression since 91019ff8de9ba23a45c7920184e473620e5244d0

Signed-off-by: Ivailo Monev <xakepa10@laimg.moc>
src/core/thread/qthread.cpp
tests/auto/qthread/tst_qthread.cpp

index b5fb029..f33e0ce 100644 (file)
@@ -438,7 +438,8 @@ void QThread::setStackSize(uint stackSize)
     static int stack_min = sysconf(_SC_THREAD_STACK_MIN);
     if (stack_min == -1)
         stack_min = PTHREAD_STACK_MIN;
-    if (Q_UNLIKELY(stackSize < stack_min)) {
+    // 0 means default stack size
+    if (Q_UNLIKELY(stackSize != 0 && stackSize < stack_min)) {
         qWarning("QThread::setStackSize: %u is less than the minimum %u", stackSize, stack_min);
         stackSize = stack_min;
     }
index c85e6ac..464f79c 100644 (file)
@@ -407,10 +407,16 @@ void tst_QThread::priority()
 
 void tst_QThread::setStackSize()
 {
+#ifdef PTHREAD_STACK_MIN
+    static const uint stack_size = PTHREAD_STACK_MIN * 2;
+#else
+    static const uint stack_size = 16384; // default on Linux
+#endif
+
     Simple_Thread thread;
     QCOMPARE(thread.stackSize(), 0u);
-    thread.setStackSize(8192u);
-    QCOMPARE(thread.stackSize(), 8192u);
+    thread.setStackSize(stack_size);
+    QCOMPARE(thread.stackSize(), stack_size);
     thread.setStackSize(0u);
     QCOMPARE(thread.stackSize(), 0u);
 }