summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/plugin/qlibrary/tst_qlibrary.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/corelib/plugin/qlibrary/tst_qlibrary.cpp')
-rw-r--r--tests/auto/corelib/plugin/qlibrary/tst_qlibrary.cpp48
1 files changed, 24 insertions, 24 deletions
diff --git a/tests/auto/corelib/plugin/qlibrary/tst_qlibrary.cpp b/tests/auto/corelib/plugin/qlibrary/tst_qlibrary.cpp
index 018756e81e..28f4581997 100644
--- a/tests/auto/corelib/plugin/qlibrary/tst_qlibrary.cpp
+++ b/tests/auto/corelib/plugin/qlibrary/tst_qlibrary.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QTest>
@@ -256,10 +256,10 @@ void tst_QLibrary::setFileNameAndVersionTwice()
QVERIFY(!library.isLoaded());
// set back
+ // it'll look like it isn't loaded, but it is and we can't unload it!
library.setFileNameAndVersion(directory + "/mylib", 1);
- QVERIFY(library.isLoaded());
- QVERIFY(library.unload());
QVERIFY(!library.isLoaded());
+ QVERIFY(!library.unload());
}
void tst_QLibrary::load_data()
@@ -273,7 +273,7 @@ void tst_QLibrary::load_data()
QTest::newRow( "notexist" ) << appDir + "/nolib" << false;
QTest::newRow( "badlibrary" ) << appDir + "/qlibrary.pro" << false;
-#ifdef Q_OS_MAC
+#ifdef Q_OS_DARWIN
QTest::newRow("ok (libmylib ver. 1)") << appDir + "/libmylib" <<true;
#endif
@@ -432,12 +432,23 @@ void tst_QLibrary::resolve()
QFETCH( QString, symbol );
QFETCH( bool, goodPointer );
- QLibrary library( lib );
- testFunc func = (testFunc) library.resolve( symbol.toLatin1() );
- if ( goodPointer ) {
- QVERIFY( func != 0 );
+ QLibrary library(lib);
+ QVERIFY(!library.isLoaded());
+ testFunc func = (testFunc) library.resolve(symbol.toLatin1());
+
+ if (goodPointer) {
+ QVERIFY(library.isLoaded());
+ QVERIFY(func);
+
+ QLibrary lib2(lib);
+ QVERIFY(!lib2.isLoaded());
+ QVERIFY(lib2.load());
+
+ // this unload() won't unload and it must still be loaded
+ QVERIFY(!lib2.unload());
+ func(); // doesn't crash
} else {
- QVERIFY( func == 0 );
+ QVERIFY(func == nullptr);
}
library.unload();
}
@@ -462,7 +473,7 @@ void tst_QLibrary::isLibrary_data()
QTest::newRow("version+.so+version") << QString("liboil-0.3.so.0.1.0") << so_VALID;
// special tests:
-#ifdef Q_OS_MAC
+#ifdef Q_OS_DARWIN
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;
@@ -499,7 +510,7 @@ void tst_QLibrary::errorString_data()
#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_DARWIN
#else
QTest::newRow("load invalid file") << (int)Load << QFINDTESTDATA("library_path/invalid.so") << false << QString("Cannot load library.*");
#endif
@@ -647,7 +658,7 @@ void tst_QLibrary::multipleInstancesForOneLibrary()
QCOMPARE(lib2.isLoaded(), false);
lib1.load();
QCOMPARE(lib1.isLoaded(), true);
- QCOMPARE(lib2.isLoaded(), true);
+ QCOMPARE(lib2.isLoaded(), false); // lib2 didn't call load()
QCOMPARE(lib1.unload(), true);
QCOMPARE(lib1.isLoaded(), false);
QCOMPARE(lib2.isLoaded(), false);
@@ -656,7 +667,7 @@ void tst_QLibrary::multipleInstancesForOneLibrary()
QCOMPARE(lib1.isLoaded(), true);
QCOMPARE(lib2.isLoaded(), true);
QCOMPARE(lib1.unload(), false);
- QCOMPARE(lib1.isLoaded(), true);
+ QCOMPARE(lib1.isLoaded(), false); // lib1 did call unload()
QCOMPARE(lib2.isLoaded(), true);
QCOMPARE(lib2.unload(), true);
QCOMPARE(lib1.isLoaded(), false);
@@ -665,17 +676,6 @@ void tst_QLibrary::multipleInstancesForOneLibrary()
// 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);
}
QTEST_MAIN(tst_QLibrary)