summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/plugin
diff options
context:
space:
mode:
authorHolger Ihrig <holger.ihrig@nokia.com>2011-08-25 15:53:06 +0200
committerHolger Ihrig <holger.ihrig@nokia.com>2011-09-01 12:42:51 +0200
commit2efc6f787c488cc2338fe9eef75dd83cdb43f31a (patch)
tree34afb97723e6f85383891ad85379c8ec199e74ed /tests/auto/corelib/plugin
parent3a7e6157d1a9865a31a5641605bbe9b0fc25e1d4 (diff)
Moving relevant tests to corelib/plugin
Task-number: QTBUG-21066 Change-Id: I918f6ef6fb825d7cf94d6b42322b2c2eb5c52aaa Reviewed-on: http://codereview.qt.nokia.com/3604 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com> Reviewed-by: Jason McDonald <jason.mcdonald@nokia.com>
Diffstat (limited to 'tests/auto/corelib/plugin')
-rw-r--r--tests/auto/corelib/plugin/plugin.pro6
-rw-r--r--tests/auto/corelib/plugin/qlibrary/.gitignore10
-rw-r--r--tests/auto/corelib/plugin/qlibrary/lib/lib.pro17
-rw-r--r--tests/auto/corelib/plugin/qlibrary/lib/mylib.c60
-rw-r--r--tests/auto/corelib/plugin/qlibrary/lib2/lib2.pro57
-rw-r--r--tests/auto/corelib/plugin/qlibrary/lib2/mylib.c60
-rw-r--r--tests/auto/corelib/plugin/qlibrary/library_path/invalid.so1
-rw-r--r--tests/auto/corelib/plugin/qlibrary/qlibrary.pro18
-rw-r--r--tests/auto/corelib/plugin/qlibrary/tst/tst.pro33
-rw-r--r--tests/auto/corelib/plugin/qlibrary/tst_qlibrary.cpp630
-rw-r--r--tests/auto/corelib/plugin/qplugin/.gitignore2
-rw-r--r--tests/auto/corelib/plugin/qplugin/debugplugin/debugplugin.pro11
-rw-r--r--tests/auto/corelib/plugin/qplugin/debugplugin/main.cpp43
-rw-r--r--tests/auto/corelib/plugin/qplugin/qplugin.pro28
-rw-r--r--tests/auto/corelib/plugin/qplugin/releaseplugin/main.cpp43
-rw-r--r--tests/auto/corelib/plugin/qplugin/releaseplugin/releaseplugin.pro11
-rw-r--r--tests/auto/corelib/plugin/qplugin/tst_qplugin.cpp120
-rw-r--r--tests/auto/corelib/plugin/qplugin/tst_qplugin.pro16
-rw-r--r--tests/auto/corelib/plugin/qpluginloader/.gitignore2
-rw-r--r--tests/auto/corelib/plugin/qpluginloader/almostplugin/almostplugin.cpp51
-rw-r--r--tests/auto/corelib/plugin/qpluginloader/almostplugin/almostplugin.h57
-rw-r--r--tests/auto/corelib/plugin/qpluginloader/almostplugin/almostplugin.pro7
-rw-r--r--tests/auto/corelib/plugin/qpluginloader/elftest/.gitattributes10
-rwxr-xr-xtests/auto/corelib/plugin/qpluginloader/elftest/corrupt1.elf64.sobin0 -> 239745 bytes
-rwxr-xr-xtests/auto/corelib/plugin/qpluginloader/elftest/corrupt2.elf64.sobin0 -> 240097 bytes
-rwxr-xr-xtests/auto/corelib/plugin/qpluginloader/elftest/corrupt3.elf64.sobin0 -> 240097 bytes
-rw-r--r--tests/auto/corelib/plugin/qpluginloader/elftest/debugobj.sobin0 -> 507232 bytes
-rw-r--r--tests/auto/corelib/plugin/qpluginloader/elftest/garbage1.so4
-rw-r--r--tests/auto/corelib/plugin/qpluginloader/elftest/garbage2.so1
-rw-r--r--tests/auto/corelib/plugin/qpluginloader/elftest/garbage3.so1
-rw-r--r--tests/auto/corelib/plugin/qpluginloader/elftest/garbage4.so1
-rw-r--r--tests/auto/corelib/plugin/qpluginloader/elftest/garbage5.so2
-rw-r--r--tests/auto/corelib/plugin/qpluginloader/lib/lib.pro18
-rw-r--r--tests/auto/corelib/plugin/qpluginloader/lib/mylib.c60
-rw-r--r--tests/auto/corelib/plugin/qpluginloader/qpluginloader.pro14
-rw-r--r--tests/auto/corelib/plugin/qpluginloader/theplugin/plugininterface.h54
-rw-r--r--tests/auto/corelib/plugin/qpluginloader/theplugin/theplugin.cpp51
-rw-r--r--tests/auto/corelib/plugin/qpluginloader/theplugin/theplugin.h57
-rw-r--r--tests/auto/corelib/plugin/qpluginloader/theplugin/theplugin.pro11
-rw-r--r--tests/auto/corelib/plugin/qpluginloader/tst/tst.pro32
-rw-r--r--tests/auto/corelib/plugin/qpluginloader/tst_qpluginloader.cpp406
-rw-r--r--tests/auto/corelib/plugin/quuid/.gitignore1
-rw-r--r--tests/auto/corelib/plugin/quuid/quuid.pro7
-rw-r--r--tests/auto/corelib/plugin/quuid/test/test.pro29
-rw-r--r--tests/auto/corelib/plugin/quuid/testProcessUniqueness/main.cpp62
-rw-r--r--tests/auto/corelib/plugin/quuid/testProcessUniqueness/testProcessUniqueness.pro8
-rw-r--r--tests/auto/corelib/plugin/quuid/tst_quuid.cpp337
47 files changed, 2449 insertions, 0 deletions
diff --git a/tests/auto/corelib/plugin/plugin.pro b/tests/auto/corelib/plugin/plugin.pro
new file mode 100644
index 0000000000..24de36e4ec
--- /dev/null
+++ b/tests/auto/corelib/plugin/plugin.pro
@@ -0,0 +1,6 @@
+TEMPLATE=subdirs
+SUBDIRS=\
+ qlibrary \
+ qplugin \
+ qpluginloader \
+ quuid
diff --git a/tests/auto/corelib/plugin/qlibrary/.gitignore b/tests/auto/corelib/plugin/qlibrary/.gitignore
new file mode 100644
index 0000000000..38963f2235
--- /dev/null
+++ b/tests/auto/corelib/plugin/qlibrary/.gitignore
@@ -0,0 +1,10 @@
+tst_qlibrary
+mylib.dl2
+mylib.dll
+mylib.exp
+mylib.lib
+mylib2.dll
+mylib2.exp
+mylib2.lib
+mylib_noextension
+system.trolltech.test.mylib.dll
diff --git a/tests/auto/corelib/plugin/qlibrary/lib/lib.pro b/tests/auto/corelib/plugin/qlibrary/lib/lib.pro
new file mode 100644
index 0000000000..6d80881cd2
--- /dev/null
+++ b/tests/auto/corelib/plugin/qlibrary/lib/lib.pro
@@ -0,0 +1,17 @@
+TEMPLATE = lib
+CONFIG += dll
+CONFIG -= staticlib
+SOURCES = mylib.c
+TARGET = mylib
+DESTDIR = ../
+QT = core
+
+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 =
+
+symbian: TARGET.CAPABILITY=ALL -TCB
+
diff --git a/tests/auto/corelib/plugin/qlibrary/lib/mylib.c b/tests/auto/corelib/plugin/qlibrary/lib/mylib.c
new file mode 100644
index 0000000000..f1a2b7a002
--- /dev/null
+++ b/tests/auto/corelib/plugin/qlibrary/lib/mylib.c
@@ -0,0 +1,60 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <qglobal.h>
+
+#if defined(Q_CC_MSVC) || defined(Q_CC_MSVC_NET) || defined(Q_CC_BOR) || defined(Q_OS_SYMBIAN)
+#define LIB_EXPORT __declspec(dllexport)
+#else
+#define LIB_EXPORT
+#endif
+
+#if defined(Q_CC_BOR)
+# define BORLAND_STDCALL __stdcall
+#else
+# define BORLAND_STDCALL
+#endif
+
+LIB_EXPORT int BORLAND_STDCALL mylibversion()
+{
+ return 1;
+}
+
diff --git a/tests/auto/corelib/plugin/qlibrary/lib2/lib2.pro b/tests/auto/corelib/plugin/qlibrary/lib2/lib2.pro
new file mode 100644
index 0000000000..b441569e5a
--- /dev/null
+++ b/tests/auto/corelib/plugin/qlibrary/lib2/lib2.pro
@@ -0,0 +1,57 @@
+TEMPLATE = lib
+CONFIG += dll
+CONFIG -= staticlib
+SOURCES = mylib.c
+TARGET = mylib
+DESTDIR = ../
+VERSION = 2
+QT = core
+
+wince*: DEFINES += WIN32_MSVC
+win32-msvc: DEFINES += WIN32_MSVC
+win32-borland: DEFINES += WIN32_BORLAND
+
+# Force a copy of the library to have an extension that is non-standard.
+# We want to test if we can load a shared library with *any* filename...
+
+!symbian {
+ win32 {
+ # vcproj and Makefile generators refer to target differently
+ contains(TEMPLATE,vc.*) {
+ src = $(TargetPath)
+ } else {
+ src = $(DESTDIR_TARGET)
+ }
+ files = mylib.dl2 system.trolltech.test.mylib.dll
+ } else {
+ src = $(DESTDIR)$(TARGET)
+ files = libmylib.so2 system.trolltech.test.mylib.so
+ }
+ for(file, files) {
+ QMAKE_POST_LINK += $$QMAKE_COPY $$src ..$$QMAKE_DIR_SEP$$file &&
+ CLEAN_FILES += ../$$file
+ }
+ QMAKE_POST_LINK = $$member(QMAKE_POST_LINK, 0, -2)
+}
+
+symbian-abld: {
+ TARGET.CAPABILITY=ALL -TCB
+ FIXEDROOT = $$replace(EPOCROOT,/,\\)
+ QMAKE_POST_LINK = \
+ copy /Y $${FIXEDROOT}epoc32\\release\\$(PLATFORM)\\$(CFG)\\mylib.dll $${FIXEDROOT}epoc32\\release\\$(PLATFORM)\\$(CFG)\\mylib.dl2 && \
+ copy /Y $${FIXEDROOT}epoc32\\release\\$(PLATFORM)\\$(CFG)\\mylib.dll $${FIXEDROOT}epoc32\\release\\$(PLATFORM)\\$(CFG)\\system.trolltech.test.mylib.dll && \
+ IF NOT "$(PLATFORM)==WINSCW" copy /Y $${FIXEDROOT}epoc32\\release\\$(PLATFORM)\\$(CFG)\\mylib.dll ..\\tst\\mylib.dl2
+}
+
+symbian-sbsv2: {
+ TARGET.CAPABILITY=ALL -TCB
+ QMAKE_POST_LINK = \
+ $(GNUCP) $(EPOCROOT)epoc32/release/$(PLATFORM_PATH)/$(CFG_PATH)/mylib.dll $(EPOCROOT)epoc32/release/$(PLATFORM_PATH)/$(CFG_PATH)/mylib.dl2 && \
+ $(GNUCP) $(EPOCROOT)epoc32/release/$(PLATFORM_PATH)/$(CFG_PATH)/mylib.dll $(EPOCROOT)epoc32/release/$(PLATFORM_PATH)/$(CFG_PATH)/system.trolltech.test.mylib.dll && \
+ if test $(PLATFORM) != WINSCW;then $(GNUCP) $(EPOCROOT)epoc32/release/$(PLATFORM_PATH)/$(CFG_PATH)/mylib.dll $${PWD}/../tst/mylib.dl2; fi
+}
+
+#no special install rule for the library used by test
+INSTALLS =
+
+
diff --git a/tests/auto/corelib/plugin/qlibrary/lib2/mylib.c b/tests/auto/corelib/plugin/qlibrary/lib2/mylib.c
new file mode 100644
index 0000000000..f824a3a82d
--- /dev/null
+++ b/tests/auto/corelib/plugin/qlibrary/lib2/mylib.c
@@ -0,0 +1,60 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <qglobal.h>
+
+#if defined(Q_CC_MSVC) || defined(Q_CC_MSVC_NET) || defined(Q_CC_BOR)|| defined(Q_OS_SYMBIAN)
+#define LIB_EXPORT __declspec(dllexport)
+#else
+#define LIB_EXPORT
+#endif
+
+#if defined(Q_CC_BOR)
+# define BORLAND_STDCALL __stdcall
+#else
+# define BORLAND_STDCALL
+#endif
+
+LIB_EXPORT int BORLAND_STDCALL mylibversion()
+{
+ return 2;
+}
+
diff --git a/tests/auto/corelib/plugin/qlibrary/library_path/invalid.so b/tests/auto/corelib/plugin/qlibrary/library_path/invalid.so
new file mode 100644
index 0000000000..4f8a56fe95
--- /dev/null
+++ b/tests/auto/corelib/plugin/qlibrary/library_path/invalid.so
@@ -0,0 +1 @@
+This should be an invalid shared object file.
diff --git a/tests/auto/corelib/plugin/qlibrary/qlibrary.pro b/tests/auto/corelib/plugin/qlibrary/qlibrary.pro
new file mode 100644
index 0000000000..5dc129fbf9
--- /dev/null
+++ b/tests/auto/corelib/plugin/qlibrary/qlibrary.pro
@@ -0,0 +1,18 @@
+QT -= gui
+TEMPLATE = subdirs
+CONFIG += ordered
+
+symbian: {
+# Can't build two versions of lib with same name in symbian, so just build one
+SUBDIRS = lib2 \
+ tst
+} else {
+SUBDIRS = lib \
+ lib2 \
+ tst
+}
+TARGET = tst_qlibrary
+
+# no special install rule for subdir
+INSTALLS =
+CONFIG += parallel_test
diff --git a/tests/auto/corelib/plugin/qlibrary/tst/tst.pro b/tests/auto/corelib/plugin/qlibrary/tst/tst.pro
new file mode 100644
index 0000000000..28c40b0b42
--- /dev/null
+++ b/tests/auto/corelib/plugin/qlibrary/tst/tst.pro
@@ -0,0 +1,33 @@
+load(qttest_p4)
+SOURCES += ../tst_qlibrary.cpp
+TARGET = ../tst_qlibrary
+QT = core
+
+win32 {
+ CONFIG(debug, debug|release) {
+ TARGET = ../../debug/tst_qlibrary
+} else {
+ TARGET = ../../release/tst_qlibrary
+ }
+}
+
+wince*: {
+ addFiles.files = ../*.dll ../*.dl2 ../mylib_noextension
+ addFiles.path = .
+ DEPLOYMENT += addFiles
+ DEFINES += SRCDIR=\\\"\\\"
+}else:symbian {
+ binDep.files = \
+ mylib.dll \
+ system.trolltech.test.mylib.dll
+ binDep.path = /sys/bin
+#mylib.dl2 nonstandard binary deployment will cause warning in emulator,
+#but it can be safely ignored.
+ custBinDep.files = mylib.dl2
+ custBinDep.path = /sys/bin
+
+ DEPLOYMENT += binDep custBinDep
+} else {
+ DEFINES += SRCDIR=\\\"$$PWD/../\\\"
+}
+
diff --git a/tests/auto/corelib/plugin/qlibrary/tst_qlibrary.cpp b/tests/auto/corelib/plugin/qlibrary/tst_qlibrary.cpp
new file mode 100644
index 0000000000..675d0e6ab6
--- /dev/null
+++ b/tests/auto/corelib/plugin/qlibrary/tst_qlibrary.cpp
@@ -0,0 +1,630 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#include <QtTest/QtTest>
+#include <qdir.h>
+#include <qlibrary.h>
+#include <QtCore/QRegExp>
+
+
+// Helper macros to let us know if some suffixes and prefixes are valid
+#define bundle_VALID false
+#define dylib_VALID false
+#define sl_VALID false
+#define a_VALID false
+#define so_VALID false
+#define dll_VALID false
+#define DLL_VALID false
+
+#if defined(Q_OS_DARWIN)
+# undef bundle_VALID
+# undef dylib_VALID
+# undef so_VALID
+# define bundle_VALID true
+# define dylib_VALID true
+# define so_VALID true
+# define SUFFIX ".dylib"
+# define PREFIX "lib"
+
+#elif defined(Q_OS_HPUX)
+# undef sl_VALID
+# define sl_VALID true
+# ifndef __ia64
+# define SUFFIX ".sl"
+# define PREFIX "lib"
+# else
+# undef so_VALID
+# define so_VALID true
+# define SUFFIX ".so"
+# define PREFIX "lib"
+# endif
+
+#elif defined(Q_OS_AIX)
+# undef a_VALID
+# undef so_VALID
+# define a_VALID true
+# define so_VALID true
+# define SUFFIX ".a"
+# define PREFIX "lib"
+
+#elif defined(Q_OS_WIN) || defined(Q_OS_SYMBIAN)
+# undef dll_VALID
+# define dll_VALID true
+# undef DLL_VALID
+# define DLL_VALID true
+# define SUFFIX ".dll"
+# define PREFIX ""
+
+#else // all other Unix
+# undef so_VALID
+# define so_VALID true
+# define SUFFIX ".so"
+# define PREFIX "lib"
+#endif
+
+static QString sys_qualifiedLibraryName(const QString &fileName)
+{
+#if defined(Q_OS_SYMBIAN)
+ return PREFIX + fileName + SUFFIX;
+#else
+ QString currDir = QDir::currentPath();
+ return currDir + "/" + PREFIX + fileName + SUFFIX;
+#endif
+}
+
+//TESTED_CLASS=
+//TESTED_FILES=
+
+QT_FORWARD_DECLARE_CLASS(QLibrary)
+class tst_QLibrary : public QObject
+{
+ Q_OBJECT
+
+public:
+ tst_QLibrary();
+ virtual ~tst_QLibrary();
+
+enum QLibraryOperation {
+ Load = 1,
+ Unload = 2,
+ Resolve = 3,
+ OperationMask = 7,
+ DontSetFileName = 0x100
+};
+private slots:
+ void load();
+ void load_data();
+ void library_data();
+ void resolve_data();
+ void resolve();
+ void unload_data();
+ void unload();
+ void unload_after_implicit_load();
+ void isLibrary_data();
+ void isLibrary();
+ void version_data();
+ void version();
+ void errorString_data();
+ void errorString();
+ void loadHints();
+ void loadHints_data();
+ 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
+}
+
+tst_QLibrary::~tst_QLibrary()
+{
+#ifdef Q_OS_WINCE
+ app->quit();
+#endif
+}
+
+
+typedef int (*VersionFunction)(void);
+
+void tst_QLibrary::version_data()
+{
+ QTest::addColumn<QString>("lib");
+ QTest::addColumn<int>("loadversion");
+ QTest::addColumn<int>("resultversion");
+
+ QTest::newRow( "ok00, version 1" ) << "mylib" << 1 << 1;
+ QTest::newRow( "ok00, version 2" ) << "mylib" << 2 << 2;
+ QTest::newRow( "ok00, default to last version" ) << "mylib" << -1 << 2;
+}
+
+void tst_QLibrary::version()
+{
+ QFETCH( QString, lib );
+ QFETCH( int, loadversion );
+ QFETCH( int, resultversion );
+
+#if !defined(Q_OS_AIX) && !defined(Q_OS_WIN) && !defined(Q_OS_SYMBIAN)
+ QString currDir = QDir::currentPath();
+ QLibrary library( currDir + QLatin1Char('/') + lib, loadversion );
+ bool ok = library.load();
+ QVERIFY(ok);
+
+ VersionFunction fnVersion = (VersionFunction)library.resolve("mylibversion");
+ QVERIFY(fnVersion);
+ QCOMPARE(fnVersion(), resultversion);
+ QVERIFY(library.unload());
+#else
+ Q_UNUSED(lib);
+ Q_UNUSED(loadversion);
+ Q_UNUSED(resultversion);
+#endif
+
+}
+
+void tst_QLibrary::load_data()
+{
+ QTest::addColumn<QString>("lib");
+ QTest::addColumn<bool>("result");
+
+#if defined(Q_OS_SYMBIAN)
+ QString currDir;
+#else
+ QString currDir = QDir::currentPath();
+#endif
+ QTest::newRow( "ok00" ) << currDir + "/mylib" << true;
+ QTest::newRow( "notexist" ) << currDir + "/nolib" << false;
+ QTest::newRow( "badlibrary" ) << currDir + "/qlibrary.pro" << false;
+
+#ifdef Q_OS_MAC
+ QTest::newRow("ok (libmylib ver. 1)") << currDir + "/libmylib" <<true;
+#endif
+
+# if defined(Q_OS_WIN32) || defined(Q_OS_WINCE) || defined(Q_OS_SYMBIAN)
+ QTest::newRow( "ok01 (with suffix)" ) << currDir + "/mylib.dll" << true;
+ QTest::newRow( "ok02 (with non-standard suffix)" ) << currDir + "/mylib.dl2" << true;
+ QTest::newRow( "ok03 (with many dots)" ) << currDir + "/system.trolltech.test.mylib.dll" << true;
+# elif defined Q_OS_UNIX
+ QTest::newRow( "ok01 (with suffix)" ) << currDir + "/libmylib" SUFFIX << true;
+ QTest::newRow( "ok02 (with non-standard suffix)" ) << currDir + "/libmylib.so2" << true;
+ QTest::newRow( "ok03 (with many dots)" ) << currDir + "/system.trolltech.test.mylib.so" << true;
+# endif // Q_OS_UNIX
+}
+
+void tst_QLibrary::load()
+{
+ QFETCH( QString, lib );
+ QFETCH( bool, result );
+
+ QLibrary library( lib );
+ bool ok = library.load();
+ if ( result ) {
+ QVERIFY( ok );
+ QVERIFY(library.unload());
+ } else {
+ QVERIFY( !ok );
+ }
+}
+
+void tst_QLibrary::unload_data()
+{
+ QTest::addColumn<QString>("lib");
+ QTest::addColumn<bool>("result");
+
+#if defined(Q_OS_SYMBIAN)
+ QString currDir;
+#else
+ QString currDir = QDir::currentPath();
+#endif
+
+ QTest::newRow( "mylib" ) << currDir + "/mylib" << true;
+#ifdef Q_WS_MAC
+ if (QSysInfo::MacintoshVersion <= QSysInfo::MV_10_3)
+ QEXPECT_FAIL("mylib", "dlcompat cannot unload libraries", Continue);
+#endif
+ QTest::newRow( "ok01" ) << currDir + "/nolib" << false;
+}
+
+void tst_QLibrary::unload()
+{
+ QFETCH( QString, lib );
+ QFETCH( bool, result );
+
+ QLibrary library( lib );
+ library.load();
+ bool ok = library.unload();
+ if ( result ) {
+ QVERIFY( ok );
+ } else {
+ QVERIFY( !ok );
+ }
+}
+
+void tst_QLibrary::unload_after_implicit_load()
+{
+#if defined(Q_OS_SYMBIAN)
+ QSKIP("SYMBIAN does not support symbols on non-STDDLL libraries.", SkipAll);
+#endif
+
+ QLibrary library( "./mylib" );
+ QFunctionPointer p = library.resolve("mylibversion");
+ QVERIFY(p); // Check if it was loaded
+ QVERIFY(library.isLoaded());
+ QVERIFY(library.unload());
+ QCOMPARE(library.isLoaded(), false);
+
+}
+
+void tst_QLibrary::resolve_data()
+{
+ QTest::addColumn<QString>("lib");
+ QTest::addColumn<QString>("symbol");
+ QTest::addColumn<bool>("goodPointer");
+
+#if defined(Q_OS_SYMBIAN)
+ QString currDir;
+#else
+ QString currDir = QDir::currentPath();
+#endif
+
+ QTest::newRow( "ok00" ) << currDir + "/mylib" << QString("mylibversion") << true;
+ QTest::newRow( "bad00" ) << currDir + "/mylib" << QString("nosym") << false;
+ QTest::newRow( "bad01" ) << currDir + "/nolib" << QString("nosym") << false;
+}
+
+void tst_QLibrary::resolve()
+{
+#if defined(Q_OS_SYMBIAN)
+ QSKIP("SYMBIAN does not support symbols on non-STDDLL libraries.", SkipAll);
+#endif
+
+ typedef int (*testFunc)();
+ QFETCH( QString, lib );
+ QFETCH( QString, symbol );
+ QFETCH( bool, goodPointer );
+
+ QLibrary library( lib );
+ testFunc func = (testFunc) library.resolve( symbol.toLatin1() );
+ if ( goodPointer ) {
+ QVERIFY( func != 0 );
+ } else {
+ QVERIFY( func == 0 );
+ }
+ library.unload();
+}
+
+void tst_QLibrary::library_data()
+{
+ QTest::addColumn<QString>("lib");
+}
+
+void tst_QLibrary::isLibrary_data()
+{
+ QTest::addColumn<QString>("filename");
+ QTest::addColumn<bool>("valid");
+
+ // use the macros #defined at the top of the file
+ QTest::newRow("bad") << QString("mylib.bad") << false;
+ QTest::newRow(".a") << QString("mylib.a") << a_VALID;
+ QTest::newRow(".bundle") << QString("mylib.bundle") << bundle_VALID;
+ QTest::newRow(".dll") << QString("mylib.dll") << dll_VALID;
+ QTest::newRow(".DLL") << QString("MYLIB.DLL") << DLL_VALID;
+ QTest::newRow(".dl2" ) << QString("mylib.dl2") << false;
+ QTest::newRow(".dylib") << QString("mylib.dylib") << dylib_VALID;
+ QTest::newRow(".sl") << QString("mylib.sl") << sl_VALID;
+ QTest::newRow(".so") << QString("mylib.so") << so_VALID;
+ QTest::newRow(".so+version") << QString("mylib.so.0") << so_VALID;
+
+ // special tests:
+#ifndef Q_OS_MAC
+ QTest::newRow("version+.so") << QString("libc-2.7.so") << so_VALID;
+ QTest::newRow("version+.so+version") << QString("liboil-0.3.so.0.1.0") << so_VALID;
+#else
+ QTest::newRow("version+.so") << QString("libc-2.7.so") << false;
+ QTest::newRow("version+.so+version") << QString("liboil-0.3.so.0.1.0") << false;
+#endif
+#ifdef Q_OS_MAC
+ QTest::newRow("good (libmylib.1.0.0.dylib)") << QString("libmylib.1.0.0.dylib") << true;
+ QTest::newRow("good (libmylib.dylib)") << QString("libmylib.dylib") << true;
+ QTest::newRow("good (libmylib.so)") << QString("libmylib.so") << true;
+ QTest::newRow("good (libmylib.so.1.0.0)") << QString("libmylib.so.1.0.0") << true;
+
+ QTest::newRow("bad (libmylib.1.0.0.foo)") << QString("libmylib.1.0.0.foo") << false;
+#elif defined(Q_OS_WIN) || defined(Q_OS_SYMBIAN)
+ QTest::newRow("good (with many dots)" ) << "/system.trolltech.test.mylib.dll" << true;
+#endif
+}
+
+void tst_QLibrary::isLibrary()
+{
+ QFETCH( QString, filename );
+ QFETCH( bool, valid );
+
+ QCOMPARE(QLibrary::isLibrary(filename), valid);
+}
+
+void tst_QLibrary::errorString_data()
+{
+ QTest::addColumn<int>("operation");
+ QTest::addColumn<QString>("fileName");
+ QTest::addColumn<bool>("success");
+ QTest::addColumn<QString>("errorString");
+
+#if defined(Q_OS_SYMBIAN)
+ QString currDir;
+#else
+ QString currDir = QDir::currentPath();
+
+ QString srcDir = SRCDIR;
+ if (srcDir.isEmpty())
+ srcDir = currDir;
+#endif
+
+ 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
+ QTest::newRow("bad resolve") << (int)Resolve << currDir + "/mylib" << false << QString("Cannot resolve symbol \"nosuchsymbol\" in .*: .*");
+#else
+ QTest::newRow("bad resolve") << (int)Resolve << currDir + "/mylib" << false << QString("Cannot resolve symbol \"nosuchsymbol\" in \\S+: .*");
+#endif
+ QTest::newRow("good resolve") << (int)Resolve << currDir + "/mylib" << true << QString("Unknown error");
+
+#ifdef Q_OS_WIN
+ QTest::newRow("bad load() with .dll suffix") << (int)Load << QString("nosuchlib.dll") << false << QString("Cannot load library nosuchlib.dll: The specified module could not be found.");
+// 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
+#elif defined Q_OS_SYMBIAN
+ QTest::newRow("load invalid file") << (int)Load << "tst_qlibrary.exe" << false << QString("Cannot load library.*");
+#else
+ QTest::newRow("load invalid file") << (int)Load << srcDir + "/library_path/invalid.so" << false << QString("Cannot load library.*");
+#endif
+}
+
+void tst_QLibrary::errorString()
+{
+ QFETCH(int, operation);
+ QFETCH(QString, fileName);
+ QFETCH(bool, success);
+ QFETCH(QString, errorString);
+
+#if defined(Q_OS_SYMBIAN)
+ if ( success )
+ {
+ QSKIP("SYMBIAN does not support symbols on non-STDDLL libraries.", SkipSingle );
+ }
+#endif
+
+ QLibrary lib;
+ if (!(operation & DontSetFileName)) {
+ lib.setFileName(fileName);
+ }
+
+ bool ok = false;
+ switch (operation & OperationMask) {
+ case Load:
+ ok = lib.load();
+ break;
+ case Unload:
+ ok = lib.load(); //###
+ ok = lib.unload();
+ break;
+ case Resolve: {
+ ok = lib.load();
+ QCOMPARE(ok, true);
+ if (success) {
+ ok = lib.resolve("mylibversion");
+ } else {
+ ok = lib.resolve("nosuchsymbol");
+ }
+ break;}
+ default:
+ QFAIL(qPrintable(QString("Unknown operation: %1").arg(operation)));
+ break;
+ }
+ QRegExp re(errorString);
+ QString libErrorString = lib.errorString();
+ QVERIFY(!lib.isLoaded() || lib.unload());
+ QVERIFY2(re.exactMatch(libErrorString), qPrintable(libErrorString));
+ QCOMPARE(ok, success);
+}
+
+void tst_QLibrary::loadHints_data()
+{
+ QTest::addColumn<QString>("lib");
+ QTest::addColumn<int>("loadHints");
+ QTest::addColumn<bool>("result");
+
+ QLibrary::LoadHints lh;
+#if defined(Q_OS_AIX)
+ if (QFile::exists("/usr/lib/libGL.a") || QFile::exists("/usr/X11R6/lib/libGL.a")) {
+# if QT_POINTER_SIZE == 4
+ QTest::newRow( "ok03 (Archive member)" ) << "libGL.a(shr.o)" << int(QLibrary::LoadArchiveMemberHint) << true;
+# else
+ QTest::newRow( "ok03 (Archive member)" ) << "libGL.a(shr_64.o)" << int(QLibrary::LoadArchiveMemberHint) << true;
+#endif
+ }
+#endif
+
+#if defined(Q_OS_SYMBIAN)
+ QString currDir;
+#else
+ QString currDir = QDir::currentPath();
+#endif
+
+ lh |= QLibrary::ResolveAllSymbolsHint;
+# if defined(Q_OS_WIN32) || defined(Q_OS_WINCE) || defined(Q_OS_SYMBIAN)
+ QTest::newRow( "ok01 (with suffix)" ) << currDir + "/mylib.dll" << int(lh) << true;
+ QTest::newRow( "ok02 (with non-standard suffix)" ) << currDir + "/mylib.dl2" << int(lh) << true;
+ QTest::newRow( "ok03 (with many dots)" ) << currDir + "/system.trolltech.test.mylib.dll" << int(lh) << true;
+# elif defined Q_OS_UNIX
+ QTest::newRow( "ok01 (with suffix)" ) << currDir + "/libmylib" SUFFIX << int(lh) << true;
+ QTest::newRow( "ok02 (with non-standard suffix)" ) << currDir + "/libmylib.so2" << int(lh) << true;
+ QTest::newRow( "ok03 (with many dots)" ) << currDir + "/system.trolltech.test.mylib.so" << int(lh) << true;
+# endif // Q_OS_UNIX
+}
+
+void tst_QLibrary::loadHints()
+{
+ QFETCH( QString, lib );
+ QFETCH( int, loadHints);
+ QFETCH( bool, result );
+ //QLibrary library( lib );
+ QLibrary library;
+ QLibrary::LoadHints lh(loadHints);
+ if (int(loadHints) != 0) {
+ lh |= library.loadHints();
+ library.setLoadHints(lh);
+ }
+ library.setFileName(lib);
+ QCOMPARE(library.loadHints(), lh);
+ bool ok = library.load();
+ if ( result ) {
+ QVERIFY( ok );
+ QVERIFY(library.unload());
+ } else {
+ QVERIFY( !ok );
+ }
+}
+
+void tst_QLibrary::fileName_data()
+{
+ QTest::addColumn<QString>("libName");
+ QTest::addColumn<QString>("expectedFilename");
+
+ QTest::newRow( "ok02" ) << sys_qualifiedLibraryName(QLatin1String("mylib"))
+ << sys_qualifiedLibraryName(QLatin1String("mylib"));
+#ifdef Q_WS_WIN
+#ifndef Q_OS_WINCE
+ QTest::newRow( "ok03" ) << "user32"
+ << "USER32.dll";
+#else
+ QTest::newRow( "ok03" ) << "coredll"
+ << "coredll.dll";
+#endif
+#endif
+}
+
+void tst_QLibrary::fileName()
+{
+ QFETCH( QString, libName);
+ QFETCH( QString, expectedFilename);
+
+ QLibrary lib(libName);
+ bool ok = lib.load();
+ if (!ok) {
+ qDebug() << lib.errorString();
+ }
+
+ QVERIFY(ok);
+#if defined(Q_OS_WIN) || defined(Q_OS_SYMBIAN)
+ QCOMPARE(lib.fileName().toLower(), expectedFilename.toLower());
+#else
+ QCOMPARE(lib.fileName(), expectedFilename);
+#endif
+ QVERIFY(lib.unload());
+
+}
+
+void tst_QLibrary::multipleInstancesForOneLibrary()
+{
+#if defined(Q_OS_SYMBIAN)
+ QString lib = "/mylib";
+#else
+ QString lib = QDir::currentPath() + "/mylib";
+#endif
+
+ {
+ QLibrary lib1(lib);
+ QLibrary lib2(lib);
+ QCOMPARE(lib1.isLoaded(), false);
+ QCOMPARE(lib2.isLoaded(), false);
+ lib1.load();
+ QCOMPARE(lib1.isLoaded(), true);
+ QCOMPARE(lib2.isLoaded(), true);
+ QCOMPARE(lib1.unload(), true);
+ QCOMPARE(lib1.isLoaded(), false);
+ QCOMPARE(lib2.isLoaded(), false);
+ lib1.load();
+ lib2.load();
+ QCOMPARE(lib1.isLoaded(), true);
+ QCOMPARE(lib2.isLoaded(), true);
+ QCOMPARE(lib1.unload(), false);
+ QCOMPARE(lib1.isLoaded(), true);
+ QCOMPARE(lib2.isLoaded(), true);
+ QCOMPARE(lib2.unload(), true);
+ QCOMPARE(lib1.isLoaded(), false);
+ QCOMPARE(lib2.isLoaded(), false);
+
+ // Finally; unload on that is already unloaded
+ QCOMPARE(lib1.unload(), false);
+ }
+
+ //now let's try with a 3rd one that will go out of scope
+ {
+ QLibrary lib1(lib);
+ QCOMPARE(lib1.isLoaded(), false);
+ lib1.load();
+ QCOMPARE(lib1.isLoaded(), true);
+ }
+ QLibrary lib2(lib);
+ //lib2 should be loaded because lib1 was loaded and never unloaded
+ QCOMPARE(lib2.isLoaded(), true);
+
+/*
+ lib1.setLoadHints(QLibrary::ResolveAllSymbolsHint);
+ lib2.setLoadHints(QLibrary::ExportExternalSymbolHint);
+*/
+}
+
+QTEST_APPLESS_MAIN(tst_QLibrary)
+#include "tst_qlibrary.moc"
diff --git a/tests/auto/corelib/plugin/qplugin/.gitignore b/tests/auto/corelib/plugin/qplugin/.gitignore
new file mode 100644
index 0000000000..671b21a458
--- /dev/null
+++ b/tests/auto/corelib/plugin/qplugin/.gitignore
@@ -0,0 +1,2 @@
+tst_qplugin
+plugins
diff --git a/tests/auto/corelib/plugin/qplugin/debugplugin/debugplugin.pro b/tests/auto/corelib/plugin/qplugin/debugplugin/debugplugin.pro
new file mode 100644
index 0000000000..d0762fc101
--- /dev/null
+++ b/tests/auto/corelib/plugin/qplugin/debugplugin/debugplugin.pro
@@ -0,0 +1,11 @@
+TEMPLATE = lib
+CONFIG += plugin debug
+CONFIG -= release debug_and_release
+SOURCES = main.cpp
+QT = core
+DESTDIR = ../plugins
+
+symbian: {
+ TARGET.EPOCALLOWDLLDATA=1
+ TARGET.CAPABILITY=ALL -TCB
+}
diff --git a/tests/auto/corelib/plugin/qplugin/debugplugin/main.cpp b/tests/auto/corelib/plugin/qplugin/debugplugin/main.cpp
new file mode 100644
index 0000000000..b1538963d8
--- /dev/null
+++ b/tests/auto/corelib/plugin/qplugin/debugplugin/main.cpp
@@ -0,0 +1,43 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <QtPlugin>
+
+Q_EXPORT_PLUGIN2(DebugPlugin, QObject)
diff --git a/tests/auto/corelib/plugin/qplugin/qplugin.pro b/tests/auto/corelib/plugin/qplugin/qplugin.pro
new file mode 100644
index 0000000000..37a12da732
--- /dev/null
+++ b/tests/auto/corelib/plugin/qplugin/qplugin.pro
@@ -0,0 +1,28 @@
+QT = core
+TEMPLATE = subdirs
+win32 {
+ exists($$[QT_INSTALL_LIBS]/QtCore4.dll) {
+ SUBDIRS = releaseplugin
+ }
+ exists($$[QT_INSTALL_LIBS]/QtCored4.dll) {
+ SUBDIRS += debugplugin
+ }
+}
+mac {
+ CONFIG(debug, debug|release): {
+ SUBDIRS += debugplugin
+ tst_qplugin_pro.depends += debugplugin
+ }
+ CONFIG(release, debug|release): {
+ SUBDIRS += releaseplugin
+ tst_qplugin_pro.depends += releaseplugin
+ }
+}
+!win32:!mac:{
+ SUBDIRS = debugplugin releaseplugin
+ tst_qplugin_pro.depends += debugplugin releaseplugin
+}
+SUBDIRS += tst_qplugin.pro
+
+
+CONFIG += parallel_test
diff --git a/tests/auto/corelib/plugin/qplugin/releaseplugin/main.cpp b/tests/auto/corelib/plugin/qplugin/releaseplugin/main.cpp
new file mode 100644
index 0000000000..3be9a7415d
--- /dev/null
+++ b/tests/auto/corelib/plugin/qplugin/releaseplugin/main.cpp
@@ -0,0 +1,43 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <QtPlugin>
+
+Q_EXPORT_PLUGIN2(ReleasePlugin, QObject)
diff --git a/tests/auto/corelib/plugin/qplugin/releaseplugin/releaseplugin.pro b/tests/auto/corelib/plugin/qplugin/releaseplugin/releaseplugin.pro
new file mode 100644
index 0000000000..ce66aaf7cb
--- /dev/null
+++ b/tests/auto/corelib/plugin/qplugin/releaseplugin/releaseplugin.pro
@@ -0,0 +1,11 @@
+TEMPLATE = lib
+CONFIG += plugin release
+CONFIG -= debug debug_and_release
+SOURCES = main.cpp
+QT = core
+DESTDIR = ../plugins
+
+symbian: {
+ TARGET.EPOCALLOWDLLDATA=1
+ TARGET.CAPABILITY=ALL -TCB
+}
diff --git a/tests/auto/corelib/plugin/qplugin/tst_qplugin.cpp b/tests/auto/corelib/plugin/qplugin/tst_qplugin.cpp
new file mode 100644
index 0000000000..c7ea963225
--- /dev/null
+++ b/tests/auto/corelib/plugin/qplugin/tst_qplugin.cpp
@@ -0,0 +1,120 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <QtTest/QtTest>
+
+#include <QCoreApplication>
+#include <QDebug>
+#include <QDir>
+#include <QPluginLoader>
+
+class tst_QPlugin : public QObject
+{
+ Q_OBJECT
+
+ QDir dir;
+
+public:
+ tst_QPlugin();
+
+private slots:
+ void loadDebugPlugin();
+ void loadReleasePlugin();
+};
+
+tst_QPlugin::tst_QPlugin()
+ : dir("plugins")
+{
+}
+
+void tst_QPlugin::loadDebugPlugin()
+{
+ foreach (QString fileName, dir.entryList(QStringList() << "*debug*", QDir::Files)) {
+ if (!QLibrary::isLibrary(fileName))
+ continue;
+ QPluginLoader loader(dir.filePath(fileName));
+#if defined(Q_OS_UNIX) && !defined(Q_OS_MAC)
+ // we can always load a plugin on unix
+ QVERIFY(loader.load());
+ QObject *object = loader.instance();
+ QVERIFY(object != 0);
+#else
+ // loading a plugin is dependent on which lib we are running against
+# if defined(QT_NO_DEBUG)
+ // release build, we cannot load debug plugins
+ QVERIFY(!loader.load());
+# else
+ // debug build, we can load debug plugins
+ QVERIFY(loader.load());
+ QObject *object = loader.instance();
+ QVERIFY(object != 0);
+# endif
+#endif
+ }
+}
+
+void tst_QPlugin::loadReleasePlugin()
+{
+ foreach (QString fileName, dir.entryList(QStringList() << "*release*", QDir::Files)) {
+ if (!QLibrary::isLibrary(fileName))
+ continue;
+ QPluginLoader loader(dir.filePath(fileName));
+#if defined(Q_OS_UNIX) && !defined(Q_OS_MAC)
+ // we can always load a plugin on unix
+ QVERIFY(loader.load());
+ QObject *object = loader.instance();
+ QVERIFY(object != 0);
+#else
+ // loading a plugin is dependent on which lib we are running against
+# if defined(QT_NO_DEBUG)
+ // release build, we can load debug plugins
+ QVERIFY(loader.load());
+ QObject *object = loader.instance();
+ QVERIFY(object != 0);
+# else
+ // debug build, we cannot load debug plugins
+ QVERIFY(!loader.load());
+# endif
+#endif
+ }
+}
+
+QTEST_MAIN(tst_QPlugin)
+#include "tst_qplugin.moc"
diff --git a/tests/auto/corelib/plugin/qplugin/tst_qplugin.pro b/tests/auto/corelib/plugin/qplugin/tst_qplugin.pro
new file mode 100644
index 0000000000..3629fb36a1
--- /dev/null
+++ b/tests/auto/corelib/plugin/qplugin/tst_qplugin.pro
@@ -0,0 +1,16 @@
+load(qttest_p4)
+
+SOURCES = tst_qplugin.cpp
+QT = core
+
+wince*: {
+ plugins.files = plugins/*
+ plugins.path = plugins
+ DEPLOYMENT += plugins
+}
+
+symbian: {
+ rpDep.files = releaseplugin.dll debugplugin.dll
+ rpDep.path = plugins
+ DEPLOYMENT += rpDep dpDep
+}
diff --git a/tests/auto/corelib/plugin/qpluginloader/.gitignore b/tests/auto/corelib/plugin/qpluginloader/.gitignore
new file mode 100644
index 0000000000..6b2fa3a715
--- /dev/null
+++ b/tests/auto/corelib/plugin/qpluginloader/.gitignore
@@ -0,0 +1,2 @@
+tst_qpluginloader
+bin/
diff --git a/tests/auto/corelib/plugin/qpluginloader/almostplugin/almostplugin.cpp b/tests/auto/corelib/plugin/qpluginloader/almostplugin/almostplugin.cpp
new file mode 100644
index 0000000000..70596c0113
--- /dev/null
+++ b/tests/auto/corelib/plugin/qpluginloader/almostplugin/almostplugin.cpp
@@ -0,0 +1,51 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <QtCore/QString>
+#include "almostplugin.h"
+#include <QtCore/qplugin.h>
+
+QString AlmostPlugin::pluginName() const
+{
+ unresolvedSymbol();
+ return QLatin1String("Plugin ok");
+}
+
+Q_EXPORT_PLUGIN2(almostplugin, AlmostPlugin)
diff --git a/tests/auto/corelib/plugin/qpluginloader/almostplugin/almostplugin.h b/tests/auto/corelib/plugin/qpluginloader/almostplugin/almostplugin.h
new file mode 100644
index 0000000000..0021180b36
--- /dev/null
+++ b/tests/auto/corelib/plugin/qpluginloader/almostplugin/almostplugin.h
@@ -0,0 +1,57 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef ALMOSTPLUGIN_H
+#define ALMOSTPLUGIN_H
+
+#include <QObject>
+#include "../theplugin/plugininterface.h"
+
+class AlmostPlugin : public QObject, public PluginInterface
+{
+ Q_OBJECT
+ Q_INTERFACES(PluginInterface)
+
+public:
+ QString pluginName() const;
+ void unresolvedSymbol() const;
+};
+
+#endif // ALMOSTPLUGIN_H
diff --git a/tests/auto/corelib/plugin/qpluginloader/almostplugin/almostplugin.pro b/tests/auto/corelib/plugin/qpluginloader/almostplugin/almostplugin.pro
new file mode 100644
index 0000000000..b45509ef01
--- /dev/null
+++ b/tests/auto/corelib/plugin/qpluginloader/almostplugin/almostplugin.pro
@@ -0,0 +1,7 @@
+TEMPLATE = lib
+CONFIG += plugin
+HEADERS = almostplugin.h
+SOURCES = almostplugin.cpp
+TARGET = almostplugin
+DESTDIR = ../bin
+*-g++*:QMAKE_LFLAGS -= -Wl,--no-undefined
diff --git a/tests/auto/corelib/plugin/qpluginloader/elftest/.gitattributes b/tests/auto/corelib/plugin/qpluginloader/elftest/.gitattributes
new file mode 100644
index 0000000000..891192ca94
--- /dev/null
+++ b/tests/auto/corelib/plugin/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/corelib/plugin/qpluginloader/elftest/corrupt1.elf64.so b/tests/auto/corelib/plugin/qpluginloader/elftest/corrupt1.elf64.so
new file mode 100755
index 0000000000..12ce7362dc
--- /dev/null
+++ b/tests/auto/corelib/plugin/qpluginloader/elftest/corrupt1.elf64.so
Binary files differ
diff --git a/tests/auto/corelib/plugin/qpluginloader/elftest/corrupt2.elf64.so b/tests/auto/corelib/plugin/qpluginloader/elftest/corrupt2.elf64.so
new file mode 100755
index 0000000000..11fdc2c118
--- /dev/null
+++ b/tests/auto/corelib/plugin/qpluginloader/elftest/corrupt2.elf64.so
Binary files differ
diff --git a/tests/auto/corelib/plugin/qpluginloader/elftest/corrupt3.elf64.so b/tests/auto/corelib/plugin/qpluginloader/elftest/corrupt3.elf64.so
new file mode 100755
index 0000000000..94a2bc3560
--- /dev/null
+++ b/tests/auto/corelib/plugin/qpluginloader/elftest/corrupt3.elf64.so
Binary files differ
diff --git a/tests/auto/corelib/plugin/qpluginloader/elftest/debugobj.so b/tests/auto/corelib/plugin/qpluginloader/elftest/debugobj.so
new file mode 100644
index 0000000000..f0ee0569a3
--- /dev/null
+++ b/tests/auto/corelib/plugin/qpluginloader/elftest/debugobj.so
Binary files differ
diff --git a/tests/auto/corelib/plugin/qpluginloader/elftest/garbage1.so b/tests/auto/corelib/plugin/qpluginloader/elftest/garbage1.so
new file mode 100644
index 0000000000..0c7453077f
--- /dev/null
+++ b/tests/auto/corelib/plugin/qpluginloader/elftest/garbage1.so
@@ -0,0 +1,4 @@
+p¶¤Ðã¨ø±ÕÛcdL+ôúæî&‘¿&÷ýeü¥=კ²
+•o°Ã’ÊŽI› §ÙÏmgƒ]!ÀZ
+L'Ž)t±
+ÙN»¸(e©× P)Y8öG ˆ6ß-yÈÏÀ ñŸ§÷—“"ô–ZÖÿ›kõ4â?Ë^náÁÇß5$ž’ôY=£ð#y \ No newline at end of file
diff --git a/tests/auto/corelib/plugin/qpluginloader/elftest/garbage2.so b/tests/auto/corelib/plugin/qpluginloader/elftest/garbage2.so
new file mode 100644
index 0000000000..c06338e0c8
--- /dev/null
+++ b/tests/auto/corelib/plugin/qpluginloader/elftest/garbage2.so
@@ -0,0 +1 @@
+£Çv.³Y‹¨tKëW3 \ No newline at end of file
diff --git a/tests/auto/corelib/plugin/qpluginloader/elftest/garbage3.so b/tests/auto/corelib/plugin/qpluginloader/elftest/garbage3.so
new file mode 100644
index 0000000000..a24c523a77
--- /dev/null
+++ b/tests/auto/corelib/plugin/qpluginloader/elftest/garbage3.so
@@ -0,0 +1 @@
+£ÝÈÈ‚åžT-õ«´ÊôÚ¥ Àä¸ï¨ì¾œÀi8¼_ñxÓõª¾I±Ð×®ÝxÎ=úØ4@þñ[¨—úBàKS$ú \ No newline at end of file
diff --git a/tests/auto/corelib/plugin/qpluginloader/elftest/garbage4.so b/tests/auto/corelib/plugin/qpluginloader/elftest/garbage4.so
new file mode 100644
index 0000000000..4f45cf5157
--- /dev/null
+++ b/tests/auto/corelib/plugin/qpluginloader/elftest/garbage4.so
@@ -0,0 +1 @@
+¶ !¦\~çU­u³†:9©ˆ œ§T+91ˆQ¬EøåÇšx¨ng5Óã—zhŒ–…ÿÆ^t™ŠµŽ¦'ÆÎmm*ˈdXH;vw+ªG“²ÃàØ ¨9Lƒ0! \ No newline at end of file
diff --git a/tests/auto/corelib/plugin/qpluginloader/elftest/garbage5.so b/tests/auto/corelib/plugin/qpluginloader/elftest/garbage5.so
new file mode 100644
index 0000000000..f8c0a1d544
--- /dev/null
+++ b/tests/auto/corelib/plugin/qpluginloader/elftest/garbage5.so
@@ -0,0 +1,2 @@
+ïÌô’Q²
+ãµ-¢9Ò \ No newline at end of file
diff --git a/tests/auto/corelib/plugin/qpluginloader/lib/lib.pro b/tests/auto/corelib/plugin/qpluginloader/lib/lib.pro
new file mode 100644
index 0000000000..ce9bf13c25
--- /dev/null
+++ b/tests/auto/corelib/plugin/qpluginloader/lib/lib.pro
@@ -0,0 +1,18 @@
+TEMPLATE = lib
+CONFIG += dll
+CONFIG -= staticlib
+SOURCES = mylib.c
+TARGET = tst_qpluginloaderlib
+DESTDIR = ../bin
+QT = core
+
+win32-msvc: DEFINES += WIN32_MSVC
+win32-borland: DEFINES += WIN32_BORLAND
+
+#no special install rule for the library used by test
+INSTALLS =
+
+symbian: {
+ TARGET.CAPABILITY=ALL -TCB
+}
+
diff --git a/tests/auto/corelib/plugin/qpluginloader/lib/mylib.c b/tests/auto/corelib/plugin/qpluginloader/lib/mylib.c
new file mode 100644
index 0000000000..dc43c35815
--- /dev/null
+++ b/tests/auto/corelib/plugin/qpluginloader/lib/mylib.c
@@ -0,0 +1,60 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <qglobal.h>
+
+#if defined(Q_CC_MSVC) || defined(Q_CC_MSVC_NET) || defined(Q_CC_BOR)
+#define LIB_EXPORT __declspec(dllexport)
+#else
+#define LIB_EXPORT
+#endif
+
+#if defined(Q_CC_BOR)
+# define BORLAND_STDCALL __stdcall
+#else
+# define BORLAND_STDCALL
+#endif
+
+LIB_EXPORT int BORLAND_STDCALL version()
+{
+ return 1;
+}
+
diff --git a/tests/auto/corelib/plugin/qpluginloader/qpluginloader.pro b/tests/auto/corelib/plugin/qpluginloader/qpluginloader.pro
new file mode 100644
index 0000000000..6e41b4c96a
--- /dev/null
+++ b/tests/auto/corelib/plugin/qpluginloader/qpluginloader.pro
@@ -0,0 +1,14 @@
+QT = core
+TEMPLATE = subdirs
+CONFIG += ordered
+SUBDIRS = lib \
+ theplugin \
+ tst
+!win32: !macx-*: !symbian: SUBDIRS += almostplugin
+TARGET = tst_qpluginloader
+
+# no special install rule for subdir
+INSTALLS =
+
+
+CONFIG += parallel_test
diff --git a/tests/auto/corelib/plugin/qpluginloader/theplugin/plugininterface.h b/tests/auto/corelib/plugin/qpluginloader/theplugin/plugininterface.h
new file mode 100644
index 0000000000..48d8443ba1
--- /dev/null
+++ b/tests/auto/corelib/plugin/qpluginloader/theplugin/plugininterface.h
@@ -0,0 +1,54 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef PLUGININTERFACE_H
+#define PLUGININTERFACE_H
+
+struct PluginInterface {
+ virtual ~PluginInterface() {}
+ virtual QString pluginName() const = 0;
+};
+
+QT_BEGIN_NAMESPACE
+Q_DECLARE_INTERFACE(PluginInterface, "com.trolltect.autotests.plugininterface/1.0")
+QT_END_NAMESPACE
+
+#endif // PLUGININTERFACE_H
+
diff --git a/tests/auto/corelib/plugin/qpluginloader/theplugin/theplugin.cpp b/tests/auto/corelib/plugin/qpluginloader/theplugin/theplugin.cpp
new file mode 100644
index 0000000000..fdf599c875
--- /dev/null
+++ b/tests/auto/corelib/plugin/qpluginloader/theplugin/theplugin.cpp
@@ -0,0 +1,51 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <QtCore/QString>
+#include "theplugin.h"
+#include <QtCore/qplugin.h>
+
+QString ThePlugin::pluginName() const
+{
+ return QLatin1String("Plugin ok");
+}
+
+Q_EXPORT_PLUGIN2(theplugin, ThePlugin)
+
diff --git a/tests/auto/corelib/plugin/qpluginloader/theplugin/theplugin.h b/tests/auto/corelib/plugin/qpluginloader/theplugin/theplugin.h
new file mode 100644
index 0000000000..5b738696e0
--- /dev/null
+++ b/tests/auto/corelib/plugin/qpluginloader/theplugin/theplugin.h
@@ -0,0 +1,57 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef THEPLUGIN_H
+#define THEPLUGIN_H
+
+#include <QObject>
+#include "plugininterface.h"
+
+class ThePlugin : public QObject, public PluginInterface
+{
+ Q_OBJECT
+ Q_INTERFACES(PluginInterface)
+
+public:
+ virtual QString pluginName() const;
+};
+
+#endif // THEPLUGIN_H
+
diff --git a/tests/auto/corelib/plugin/qpluginloader/theplugin/theplugin.pro b/tests/auto/corelib/plugin/qpluginloader/theplugin/theplugin.pro
new file mode 100644
index 0000000000..44b46b439f
--- /dev/null
+++ b/tests/auto/corelib/plugin/qpluginloader/theplugin/theplugin.pro
@@ -0,0 +1,11 @@
+TEMPLATE = lib
+CONFIG += plugin
+HEADERS = theplugin.h
+SOURCES = theplugin.cpp
+TARGET = $$qtLibraryTarget(theplugin)
+DESTDIR = ../bin
+
+symbian: {
+ TARGET.EPOCALLOWDLLDATA=1
+ TARGET.CAPABILITY=ALL -TCB
+}
diff --git a/tests/auto/corelib/plugin/qpluginloader/tst/tst.pro b/tests/auto/corelib/plugin/qpluginloader/tst/tst.pro
new file mode 100644
index 0000000000..7ae6d89143
--- /dev/null
+++ b/tests/auto/corelib/plugin/qpluginloader/tst/tst.pro
@@ -0,0 +1,32 @@
+load(qttest_p4)
+SOURCES += ../tst_qpluginloader.cpp
+TARGET = ../tst_qpluginloader
+QT = core
+HEADERS += ../theplugin/plugininterface.h
+
+win32 {
+ CONFIG(debug, debug|release) {
+ TARGET = ../../debug/tst_qpluginloader
+} else {
+ TARGET = ../../release/tst_qpluginloader
+ }
+}
+
+
+wince*: {
+ addFiles.files = $$OUT_PWD/../bin/*.dll
+ addFiles.path = bin
+ DEPLOYMENT += addFiles
+}
+
+symbian: {
+ libDep.files = tst_qpluginloaderlib.dll
+ libDep.path = /sys/bin
+ pluginDep.files = theplugin.dll
+ pluginDep.path = bin
+
+ DEPLOYMENT += libDep pluginDep
+}
+
+DEFINES += SRCDIR=\\\"$$PWD/../\\\"
+mac*:CONFIG+=insignificant_test
diff --git a/tests/auto/corelib/plugin/qpluginloader/tst_qpluginloader.cpp b/tests/auto/corelib/plugin/qpluginloader/tst_qpluginloader.cpp
new file mode 100644
index 0000000000..76dbd48a14
--- /dev/null
+++ b/tests/auto/corelib/plugin/qpluginloader/tst_qpluginloader.cpp
@@ -0,0 +1,406 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#include <QtTest/QtTest>
+#include <qdir.h>
+#include <qpluginloader.h>
+#include "theplugin/plugininterface.h"
+
+// Helper macros to let us know if some suffixes are valid
+#define bundle_VALID false
+#define dylib_VALID false
+#define sl_VALID false
+#define a_VALID false
+#define so_VALID false
+#define dll_VALID false
+
+#if defined(Q_OS_DARWIN)
+# undef bundle_VALID
+# undef dylib_VALID
+# undef so_VALID
+# define bundle_VALID true
+# define dylib_VALID true
+# define so_VALID true
+# define SUFFIX ".dylib"
+# define PREFIX "lib"
+
+#elif defined(Q_OS_HPUX) && !defined(__ia64)
+# undef sl_VALID
+# define sl_VALID true
+# define SUFFIX ".sl"
+# define PREFIX "lib"
+
+#elif defined(Q_OS_AIX)
+# undef a_VALID
+# undef so_VALID
+# define a_VALID true
+# define so_VALID true
+# define SUFFIX ".so"
+# define PREFIX "lib"
+
+#elif defined(Q_OS_WIN)
+# undef dll_VALID
+# define dll_VALID true
+# ifdef QT_NO_DEBUG
+# define SUFFIX ".dll"
+# else
+# define SUFFIX "d.dll"
+# endif
+# define PREFIX ""
+
+#elif defined(Q_OS_SYMBIAN)
+# undef dll_VALID
+# define dll_VALID true
+# define SUFFIX ".dll"
+# define PREFIX ""
+
+#else // all other Unix
+# undef so_VALID
+# define so_VALID true
+# define SUFFIX ".so"
+# define PREFIX "lib"
+#endif
+
+static QString sys_qualifiedLibraryName(const QString &fileName)
+{
+ QString currDir = QDir::currentPath();
+ return currDir + "/bin/" + PREFIX + fileName + SUFFIX;
+}
+
+//TESTED_CLASS=
+//TESTED_FILES=
+
+QT_FORWARD_DECLARE_CLASS(QPluginLoader)
+class tst_QPluginLoader : public QObject
+{
+ Q_OBJECT
+
+public:
+ tst_QPluginLoader();
+ virtual ~tst_QPluginLoader();
+
+private slots:
+ void errorString();
+ void loadHints();
+ void deleteinstanceOnUnload();
+ void checkingStubsFromDifferentDrives();
+ void loadDebugObj();
+ void loadCorruptElf();
+ void loadGarbage();
+};
+
+tst_QPluginLoader::tst_QPluginLoader()
+
+{
+}
+
+tst_QPluginLoader::~tst_QPluginLoader()
+{
+}
+
+//#define SHOW_ERRORS 1
+
+void tst_QPluginLoader::errorString()
+{
+#if defined(Q_OS_WINCE)
+ // On WinCE we need an QCoreApplication object for current dir
+ int argc = 0;
+ QCoreApplication app(argc,0);
+#endif
+ const QString unknown(QLatin1String("Unknown error"));
+
+ {
+ QPluginLoader loader; // default constructed
+ bool loaded = loader.load();
+#ifdef SHOW_ERRORS
+ qDebug() << loader.errorString();
+#endif
+ QCOMPARE(loaded, false);
+ QCOMPARE(loader.errorString(), unknown);
+
+ QObject *obj = loader.instance();
+#ifdef SHOW_ERRORS
+ qDebug() << loader.errorString();
+#endif
+ QCOMPARE(obj, static_cast<QObject*>(0));
+ QCOMPARE(loader.errorString(), unknown);
+
+ bool unloaded = loader.unload();
+#ifdef SHOW_ERRORS
+ qDebug() << loader.errorString();
+#endif
+ QCOMPARE(unloaded, false);
+ QCOMPARE(loader.errorString(), unknown);
+ }
+ {
+ QPluginLoader loader( sys_qualifiedLibraryName("tst_qpluginloaderlib")); //not a plugin
+ bool loaded = loader.load();
+#ifdef SHOW_ERRORS
+ qDebug() << loader.errorString();
+#endif
+ QCOMPARE(loaded, false);
+ QVERIFY(loader.errorString() != unknown);
+
+ QObject *obj = loader.instance();
+#ifdef SHOW_ERRORS
+ qDebug() << loader.errorString();
+#endif
+ QCOMPARE(obj, static_cast<QObject*>(0));
+ QVERIFY(loader.errorString() != unknown);
+
+ bool unloaded = loader.unload();
+#ifdef SHOW_ERRORS
+ qDebug() << loader.errorString();
+#endif
+ QCOMPARE(unloaded, false);
+ QVERIFY(loader.errorString() != unknown);
+ }
+
+ {
+ QPluginLoader loader( sys_qualifiedLibraryName("nosuchfile")); //not a file
+ bool loaded = loader.load();
+#ifdef SHOW_ERRORS
+ qDebug() << loader.errorString();
+#endif
+ QCOMPARE(loaded, false);
+ QVERIFY(loader.errorString() != unknown);
+
+ QObject *obj = loader.instance();
+#ifdef SHOW_ERRORS
+ qDebug() << loader.errorString();
+#endif
+ QCOMPARE(obj, static_cast<QObject*>(0));
+ QVERIFY(loader.errorString() != unknown);
+
+ bool unloaded = loader.unload();
+#ifdef SHOW_ERRORS
+ qDebug() << loader.errorString();
+#endif
+ QCOMPARE(unloaded, false);
+ QVERIFY(loader.errorString() != unknown);
+ }
+
+#if !defined Q_OS_WIN && !defined Q_OS_MAC && !defined Q_OS_HPUX && !defined Q_OS_SYMBIAN
+ {
+ QPluginLoader loader( sys_qualifiedLibraryName("almostplugin")); //a plugin with unresolved symbols
+ loader.setLoadHints(QLibrary::ResolveAllSymbolsHint);
+ QCOMPARE(loader.load(), false);
+#ifdef SHOW_ERRORS
+ qDebug() << loader.errorString();
+#endif
+ QVERIFY(loader.errorString() != unknown);
+
+ QCOMPARE(loader.instance(), static_cast<QObject*>(0));
+#ifdef SHOW_ERRORS
+ qDebug() << loader.errorString();
+#endif
+ QVERIFY(loader.errorString() != unknown);
+
+ QCOMPARE(loader.unload(), false);
+#ifdef SHOW_ERRORS
+ qDebug() << loader.errorString();
+#endif
+ QVERIFY(loader.errorString() != unknown);
+ }
+#endif
+
+ {
+ QPluginLoader loader( sys_qualifiedLibraryName("theplugin")); //a plugin
+ QCOMPARE(loader.load(), true);
+ QCOMPARE(loader.errorString(), unknown);
+
+ QVERIFY(loader.instance() != static_cast<QObject*>(0));
+ QCOMPARE(loader.errorString(), unknown);
+
+ // Make sure that plugin really works
+ PluginInterface* theplugin = qobject_cast<PluginInterface*>(loader.instance());
+ QString pluginName = theplugin->pluginName();
+ QCOMPARE(pluginName, QLatin1String("Plugin ok"));
+
+ QCOMPARE(loader.unload(), true);
+ QCOMPARE(loader.errorString(), unknown);
+ }
+}
+
+void tst_QPluginLoader::loadHints()
+{
+ QPluginLoader loader;
+ QCOMPARE(loader.loadHints(), (QLibrary::LoadHints)0); //Do not crash
+ loader.setLoadHints(QLibrary::ResolveAllSymbolsHint);
+ loader.setFileName( sys_qualifiedLibraryName("theplugin")); //a plugin
+ QCOMPARE(loader.loadHints(), QLibrary::ResolveAllSymbolsHint);
+}
+
+void tst_QPluginLoader::deleteinstanceOnUnload()
+{
+ for (int pass = 0; pass < 2; ++pass) {
+ QPluginLoader loader1;
+ loader1.setFileName( sys_qualifiedLibraryName("theplugin")); //a plugin
+ if (pass == 0)
+ loader1.load(); // not recommended, instance() should do the job.
+ PluginInterface *instance1 = qobject_cast<PluginInterface*>(loader1.instance());
+ QVERIFY(instance1);
+ QCOMPARE(instance1->pluginName(), QLatin1String("Plugin ok"));
+
+ QPluginLoader loader2;
+ loader2.setFileName( sys_qualifiedLibraryName("theplugin")); //a plugin
+ if (pass == 0)
+ loader2.load(); // not recommended, instance() should do the job.
+ PluginInterface *instance2 = qobject_cast<PluginInterface*>(loader2.instance());
+ QCOMPARE(instance2->pluginName(), QLatin1String("Plugin ok"));
+
+ QSignalSpy spy1(loader1.instance(), SIGNAL(destroyed()));
+ QSignalSpy spy2(loader2.instance(), SIGNAL(destroyed()));
+ if (pass == 0) {
+ QCOMPARE(loader2.unload(), false); // refcount not reached 0, not really unloaded
+ QCOMPARE(spy1.count(), 0);
+ QCOMPARE(spy2.count(), 0);
+ }
+ QCOMPARE(instance1->pluginName(), QLatin1String("Plugin ok"));
+ QCOMPARE(instance2->pluginName(), QLatin1String("Plugin ok"));
+ QVERIFY(loader1.unload()); // refcount reached 0, did really unload
+ QCOMPARE(spy1.count(), 1);
+ QCOMPARE(spy2.count(), 1);
+ }
+}
+
+void tst_QPluginLoader::checkingStubsFromDifferentDrives()
+{
+#if defined(Q_OS_SYMBIAN)
+
+ // This test needs C-drive + some additional drive (driveForStubs)
+
+ const QString driveForStubs("E:/");// != "C:/"
+ const QString stubDir("system/temp/stubtest/");
+ const QString stubName("dummyStub.qtplugin");
+ const QString fullStubFileName(stubDir + stubName);
+ QDir dir(driveForStubs);
+ bool test1(false); bool test2(false);
+
+ // initial clean up
+ QFile::remove(driveForStubs + fullStubFileName);
+ dir.rmdir(driveForStubs + stubDir);
+
+ // create a stub dir and do stub drive check
+ if (!dir.mkpath(stubDir))
+ QSKIP("Required drive not available for this test", SkipSingle);
+
+ {// test without stub, should not be found
+ QPluginLoader loader("C:/" + fullStubFileName);
+ test1 = !loader.fileName().length();
+ }
+
+ // create a stub to defined drive
+ QFile tempFile(driveForStubs + fullStubFileName);
+ tempFile.open(QIODevice::ReadWrite);
+ QFileInfo fileInfo(tempFile);
+
+ {// now should be found even tried to find from C:
+ QPluginLoader loader("C:/" + fullStubFileName);
+ test2 = (loader.fileName() == fileInfo.absoluteFilePath());
+ }
+
+ // clean up
+ tempFile.close();
+ if (!QFile::remove(driveForStubs + fullStubFileName))
+ QWARN("Could not remove stub file");
+ if (!dir.rmdir(driveForStubs + stubDir))
+ QWARN("Could not remove stub directory");
+
+ // test after cleanup
+ QVERIFY(test1);
+ QVERIFY(test2);
+
+#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 a valid Qt plugin"));
+
+ QPluginLoader lib2(SRCDIR "elftest/corrupt2.elf64.so");
+ QCOMPARE(lib2.load(), false);
+ QVERIFY(lib2.errorString().contains("not a valid Qt plugin"));
+
+ QPluginLoader lib3(SRCDIR "elftest/corrupt3.elf64.so");
+ QCOMPARE(lib3.load(), false);
+ QVERIFY(lib3.errorString().contains("not a valid Qt plugin"));
+} 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"
diff --git a/tests/auto/corelib/plugin/quuid/.gitignore b/tests/auto/corelib/plugin/quuid/.gitignore
new file mode 100644
index 0000000000..4ef3142f0f
--- /dev/null
+++ b/tests/auto/corelib/plugin/quuid/.gitignore
@@ -0,0 +1 @@
+tst_quuid
diff --git a/tests/auto/corelib/plugin/quuid/quuid.pro b/tests/auto/corelib/plugin/quuid/quuid.pro
new file mode 100644
index 0000000000..461956f313
--- /dev/null
+++ b/tests/auto/corelib/plugin/quuid/quuid.pro
@@ -0,0 +1,7 @@
+TEMPLATE = subdirs
+
+SUBDIRS = testProcessUniqueness
+
+SUBDIRS += test
+
+CONFIG += parallel_test
diff --git a/tests/auto/corelib/plugin/quuid/test/test.pro b/tests/auto/corelib/plugin/quuid/test/test.pro
new file mode 100644
index 0000000000..06ae3bd362
--- /dev/null
+++ b/tests/auto/corelib/plugin/quuid/test/test.pro
@@ -0,0 +1,29 @@
+load(qttest_p4)
+
+QT = core
+SOURCES += ../tst_quuid.cpp
+TARGET = tst_quuid
+
+CONFIG(debug_and_release_target) {
+ CONFIG(debug, debug|release) {
+ DESTDIR = ../debug
+ } else {
+ DESTDIR = ../release
+ }
+} else {
+ DESTDIR = ..
+}
+
+wince* {
+ addFile_processUniqueness.files = $$OUT_PWD/../testProcessUniqueness/testProcessUniqueness.exe
+ addFile_processUniqueness.path = testProcessUniqueness
+
+ DEPLOYMENT += addFile_processUniqueness
+}
+
+symbian {
+ binDep.files = testProcessUniqueness.exe
+ binDep.path = \\sys\\bin
+
+ DEPLOYMENT += binDep
+}
diff --git a/tests/auto/corelib/plugin/quuid/testProcessUniqueness/main.cpp b/tests/auto/corelib/plugin/quuid/testProcessUniqueness/main.cpp
new file mode 100644
index 0000000000..085f56539d
--- /dev/null
+++ b/tests/auto/corelib/plugin/quuid/testProcessUniqueness/main.cpp
@@ -0,0 +1,62 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <stdio.h>
+#include <QUuid>
+
+// This is a testcase for QTBUG-11213
+int main(int argc, char **argv)
+{
+ Q_UNUSED(argc)
+ Q_UNUSED(argv)
+
+ // First, break QUuid.
+ qrand();
+
+ // Now print a few uuids.
+ printf("%s", qPrintable(QUuid::createUuid().toString()));
+ printf("%s", qPrintable(QUuid::createUuid().toString()));
+ printf("%s", qPrintable(QUuid::createUuid().toString()));
+
+ // Done
+ return 0;
+}
+
diff --git a/tests/auto/corelib/plugin/quuid/testProcessUniqueness/testProcessUniqueness.pro b/tests/auto/corelib/plugin/quuid/testProcessUniqueness/testProcessUniqueness.pro
new file mode 100644
index 0000000000..88df1a25d7
--- /dev/null
+++ b/tests/auto/corelib/plugin/quuid/testProcessUniqueness/testProcessUniqueness.pro
@@ -0,0 +1,8 @@
+SOURCES = main.cpp
+CONFIG += console
+
+DESTDIR = ./
+
+# no install rule for application used by test
+INSTALLS =
+
diff --git a/tests/auto/corelib/plugin/quuid/tst_quuid.cpp b/tests/auto/corelib/plugin/quuid/tst_quuid.cpp
new file mode 100644
index 0000000000..5761ea1a8c
--- /dev/null
+++ b/tests/auto/corelib/plugin/quuid/tst_quuid.cpp
@@ -0,0 +1,337 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#include <QtTest/QtTest>
+
+#include <qcoreapplication.h>
+#include <quuid.h>
+
+
+
+#include <quuid.h>
+
+//TESTED_CLASS=
+//TESTED_FILES=
+
+class tst_QUuid : public QObject
+{
+ Q_OBJECT
+
+public:
+ tst_QUuid();
+
+private slots:
+ void fromChar();
+ void toString();
+ void fromString();
+ void toByteArray();
+ void fromByteArray();
+ void toRfc4122();
+ void fromRfc4122();
+ void check_QDataStream();
+ void isNull();
+ void equal();
+ void notEqual();
+
+ // Only in Qt > 3.2.x
+ void generate();
+ void less();
+ void more();
+ void variants();
+ void versions();
+
+ void threadUniqueness();
+ void processUniqueness();
+
+ void hash();
+
+public:
+ // Variables
+ QUuid uuidA;
+ QUuid uuidB;
+};
+
+tst_QUuid::tst_QUuid()
+{
+ //"{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);
+}
+
+void tst_QUuid::fromChar()
+{
+ QCOMPARE(uuidA, QUuid("{fc69b59e-cc34-4436-a43c-ee95d128b8c5}"));
+ QCOMPARE(uuidA, QUuid("fc69b59e-cc34-4436-a43c-ee95d128b8c5}"));
+ QCOMPARE(uuidA, QUuid("{fc69b59e-cc34-4436-a43c-ee95d128b8c5"));
+ QCOMPARE(uuidA, QUuid("fc69b59e-cc34-4436-a43c-ee95d128b8c5"));
+ QCOMPARE(QUuid(), QUuid("{fc69b59e-cc34-4436-a43c-ee95d128b8c"));
+ QCOMPARE(QUuid(), QUuid("{fc69b59e-cc34"));
+ QCOMPARE(QUuid(), QUuid("fc69b59e-cc34-"));
+ QCOMPARE(QUuid(), QUuid("fc69b59e-cc34"));
+ QCOMPARE(QUuid(), QUuid("cc34"));
+ QCOMPARE(QUuid(), QUuid(NULL));
+
+ QCOMPARE(uuidB, QUuid(QString("{1ab6e93a-b1cb-4a87-ba47-ec7e99039a7b}")));
+}
+
+void tst_QUuid::toString()
+{
+ QCOMPARE(uuidA.toString(), QString("{fc69b59e-cc34-4436-a43c-ee95d128b8c5}"));
+
+ QCOMPARE(uuidB.toString(), QString("{1ab6e93a-b1cb-4a87-ba47-ec7e99039a7b}"));
+}
+
+void tst_QUuid::fromString()
+{
+ QCOMPARE(uuidA, QUuid(QString("{fc69b59e-cc34-4436-a43c-ee95d128b8c5}")));
+ QCOMPARE(uuidA, QUuid(QString("fc69b59e-cc34-4436-a43c-ee95d128b8c5}")));
+ QCOMPARE(uuidA, QUuid(QString("{fc69b59e-cc34-4436-a43c-ee95d128b8c5")));
+ QCOMPARE(uuidA, QUuid(QString("fc69b59e-cc34-4436-a43c-ee95d128b8c5")));
+ QCOMPARE(QUuid(), QUuid(QString("{fc69b59e-cc34-4436-a43c-ee95d128b8c")));
+
+ QCOMPARE(uuidB, QUuid(QString("{1ab6e93a-b1cb-4a87-ba47-ec7e99039a7b}")));
+}
+
+void tst_QUuid::toByteArray()
+{
+ QCOMPARE(uuidA.toByteArray(), QByteArray("{fc69b59e-cc34-4436-a43c-ee95d128b8c5}"));
+
+ QCOMPARE(uuidB.toByteArray(), QByteArray("{1ab6e93a-b1cb-4a87-ba47-ec7e99039a7b}"));
+}
+
+void tst_QUuid::fromByteArray()
+{
+ QCOMPARE(uuidA, QUuid(QByteArray("{fc69b59e-cc34-4436-a43c-ee95d128b8c5}")));
+ QCOMPARE(uuidA, QUuid(QByteArray("fc69b59e-cc34-4436-a43c-ee95d128b8c5}")));
+ QCOMPARE(uuidA, QUuid(QByteArray("{fc69b59e-cc34-4436-a43c-ee95d128b8c5")));
+ QCOMPARE(uuidA, QUuid(QByteArray("fc69b59e-cc34-4436-a43c-ee95d128b8c5")));
+ QCOMPARE(QUuid(), QUuid(QByteArray("{fc69b59e-cc34-4436-a43c-ee95d128b8c")));
+
+ QCOMPARE(uuidB, QUuid(QByteArray("{1ab6e93a-b1cb-4a87-ba47-ec7e99039a7b}")));
+}
+
+void tst_QUuid::toRfc4122()
+{
+ QCOMPARE(uuidA.toRfc4122(), QByteArray::fromHex("fc69b59ecc344436a43cee95d128b8c5"));
+
+ QCOMPARE(uuidB.toRfc4122(), QByteArray::fromHex("1ab6e93ab1cb4a87ba47ec7e99039a7b"));
+}
+
+void tst_QUuid::fromRfc4122()
+{
+ QCOMPARE(uuidA, QUuid::fromRfc4122(QByteArray::fromHex("fc69b59ecc344436a43cee95d128b8c5")));
+
+ QCOMPARE(uuidB, QUuid::fromRfc4122(QByteArray::fromHex("1ab6e93ab1cb4a87ba47ec7e99039a7b")));
+}
+
+void tst_QUuid::check_QDataStream()
+{
+ QUuid tmp;
+ QByteArray ar;
+ {
+ QDataStream out(&ar,QIODevice::WriteOnly);
+ out.setByteOrder(QDataStream::BigEndian);
+ out << uuidA;
+ }
+ {
+ QDataStream in(&ar,QIODevice::ReadOnly);
+ in.setByteOrder(QDataStream::BigEndian);
+ in >> tmp;
+ QCOMPARE(uuidA, tmp);
+ }
+ {
+ QDataStream out(&ar,QIODevice::WriteOnly);
+ out.setByteOrder(QDataStream::LittleEndian);
+ out << uuidA;
+ }
+ {
+ QDataStream in(&ar,QIODevice::ReadOnly);
+ in.setByteOrder(QDataStream::LittleEndian);
+ in >> tmp;
+ QCOMPARE(uuidA, tmp);
+ }
+}
+
+void tst_QUuid::isNull()
+{
+ QVERIFY( !uuidA.isNull() );
+
+ QUuid should_be_null_uuid;
+ QVERIFY( should_be_null_uuid.isNull() );
+}
+
+
+void tst_QUuid::equal()
+{
+ QVERIFY( !(uuidA == uuidB) );
+
+ QUuid copy(uuidA);
+ QVERIFY(uuidA == copy);
+
+ QUuid assigned;
+ assigned = uuidA;
+ QVERIFY(uuidA == assigned);
+}
+
+
+void tst_QUuid::notEqual()
+{
+ QVERIFY( uuidA != uuidB );
+}
+
+
+void tst_QUuid::generate()
+{
+ QUuid shouldnt_be_null_uuidA = QUuid::createUuid();
+ QUuid shouldnt_be_null_uuidB = QUuid::createUuid();
+ QVERIFY( !shouldnt_be_null_uuidA.isNull() );
+ QVERIFY( !shouldnt_be_null_uuidB.isNull() );
+ QVERIFY( shouldnt_be_null_uuidA != shouldnt_be_null_uuidB );
+}
+
+
+void tst_QUuid::less()
+{
+ QVERIFY( !(uuidA < uuidB) );
+
+ QUuid null_uuid;
+ QVERIFY(null_uuid < uuidA); // Null uuid is always less than a valid one
+}
+
+
+void tst_QUuid::more()
+{
+ QVERIFY( uuidA > uuidB );
+
+ QUuid null_uuid;
+ QVERIFY( !(null_uuid > uuidA) ); // Null uuid is always less than a valid one
+}
+
+
+void tst_QUuid::variants()
+{
+ QVERIFY( uuidA.variant() == QUuid::DCE );
+ QVERIFY( uuidB.variant() == QUuid::DCE );
+
+ QUuid NCS = "{3a2f883c-4000-000d-0000-00fb40000000}";
+ QVERIFY( NCS.variant() == QUuid::NCS );
+}
+
+
+void tst_QUuid::versions()
+{
+ QVERIFY( uuidA.version() == QUuid::Random );
+ QVERIFY( uuidB.version() == QUuid::Random );
+
+ QUuid DCE_time= "{406c45a0-3b7e-11d0-80a3-0000c08810a7}";
+ QVERIFY( DCE_time.version() == QUuid::Time );
+
+ QUuid NCS = "{3a2f883c-4000-000d-0000-00fb40000000}";
+ QVERIFY( NCS.version() == QUuid::VerUnknown );
+}
+
+class UuidThread : public QThread
+{
+public:
+ QUuid uuid;
+
+ void run()
+ {
+ uuid = QUuid::createUuid();
+ }
+};
+
+void tst_QUuid::threadUniqueness()
+{
+ QVector<UuidThread *> threads(qMax(2, QThread::idealThreadCount()));
+ for (int i = 0; i < threads.count(); ++i)
+ threads[i] = new UuidThread;
+ for (int i = 0; i < threads.count(); ++i)
+ threads[i]->start();
+ for (int i = 0; i < threads.count(); ++i)
+ QVERIFY(threads[i]->wait(1000));
+ for (int i = 1; i < threads.count(); ++i)
+ QVERIFY(threads[0]->uuid != threads[i]->uuid);
+ qDeleteAll(threads);
+}
+
+void tst_QUuid::processUniqueness()
+{
+ QProcess process;
+ QString processOneOutput;
+ QString processTwoOutput;
+
+ // Start it once
+#ifdef Q_OS_MAC
+ process.start("testProcessUniqueness/testProcessUniqueness.app");
+#else
+ process.start("testProcessUniqueness/testProcessUniqueness");
+#endif
+ QVERIFY(process.waitForFinished());
+ processOneOutput = process.readAllStandardOutput();
+
+ // Start it twice
+#ifdef Q_OS_MAC
+ process.start("testProcessUniqueness/testProcessUniqueness.app");
+#else
+ process.start("testProcessUniqueness/testProcessUniqueness");
+#endif
+ QVERIFY(process.waitForFinished());
+ processTwoOutput = process.readAllStandardOutput();
+
+ // They should be *different*!
+ QVERIFY(processOneOutput != processTwoOutput);
+}
+
+void tst_QUuid::hash()
+{
+ uint h = qHash(uuidA);
+ QCOMPARE(qHash(uuidA), h);
+ QCOMPARE(qHash(QUuid(uuidA.toString())), h);
+}
+
+
+
+QTEST_MAIN(tst_QUuid)
+#include "tst_quuid.moc"