mirror of
https://github.com/crystalidea/qt6windows7.git
synced 2025-07-07 01:35:25 +08:00
qt 6.5.1 original
This commit is contained in:
2
tests/auto/corelib/plugin/qpluginloader/BLACKLIST
Normal file
2
tests/auto/corelib/plugin/qpluginloader/BLACKLIST
Normal file
@ -0,0 +1,2 @@
|
||||
[loadMachO]
|
||||
macos cmake
|
13
tests/auto/corelib/plugin/qpluginloader/CMakeLists.txt
Normal file
13
tests/auto/corelib/plugin/qpluginloader/CMakeLists.txt
Normal file
@ -0,0 +1,13 @@
|
||||
# Copyright (C) 2022 The Qt Company Ltd.
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
add_subdirectory(lib)
|
||||
add_subdirectory(staticplugin)
|
||||
add_subdirectory(theplugin)
|
||||
add_subdirectory(tst)
|
||||
if(UNIX AND NOT ANDROID AND NOT APPLE)
|
||||
add_subdirectory(almostplugin)
|
||||
endif()
|
||||
if(MACOS AND QT_FEATURE_private_tests AND TARGET Qt::Gui)
|
||||
add_subdirectory(machtest)
|
||||
endif()
|
@ -0,0 +1,18 @@
|
||||
# Copyright (C) 2022 The Qt Company Ltd.
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
#####################################################################
|
||||
## almostplugin Generic Library:
|
||||
#####################################################################
|
||||
|
||||
qt_internal_add_cmake_library(almostplugin
|
||||
MODULE
|
||||
INSTALL_DIRECTORY "${INSTALL_TESTSDIR}/tst_qpluginloader/bin"
|
||||
OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/../bin"
|
||||
SOURCES
|
||||
almostplugin.cpp almostplugin.h
|
||||
LIBRARIES
|
||||
Qt::Core
|
||||
)
|
||||
|
||||
qt_autogen_tools_initial_setup(almostplugin)
|
@ -0,0 +1,11 @@
|
||||
// Copyright (C) 2016 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||
#include <QtCore/QString>
|
||||
#include "almostplugin.h"
|
||||
#include <QtCore/qplugin.h>
|
||||
|
||||
QString AlmostPlugin::pluginName() const
|
||||
{
|
||||
unresolvedSymbol();
|
||||
return QLatin1String("Plugin ok");
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
// Copyright (C) 2016 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||
#ifndef ALMOSTPLUGIN_H
|
||||
#define ALMOSTPLUGIN_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QtPlugin>
|
||||
#include "../theplugin/plugininterface.h"
|
||||
|
||||
class AlmostPlugin : public QObject, public PluginInterface
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.autotests.plugininterface" FILE "../empty.json")
|
||||
Q_INTERFACES(PluginInterface)
|
||||
|
||||
public:
|
||||
QString pluginName() const override;
|
||||
void unresolvedSymbol() const;
|
||||
};
|
||||
|
||||
#endif // ALMOSTPLUGIN_H
|
BIN
tests/auto/corelib/plugin/qpluginloader/elftest/debugobj.so
Normal file
BIN
tests/auto/corelib/plugin/qpluginloader/elftest/debugobj.so
Normal file
Binary file not shown.
1
tests/auto/corelib/plugin/qpluginloader/empty.json
Normal file
1
tests/auto/corelib/plugin/qpluginloader/empty.json
Normal file
@ -0,0 +1 @@
|
||||
{}
|
57
tests/auto/corelib/plugin/qpluginloader/fakeplugin.cpp
Normal file
57
tests/auto/corelib/plugin/qpluginloader/fakeplugin.cpp
Normal file
@ -0,0 +1,57 @@
|
||||
// Copyright (C) 2021 Intel Corporation.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||
#ifndef QT_VERSION_MAJOR
|
||||
# include <QtCore/qglobal.h>
|
||||
#endif
|
||||
|
||||
extern "C" void *qt_plugin_instance()
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
#ifdef QT_DEBUG
|
||||
static constexpr bool IsDebug = true;
|
||||
#else
|
||||
static constexpr bool IsDebug = false;
|
||||
#endif
|
||||
|
||||
#ifndef PLUGIN_VERSION
|
||||
# define PLUGIN_VERSION (QT_VERSION_MAJOR >= 7 ? 1 : 0)
|
||||
#endif
|
||||
#if PLUGIN_VERSION == 1
|
||||
# define PLUGIN_HEADER 1, QT_VERSION_MAJOR, 0, IsDebug ? 0x80 : 0
|
||||
#else
|
||||
# define PLUGIN_HEADER 0, QT_VERSION_MAJOR, 0, IsDebug
|
||||
#endif
|
||||
|
||||
#if defined(__ELF__) && PLUGIN_VERSION >= 1
|
||||
// GCC will produce:
|
||||
// fakeplugin.cpp:64:3: warning: ‘no_sanitize’ attribute ignored [-Wattributes]
|
||||
__attribute__((section(".note.qt.metadata"), used, no_sanitize("address"), aligned(sizeof(void*))))
|
||||
static const struct {
|
||||
unsigned n_namesz = sizeof(name);
|
||||
unsigned n_descsz = sizeof(payload);
|
||||
unsigned n_type = 0x74510001;
|
||||
char name[12] = "qt-project!";
|
||||
alignas(unsigned) unsigned char payload[2 + 4] = {
|
||||
PLUGIN_HEADER,
|
||||
0xbf,
|
||||
0xff,
|
||||
};
|
||||
} qtnotemetadata;
|
||||
#elif PLUGIN_VERSION >= 0
|
||||
# ifdef _MSC_VER
|
||||
# pragma section(".qtmetadata",read,shared)
|
||||
__declspec(allocate(".qtmetadata"))
|
||||
# elif defined(__APPLE__)
|
||||
__attribute__ ((section ("__TEXT,qtmetadata"), used))
|
||||
# else
|
||||
__attribute__ ((section(".qtmetadata"), used))
|
||||
# endif
|
||||
static const unsigned char qtmetadata[] = {
|
||||
'Q', 'T', 'M', 'E', 'T', 'A', 'D', 'A', 'T', 'A', ' ', '!',
|
||||
PLUGIN_HEADER,
|
||||
0xbf,
|
||||
0xff,
|
||||
};
|
||||
#endif
|
34
tests/auto/corelib/plugin/qpluginloader/lib/CMakeLists.txt
Normal file
34
tests/auto/corelib/plugin/qpluginloader/lib/CMakeLists.txt
Normal file
@ -0,0 +1,34 @@
|
||||
# Copyright (C) 2022 The Qt Company Ltd.
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
#####################################################################
|
||||
## tst_qpluginloaderlib Generic Library:
|
||||
#####################################################################
|
||||
|
||||
qt_internal_add_cmake_library(tst_qpluginloaderlib
|
||||
SHARED
|
||||
INSTALL_DIRECTORY "${INSTALL_TESTSDIR}/tst_qpluginloader/bin"
|
||||
OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/../bin"
|
||||
SOURCES
|
||||
mylib.c
|
||||
LIBRARIES
|
||||
Qt::Core
|
||||
)
|
||||
|
||||
if(WIN32)
|
||||
# CMake sets for Windows-GNU platforms the suffix "lib"
|
||||
set_property(TARGET tst_qpluginloaderlib PROPERTY PREFIX "")
|
||||
endif()
|
||||
|
||||
## Scopes:
|
||||
#####################################################################
|
||||
|
||||
qt_internal_extend_target(tst_qpluginloaderlib CONDITION MSVC
|
||||
DEFINES
|
||||
WIN32_MSVC
|
||||
)
|
||||
|
||||
set_target_properties(tst_qpluginloaderlib PROPERTIES
|
||||
C_VISIBILITY_PRESET "default"
|
||||
CXX_VISIBILITY_PRESET "default"
|
||||
)
|
28
tests/auto/corelib/plugin/qpluginloader/lib/mylib.c
Normal file
28
tests/auto/corelib/plugin/qpluginloader/lib/mylib.c
Normal file
@ -0,0 +1,28 @@
|
||||
// Copyright (C) 2016 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||
|
||||
#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
|
||||
|
||||
static int pluginVariable = 0xc0ffee;
|
||||
LIB_EXPORT int *pointerAddress()
|
||||
{
|
||||
return &pluginVariable;
|
||||
}
|
||||
|
||||
LIB_EXPORT int BORLAND_STDCALL version()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
@ -0,0 +1 @@
|
||||
|
171
tests/auto/corelib/plugin/qpluginloader/machtest/generate-bad.pl
Normal file
171
tests/auto/corelib/plugin/qpluginloader/machtest/generate-bad.pl
Normal file
@ -0,0 +1,171 @@
|
||||
#!/usr/bin/perl
|
||||
# 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;
|
||||
use constant MH_MAGIC => 0xfeedface;
|
||||
use constant MH_MAGIC_64 => 0xfeedfacf;
|
||||
use constant CPU_TYPE_X86 => 7;
|
||||
use constant CPU_TYPE_X86_64 => CPU_TYPE_X86 | 0x01000000;
|
||||
use constant CPU_SUBTYPE_I386_ALL => 3;
|
||||
use constant MH_DYLIB => 6;
|
||||
use constant LC_SEGMENT => 1;
|
||||
use constant LC_SEGMENT_64 => 0x19;
|
||||
|
||||
my $good = pack("(L7 L2 Z16 L8 Z16 Z16 L9 . L)>",
|
||||
MH_MAGIC, CPU_TYPE_X86, CPU_SUBTYPE_I386_ALL, MH_DYLIB, # 0-3
|
||||
1, # 4: ncmds
|
||||
4 * (37 - 6), # 5: sizeofcmds
|
||||
0, # 6: flags
|
||||
|
||||
LC_SEGMENT, # 7: cmd
|
||||
4 * (37 - 6), # 8: cmdsize
|
||||
'__TEXT', # 9-12: segname
|
||||
0, # 13: vmaddr
|
||||
0x1000, # 14: vmsize
|
||||
0, # 15: fileoff
|
||||
0x204, # 16: filesize
|
||||
7, # 17: maxprot (rwx)
|
||||
5, # 18: initprot (r-x)
|
||||
1, # 19: nsects
|
||||
0, # 20: flags
|
||||
|
||||
'qtmetadata', # 21-24: sectname
|
||||
'__TEXT', # 25-28: segname
|
||||
0x200, # 29: addr
|
||||
4, # 30: size
|
||||
0x200, # 31: offset
|
||||
2, # 32: align (2^2)
|
||||
0, # 33: reloff
|
||||
0, # 34: nreloc
|
||||
0, # 35: flags
|
||||
0, # 36: reserved1
|
||||
0, # 37: reserved2
|
||||
|
||||
0x200,
|
||||
0xc0ffee # data
|
||||
);
|
||||
|
||||
my $good64 = pack("(L8 L2 Z16 Q4 L4 Z16 Z16 Q2 L8 . Q)>",
|
||||
MH_MAGIC_64, CPU_TYPE_X86_64, CPU_SUBTYPE_I386_ALL, MH_DYLIB, # 0-3
|
||||
1, # 4: ncmds
|
||||
4 * (45 - 7), # 5: sizeofcmds
|
||||
0, # 6: flags
|
||||
0, # 7: reserved
|
||||
|
||||
LC_SEGMENT_64, # 8: cmd
|
||||
4 * (45 - 7), # 9: cmdsize
|
||||
'__TEXT', # 10-13: segname
|
||||
0, # 14-15: vmaddr
|
||||
0x1000, # 16-17: vmsize
|
||||
0, # 18-19: fileoff
|
||||
0x208, # 20-21: filesize
|
||||
7, # 22: maxprot (rwx)
|
||||
5, # 23: initprot (r-x)
|
||||
1, # 24: nsects
|
||||
0, # 25: flags
|
||||
|
||||
'qtmetadata', # 26-29: sectname
|
||||
'__TEXT', # 30-33: segname
|
||||
0x200, # 34-35: addr
|
||||
4, # 36-37: size
|
||||
0x200, # 38: offset
|
||||
3, # 39: align (2^3)
|
||||
0, # 40: reloff
|
||||
0, # 41: nreloc
|
||||
0, # 42: flags
|
||||
0, # 43: reserved1
|
||||
0, # 44: reserved2
|
||||
0, # 45: reserved3
|
||||
|
||||
0x200,
|
||||
0xc0ffeec0ffee # data
|
||||
);
|
||||
|
||||
my $fat = pack("L>*",
|
||||
FAT_MAGIC, # 1: magic
|
||||
2, # 2: nfat_arch
|
||||
|
||||
CPU_TYPE_X86, # 3: cputype
|
||||
CPU_SUBTYPE_I386_ALL, # 4: cpusubtype
|
||||
0x1000, # 5: offset
|
||||
0x1000, # 6: size
|
||||
12, # 7: align (2^12)
|
||||
|
||||
CPU_TYPE_X86_64, # 8: cputype
|
||||
CPU_SUBTYPE_I386_ALL, # 9: cpusubtype
|
||||
0x2000, # 10: offset
|
||||
0x1000, # 11: size
|
||||
12, # 12: align (2^12)
|
||||
);
|
||||
|
||||
my $buffer;
|
||||
|
||||
our $badcount = 1;
|
||||
sub generate($) {
|
||||
open OUT, ">", "bad$badcount.dylib" or die("Could not open file bad$badcount.dylib: $!\n");
|
||||
binmode OUT;
|
||||
print OUT $_[0];
|
||||
close OUT;
|
||||
++$badcount;
|
||||
}
|
||||
|
||||
# Bad file 1-2
|
||||
# Except that the cmdsize fields are null
|
||||
$buffer = $good;
|
||||
vec($buffer, 5, 32) = 0;
|
||||
generate $buffer;
|
||||
|
||||
$buffer = $good;
|
||||
vec($buffer, 8, 32) = 0;
|
||||
generate $buffer;
|
||||
|
||||
# Bad file 3-4: same as above but 64-bit
|
||||
$buffer = $good64;
|
||||
vec($buffer, 5, 32) = 0;
|
||||
generate $buffer;
|
||||
|
||||
$buffer = $good64;
|
||||
vec($buffer, 9, 32) = 0;
|
||||
generate $buffer;
|
||||
|
||||
# Bad file 5-8: same as 1-4, but set cmdsize to bigger than file
|
||||
$buffer = $good;
|
||||
vec($buffer, 5, 32) = 0x1000;
|
||||
generate $buffer;
|
||||
|
||||
$buffer = $good;
|
||||
vec($buffer, 8, 32) = 0x1000;
|
||||
generate $buffer;
|
||||
|
||||
$buffer = $good64;
|
||||
vec($buffer, 5, 32) = 0x1000;
|
||||
generate $buffer;
|
||||
|
||||
$buffer = $good64;
|
||||
vec($buffer, 9, 32) = 0x1000;
|
||||
generate $buffer;
|
||||
|
||||
# Bad file 9-10: overflow size+offset
|
||||
$buffer = $good;
|
||||
vec($buffer, 30, 32) = 0xffffffe0;
|
||||
generate $buffer;
|
||||
|
||||
$buffer = $good64;
|
||||
vec($buffer, 36, 32) = 0xffffffff;
|
||||
vec($buffer, 37, 32) = 0xffffffe0;
|
||||
generate $buffer;
|
||||
|
||||
# Bad file 11: FAT binary with just the header
|
||||
generate $fat;
|
||||
|
||||
# Bad file 12: FAT binary where the Mach contents don't match the FAT directory
|
||||
$buffer = pack("a4096 a4096 a4096", $fat, $good64, $good);
|
||||
generate $buffer;
|
||||
|
||||
# Bad file 13: FAT binary with overflowing size
|
||||
$buffer = pack("a4096 a4096 a4096", $fat, $good, $good64);
|
||||
vec($buffer, 5, 32) = 0xfffffffe0;
|
||||
vec($buffer, 10, 32) = 0xfffffffe0;
|
||||
generate $buffer;
|
@ -0,0 +1,74 @@
|
||||
#!/usr/bin/perl
|
||||
# Copyright (C) 2016 Intel Corporation.
|
||||
# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||
|
||||
# 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);
|
@ -0,0 +1 @@
|
||||
void dummy() {}
|
@ -0,0 +1,25 @@
|
||||
# Copyright (C) 2022 The Qt Company Ltd.
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
#####################################################################
|
||||
## staticplugin Generic Library:
|
||||
#####################################################################
|
||||
|
||||
qt_internal_add_cmake_library(staticplugin
|
||||
STATIC
|
||||
SOURCES
|
||||
main.cpp
|
||||
LIBRARIES
|
||||
Qt::Core
|
||||
MOC_OPTIONS
|
||||
"-M"
|
||||
"ExtraMetaData=StaticPlugin"
|
||||
"-M"
|
||||
"ExtraMetaData=foo"
|
||||
)
|
||||
|
||||
# TEMPLATE = "lib"
|
||||
|
||||
qt_autogen_tools_initial_setup(staticplugin)
|
||||
|
||||
target_compile_definitions(staticplugin PRIVATE QT_STATICPLUGIN)
|
@ -0,0 +1,14 @@
|
||||
// Copyright (C) 2018 Intel Corporation.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||
#include <QtPlugin>
|
||||
#include <QObject>
|
||||
|
||||
class StaticPlugin : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PLUGIN_METADATA(IID "SomeIID" URI "qt.test.pluginloader.staticplugin")
|
||||
public:
|
||||
StaticPlugin() {}
|
||||
};
|
||||
|
||||
#include "main.moc"
|
@ -0,0 +1,32 @@
|
||||
# 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
|
||||
LIBRARIES
|
||||
Qt::Core
|
||||
)
|
||||
qt_autogen_tools_initial_setup(theplugin)
|
||||
|
||||
if (UNIX AND NOT APPLE)
|
||||
qt_internal_add_cmake_library(theoldplugin
|
||||
MODULE
|
||||
INSTALL_DIRECTORY "${INSTALL_TESTSDIR}/tst_qpluginloader/bin"
|
||||
OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/../bin"
|
||||
SOURCES
|
||||
theoldplugin.cpp theoldplugin.h
|
||||
LIBRARIES
|
||||
Qt::Core
|
||||
)
|
||||
qt_autogen_tools_initial_setup(theoldplugin)
|
||||
|
||||
# Force unoptimized builds with debugging information so some "QTMETADATA !"
|
||||
# strings appear elsewhere in the binary.
|
||||
target_compile_options(theplugin PRIVATE -O0 -g3)
|
||||
target_compile_options(theoldplugin PRIVATE -O0 -g3)
|
||||
endif()
|
||||
|
@ -0,0 +1,22 @@
|
||||
// Copyright (C) 2016 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||
#ifndef PLUGININTERFACE_H
|
||||
#define PLUGININTERFACE_H
|
||||
|
||||
#include <QtCore/QtGlobal>
|
||||
|
||||
struct PluginInterface {
|
||||
virtual ~PluginInterface() {}
|
||||
virtual QString pluginName() const = 0;
|
||||
};
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
#define PluginInterface_iid "org.qt-project.Qt.autotests.plugininterface"
|
||||
|
||||
Q_DECLARE_INTERFACE(PluginInterface, PluginInterface_iid)
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif // PLUGININTERFACE_H
|
||||
|
@ -0,0 +1,80 @@
|
||||
// Copyright (C) 2021 Intel Corporation.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||
#include "theoldplugin.h"
|
||||
#include <QtCore/QString>
|
||||
#include <QtCore/qplugin.h>
|
||||
|
||||
QString TheOldPlugin::pluginName() const
|
||||
{
|
||||
return QLatin1String("Plugin ok");
|
||||
}
|
||||
|
||||
static int pluginVariable = 0xc0ffee;
|
||||
extern "C" Q_DECL_EXPORT int *pointerAddress()
|
||||
{
|
||||
return &pluginVariable;
|
||||
}
|
||||
|
||||
// This hardcodes the old plugin metadata from before Qt 6.2
|
||||
QT_PLUGIN_METADATA_SECTION
|
||||
static constexpr unsigned char qt_pluginMetaData_ThePlugin[] = {
|
||||
'Q', 'T', 'M', 'E', 'T', 'A', 'D', 'A', 'T', 'A', ' ', '!',
|
||||
// metadata version, Qt version, architectural requirements
|
||||
0, QT_VERSION_MAJOR, QT_VERSION_MINOR, qPluginArchRequirements(),
|
||||
0xbf,
|
||||
// "IID"
|
||||
0x02, 0x78, 0x2b, 'o', 'r', 'g', '.', 'q',
|
||||
't', '-', 'p', 'r', 'o', 'j', 'e', 'c',
|
||||
't', '.', 'Q', 't', '.', 'a', 'u', 't',
|
||||
'o', 't', 'e', 's', 't', 's', '.', 'p',
|
||||
'l', 'u', 'g', 'i', 'n', 'i', 'n', 't',
|
||||
'e', 'r', 'f', 'a', 'c', 'e',
|
||||
// "className"
|
||||
0x03, 0x69, 'T', 'h', 'e', 'P', 'l', 'u',
|
||||
'g', 'i', 'n',
|
||||
// "MetaData"
|
||||
0x04, 0xa2, 0x67, 'K', 'P', 'l', 'u', 'g',
|
||||
'i', 'n', 0xa8, 0x64, 'N', 'a', 'm', 'e',
|
||||
0x6e, 'W', 'i', 'n', 'd', 'o', 'w', 'G',
|
||||
'e', 'o', 'm', 'e', 't', 'r', 'y', 0x68,
|
||||
'N', 'a', 'm', 'e', '[', 'm', 'r', ']',
|
||||
0x78, 0x1f, uchar('\xe0'), uchar('\xa4'), uchar('\x9a'), uchar('\xe0'), uchar('\xa5'), uchar('\x8c'),
|
||||
uchar('\xe0'), uchar('\xa4'), uchar('\x95'), uchar('\xe0'), uchar('\xa4'), uchar('\x9f'), ' ', uchar('\xe0'),
|
||||
uchar('\xa4'), uchar('\xad'), uchar('\xe0'), uchar('\xa5'), uchar('\x82'), uchar('\xe0'), uchar('\xa4'), uchar('\xae'),
|
||||
uchar('\xe0'), uchar('\xa4'), uchar('\xbf'), uchar('\xe0'), uchar('\xa4'), uchar('\xa4'), uchar('\xe0'), uchar('\xa5'),
|
||||
uchar('\x80'), 0x68, 'N', 'a', 'm', 'e', '[', 'p',
|
||||
'a', ']', 0x78, 0x24, uchar('\xe0'), uchar('\xa8'), uchar('\xb5'), uchar('\xe0'),
|
||||
uchar('\xa8'), uchar('\xbf'), uchar('\xe0'), uchar('\xa9'), uchar('\xb0'), uchar('\xe0'), uchar('\xa8'), uchar('\xa1'),
|
||||
uchar('\xe0'), uchar('\xa9'), uchar('\x8b'), uchar('\xe0'), uchar('\xa8'), uchar('\x9c'), uchar('\xe0'), uchar('\xa9'),
|
||||
uchar('\x81'), uchar('\xe0'), uchar('\xa8'), uchar('\xae'), uchar('\xe0'), uchar('\xa9'), uchar('\x88'), uchar('\xe0'),
|
||||
uchar('\xa8'), uchar('\x9f'), uchar('\xe0'), uchar('\xa8'), uchar('\xb0'), uchar('\xe0'), uchar('\xa9'), uchar('\x80'),
|
||||
0x68, 'N', 'a', 'm', 'e', '[', 't', 'h',
|
||||
']', 0x78, 0x39, uchar('\xe0'), uchar('\xb8'), uchar('\xa1'), uchar('\xe0'), uchar('\xb8'),
|
||||
uchar('\xb4'), uchar('\xe0'), uchar('\xb8'), uchar('\x95'), uchar('\xe0'), uchar('\xb8'), uchar('\xb4'), uchar('\xe0'),
|
||||
uchar('\xb8'), uchar('\x82'), uchar('\xe0'), uchar('\xb8'), uchar('\x99'), uchar('\xe0'), uchar('\xb8'), uchar('\xb2'),
|
||||
uchar('\xe0'), uchar('\xb8'), uchar('\x94'), uchar('\xe0'), uchar('\xb8'), uchar('\x82'), uchar('\xe0'), uchar('\xb8'),
|
||||
uchar('\xad'), uchar('\xe0'), uchar('\xb8'), uchar('\x87'), uchar('\xe0'), uchar('\xb8'), uchar('\xab'), uchar('\xe0'),
|
||||
uchar('\xb8'), uchar('\x99'), uchar('\xe0'), uchar('\xb9'), uchar('\x89'), uchar('\xe0'), uchar('\xb8'), uchar('\xb2'),
|
||||
uchar('\xe0'), uchar('\xb8'), uchar('\x95'), uchar('\xe0'), uchar('\xb9'), uchar('\x88'), uchar('\xe0'), uchar('\xb8'),
|
||||
uchar('\xb2'), uchar('\xe0'), uchar('\xb8'), uchar('\x87'), 0x68, 'N', 'a', 'm',
|
||||
'e', '[', 'u', 'k', ']', 0x78, 0x19, uchar('\xd0'),
|
||||
uchar('\xa0'), uchar('\xd0'), uchar('\xbe'), uchar('\xd0'), uchar('\xb7'), uchar('\xd0'), uchar('\xbc'), uchar('\xd1'),
|
||||
uchar('\x96'), uchar('\xd1'), uchar('\x80'), uchar('\xd0'), uchar('\xb8'), ' ', uchar('\xd0'), uchar('\xb2'),
|
||||
uchar('\xd1'), uchar('\x96'), uchar('\xd0'), uchar('\xba'), uchar('\xd0'), uchar('\xbd'), uchar('\xd0'), uchar('\xb0'),
|
||||
0x6b, 'N', 'a', 'm', 'e', '[', 'z', 'h',
|
||||
'_', 'C', 'N', ']', 0x6c, uchar('\xe7'), uchar('\xaa'), uchar('\x97'),
|
||||
uchar('\xe5'), uchar('\x8f'), uchar('\xa3'), uchar('\xe5'), uchar('\xbd'), uchar('\xa2'), uchar('\xe7'), uchar('\x8a'),
|
||||
uchar('\xb6'), 0x6b, 'N', 'a', 'm', 'e', '[', 'z',
|
||||
'h', '_', 'T', 'W', ']', 0x6c, uchar('\xe8'), uchar('\xa6'),
|
||||
uchar('\x96'), uchar('\xe7'), uchar('\xaa'), uchar('\x97'), uchar('\xe4'), uchar('\xbd'), uchar('\x8d'), uchar('\xe7'),
|
||||
uchar('\xbd'), uchar('\xae'), 0x6c, 'S', 'e', 'r', 'v', 'i',
|
||||
'c', 'e', 'T', 'y', 'p', 'e', 's', 0x81,
|
||||
0x68, 'K', 'C', 'M', 'o', 'd', 'u', 'l',
|
||||
'e', 0x76, 'X', '-', 'K', 'D', 'E', '-',
|
||||
'P', 'a', 'r', 'e', 'n', 't', 'C', 'o',
|
||||
'm', 'p', 'o', 'n', 'e', 'n', 't', 's',
|
||||
0x81, 0x6e, 'w', 'i', 'n', 'd', 'o', 'w',
|
||||
'g', 'e', 'o', 'm', 'e', 't', 'r', 'y',
|
||||
0xff,
|
||||
};
|
||||
QT_MOC_EXPORT_PLUGIN(TheOldPlugin, ThePlugin)
|
@ -0,0 +1,21 @@
|
||||
// Copyright (C) 2021 Intel Corportaion.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||
#ifndef THEOLDPLUGIN_H
|
||||
#define THEOLDPLUGIN_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QtPlugin>
|
||||
#include "plugininterface.h"
|
||||
|
||||
class TheOldPlugin : public QObject, public PluginInterface
|
||||
{
|
||||
Q_OBJECT
|
||||
// Q_PLUGIN_METADATA intentionally missing
|
||||
Q_INTERFACES(PluginInterface)
|
||||
|
||||
public:
|
||||
virtual QString pluginName() const override;
|
||||
};
|
||||
|
||||
#endif // THEOLDPLUGIN_H
|
||||
|
@ -0,0 +1,16 @@
|
||||
// Copyright (C) 2016 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||
#include <QtCore/QString>
|
||||
#include "theplugin.h"
|
||||
#include <QtCore/qplugin.h>
|
||||
|
||||
QString ThePlugin::pluginName() const
|
||||
{
|
||||
return QLatin1String("Plugin ok");
|
||||
}
|
||||
|
||||
static int pluginVariable = 0xc0ffee;
|
||||
extern "C" Q_DECL_EXPORT int *pointerAddress()
|
||||
{
|
||||
return &pluginVariable;
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
// Copyright (C) 2016 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||
#ifndef THEPLUGIN_H
|
||||
#define THEPLUGIN_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QtPlugin>
|
||||
#include "plugininterface.h"
|
||||
|
||||
class ThePlugin : public QObject, public PluginInterface
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.autotests.plugininterface" FILE "../utf8_data.json")
|
||||
Q_INTERFACES(PluginInterface)
|
||||
|
||||
public:
|
||||
virtual QString pluginName() const override;
|
||||
};
|
||||
|
||||
#endif // THEPLUGIN_H
|
||||
|
71
tests/auto/corelib/plugin/qpluginloader/tst/CMakeLists.txt
Normal file
71
tests/auto/corelib/plugin/qpluginloader/tst/CMakeLists.txt
Normal file
@ -0,0 +1,71 @@
|
||||
# Copyright (C) 2022 The Qt Company Ltd.
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
#####################################################################
|
||||
## tst_qpluginloader Test:
|
||||
#####################################################################
|
||||
|
||||
# Collect test data
|
||||
list(APPEND test_data "../elftest")
|
||||
list(APPEND test_data "../machtest")
|
||||
|
||||
qt_internal_add_test(tst_qpluginloader
|
||||
OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/../"
|
||||
SOURCES
|
||||
../fakeplugin.cpp
|
||||
../theplugin/plugininterface.h
|
||||
../tst_qpluginloader.cpp
|
||||
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
|
||||
LIBRARIES
|
||||
Qt::CorePrivate
|
||||
)
|
||||
|
||||
qt_internal_extend_target(tst_qpluginloader CONDITION CMAKE_BUILD_TYPE STREQUAL Debug AND WIN32 AND debug_and_release
|
||||
LIBRARIES
|
||||
# Remove: L../staticplugin/debug
|
||||
)
|
||||
|
||||
qt_internal_extend_target(tst_qpluginloader CONDITION WIN32 AND debug_and_release AND NOT CMAKE_BUILD_TYPE STREQUAL Debug
|
||||
LIBRARIES
|
||||
# Remove: L../staticplugin/release
|
||||
)
|
||||
|
||||
qt_internal_extend_target(tst_qpluginloader CONDITION UNIX OR NOT debug_and_release
|
||||
LIBRARIES
|
||||
# Remove: L../staticplugin
|
||||
)
|
1125
tests/auto/corelib/plugin/qpluginloader/tst_qpluginloader.cpp
Normal file
1125
tests/auto/corelib/plugin/qpluginloader/tst_qpluginloader.cpp
Normal file
File diff suppressed because it is too large
Load Diff
17
tests/auto/corelib/plugin/qpluginloader/utf8_data.json
Normal file
17
tests/auto/corelib/plugin/qpluginloader/utf8_data.json
Normal file
@ -0,0 +1,17 @@
|
||||
{
|
||||
"KPlugin": {
|
||||
"Name": "WindowGeometry",
|
||||
"Name[mr]": "चौकट भूमिती",
|
||||
"Name[pa]": "ਵਿੰਡੋਜੁਮੈਟਰੀ",
|
||||
"Name[th]": "มิติขนาดของหน้าต่าง",
|
||||
"Name[uk]": "Розміри вікна",
|
||||
"Name[zh_CN]": "窗口形状",
|
||||
"Name[zh_TW]": "視窗位置",
|
||||
"ServiceTypes": [
|
||||
"KCModule"
|
||||
]
|
||||
},
|
||||
"X-KDE-ParentComponents": [
|
||||
"windowgeometry"
|
||||
]
|
||||
}
|
Reference in New Issue
Block a user