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/CMakeLists.txt16
-rw-r--r--tests/auto/corelib/plugin/qlibrary/lib/mylib.c2
-rw-r--r--tests/auto/corelib/plugin/qlibrary/lib2/CMakeLists.txt39
-rw-r--r--tests/auto/corelib/plugin/qlibrary/lib2/mylib.c2
-rw-r--r--tests/auto/corelib/plugin/qlibrary/tst/CMakeLists.txt4
-rw-r--r--tests/auto/corelib/plugin/qlibrary/tst_qlibrary.cpp48
7 files changed, 35 insertions, 82 deletions
diff --git a/tests/auto/corelib/plugin/qlibrary/CMakeLists.txt b/tests/auto/corelib/plugin/qlibrary/CMakeLists.txt
index 0b869cd49c..b8f4af5aa8 100644
--- a/tests/auto/corelib/plugin/qlibrary/CMakeLists.txt
+++ b/tests/auto/corelib/plugin/qlibrary/CMakeLists.txt
@@ -1,7 +1,11 @@
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
-# Generated from qlibrary.pro.
+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)
diff --git a/tests/auto/corelib/plugin/qlibrary/lib/CMakeLists.txt b/tests/auto/corelib/plugin/qlibrary/lib/CMakeLists.txt
index b3e17aea2c..1a318e1483 100644
--- a/tests/auto/corelib/plugin/qlibrary/lib/CMakeLists.txt
+++ b/tests/auto/corelib/plugin/qlibrary/lib/CMakeLists.txt
@@ -1,8 +1,6 @@
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
-# Generated from lib.pro.
-
#####################################################################
## mylib Generic Library:
#####################################################################
@@ -10,14 +8,12 @@
qt_internal_add_cmake_library(mylib
SHARED
INSTALL_DIRECTORY "${INSTALL_TESTSDIR}/tst_qlibrary"
- #OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/../" # special case
SOURCES
mylib.c
LIBRARIES
Qt::Core
)
-# special case begin
set_target_properties(mylib PROPERTIES
VERSION 1.0.0
SOVERSION 1
@@ -69,12 +65,6 @@ else() #Win32
"${CMAKE_CURRENT_BINARY_DIR}/../mylib.dll"
VERBATIM)
endif()
-# special case end
-
-#### Keys ignored in scope 1:.:.:lib.pro:<TRUE>:
-# INSTALLS = "target"
-# TEMPLATE = "lib"
-# target.path = "$$[QT_INSTALL_TESTS]/tst_qlibrary"
## Scopes:
#####################################################################
@@ -83,9 +73,3 @@ qt_internal_extend_target(mylib CONDITION MSVC
DEFINES
WIN32_MSVC
)
-
-#### Keys ignored in scope 4:.:.:lib.pro:(CMAKE_BUILD_TYPE STREQUAL Debug):
-# DESTDIR = "../debug/"
-
-#### Keys ignored in scope 5:.:.:lib.pro:else:
-# DESTDIR = "../release/"
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/CMakeLists.txt b/tests/auto/corelib/plugin/qlibrary/lib2/CMakeLists.txt
index cb9ce49239..f6bdeb453a 100644
--- a/tests/auto/corelib/plugin/qlibrary/lib2/CMakeLists.txt
+++ b/tests/auto/corelib/plugin/qlibrary/lib2/CMakeLists.txt
@@ -1,23 +1,20 @@
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
-# Generated from lib2.pro.
-
#####################################################################
## mylib Generic Library:
#####################################################################
-qt_internal_add_cmake_library(mylib2 # special case
+qt_internal_add_cmake_library(mylib2
SHARED
INSTALL_DIRECTORY "${INSTALL_TESTSDIR}tst_qlibrary"
- #OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/../" # special case
+ #OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/../"
SOURCES
mylib.c
LIBRARIES
Qt::Core
)
-# special case begin
# This test is very "annoying" to get working with CMake as it involves having
# two targets with the same name on the parent scope, which is not possible with
# CMake. Furthermore, on UNIX, this version of the library should override the
@@ -103,41 +100,11 @@ else() #Win32
"${CMAKE_CURRENT_BINARY_DIR}/../mylib.dl2"
VERBATIM)
endif()
-# special case end
-
-#### Keys ignored in scope 1:.:.:lib2.pro:<TRUE>:
-# INSTALLS = "target" "renamed_target"
-# QMAKE_POST_LINK = "$$member(QMAKE_POST_LINK, 0, -2)"
-# TEMPLATE = "lib"
-# VERSION = "2"
-# renamed_target.extra = "$$member(renamed_target.extra, 0, -2)"
-# renamed_target.path = "$$target.path"
-# target.path = "$$[QT_INSTALL_TESTS]$${QMAKE_DIR_SEP}tst_qlibrary"
## Scopes:
#####################################################################
-qt_internal_extend_target(mylib2 CONDITION MSVC # special case
+qt_internal_extend_target(mylib2 CONDITION MSVC
DEFINES
WIN32_MSVC
)
-
-#### Keys ignored in scope 3:.:.:lib2.pro:WIN32:
-# DESTDIR = "../$$BUILD_FOLDER/"
-# files = "$$BUILD_FOLDER$${QMAKE_DIR_SEP}mylib.dl2" "$$BUILD_FOLDER$${QMAKE_DIR_SEP}system.qt.test.mylib.dll"
-
-#### Keys ignored in scope 4:.:.:lib2.pro:(CMAKE_BUILD_TYPE STREQUAL Debug):
-# BUILD_FOLDER = "debug"
-
-#### Keys ignored in scope 5:.:.:lib2.pro:else:
-# BUILD_FOLDER = "release"
-
-#### Keys ignored in scope 6:.:.:lib2.pro:TEMPLATE___contains___vc._x_:
-# src = "$(TargetPath)"
-
-#### Keys ignored in scope 7:.:.:lib2.pro:else:
-# src = "$(DESTDIR_TARGET)"
-
-#### Keys ignored in scope 8:.:.:lib2.pro:else:
-# files = "libmylib.so2" "system.qt.test.mylib.so"
-# src = "$(DESTDIR)$(TARGET)"
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/CMakeLists.txt b/tests/auto/corelib/plugin/qlibrary/tst/CMakeLists.txt
index 7f5ea9de9b..fc452f37f5 100644
--- a/tests/auto/corelib/plugin/qlibrary/tst/CMakeLists.txt
+++ b/tests/auto/corelib/plugin/qlibrary/tst/CMakeLists.txt
@@ -1,8 +1,6 @@
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
-# Generated from tst.pro.
-
#####################################################################
## tst_qlibrary Test:
#####################################################################
@@ -15,7 +13,7 @@ qt_internal_add_test(tst_qlibrary
SOURCES
../tst_qlibrary.cpp
TESTDATA ${test_data}
- LIBRARIES mylib mylib2 # special case
+ LIBRARIES mylib mylib2
)
add_dependencies(tst_qlibrary mylib mylib2)
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)