130 #ifdef Q_OS_UNIX |
132 #ifdef Q_OS_UNIX |
131 QFile::remove("/tmp/qt-0/valuespace_shmlayer"); |
133 QFile::remove("/tmp/qt-0/valuespace_shmlayer"); |
132 #endif |
134 #endif |
133 |
135 |
134 QValueSpace::initValueSpaceServer(); |
136 QValueSpace::initValueSpaceServer(); |
|
137 |
|
138 if (QValueSpace::availableLayers().contains(QVALUESPACE_GCONF_LAYER)) { |
|
139 QCOMPARE(QProcess::execute("gconftool-2 -u /value"), 0); |
|
140 QCOMPARE(QProcess::execute("gconftool-2 -u /testConstructor/value"), 0); |
|
141 QCOMPARE(QProcess::execute("gconftool-2 -u /testConstructor/subpath/value"), 0); |
|
142 } |
|
143 |
135 } |
144 } |
136 |
145 |
137 void tst_QValueSpacePublisher::cleanupTestCase() |
146 void tst_QValueSpacePublisher::cleanupTestCase() |
138 { |
147 { |
139 } |
148 } |
472 QTest::addColumn<unsigned int>("count"); |
481 QTest::addColumn<unsigned int>("count"); |
473 QTest::addColumn<bool>("sequential"); |
482 QTest::addColumn<bool>("sequential"); |
474 |
483 |
475 QList<QAbstractValueSpaceLayer *> layers = QValueSpaceManager::instance()->getLayers(); |
484 QList<QAbstractValueSpaceLayer *> layers = QValueSpaceManager::instance()->getLayers(); |
476 |
485 |
|
486 int foundLayers = 0; |
477 for (int i = 0; i < layers.count(); ++i) { |
487 for (int i = 0; i < layers.count(); ++i) { |
478 QAbstractValueSpaceLayer *layer = layers.at(i); |
488 QAbstractValueSpaceLayer *layer = layers.at(i); |
479 |
489 |
480 if (layer->id() == QVALUESPACE_NONVOLATILEREGISTRY_LAYER) |
490 if (layer->id() == QVALUESPACE_NONVOLATILEREGISTRY_LAYER) |
|
491 continue; |
|
492 |
|
493 //GConfLayer can't provide thread-safety because it eventually depends on |
|
494 //DBus which isn't fully thread-safe |
|
495 if (layer->id() == QVALUESPACE_GCONF_LAYER) |
481 continue; |
496 continue; |
482 |
497 |
483 #ifdef Q_OS_WINCE |
498 #ifdef Q_OS_WINCE |
484 // Limit number of items on Windows CE to prevent out of disk space errors. |
499 // Limit number of items on Windows CE to prevent out of disk space errors. |
485 if (layer->id() == QVALUESPACE_VOLATILEREGISTRY_LAYER) { |
500 if (layer->id() == QVALUESPACE_VOLATILEREGISTRY_LAYER) { |
569 QTest::newRow("2 threads, 5000 items") |
584 QTest::newRow("2 threads, 5000 items") |
570 << layer->id() << uint(2) << uint(5000) << false; |
585 << layer->id() << uint(2) << uint(5000) << false; |
571 QTest::newRow("100 threads, 100 items") |
586 QTest::newRow("100 threads, 100 items") |
572 << layer->id() << uint(100) << uint(100) << false; |
587 << layer->id() << uint(100) << uint(100) << false; |
573 } |
588 } |
574 } |
589 foundLayers++; |
|
590 } |
|
591 |
|
592 if (foundLayers == 0) |
|
593 QSKIP("No layers providing thread-safety found", SkipAll); |
575 } |
594 } |
576 |
595 |
577 void tst_QValueSpacePublisher::threads() |
596 void tst_QValueSpacePublisher::threads() |
578 { |
597 { |
579 QFETCH(QUuid, uuid); |
598 QFETCH(QUuid, uuid); |
580 QFETCH(unsigned int, threads); |
599 QFETCH(unsigned int, threads); |
581 QFETCH(unsigned int, count); |
600 QFETCH(unsigned int, count); |
582 QFETCH(bool, sequential); |
601 QFETCH(bool, sequential); |
583 |
602 |
|
603 if (QValueSpace::availableLayers().contains(QVALUESPACE_GCONF_LAYER)) { |
|
604 QCOMPARE(QProcess::execute("gconftool-2 --recursive-unset /threads"), 0); |
|
605 } |
584 QStringList expectedPaths; |
606 QStringList expectedPaths; |
585 for (unsigned int i = 0; i < threads; ++i) |
607 for (unsigned int i = 0; i < threads; ++i) |
586 expectedPaths.append(QString("thread%1").arg(i)); |
608 expectedPaths.append(QString("thread%1").arg(i)); |
587 |
609 |
588 QHash<QString, QString> expectedValues; |
610 QHash<QString, QString> expectedValues; |