diff options
author | Arvid Ephraim Picciani <arvid.picciani@nokia.com> | 2010-08-17 19:28:45 (GMT) |
---|---|---|
committer | Arvid Ephraim Picciani <arvid.picciani@nokia.com> | 2010-08-27 14:59:16 (GMT) |
commit | 3c2a43f91e0225bde8d6e6d6076dfe2cddbc2f8e (patch) | |
tree | e299b1dbc2820c902eed9632b97e63c62f7308b0 /tests/auto/qpluginloader | |
parent | de4fdc9743b4b4261ecf86b8891441ea293ba489 (diff) | |
download | Qt-3c2a43f91e0225bde8d6e6d6076dfe2cddbc2f8e.zip Qt-3c2a43f91e0225bde8d6e6d6076dfe2cddbc2f8e.tar.gz Qt-3c2a43f91e0225bde8d6e6d6076dfe2cddbc2f8e.tar.bz2 |
Optimize plugin loading on ELF platforms
Diffstat (limited to 'tests/auto/qpluginloader')
-rw-r--r-- | tests/auto/qpluginloader/elftest/.gitattributes | 10 | ||||
-rwxr-xr-x | tests/auto/qpluginloader/elftest/corrupt1.elf64.so | bin | 0 -> 239745 bytes | |||
-rwxr-xr-x | tests/auto/qpluginloader/elftest/corrupt2.elf64.so | bin | 0 -> 240097 bytes | |||
-rwxr-xr-x | tests/auto/qpluginloader/elftest/corrupt3.elf64.so | bin | 0 -> 240097 bytes | |||
-rw-r--r-- | tests/auto/qpluginloader/elftest/debugobj.so | bin | 0 -> 507232 bytes | |||
-rw-r--r-- | tests/auto/qpluginloader/elftest/garbage1.so | 4 | ||||
-rw-r--r-- | tests/auto/qpluginloader/elftest/garbage2.so | 1 | ||||
-rw-r--r-- | tests/auto/qpluginloader/elftest/garbage3.so | 1 | ||||
-rw-r--r-- | tests/auto/qpluginloader/elftest/garbage4.so | 1 | ||||
-rw-r--r-- | tests/auto/qpluginloader/elftest/garbage5.so | 2 | ||||
-rw-r--r-- | tests/auto/qpluginloader/tst/tst.pro | 2 | ||||
-rw-r--r-- | tests/auto/qpluginloader/tst_qpluginloader.cpp | 81 |
12 files changed, 101 insertions, 1 deletions
diff --git a/tests/auto/qpluginloader/elftest/.gitattributes b/tests/auto/qpluginloader/elftest/.gitattributes new file mode 100644 index 0000000..891192c --- /dev/null +++ b/tests/auto/qpluginloader/elftest/.gitattributes @@ -0,0 +1,10 @@ +corrupt1.elf64.so set -crlf -diff +corrupt2.elf64.so set -crlf -diff +corrupt3.elf64.so set -crlf -diff +debugobj.so set -crlf -diff +garbage1.so set -crlf -diff +garbage2.so set -crlf -diff +garbage3.so set -crlf -diff +garbage4.so set -crlf -diff +garbage5.so set -crlf -diff + diff --git a/tests/auto/qpluginloader/elftest/corrupt1.elf64.so b/tests/auto/qpluginloader/elftest/corrupt1.elf64.so Binary files differnew file mode 100755 index 0000000..12ce736 --- /dev/null +++ b/tests/auto/qpluginloader/elftest/corrupt1.elf64.so diff --git a/tests/auto/qpluginloader/elftest/corrupt2.elf64.so b/tests/auto/qpluginloader/elftest/corrupt2.elf64.so Binary files differnew file mode 100755 index 0000000..11fdc2c --- /dev/null +++ b/tests/auto/qpluginloader/elftest/corrupt2.elf64.so diff --git a/tests/auto/qpluginloader/elftest/corrupt3.elf64.so b/tests/auto/qpluginloader/elftest/corrupt3.elf64.so Binary files differnew file mode 100755 index 0000000..94a2bc3 --- /dev/null +++ b/tests/auto/qpluginloader/elftest/corrupt3.elf64.so diff --git a/tests/auto/qpluginloader/elftest/debugobj.so b/tests/auto/qpluginloader/elftest/debugobj.so Binary files differnew file mode 100644 index 0000000..f0ee056 --- /dev/null +++ b/tests/auto/qpluginloader/elftest/debugobj.so diff --git a/tests/auto/qpluginloader/elftest/garbage1.so b/tests/auto/qpluginloader/elftest/garbage1.so new file mode 100644 index 0000000..0c74530 --- /dev/null +++ b/tests/auto/qpluginloader/elftest/garbage1.so @@ -0,0 +1,4 @@ +pcdL+&&e= +oÒʎIٝmg]!Z +L')t +N(eP)Y8G 6-y"Zk4?^n5$Y=#y
\ No newline at end of file diff --git a/tests/auto/qpluginloader/elftest/garbage2.so b/tests/auto/qpluginloader/elftest/garbage2.so new file mode 100644 index 0000000..c06338e --- /dev/null +++ b/tests/auto/qpluginloader/elftest/garbage2.so @@ -0,0 +1 @@ +v.YtKW3
\ No newline at end of file diff --git a/tests/auto/qpluginloader/elftest/garbage3.so b/tests/auto/qpluginloader/elftest/garbage3.so new file mode 100644 index 0000000..a24c523 --- /dev/null +++ b/tests/auto/qpluginloader/elftest/garbage3.so @@ -0,0 +1 @@ +ȂT-ڥ 쾜i8_xIx=4@[BKS$
\ No newline at end of file diff --git a/tests/auto/qpluginloader/elftest/garbage4.so b/tests/auto/qpluginloader/elftest/garbage4.so new file mode 100644 index 0000000..4f45cf5 --- /dev/null +++ b/tests/auto/qpluginloader/elftest/garbage4.so @@ -0,0 +1 @@ +!\~Uu:9T+91QEǚxng5zh^t'mm*ˈdXH;vw+G
9L0!
\ No newline at end of file diff --git a/tests/auto/qpluginloader/elftest/garbage5.so b/tests/auto/qpluginloader/elftest/garbage5.so new file mode 100644 index 0000000..f8c0a1d --- /dev/null +++ b/tests/auto/qpluginloader/elftest/garbage5.so @@ -0,0 +1,2 @@ +Q +-9
\ No newline at end of file diff --git a/tests/auto/qpluginloader/tst/tst.pro b/tests/auto/qpluginloader/tst/tst.pro index 2d757e7..e270120 100644 --- a/tests/auto/qpluginloader/tst/tst.pro +++ b/tests/auto/qpluginloader/tst/tst.pro @@ -27,3 +27,5 @@ symbian: { DEPLOYMENT += libDep pluginDep } + +DEFINES += SRCDIR=\\\"$$PWD/../\\\" diff --git a/tests/auto/qpluginloader/tst_qpluginloader.cpp b/tests/auto/qpluginloader/tst_qpluginloader.cpp index 1e382b8..9374dd0 100644 --- a/tests/auto/qpluginloader/tst_qpluginloader.cpp +++ b/tests/auto/qpluginloader/tst_qpluginloader.cpp @@ -100,6 +100,14 @@ # define PREFIX "lib" #endif +#ifdef QT_NO_DEBUG +# define QLIBRARY_AS_DEBUG false +#else +# define QLIBRARY_AS_DEBUG true +#endif + +// #define SHOW_ERRORS 1 + static QString sys_qualifiedLibraryName(const QString &fileName) { QString currDir = QDir::currentPath(); @@ -119,10 +127,14 @@ public: virtual ~tst_QPluginLoader(); private slots: + void clearPluginCache(); void errorString(); void loadHints(); void deleteinstanceOnUnload(); void checkingStubsFromDifferentDrives(); + void loadDebugObj(); + void loadCorruptElf(); + void loadGarbage(); }; tst_QPluginLoader::tst_QPluginLoader() @@ -134,7 +146,25 @@ tst_QPluginLoader::~tst_QPluginLoader() { } -//#define SHOW_ERRORS 1 +void tst_QPluginLoader::clearPluginCache() +{ + QString regkey = QString::fromLatin1("Qt Plugin Cache %1.%2.%3") + .arg((QT_VERSION & 0xff0000) >> 16) + .arg((QT_VERSION & 0xff00) >> 8) + .arg(QLIBRARY_AS_DEBUG ? QLatin1String("debug") : QLatin1String("false")); +#ifdef Q_WS_MAC +#if defined(__x86_64__) + regkey += QLatin1String("-x86_64"); +#elif defined(__i386__) + regkey += QLatin1String("-i386"); +#elif defined(__ppc64__) + regkey += QLatin1String("-ppc64"); +#elif defined(__ppc__) + regkey += QLatin1String("-ppc"); +#endif +#endif // Q_WS_MAC + QSettings(QSettings::UserScope, QLatin1String("Trolltech")).remove(regkey); +} void tst_QPluginLoader::errorString() { @@ -350,5 +380,54 @@ void tst_QPluginLoader::checkingStubsFromDifferentDrives() #endif//Q_OS_SYMBIAN } +void tst_QPluginLoader::loadDebugObj() +{ +#if defined (__ELF__) + QVERIFY(QFile::exists(SRCDIR "elftest/debugobj.so")); + QPluginLoader lib1(SRCDIR "elftest/debugobj.so"); + QCOMPARE(lib1.load(), false); +#endif +} + +void tst_QPluginLoader::loadCorruptElf() +{ +#if defined (__ELF__) +if (sizeof(void*) == 8) { + QVERIFY(QFile::exists(SRCDIR "elftest/corrupt1.elf64.so")); + + QPluginLoader lib1(SRCDIR "elftest/corrupt1.elf64.so"); + QCOMPARE(lib1.load(), false); + QVERIFY(lib1.errorString().contains("not an ELF object")); + + QPluginLoader lib2(SRCDIR "elftest/corrupt2.elf64.so"); + QCOMPARE(lib2.load(), false); + QVERIFY(lib2.errorString().contains("invalid")); + + QPluginLoader lib3(SRCDIR "elftest/corrupt3.elf64.so"); + QCOMPARE(lib3.load(), false); + QVERIFY(lib3.errorString().contains("invalid")); +} else if (sizeof(void*) == 4) { + QPluginLoader libW(SRCDIR "elftest/corrupt3.elf64.so"); + QCOMPARE(libW.load(), false); + QVERIFY(libW.errorString().contains("architecture")); +} else { + QFAIL("Please port QElfParser to this platform or blacklist this test."); +} +#endif +} + +void tst_QPluginLoader::loadGarbage() +{ +#if defined (Q_OS_UNIX) && !defined(Q_OS_SYMBIAN) + for (int i=0; i<5; i++) { + QPluginLoader lib(QString(SRCDIR "elftest/garbage%1.so").arg(i)); + QCOMPARE(lib.load(), false); +#ifdef SHOW_ERRORS + qDebug() << lib.errorString(); +#endif + } +#endif +} + QTEST_APPLESS_MAIN(tst_QPluginLoader) #include "tst_qpluginloader.moc" |