diff options
author | Rohan McGovern <rohan.mcgovern@nokia.com> | 2011-11-24 10:36:10 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2011-12-01 09:12:52 +0100 |
commit | 3385fb91e1e55e1bfa1f78dfb8ce2e9f3fdaedef (patch) | |
tree | b77bb527bf3a21dc95a317248b2640c73751f629 /tests/auto/corelib/plugin | |
parent | 13eba9ddf47d570fc4562c20fcfbacd1dfa4a61a (diff) |
Fixed installation of corelib tests
In .pro files, removed wince/symbian-specific DEPLOYMENT cases and
replaced them with TESTDATA where appropriate.
In .cpp files, removed SRCDIR and relative paths to testdata and
replaced them with the QFINDTESTDATA macro where appropriate.
Modified test helper apps/libs to install themselves under the test
they relate to.
This change allows corelib tests to be correctly installed, along with
their testdata, via `make install'.
Change-Id: I5e202e2f3b577af7e39072d5c9fe13e0ca125304
Reviewed-by: Jason McDonald <jason.mcdonald@nokia.com>
Diffstat (limited to 'tests/auto/corelib/plugin')
13 files changed, 54 insertions, 82 deletions
diff --git a/tests/auto/corelib/plugin/qlibrary/lib/lib.pro b/tests/auto/corelib/plugin/qlibrary/lib/lib.pro index f95e6338e0..d8551faddc 100644 --- a/tests/auto/corelib/plugin/qlibrary/lib/lib.pro +++ b/tests/auto/corelib/plugin/qlibrary/lib/lib.pro @@ -10,5 +10,6 @@ wince*: DEFINES += WIN32_MSVC win32-msvc: DEFINES += WIN32_MSVC win32-borland: DEFINES += WIN32_BORLAND -#no special install rule for the library used by test -INSTALLS = +# This project is testdata for tst_qlibrary +target.path = $$[QT_INSTALL_TESTS]/tst_qlibrary +INSTALLS += target diff --git a/tests/auto/corelib/plugin/qlibrary/lib2/lib2.pro b/tests/auto/corelib/plugin/qlibrary/lib2/lib2.pro index 835240af22..7d319d644e 100644 --- a/tests/auto/corelib/plugin/qlibrary/lib2/lib2.pro +++ b/tests/auto/corelib/plugin/qlibrary/lib2/lib2.pro @@ -26,13 +26,17 @@ win32 { src = $(DESTDIR)$(TARGET) files = libmylib.so2 system.trolltech.test.mylib.so } + +# This project is testdata for tst_qlibrary +target.path = $$[QT_INSTALL_TESTS]$${QMAKE_DIR_SEP}tst_qlibrary +renamed_target.path = $$target.path + for(file, files) { QMAKE_POST_LINK += $$QMAKE_COPY $$src ..$$QMAKE_DIR_SEP$$file && + renamed_target.extra += $$QMAKE_COPY $$src $(INSTALL_ROOT)$${target.path}$$QMAKE_DIR_SEP$$file && CLEAN_FILES += ../$$file } +renamed_target.extra = $$member(renamed_target.extra, 0, -2) QMAKE_POST_LINK = $$member(QMAKE_POST_LINK, 0, -2) -#no special install rule for the library used by test -INSTALLS = - - +INSTALLS += target renamed_target diff --git a/tests/auto/corelib/plugin/qlibrary/tst/tst.pro b/tests/auto/corelib/plugin/qlibrary/tst/tst.pro index a1854ad419..6e71ec8ff9 100644 --- a/tests/auto/corelib/plugin/qlibrary/tst/tst.pro +++ b/tests/auto/corelib/plugin/qlibrary/tst/tst.pro @@ -11,11 +11,4 @@ win32 { } } -wince* { - addFiles.files = ../*.dll ../*.dl2 ../mylib_noextension - addFiles.path = . - DEPLOYMENT += addFiles - DEFINES += SRCDIR=\\\"\\\" -} else { - DEFINES += SRCDIR=\\\"$$PWD/../\\\" -} +TESTDATA += ../library_path/invalid.so diff --git a/tests/auto/corelib/plugin/qlibrary/tst_qlibrary.cpp b/tests/auto/corelib/plugin/qlibrary/tst_qlibrary.cpp index 97e38ff2ef..c1f090afc5 100644 --- a/tests/auto/corelib/plugin/qlibrary/tst_qlibrary.cpp +++ b/tests/auto/corelib/plugin/qlibrary/tst_qlibrary.cpp @@ -115,10 +115,6 @@ class tst_QLibrary : public QObject { Q_OBJECT -public: - tst_QLibrary(); - virtual ~tst_QLibrary(); - enum QLibraryOperation { Load = 1, Unload = 2, @@ -127,6 +123,8 @@ enum QLibraryOperation { DontSetFileName = 0x100 }; private slots: + void initTestCase(); + void load(); void load_data(); void library_data(); @@ -146,33 +144,17 @@ private slots: void fileName_data(); void fileName(); void multipleInstancesForOneLibrary(); - -#ifdef Q_OS_WINCE -private: - QCoreApplication* app; -#endif }; -tst_QLibrary::tst_QLibrary() - -{ -#ifdef Q_OS_WINCE - char* argv = "app"; - int argc = 1; - app = new QCoreApplication(argc,&argv); -#endif -} +typedef int (*VersionFunction)(void); -tst_QLibrary::~tst_QLibrary() +void tst_QLibrary::initTestCase() { -#ifdef Q_OS_WINCE - app->quit(); -#endif + // chdir to our testdata directory, and use relative paths in some tests. + QString testdatadir = QFileInfo(QFINDTESTDATA("library_path")).absolutePath(); + QVERIFY2(QDir::setCurrent(testdatadir), qPrintable("Could not chdir to " + testdatadir)); } - -typedef int (*VersionFunction)(void); - void tst_QLibrary::version_data() { QTest::addColumn<QString>("lib"); @@ -376,10 +358,6 @@ void tst_QLibrary::errorString_data() QString currDir = QDir::currentPath(); - QString srcDir = SRCDIR; - if (srcDir.isEmpty()) - srcDir = currDir; - QTest::newRow("bad load()") << (int)Load << QString("nosuchlib") << false << QString("Cannot load library nosuchlib: .*"); QTest::newRow("call errorString() on QLibrary with no d-pointer (crashtest)") << (int)(Load | DontSetFileName) << QString() << false << QString("Unknown error"); #ifdef Q_OS_WINCE @@ -394,7 +372,7 @@ void tst_QLibrary::errorString_data() // QTest::newRow("bad unload") << (int)Unload << QString("nosuchlib.dll") << false << QString("QLibrary::unload_sys: Cannot unload nosuchlib.dll (The specified module could not be found.)"); #elif defined Q_OS_MAC #else - QTest::newRow("load invalid file") << (int)Load << srcDir + "/library_path/invalid.so" << false << QString("Cannot load library.*"); + QTest::newRow("load invalid file") << (int)Load << QFINDTESTDATA("library_path/invalid.so") << false << QString("Cannot load library.*"); #endif } @@ -569,5 +547,5 @@ void tst_QLibrary::multipleInstancesForOneLibrary() QCOMPARE(lib2.isLoaded(), true); } -QTEST_APPLESS_MAIN(tst_QLibrary) +QTEST_MAIN(tst_QLibrary) #include "tst_qlibrary.moc" diff --git a/tests/auto/corelib/plugin/qplugin/tst_qplugin.pro b/tests/auto/corelib/plugin/qplugin/tst_qplugin.pro index a569cfffb7..8c6540fe87 100644 --- a/tests/auto/corelib/plugin/qplugin/tst_qplugin.pro +++ b/tests/auto/corelib/plugin/qplugin/tst_qplugin.pro @@ -3,8 +3,4 @@ TARGET = tst_qplugin QT = core testlib SOURCES = tst_qplugin.cpp -wince* { - plugins.files = plugins/* - plugins.path = plugins - DEPLOYMENT += plugins -} +TESTDATA += plugins/* diff --git a/tests/auto/corelib/plugin/qpluginloader/almostplugin/almostplugin.pro b/tests/auto/corelib/plugin/qpluginloader/almostplugin/almostplugin.pro index b45509ef01..333b19dad3 100644 --- a/tests/auto/corelib/plugin/qpluginloader/almostplugin/almostplugin.pro +++ b/tests/auto/corelib/plugin/qpluginloader/almostplugin/almostplugin.pro @@ -5,3 +5,7 @@ SOURCES = almostplugin.cpp TARGET = almostplugin DESTDIR = ../bin *-g++*:QMAKE_LFLAGS -= -Wl,--no-undefined + +# This is testdata for the tst_qpluginloader test. +target.path = $$[QT_INSTALL_TESTS]/tst_qpluginloader/bin +INSTALLS += target diff --git a/tests/auto/corelib/plugin/qpluginloader/lib/lib.pro b/tests/auto/corelib/plugin/qpluginloader/lib/lib.pro index 1a784924b4..a45df7134a 100644 --- a/tests/auto/corelib/plugin/qpluginloader/lib/lib.pro +++ b/tests/auto/corelib/plugin/qpluginloader/lib/lib.pro @@ -9,5 +9,6 @@ QT = core win32-msvc: DEFINES += WIN32_MSVC win32-borland: DEFINES += WIN32_BORLAND -#no special install rule for the library used by test -INSTALLS = +# This is testdata for the tst_qpluginloader test. +target.path = $$[QT_INSTALL_TESTS]/tst_qpluginloader/bin +INSTALLS += target diff --git a/tests/auto/corelib/plugin/qpluginloader/theplugin/theplugin.pro b/tests/auto/corelib/plugin/qpluginloader/theplugin/theplugin.pro index bd318a3c6f..382250ac98 100644 --- a/tests/auto/corelib/plugin/qpluginloader/theplugin/theplugin.pro +++ b/tests/auto/corelib/plugin/qpluginloader/theplugin/theplugin.pro @@ -4,3 +4,7 @@ HEADERS = theplugin.h SOURCES = theplugin.cpp TARGET = $$qtLibraryTarget(theplugin) DESTDIR = ../bin + +# This is testdata for the tst_qpluginloader test. +target.path = $$[QT_INSTALL_TESTS]/tst_qpluginloader/bin +INSTALLS += target diff --git a/tests/auto/corelib/plugin/qpluginloader/tst/tst.pro b/tests/auto/corelib/plugin/qpluginloader/tst/tst.pro index 0de46be2c9..810efe856c 100644 --- a/tests/auto/corelib/plugin/qpluginloader/tst/tst.pro +++ b/tests/auto/corelib/plugin/qpluginloader/tst/tst.pro @@ -3,7 +3,6 @@ TARGET = ../tst_qpluginloader QT = core testlib SOURCES = ../tst_qpluginloader.cpp HEADERS = ../theplugin/plugininterface.h -DEFINES += SRCDIR=\\\"$$PWD/../\\\" win32 { CONFIG(debug, debug|release) { @@ -13,10 +12,6 @@ win32 { } } -wince* { - addFiles.files = $$OUT_PWD/../bin/*.dll - addFiles.path = bin - DEPLOYMENT += addFiles -} +TESTDATA += ../elftest mac: CONFIG += insignificant_test # QTBUG-22765 diff --git a/tests/auto/corelib/plugin/qpluginloader/tst_qpluginloader.cpp b/tests/auto/corelib/plugin/qpluginloader/tst_qpluginloader.cpp index a874324c60..4b1ed7199d 100644 --- a/tests/auto/corelib/plugin/qpluginloader/tst_qpluginloader.cpp +++ b/tests/auto/corelib/plugin/qpluginloader/tst_qpluginloader.cpp @@ -95,8 +95,7 @@ static QString sys_qualifiedLibraryName(const QString &fileName) { - QString currDir = QDir::currentPath(); - return currDir + "/bin/" + PREFIX + fileName + SUFFIX; + return QFINDTESTDATA(QString("bin/%1%2%3").arg(PREFIX).arg(fileName).arg(SUFFIX)); } //TESTED_CLASS= @@ -249,8 +248,8 @@ void tst_QPluginLoader::deleteinstanceOnUnload() void tst_QPluginLoader::loadDebugObj() { #if defined (__ELF__) - QVERIFY(QFile::exists(SRCDIR "elftest/debugobj.so")); - QPluginLoader lib1(SRCDIR "elftest/debugobj.so"); + QVERIFY(QFile::exists(QFINDTESTDATA("elftest/debugobj.so"))); + QPluginLoader lib1(QFINDTESTDATA("elftest/debugobj.so")); QCOMPARE(lib1.load(), false); #endif } @@ -259,21 +258,21 @@ void tst_QPluginLoader::loadCorruptElf() { #if defined (__ELF__) if (sizeof(void*) == 8) { - QVERIFY(QFile::exists(SRCDIR "elftest/corrupt1.elf64.so")); + QVERIFY(QFile::exists(QFINDTESTDATA("elftest/corrupt1.elf64.so"))); - QPluginLoader lib1(SRCDIR "elftest/corrupt1.elf64.so"); + QPluginLoader lib1(QFINDTESTDATA("elftest/corrupt1.elf64.so")); QCOMPARE(lib1.load(), false); QVERIFY2(lib1.errorString().contains("not an ELF object"), qPrintable(lib1.errorString())); - QPluginLoader lib2(SRCDIR "elftest/corrupt2.elf64.so"); + QPluginLoader lib2(QFINDTESTDATA("elftest/corrupt2.elf64.so")); QCOMPARE(lib2.load(), false); QVERIFY2(lib2.errorString().contains("invalid"), qPrintable(lib2.errorString())); - QPluginLoader lib3(SRCDIR "elftest/corrupt3.elf64.so"); + QPluginLoader lib3(QFINDTESTDATA("elftest/corrupt3.elf64.so")); QCOMPARE(lib3.load(), false); QVERIFY2(lib3.errorString().contains("invalid"), qPrintable(lib3.errorString())); } else if (sizeof(void*) == 4) { - QPluginLoader libW(SRCDIR "elftest/corrupt3.elf64.so"); + QPluginLoader libW(QFINDTESTDATA("elftest/corrupt3.elf64.so")); QCOMPARE(libW.load(), false); QVERIFY2(libW.errorString().contains("architecture"), qPrintable(libW.errorString())); } else { @@ -286,12 +285,12 @@ void tst_QPluginLoader::loadGarbage() { #if defined (Q_OS_UNIX) for (int i=0; i<5; i++) { - QPluginLoader lib(QString(SRCDIR "elftest/garbage%1.so").arg(i)); + QPluginLoader lib(QFINDTESTDATA(QString("elftest/garbage%1.so").arg(i))); QCOMPARE(lib.load(), false); QVERIFY(lib.errorString() != QString("Unknown error")); } #endif } -QTEST_APPLESS_MAIN(tst_QPluginLoader) +QTEST_MAIN(tst_QPluginLoader) #include "tst_qpluginloader.moc" diff --git a/tests/auto/corelib/plugin/quuid/test/test.pro b/tests/auto/corelib/plugin/quuid/test/test.pro index 4999177a48..0f6f915814 100644 --- a/tests/auto/corelib/plugin/quuid/test/test.pro +++ b/tests/auto/corelib/plugin/quuid/test/test.pro @@ -12,9 +12,3 @@ CONFIG(debug_and_release_target) { } else { DESTDIR = .. } - -wince* { - addFile_processUniqueness.files = $$OUT_PWD/../testProcessUniqueness/testProcessUniqueness.exe - addFile_processUniqueness.path = testProcessUniqueness - DEPLOYMENT += addFile_processUniqueness -} diff --git a/tests/auto/corelib/plugin/quuid/testProcessUniqueness/testProcessUniqueness.pro b/tests/auto/corelib/plugin/quuid/testProcessUniqueness/testProcessUniqueness.pro index 88df1a25d7..958127e77e 100644 --- a/tests/auto/corelib/plugin/quuid/testProcessUniqueness/testProcessUniqueness.pro +++ b/tests/auto/corelib/plugin/quuid/testProcessUniqueness/testProcessUniqueness.pro @@ -3,6 +3,6 @@ CONFIG += console DESTDIR = ./ -# no install rule for application used by test -INSTALLS = - +# This app is testdata for tst_quuid +target.path = $$[QT_INSTALL_TESTS]/tst_quuid/$$TARGET +INSTALLS += target diff --git a/tests/auto/corelib/plugin/quuid/tst_quuid.cpp b/tests/auto/corelib/plugin/quuid/tst_quuid.cpp index 5761ea1a8c..fc0f923427 100644 --- a/tests/auto/corelib/plugin/quuid/tst_quuid.cpp +++ b/tests/auto/corelib/plugin/quuid/tst_quuid.cpp @@ -56,10 +56,9 @@ class tst_QUuid : public QObject { Q_OBJECT -public: - tst_QUuid(); - private slots: + void initTestCase(); + void fromChar(); void toString(); void fromString(); @@ -90,13 +89,17 @@ public: QUuid uuidB; }; -tst_QUuid::tst_QUuid() +void tst_QUuid::initTestCase() { //"{fc69b59e-cc34-4436-a43c-ee95d128b8c5}"; uuidA = QUuid(0xfc69b59e, 0xcc34 ,0x4436 ,0xa4 ,0x3c ,0xee ,0x95 ,0xd1 ,0x28 ,0xb8 ,0xc5); //"{1ab6e93a-b1cb-4a87-ba47-ec7e99039a7b}"; uuidB = QUuid(0x1ab6e93a ,0xb1cb ,0x4a87 ,0xba ,0x47 ,0xec ,0x7e ,0x99 ,0x03 ,0x9a ,0x7b); + + // chdir to the directory containing our testdata, then refer to it with relative paths + QString testdata_dir = QFileInfo(QFINDTESTDATA("testProcessUniqueness")).absolutePath(); + QVERIFY2(QDir::setCurrent(testdata_dir), qPrintable("Could not chdir to " + testdata_dir)); } void tst_QUuid::fromChar() |