summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/plugin/qlibrary
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/corelib/plugin/qlibrary')
-rw-r--r--tests/auto/corelib/plugin/qlibrary/CMakeLists.txt6
-rw-r--r--tests/auto/corelib/plugin/qlibrary/lib/mylib.c2
-rw-r--r--tests/auto/corelib/plugin/qlibrary/lib2/mylib.c2
-rw-r--r--tests/auto/corelib/plugin/qlibrary/tst_qlibrary.cpp42
4 files changed, 29 insertions, 23 deletions
diff --git a/tests/auto/corelib/plugin/qlibrary/CMakeLists.txt b/tests/auto/corelib/plugin/qlibrary/CMakeLists.txt
index 06388a7abb..b8f4af5aa8 100644
--- a/tests/auto/corelib/plugin/qlibrary/CMakeLists.txt
+++ b/tests/auto/corelib/plugin/qlibrary/CMakeLists.txt
@@ -1,6 +1,12 @@
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qlibrary LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
add_subdirectory(lib)
add_subdirectory(lib2)
add_subdirectory(tst)
diff --git a/tests/auto/corelib/plugin/qlibrary/lib/mylib.c b/tests/auto/corelib/plugin/qlibrary/lib/mylib.c
index 63622bdf1a..61fe52d182 100644
--- a/tests/auto/corelib/plugin/qlibrary/lib/mylib.c
+++ b/tests/auto/corelib/plugin/qlibrary/lib/mylib.c
@@ -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 <qglobal.h>
diff --git a/tests/auto/corelib/plugin/qlibrary/lib2/mylib.c b/tests/auto/corelib/plugin/qlibrary/lib2/mylib.c
index d036a1ae93..5312a9355b 100644
--- a/tests/auto/corelib/plugin/qlibrary/lib2/mylib.c
+++ b/tests/auto/corelib/plugin/qlibrary/lib2/mylib.c
@@ -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 <qglobal.h>
diff --git a/tests/auto/corelib/plugin/qlibrary/tst_qlibrary.cpp b/tests/auto/corelib/plugin/qlibrary/tst_qlibrary.cpp
index 39e47b8772..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()
@@ -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();
}
@@ -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)