summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/plugin/qpluginloader
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/corelib/plugin/qpluginloader')
-rw-r--r--tests/auto/corelib/plugin/qpluginloader/BLACKLIST2
-rw-r--r--tests/auto/corelib/plugin/qpluginloader/CMakeLists.txt9
-rw-r--r--tests/auto/corelib/plugin/qpluginloader/almostplugin/CMakeLists.txt20
-rw-r--r--tests/auto/corelib/plugin/qpluginloader/almostplugin/almostplugin.cpp29
-rw-r--r--tests/auto/corelib/plugin/qpluginloader/almostplugin/almostplugin.h29
-rw-r--r--tests/auto/corelib/plugin/qpluginloader/fakeplugin.cpp29
-rw-r--r--tests/auto/corelib/plugin/qpluginloader/lib/CMakeLists.txt14
-rw-r--r--tests/auto/corelib/plugin/qpluginloader/lib/mylib.c29
-rw-r--r--tests/auto/corelib/plugin/qpluginloader/machtest/CMakeLists.txt138
-rwxr-xr-xtests/auto/corelib/plugin/qpluginloader/machtest/generate-bad.pl29
-rwxr-xr-xtests/auto/corelib/plugin/qpluginloader/machtest/ppcconverter.pl99
-rw-r--r--tests/auto/corelib/plugin/qpluginloader/staticplugin/CMakeLists.txt6
-rw-r--r--tests/auto/corelib/plugin/qpluginloader/staticplugin/main.cpp29
-rw-r--r--tests/auto/corelib/plugin/qpluginloader/theplugin/CMakeLists.txt7
-rw-r--r--tests/auto/corelib/plugin/qpluginloader/theplugin/plugininterface.h29
-rw-r--r--tests/auto/corelib/plugin/qpluginloader/theplugin/theoldplugin.cpp29
-rw-r--r--tests/auto/corelib/plugin/qpluginloader/theplugin/theoldplugin.h29
-rw-r--r--tests/auto/corelib/plugin/qpluginloader/theplugin/theplugin.cpp29
-rw-r--r--tests/auto/corelib/plugin/qpluginloader/theplugin/theplugin.h29
-rw-r--r--tests/auto/corelib/plugin/qpluginloader/tst/CMakeLists.txt40
-rw-r--r--tests/auto/corelib/plugin/qpluginloader/tst_qpluginloader.cpp170
21 files changed, 323 insertions, 501 deletions
diff --git a/tests/auto/corelib/plugin/qpluginloader/BLACKLIST b/tests/auto/corelib/plugin/qpluginloader/BLACKLIST
deleted file mode 100644
index bfcfdff61b..0000000000
--- a/tests/auto/corelib/plugin/qpluginloader/BLACKLIST
+++ /dev/null
@@ -1,2 +0,0 @@
-[loadMachO]
-macos cmake
diff --git a/tests/auto/corelib/plugin/qpluginloader/CMakeLists.txt b/tests/auto/corelib/plugin/qpluginloader/CMakeLists.txt
index a051bb3ea6..592b8632fa 100644
--- a/tests/auto/corelib/plugin/qpluginloader/CMakeLists.txt
+++ b/tests/auto/corelib/plugin/qpluginloader/CMakeLists.txt
@@ -1,4 +1,11 @@
-# Generated from qpluginloader.pro.
+# 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_qpluginloader LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
add_subdirectory(lib)
add_subdirectory(staticplugin)
diff --git a/tests/auto/corelib/plugin/qpluginloader/almostplugin/CMakeLists.txt b/tests/auto/corelib/plugin/qpluginloader/almostplugin/CMakeLists.txt
index fe5d6295aa..15ae79dfb1 100644
--- a/tests/auto/corelib/plugin/qpluginloader/almostplugin/CMakeLists.txt
+++ b/tests/auto/corelib/plugin/qpluginloader/almostplugin/CMakeLists.txt
@@ -1,4 +1,5 @@
-# Generated from almostplugin.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## almostplugin Generic Library:
@@ -10,23 +11,8 @@ qt_internal_add_cmake_library(almostplugin
OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/../bin"
SOURCES
almostplugin.cpp almostplugin.h
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::Core
)
-#### Keys ignored in scope 1:.:.:almostplugin.pro:<TRUE>:
-# INSTALLS = "target"
-# TEMPLATE = "lib"
-# target.path = "$$[QT_INSTALL_TESTS]/tst_qpluginloader/bin"
-
-## Scopes:
-#####################################################################
-
qt_autogen_tools_initial_setup(almostplugin)
-# special case begin
-# We want the opposite of this
-#qt_internal_extend_target(almostplugin CONDITION GCC
-# LINK_OPTIONS
-# "--Wl,--no-undefined"
-#)
-# special case end
diff --git a/tests/auto/corelib/plugin/qpluginloader/almostplugin/almostplugin.cpp b/tests/auto/corelib/plugin/qpluginloader/almostplugin/almostplugin.cpp
index 75806dd285..29b6df2683 100644
--- a/tests/auto/corelib/plugin/qpluginloader/almostplugin/almostplugin.cpp
+++ b/tests/auto/corelib/plugin/qpluginloader/almostplugin/almostplugin.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QtCore/QString>
#include "almostplugin.h"
#include <QtCore/qplugin.h>
diff --git a/tests/auto/corelib/plugin/qpluginloader/almostplugin/almostplugin.h b/tests/auto/corelib/plugin/qpluginloader/almostplugin/almostplugin.h
index 4dd8df52f0..dea26875c2 100644
--- a/tests/auto/corelib/plugin/qpluginloader/almostplugin/almostplugin.h
+++ b/tests/auto/corelib/plugin/qpluginloader/almostplugin/almostplugin.h
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#ifndef ALMOSTPLUGIN_H
#define ALMOSTPLUGIN_H
diff --git a/tests/auto/corelib/plugin/qpluginloader/fakeplugin.cpp b/tests/auto/corelib/plugin/qpluginloader/fakeplugin.cpp
index 899586ed15..e84bfa6dbc 100644
--- a/tests/auto/corelib/plugin/qpluginloader/fakeplugin.cpp
+++ b/tests/auto/corelib/plugin/qpluginloader/fakeplugin.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2021 Intel Corporation.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2021 Intel Corporation.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#ifndef QT_VERSION_MAJOR
# include <QtCore/qglobal.h>
#endif
diff --git a/tests/auto/corelib/plugin/qpluginloader/lib/CMakeLists.txt b/tests/auto/corelib/plugin/qpluginloader/lib/CMakeLists.txt
index 7914f07c0d..283bdb1352 100644
--- a/tests/auto/corelib/plugin/qpluginloader/lib/CMakeLists.txt
+++ b/tests/auto/corelib/plugin/qpluginloader/lib/CMakeLists.txt
@@ -1,4 +1,5 @@
-# Generated from lib.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## tst_qpluginloaderlib Generic Library:
@@ -10,21 +11,14 @@ qt_internal_add_cmake_library(tst_qpluginloaderlib
OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/../bin"
SOURCES
mylib.c
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::Core
)
-# special case begin
if(WIN32)
# CMake sets for Windows-GNU platforms the suffix "lib"
set_property(TARGET tst_qpluginloaderlib PROPERTY PREFIX "")
endif()
-# special case begin
-
-#### Keys ignored in scope 1:.:.:lib.pro:<TRUE>:
-# INSTALLS = "target"
-# TEMPLATE = "lib"
-# target.path = "$$[QT_INSTALL_TESTS]/tst_qpluginloader/bin"
## Scopes:
#####################################################################
@@ -34,9 +28,7 @@ qt_internal_extend_target(tst_qpluginloaderlib CONDITION MSVC
WIN32_MSVC
)
-# special case begin
set_target_properties(tst_qpluginloaderlib PROPERTIES
C_VISIBILITY_PRESET "default"
CXX_VISIBILITY_PRESET "default"
)
-# special case end
diff --git a/tests/auto/corelib/plugin/qpluginloader/lib/mylib.c b/tests/auto/corelib/plugin/qpluginloader/lib/mylib.c
index 8d23b999c4..3f1fe03114 100644
--- a/tests/auto/corelib/plugin/qpluginloader/lib/mylib.c
+++ b/tests/auto/corelib/plugin/qpluginloader/lib/mylib.c
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <qglobal.h>
diff --git a/tests/auto/corelib/plugin/qpluginloader/machtest/CMakeLists.txt b/tests/auto/corelib/plugin/qpluginloader/machtest/CMakeLists.txt
index 05cd044aa3..6cb69fc46d 100644
--- a/tests/auto/corelib/plugin/qpluginloader/machtest/CMakeLists.txt
+++ b/tests/auto/corelib/plugin/qpluginloader/machtest/CMakeLists.txt
@@ -1,2 +1,138 @@
-# Generated from machtest.pro.
+set_directory_properties(PROPERTIES
+ _qt_good_targets ""
+ _qt_stub_targets ""
+)
+function(add_plugin_binary)
+ set(no_value_options "")
+ set(single_value_options NAME ARCH OUT_TARGET)
+ set(multi_value_options SOURCES)
+ cmake_parse_arguments(PARSE_ARGV 0 arg
+ "${no_value_options}" "${single_value_options}" "${multi_value_options}"
+ )
+
+ set(output_name ${arg_NAME}.${arg_ARCH})
+ set(target tst_qpluginloader.${output_name})
+ set(${arg_OUT_TARGET} ${target} PARENT_SCOPE)
+ set_property(DIRECTORY APPEND PROPERTY _qt_${arg_NAME}_targets ${target})
+ add_library(${target} MODULE ${arg_SOURCES})
+ add_dependencies(tst_qpluginloader ${target})
+ set_target_properties(${target} PROPERTIES
+ OUTPUT_NAME ${output_name}
+ PREFIX ""
+ SUFFIX ".dylib"
+ DEBUG_POSTFIX ""
+ OSX_ARCHITECTURES ${arg_ARCH}
+ )
+endfunction()
+
+function(add_good_binary)
+ set(no_value_options "")
+ set(single_value_options ARCH)
+ set(multi_value_options "")
+ cmake_parse_arguments(PARSE_ARGV 0 arg
+ "${no_value_options}" "${single_value_options}" "${multi_value_options}"
+ )
+
+ add_plugin_binary(
+ NAME good
+ ARCH ${arg_ARCH}
+ SOURCES ../fakeplugin.cpp
+ OUT_TARGET target
+ )
+
+ # We cannot link against Qt6::Core, because the architecture might not match.
+ # Extract the include directories from Qt6::Core.
+ get_target_property(incdirs Qt6::Core INTERFACE_INCLUDE_DIRECTORIES)
+ target_include_directories(${target} PRIVATE ${incdirs})
+
+ # Extract the compile definitions from Qt6::Core and disable version tagging.
+ get_target_property(compdefs Qt6::Core INTERFACE_COMPILE_DEFINITIONS)
+ target_compile_definitions(${target} PRIVATE
+ ${compdefs}
+ QT_NO_VERSION_TAGGING
+ )
+endfunction()
+
+function(add_stub_binary)
+ set(no_value_options "")
+ set(single_value_options ARCH)
+ set(multi_value_options "")
+ cmake_parse_arguments(PARSE_ARGV 0 arg
+ "${no_value_options}" "${single_value_options}" "${multi_value_options}"
+ )
+
+ add_plugin_binary(
+ NAME stub
+ ARCH ${arg_ARCH}
+ SOURCES stub.cpp
+ )
+endfunction()
+
+function(add_fat_binary)
+ set(no_value_options "")
+ set(single_value_options NAME OUT_TARGET)
+ set(multi_value_options TARGETS)
+ cmake_parse_arguments(PARSE_ARGV 0 arg
+ "${no_value_options}" "${single_value_options}" "${multi_value_options}"
+ )
+
+ set(arch_args "")
+ foreach(dependency IN LISTS arg_TARGETS)
+ get_target_property(arch ${dependency} OSX_ARCHITECTURES)
+ list(APPEND arch_args -arch ${arch} $<TARGET_FILE_NAME:${dependency}>)
+ endforeach()
+
+ set(output_name good.fat.${arg_NAME})
+ set(output_file ${output_name}.dylib)
+ set(target tst_qpluginloader.${output_name})
+ set(${arg_OUT_TARGET} ${target} PARENT_SCOPE)
+ add_custom_command(
+ OUTPUT ${output_file}
+ COMMAND lipo -create -output ${output_file} ${arch_args}
+ DEPENDS ${arg_TARGETS}
+ )
+ add_custom_target(${target}
+ DEPENDS ${output_file}
+ )
+ add_dependencies(tst_qpluginloader ${target})
+endfunction()
+
+set(archs_to_test arm64 x86_64)
+foreach(arch IN LISTS archs_to_test)
+ add_good_binary(ARCH ${arch})
+ add_stub_binary(ARCH ${arch})
+endforeach()
+
+get_directory_property(good_targets _qt_good_targets)
+add_fat_binary(NAME all TARGETS ${good_targets})
+
+set(targets ${good_targets})
+list(FILTER targets EXCLUDE REGEX "\\.arm64$")
+add_fat_binary(NAME no-arm64 TARGETS ${targets})
+
+set(targets ${good_targets})
+list(FILTER targets EXCLUDE REGEX "\\.x86_64$")
+add_fat_binary(NAME no-x86_64 TARGETS ${targets})
+
+get_directory_property(stub_targets _qt_stub_targets)
+set(targets ${stub_targets})
+list(FILTER targets INCLUDE REGEX "\\.arm64$")
+add_fat_binary(NAME stub-arm64 TARGETS ${targets})
+
+set(targets ${stub_targets})
+list(FILTER targets INCLUDE REGEX "\\.x86_64$")
+add_fat_binary(NAME stub-x86_64 TARGETS ${targets})
+
+set(bad_binary_names "")
+foreach(i RANGE 1 13)
+ list(APPEND bad_binary_names "bad${i}.dylib")
+endforeach()
+add_custom_command(
+ OUTPUT ${bad_binary_names}
+ COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/generate-bad.pl
+)
+add_custom_target(tst_qpluginloader_generate_bad_binaries
+ DEPENDS ${bad_binary_names}
+)
+add_dependencies(tst_qpluginloader tst_qpluginloader_generate_bad_binaries)
diff --git a/tests/auto/corelib/plugin/qpluginloader/machtest/generate-bad.pl b/tests/auto/corelib/plugin/qpluginloader/machtest/generate-bad.pl
index 4fed135049..3de1eb581a 100755
--- a/tests/auto/corelib/plugin/qpluginloader/machtest/generate-bad.pl
+++ b/tests/auto/corelib/plugin/qpluginloader/machtest/generate-bad.pl
@@ -1,31 +1,6 @@
#!/usr/bin/perl
-#############################################################################
-##
-## Copyright (C) 2016 Intel Corporation.
-## Contact: https://www.qt.io/licensing/
-##
-## This file is the build configuration utility of the Qt Toolkit.
-##
-## $QT_BEGIN_LICENSE:GPL-EXCEPT$
-## Commercial License Usage
-## Licensees holding valid commercial Qt licenses may use this file in
-## accordance with the commercial license agreement provided with the
-## Software or, alternatively, in accordance with the terms contained in
-## a written agreement between you and The Qt Company. For licensing terms
-## and conditions see https://www.qt.io/terms-conditions. For further
-## information use the contact form at https://www.qt.io/contact-us.
-##
-## GNU General Public License Usage
-## Alternatively, this file may be used under the terms of the GNU
-## General Public License version 3 as published by the Free Software
-## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-## included in the packaging of this file. Please review the following
-## information to ensure the GNU General Public License requirements will
-## be met: https://www.gnu.org/licenses/gpl-3.0.html.
-##
-## $QT_END_LICENSE$
-##
-#############################################################################
+# Copyright (C) 2016 Intel Corporation.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
use strict;
use constant FAT_MAGIC => 0xcafebabe;
diff --git a/tests/auto/corelib/plugin/qpluginloader/machtest/ppcconverter.pl b/tests/auto/corelib/plugin/qpluginloader/machtest/ppcconverter.pl
deleted file mode 100755
index 7242d7596b..0000000000
--- a/tests/auto/corelib/plugin/qpluginloader/machtest/ppcconverter.pl
+++ /dev/null
@@ -1,99 +0,0 @@
-#!/usr/bin/perl
-#############################################################################
-##
-## Copyright (C) 2016 Intel Corporation.
-## Contact: https://www.qt.io/licensing/
-##
-## This file is the build configuration utility of the Qt Toolkit.
-##
-## $QT_BEGIN_LICENSE:GPL-EXCEPT$
-## Commercial License Usage
-## Licensees holding valid commercial Qt licenses may use this file in
-## accordance with the commercial license agreement provided with the
-## Software or, alternatively, in accordance with the terms contained in
-## a written agreement between you and The Qt Company. For licensing terms
-## and conditions see https://www.qt.io/terms-conditions. For further
-## information use the contact form at https://www.qt.io/contact-us.
-##
-## GNU General Public License Usage
-## Alternatively, this file may be used under the terms of the GNU
-## General Public License version 3 as published by the Free Software
-## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-## included in the packaging of this file. Please review the following
-## information to ensure the GNU General Public License requirements will
-## be met: https://www.gnu.org/licenses/gpl-3.0.html.
-##
-## $QT_END_LICENSE$
-##
-#############################################################################
-
-# Changes the Mach-O file type header to PowerPC.
-#
-# The header is (from mach-o/loader.h):
-# struct mach_header {
-# uint32_t magic; /* mach magic number identifier */
-# cpu_type_t cputype; /* cpu specifier */
-# cpu_subtype_t cpusubtype; /* machine specifier */
-# uint32_t filetype; /* type of file */
-# uint32_t ncmds; /* number of load commands */
-# uint32_t sizeofcmds; /* the size of all the load commands */
-# uint32_t flags; /* flags */
-# };
-#
-# The 64-bit header is identical in the first three fields, except for a different
-# magic number. We will not touch the magic number, we'll just reset the cputype
-# field to the PowerPC type and the subtype field to zero.
-#
-# We will not change the file's endianness. That means we might create a little-endian
-# PowerPC binary, which could not be run in real life.
-#
-# We will also not change the 64-bit ABI flag, which is found in the cputype's high
-# byte. That means we'll create a PPC64 binary if fed a 64-bit input.
-#
-use strict;
-use constant MH_MAGIC => 0xfeedface;
-use constant MH_CIGAM => 0xcefaedfe;
-use constant MH_MAGIC_64 => 0xfeedfacf;
-use constant MH_CIGAM_64 => 0xcffaedfe;
-use constant CPU_TYPE_POWERPC => 18;
-use constant CPU_SUBTYPE_POWERPC_ALL => 0;
-
-my $infile = shift @ARGV or die("Missing input filename");
-my $outfile = shift @ARGV or die("Missing output filename");
-
-open IN, "<$infile" or die("Can't open $infile for reading: $!\n");
-open OUT, ">$outfile" or die("Can't open $outfile for writing: $!\n");
-
-binmode IN;
-binmode OUT;
-
-# Read the first 12 bytes, which includes the interesting fields of the header
-my $buffer;
-read(IN, $buffer, 12);
-
-my $magic = vec($buffer, 0, 32);
-if ($magic == MH_MAGIC || $magic == MH_MAGIC_64) {
- # Big endian
- # The low byte of cputype is at offset 7
- vec($buffer, 7, 8) = CPU_TYPE_POWERPC;
-} elsif ($magic == MH_CIGAM || $magic == MH_CIGAM_64) {
- # Little endian
- # The low byte of cpytype is at offset 4
- vec($buffer, 4, 8) = CPU_TYPE_POWERPC;
-} else {
- $magic = '';
- $magic .= sprintf("%02X ", $_) for unpack("CCCC", $buffer);
- die("Invalid input. Unknown magic $magic\n");
-}
-vec($buffer, 2, 32) = CPU_SUBTYPE_POWERPC_ALL;
-
-print OUT $buffer;
-
-# Copy the rest
-while (!eof(IN)) {
- read(IN, $buffer, 4096) and
- print OUT $buffer or
- die("Problem copying: $!\n");
-}
-close(IN);
-close(OUT);
diff --git a/tests/auto/corelib/plugin/qpluginloader/staticplugin/CMakeLists.txt b/tests/auto/corelib/plugin/qpluginloader/staticplugin/CMakeLists.txt
index 1448ff3933..647c8ac207 100644
--- a/tests/auto/corelib/plugin/qpluginloader/staticplugin/CMakeLists.txt
+++ b/tests/auto/corelib/plugin/qpluginloader/staticplugin/CMakeLists.txt
@@ -1,4 +1,5 @@
-# Generated from staticplugin.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## staticplugin Generic Library:
@@ -8,7 +9,7 @@ qt_internal_add_cmake_library(staticplugin
STATIC
SOURCES
main.cpp
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::Core
MOC_OPTIONS
"-M"
@@ -17,7 +18,6 @@ qt_internal_add_cmake_library(staticplugin
"ExtraMetaData=foo"
)
-#### Keys ignored in scope 1:.:.:staticplugin.pro:<TRUE>:
# TEMPLATE = "lib"
qt_autogen_tools_initial_setup(staticplugin)
diff --git a/tests/auto/corelib/plugin/qpluginloader/staticplugin/main.cpp b/tests/auto/corelib/plugin/qpluginloader/staticplugin/main.cpp
index 6d163ea336..208096b425 100644
--- a/tests/auto/corelib/plugin/qpluginloader/staticplugin/main.cpp
+++ b/tests/auto/corelib/plugin/qpluginloader/staticplugin/main.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2018 Intel Corporation.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2018 Intel Corporation.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QtPlugin>
#include <QObject>
diff --git a/tests/auto/corelib/plugin/qpluginloader/theplugin/CMakeLists.txt b/tests/auto/corelib/plugin/qpluginloader/theplugin/CMakeLists.txt
index 1e7754a167..dfce9d6a52 100644
--- a/tests/auto/corelib/plugin/qpluginloader/theplugin/CMakeLists.txt
+++ b/tests/auto/corelib/plugin/qpluginloader/theplugin/CMakeLists.txt
@@ -1,10 +1,13 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
qt_internal_add_cmake_library(theplugin
MODULE
INSTALL_DIRECTORY "${INSTALL_TESTSDIR}/tst_qpluginloader/bin"
OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/../bin"
SOURCES
theplugin.cpp theplugin.h
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::Core
)
qt_autogen_tools_initial_setup(theplugin)
@@ -16,7 +19,7 @@ if (UNIX AND NOT APPLE)
OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/../bin"
SOURCES
theoldplugin.cpp theoldplugin.h
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::Core
)
qt_autogen_tools_initial_setup(theoldplugin)
diff --git a/tests/auto/corelib/plugin/qpluginloader/theplugin/plugininterface.h b/tests/auto/corelib/plugin/qpluginloader/theplugin/plugininterface.h
index 12285ba016..3fd6c384a4 100644
--- a/tests/auto/corelib/plugin/qpluginloader/theplugin/plugininterface.h
+++ b/tests/auto/corelib/plugin/qpluginloader/theplugin/plugininterface.h
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#ifndef PLUGININTERFACE_H
#define PLUGININTERFACE_H
diff --git a/tests/auto/corelib/plugin/qpluginloader/theplugin/theoldplugin.cpp b/tests/auto/corelib/plugin/qpluginloader/theplugin/theoldplugin.cpp
index fd7a6e16d3..20e65b4bb0 100644
--- a/tests/auto/corelib/plugin/qpluginloader/theplugin/theoldplugin.cpp
+++ b/tests/auto/corelib/plugin/qpluginloader/theplugin/theoldplugin.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2021 Intel Corporation.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2021 Intel Corporation.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include "theoldplugin.h"
#include <QtCore/QString>
#include <QtCore/qplugin.h>
diff --git a/tests/auto/corelib/plugin/qpluginloader/theplugin/theoldplugin.h b/tests/auto/corelib/plugin/qpluginloader/theplugin/theoldplugin.h
index 57fd5a41c9..786ce3f618 100644
--- a/tests/auto/corelib/plugin/qpluginloader/theplugin/theoldplugin.h
+++ b/tests/auto/corelib/plugin/qpluginloader/theplugin/theoldplugin.h
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2021 Intel Corportaion.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2021 Intel Corportaion.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#ifndef THEOLDPLUGIN_H
#define THEOLDPLUGIN_H
diff --git a/tests/auto/corelib/plugin/qpluginloader/theplugin/theplugin.cpp b/tests/auto/corelib/plugin/qpluginloader/theplugin/theplugin.cpp
index 01563c3dc9..bfa45c7c48 100644
--- a/tests/auto/corelib/plugin/qpluginloader/theplugin/theplugin.cpp
+++ b/tests/auto/corelib/plugin/qpluginloader/theplugin/theplugin.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QtCore/QString>
#include "theplugin.h"
#include <QtCore/qplugin.h>
diff --git a/tests/auto/corelib/plugin/qpluginloader/theplugin/theplugin.h b/tests/auto/corelib/plugin/qpluginloader/theplugin/theplugin.h
index 7c9324b8b3..a6b7e4a083 100644
--- a/tests/auto/corelib/plugin/qpluginloader/theplugin/theplugin.h
+++ b/tests/auto/corelib/plugin/qpluginloader/theplugin/theplugin.h
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#ifndef THEPLUGIN_H
#define THEPLUGIN_H
diff --git a/tests/auto/corelib/plugin/qpluginloader/tst/CMakeLists.txt b/tests/auto/corelib/plugin/qpluginloader/tst/CMakeLists.txt
index 1193a9d731..16dd1cf9cf 100644
--- a/tests/auto/corelib/plugin/qpluginloader/tst/CMakeLists.txt
+++ b/tests/auto/corelib/plugin/qpluginloader/tst/CMakeLists.txt
@@ -1,4 +1,5 @@
-# Generated from tst.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## tst_qpluginloader Test:
@@ -14,30 +15,57 @@ qt_internal_add_test(tst_qpluginloader
../fakeplugin.cpp
../theplugin/plugininterface.h
../tst_qpluginloader.cpp
- PUBLIC_LIBRARIES
+ LIBRARIES
staticplugin
TESTDATA ${test_data}
)
+add_dependencies(tst_qpluginloader tst_qpluginloaderlib staticplugin theplugin)
+if (UNIX)
+ if(NOT APPLE)
+ add_dependencies(tst_qpluginloader theoldplugin)
+ endif()
+ if (NOT ANDROID AND NOT APPLE)
+ add_dependencies(tst_qpluginloader almostplugin)
+ endif()
+endif()
+
+if(ANDROID)
+ add_compile_definitions(ANDROID_ARCH="${CMAKE_ANDROID_ARCH_ABI}")
+ set(plugins
+ theplugin
+ theoldplugin
+ tst_qpluginloaderlib
+ )
+ set(extra_libs)
+ foreach(plugin IN LISTS plugins)
+ list(APPEND extra_libs
+ "${CMAKE_CURRENT_BINARY_DIR}/../bin/lib${plugin}_${CMAKE_ANDROID_ARCH_ABI}.so")
+ endforeach()
+ set_target_properties(tst_qpluginloader PROPERTIES
+ QT_ANDROID_EXTRA_LIBS "${extra_libs}"
+ )
+endif()
+
## Scopes:
#####################################################################
qt_internal_extend_target(tst_qpluginloader CONDITION QT_FEATURE_private_tests
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::CorePrivate
)
qt_internal_extend_target(tst_qpluginloader CONDITION CMAKE_BUILD_TYPE STREQUAL Debug AND WIN32 AND debug_and_release
- PUBLIC_LIBRARIES
+ LIBRARIES
# Remove: L../staticplugin/debug
)
qt_internal_extend_target(tst_qpluginloader CONDITION WIN32 AND debug_and_release AND NOT CMAKE_BUILD_TYPE STREQUAL Debug
- PUBLIC_LIBRARIES
+ LIBRARIES
# Remove: L../staticplugin/release
)
qt_internal_extend_target(tst_qpluginloader CONDITION UNIX OR NOT debug_and_release
- PUBLIC_LIBRARIES
+ LIBRARIES
# Remove: L../staticplugin
)
diff --git a/tests/auto/corelib/plugin/qpluginloader/tst_qpluginloader.cpp b/tests/auto/corelib/plugin/qpluginloader/tst_qpluginloader.cpp
index fcce21433e..f4ecf5bfb3 100644
--- a/tests/auto/corelib/plugin/qpluginloader/tst_qpluginloader.cpp
+++ b/tests/auto/corelib/plugin/qpluginloader/tst_qpluginloader.cpp
@@ -1,31 +1,6 @@
-/****************************************************************************
-**
-** Copyright (C) 2020 The Qt Company Ltd.
-** Copyright (C) 2021 Intel Corporation.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2020 The Qt Company Ltd.
+// Copyright (C) 2021 Intel Corporation.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QTest>
#include <QSignalSpy>
@@ -41,6 +16,8 @@
# include <QtCore/private/qmachparser_p.h>
#endif
+using namespace Qt::StringLiterals;
+
// Helper macros to let us know if some suffixes are valid
#define bundle_VALID false
#define dylib_VALID false
@@ -153,7 +130,7 @@ static std::unique_ptr<QTemporaryFile> patchElf(const QString &source, ElfPatche
const char *basename = QTest::currentDataTag();
if (!basename)
basename = QTest::currentTestFunction();
- tmplib.reset(new QTemporaryFile(basename + QString(".XXXXXX" SUFFIX)));
+ tmplib.reset(new QTemporaryFile(QDir::currentPath() + u'/' + basename + u".XXXXXX" SUFFIX ""_s));
QVERIFY2(tmplib->open(), qPrintable(tmplib->errorString()));
// sanity-check
@@ -185,12 +162,22 @@ static std::unique_ptr<QTemporaryFile> patchElf(const QString &source, ElfPatche
static QString sys_qualifiedLibraryName(const QString &fileName)
{
+#ifdef Q_OS_ANDROID
+ // On Android all the libraries must be located in the APK's libs subdir
+ const QStringList paths = QCoreApplication::libraryPaths();
+ if (!paths.isEmpty()) {
+ return QLatin1String("%1/%2%3_%4%5").arg(paths.first(), PREFIX, fileName,
+ ANDROID_ARCH, SUFFIX);
+ }
+ return fileName;
+#else
QString name = QLatin1String("bin/") + QLatin1String(PREFIX) + fileName + QLatin1String(SUFFIX);
const QString libname = QFINDTESTDATA(name);
QFileInfo fi(libname);
if (fi.exists())
return fi.canonicalFilePath();
return libname;
+#endif
}
QT_FORWARD_DECLARE_CLASS(QPluginLoader)
@@ -221,6 +208,7 @@ private slots:
void preloadedPlugin_data();
void preloadedPlugin();
void staticPlugins();
+ void reregisteredStaticPlugins();
};
Q_IMPORT_PLUGIN(StaticPlugin)
@@ -292,7 +280,9 @@ void tst_QPluginLoader::errorString()
QVERIFY(!unloaded);
}
-#if !defined(Q_OS_WIN) && !defined(Q_OS_MAC) && !defined(Q_OS_HPUX)
+// A bug in QNX causes the test to crash on exit after attempting to load
+// a shared library with undefined symbols (tracked as QTBUG-114682).
+#if !defined(Q_OS_WIN) && !defined(Q_OS_DARWIN) && !defined(Q_OS_HPUX) && !defined(Q_OS_QNX)
{
QPluginLoader loader( sys_qualifiedLibraryName("almostplugin")); //a plugin with unresolved symbols
loader.setLoadHints(QLibrary::ResolveAllSymbolsHint);
@@ -349,10 +339,37 @@ void tst_QPluginLoader::loadHints()
QSKIP("This test requires Qt to create shared libraries.");
#endif
QPluginLoader loader;
- QCOMPARE(loader.loadHints(), QLibrary::LoadHints{}); //Do not crash
+ QCOMPARE(loader.loadHints(), QLibrary::PreventUnloadHint); //Do not crash
loader.setLoadHints(QLibrary::ResolveAllSymbolsHint);
+ QCOMPARE(loader.loadHints(), QLibrary::ResolveAllSymbolsHint);
+ // We can clear load hints when file name is not set.
+ loader.setLoadHints(QLibrary::LoadHints{});
+ QCOMPARE(loader.loadHints(), QLibrary::LoadHints{});
+ // Set the hints again
+ loader.setLoadHints(QLibrary::ResolveAllSymbolsHint);
+ QCOMPARE(loader.loadHints(), QLibrary::ResolveAllSymbolsHint);
loader.setFileName( sys_qualifiedLibraryName("theplugin")); //a plugin
QCOMPARE(loader.loadHints(), QLibrary::ResolveAllSymbolsHint);
+
+ QPluginLoader loader4;
+ QCOMPARE(loader4.loadHints(), QLibrary::PreventUnloadHint);
+ loader4.setLoadHints(QLibrary::LoadHints{});
+ QCOMPARE(loader4.loadHints(), QLibrary::LoadHints{});
+ loader4.setFileName(sys_qualifiedLibraryName("theplugin"));
+ // Hints are merged with hints from the previous loader.
+ QCOMPARE(loader4.loadHints(), QLibrary::ResolveAllSymbolsHint);
+ // We cannot clear load hints after associating the loader with a file.
+ loader.setLoadHints(QLibrary::LoadHints{});
+ QCOMPARE(loader.loadHints(), QLibrary::ResolveAllSymbolsHint);
+
+ QPluginLoader loader2;
+ QCOMPARE(loader2.loadHints(), QLibrary::PreventUnloadHint);
+ loader2.setFileName(sys_qualifiedLibraryName("theplugin"));
+ // Hints are merged with hints from previous loaders.
+ QCOMPARE(loader2.loadHints(), QLibrary::PreventUnloadHint | QLibrary::ResolveAllSymbolsHint);
+
+ QPluginLoader loader3(sys_qualifiedLibraryName("theplugin"));
+ QCOMPARE(loader3.loadHints(), QLibrary::PreventUnloadHint | QLibrary::ResolveAllSymbolsHint);
}
void tst_QPluginLoader::deleteinstanceOnUnload()
@@ -382,14 +399,14 @@ void tst_QPluginLoader::deleteinstanceOnUnload()
QVERIFY(spy2.isValid());
if (pass == 0) {
QCOMPARE(loader2.unload(), false); // refcount not reached 0, not really unloaded
- QCOMPARE(spy1.count(), 0);
- QCOMPARE(spy2.count(), 0);
+ QCOMPARE(spy1.size(), 0);
+ QCOMPARE(spy2.size(), 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);
+ QCOMPARE(spy1.size(), 1);
+ QCOMPARE(spy2.size(), 1);
}
}
@@ -457,7 +474,7 @@ static void loadCorruptElfCommonRows()
memcpy(h, &o, sizeof(o));
});
newRow("invalid-word-size", "file is for a different word size", [](H h) {
- h->e_ident[EI_CLASS] = ELFCLASSNONE;;
+ h->e_ident[EI_CLASS] = ELFCLASSNONE;
});
newRow("unknown-word-size", "file is for a different word size", [](H h) {
h->e_ident[EI_CLASS] |= 0x40;
@@ -843,26 +860,23 @@ void tst_QPluginLoader::loadMachO_data()
# ifdef Q_PROCESSOR_X86_64
QTest::newRow("machtest/good.x86_64.dylib") << true;
- QTest::newRow("machtest/good.i386.dylib") << false;
+ QTest::newRow("machtest/good.arm64.dylib") << false;
QTest::newRow("machtest/good.fat.no-x86_64.dylib") << false;
- QTest::newRow("machtest/good.fat.no-i386.dylib") << true;
-# elif defined(Q_PROCESSOR_X86_32)
- QTest::newRow("machtest/good.i386.dylib") << true;
+ QTest::newRow("machtest/good.fat.no-arm64.dylib") << true;
+# elif defined(Q_PROCESSOR_ARM)
+ QTest::newRow("machtest/good.arm64.dylib") << true;
QTest::newRow("machtest/good.x86_64.dylib") << false;
- QTest::newRow("machtest/good.fat.no-i386.dylib") << false;
+ QTest::newRow("machtest/good.fat.no-arm64.dylib") << false;
QTest::newRow("machtest/good.fat.no-x86_64.dylib") << true;
# endif
-# ifndef Q_PROCESSOR_POWER_64
- QTest::newRow("machtest/good.ppc64.dylib") << false;
-# endif
QTest::newRow("machtest/good.fat.all.dylib") << true;
QTest::newRow("machtest/good.fat.stub-x86_64.dylib") << false;
- QTest::newRow("machtest/good.fat.stub-i386.dylib") << false;
+ QTest::newRow("machtest/good.fat.stub-arm64.dylib") << false;
QDir d(QFINDTESTDATA("machtest"));
- QStringList badlist = d.entryList(QStringList() << "bad*.dylib");
- foreach (const QString &bad, badlist)
+ const QStringList badlist = d.entryList(QStringList() << "bad*.dylib");
+ for (const QString &bad : badlist)
QTest::newRow(qPrintable("machtest/" + bad)) << false;
#endif
}
@@ -886,12 +900,7 @@ void tst_QPluginLoader::loadMachO()
}
QVERIFY(r.pos > 0);
- QVERIFY(size_t(r.length) >= sizeof(void*));
QVERIFY(r.pos + r.length < data.size());
- QCOMPARE(r.pos & (sizeof(void*) - 1), 0UL);
-
- void *value = *(void**)(data.constData() + r.pos);
- QCOMPARE(value, sizeof(void*) > 4 ? (void*)(0xc0ffeec0ffeeL) : (void*)0xc0ffee);
// now that we know it's valid, let's try to make it invalid
ulong offeredlen = r.pos;
@@ -909,11 +918,19 @@ void tst_QPluginLoader::relativePath()
#if !defined(QT_SHARED)
QSKIP("This test requires Qt to create shared libraries.");
#endif
+#ifdef Q_OS_ANDROID
+ // On Android we do not need to explicitly set library paths, as they are
+ // already set.
+ // But we need to use ARCH suffix in pulgin name
+ const QString pluginName("theplugin_" ANDROID_ARCH SUFFIX);
+#else
// Windows binaries run from release and debug subdirs, so we can't rely on the current dir.
const QString binDir = QFINDTESTDATA("bin");
QVERIFY(!binDir.isEmpty());
QCoreApplication::addLibraryPath(binDir);
- QPluginLoader loader("theplugin" SUFFIX);
+ const QString pluginName("theplugin" SUFFIX);
+#endif
+ QPluginLoader loader(pluginName);
loader.load(); // not recommended, instance() should do the job.
PluginInterface *instance = qobject_cast<PluginInterface*>(loader.instance());
QVERIFY(instance);
@@ -926,13 +943,27 @@ void tst_QPluginLoader::absolutePath()
#if !defined(QT_SHARED)
QSKIP("This test requires Qt to create shared libraries.");
#endif
+#ifdef Q_OS_ANDROID
+ // On Android we need to clear library paths to make sure that the absolute
+ // path works
+ const QStringList libraryPaths = QCoreApplication::libraryPaths();
+ QVERIFY(!libraryPaths.isEmpty());
+ QCoreApplication::setLibraryPaths(QStringList());
+ const QString pluginPath(libraryPaths.first() + "/" PREFIX "theplugin_" ANDROID_ARCH SUFFIX);
+#else
// Windows binaries run from release and debug subdirs, so we can't rely on the current dir.
const QString binDir = QFINDTESTDATA("bin");
QVERIFY(!binDir.isEmpty());
QVERIFY(QDir::isAbsolutePath(binDir));
- QPluginLoader loader(binDir + "/" PREFIX "theplugin" SUFFIX);
+ const QString pluginPath(binDir + "/" PREFIX "theplugin" SUFFIX);
+#endif
+ QPluginLoader loader(pluginPath);
loader.load(); // not recommended, instance() should do the job.
PluginInterface *instance = qobject_cast<PluginInterface*>(loader.instance());
+#ifdef Q_OS_ANDROID
+ // Restore library paths
+ QCoreApplication::setLibraryPaths(libraryPaths);
+#endif
QVERIFY(instance);
QCOMPARE(instance->pluginName(), QLatin1String("Plugin ok"));
QVERIFY(loader.unload());
@@ -953,7 +984,7 @@ void tst_QPluginLoader::reloadPlugin()
QSignalSpy spy(loader.instance(), &QObject::destroyed);
QVERIFY(spy.isValid());
QVERIFY(loader.unload()); // refcount reached 0, did really unload
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
// reload plugin
QVERIFY(loader.load());
@@ -968,6 +999,10 @@ void tst_QPluginLoader::reloadPlugin()
void tst_QPluginLoader::loadSectionTableStrippedElf()
{
+#ifdef Q_OS_ANDROID
+ if (QNativeInterface::QAndroidApplication::sdkVersion() >= 24)
+ QSKIP("Android 7+ (API 24+) linker doesn't allow missing or bad section header");
+#endif
#if !defined(QT_SHARED)
QSKIP("This test requires a shared build of Qt, as QPluginLoader::setFileName is a no-op in static builds");
#elif !defined(Q_OF_ELF)
@@ -1060,19 +1095,18 @@ void tst_QPluginLoader::staticPlugins()
const QObjectList instances = QPluginLoader::staticInstances();
QVERIFY(instances.size());
- bool found = false;
- for (QObject *obj : instances) {
- found = obj->metaObject()->className() == QLatin1String("StaticPlugin");
- if (found)
- break;
- }
- QVERIFY(found);
+ // ensure the our plugin only shows up once
+ int foundCount = std::count_if(instances.begin(), instances.end(), [](QObject *obj) {
+ return obj->metaObject()->className() == QLatin1String("StaticPlugin");
+ });
+ QCOMPARE(foundCount, 1);
const auto plugins = QPluginLoader::staticPlugins();
QCOMPARE(plugins.size(), instances.size());
// find the metadata
QJsonObject metaData;
+ bool found = false;
for (const auto &p : plugins) {
metaData = p.metaData();
found = metaData.value("className").toString() == QLatin1String("StaticPlugin");
@@ -1088,6 +1122,18 @@ void tst_QPluginLoader::staticPlugins()
QCOMPARE(metaData.value("URI").toString(), "qt.test.pluginloader.staticplugin");
}
+void tst_QPluginLoader::reregisteredStaticPlugins()
+{
+ // the Q_IMPORT_PLUGIN macro will have already done this
+ qRegisterStaticPluginFunction(qt_static_plugin_StaticPlugin());
+ staticPlugins();
+ if (QTest::currentTestFailed())
+ return;
+
+ qRegisterStaticPluginFunction(qt_static_plugin_StaticPlugin());
+ staticPlugins();
+}
+
QTEST_MAIN(tst_QPluginLoader)
#include "tst_qpluginloader.moc"