diff --git a/tests/auto/corelib/plugin/CMakeLists.txt b/tests/auto/corelib/plugin/CMakeLists.txt index 06ed2361e7..f6b3d68511 100644 --- a/tests/auto/corelib/plugin/CMakeLists.txt +++ b/tests/auto/corelib/plugin/CMakeLists.txt @@ -4,9 +4,11 @@ if(QT_BUILD_SHARED_LIBS) add_subdirectory(qfactoryloader) endif() add_subdirectory(quuid) -# QTBUG-87438 # special case -if(QT_FEATURE_library AND NOT ANDROID) - add_subdirectory(qpluginloader) +if(QT_FEATURE_library) + # QTBUG-87438 # special case + if(NOT ANDROID) + add_subdirectory(qpluginloader) + endif() add_subdirectory(qlibrary) endif() if(QT_BUILD_SHARED_LIBS AND QT_FEATURE_library) diff --git a/tests/auto/corelib/plugin/qlibrary/lib/CMakeLists.txt b/tests/auto/corelib/plugin/qlibrary/lib/CMakeLists.txt index 3ae8d11b6c..25292c0cc5 100644 --- a/tests/auto/corelib/plugin/qlibrary/lib/CMakeLists.txt +++ b/tests/auto/corelib/plugin/qlibrary/lib/CMakeLists.txt @@ -37,7 +37,8 @@ if (MACOS) "${CMAKE_CURRENT_BINARY_DIR}/*dylib" "${CMAKE_CURRENT_BINARY_DIR}/../") elseif (UNIX) - add_custom_command(TARGET mylib POST_BUILD + if (NOT ANDROID) + add_custom_command(TARGET mylib POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different $ "${CMAKE_CURRENT_BINARY_DIR}/../libmylib.so.1.0.0" @@ -48,6 +49,16 @@ elseif (UNIX) "libmylib.so.1.0.0" "${CMAKE_CURRENT_BINARY_DIR}/../libmylib.so1" VERBATIM) + else() + # Android does not use symlinks. Also, according to our conventions, + # libraries on Android MUST be named in the following pattern: + # lib*.so + add_custom_command(TARGET mylib POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy_if_different + $ + "${CMAKE_CURRENT_BINARY_DIR}/../libmylib.so" + VERBATIM) + endif() else() #Win32 add_custom_command(TARGET mylib POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different diff --git a/tests/auto/corelib/plugin/qlibrary/lib2/CMakeLists.txt b/tests/auto/corelib/plugin/qlibrary/lib2/CMakeLists.txt index 9caf22f4f9..902c53ea84 100644 --- a/tests/auto/corelib/plugin/qlibrary/lib2/CMakeLists.txt +++ b/tests/auto/corelib/plugin/qlibrary/lib2/CMakeLists.txt @@ -40,25 +40,36 @@ if(WIN32) endif() if (UNIX) - add_custom_command(TARGET mylib2 POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy_if_different + if(NOT ANDROID) + add_custom_command(TARGET mylib2 POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy_if_different + $ + "${CMAKE_CURRENT_BINARY_DIR}/../system.qt.test.mylib.so" + COMMAND ${CMAKE_COMMAND} -E copy_if_different + $ + "${CMAKE_CURRENT_BINARY_DIR}/../libmylib.so.2.0.0" + COMMAND ${CMAKE_COMMAND} -E create_symlink + "libmylib.so.2.0.0" + "${CMAKE_CURRENT_BINARY_DIR}/../libmylib.so.2" + COMMAND ${CMAKE_COMMAND} -E remove + "${CMAKE_CURRENT_BINARY_DIR}/../libmylib.so" + COMMAND ${CMAKE_COMMAND} -E create_symlink + "libmylib.so.2.0.0" + "${CMAKE_CURRENT_BINARY_DIR}/../libmylib.so" + COMMAND ${CMAKE_COMMAND} -E create_symlink + "libmylib.so.2.0.0" + "${CMAKE_CURRENT_BINARY_DIR}/../libmylib.so2" + VERBATIM) + else() + # Android does not use symlinks. Also, according to our conventions, + # libraries on Android MUST be named in the following pattern: + # lib*.so + add_custom_command(TARGET mylib2 POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy_if_different $ - "${CMAKE_CURRENT_BINARY_DIR}/../system.qt.test.mylib.so" - COMMAND ${CMAKE_COMMAND} -E copy_if_different - $ - "${CMAKE_CURRENT_BINARY_DIR}/../libmylib.so.2.0.0" - COMMAND ${CMAKE_COMMAND} -E create_symlink - "libmylib.so.2.0.0" - "${CMAKE_CURRENT_BINARY_DIR}/../libmylib.so.2" - COMMAND ${CMAKE_COMMAND} -E remove - "${CMAKE_CURRENT_BINARY_DIR}/../libmylib.so" - COMMAND ${CMAKE_COMMAND} -E create_symlink - "libmylib.so.2.0.0" - "${CMAKE_CURRENT_BINARY_DIR}/../libmylib.so" - COMMAND ${CMAKE_COMMAND} -E create_symlink - "libmylib.so.2.0.0" - "${CMAKE_CURRENT_BINARY_DIR}/../libmylib.so2" - VERBATIM) + "${CMAKE_CURRENT_BINARY_DIR}/../libsystem.qt.test.mylib.so" + VERBATIM) + endif() else() #Win32 add_custom_command(TARGET mylib2 POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different diff --git a/tests/auto/corelib/plugin/qlibrary/tst/CMakeLists.txt b/tests/auto/corelib/plugin/qlibrary/tst/CMakeLists.txt index 73c05aeebe..ee50a7f581 100644 --- a/tests/auto/corelib/plugin/qlibrary/tst/CMakeLists.txt +++ b/tests/auto/corelib/plugin/qlibrary/tst/CMakeLists.txt @@ -15,39 +15,13 @@ qt_internal_add_test(tst_qlibrary LIBRARIES mylib mylib2 # special case ) -## Scopes: -##################################################################### +add_dependencies(tst_qlibrary mylib mylib2) if(ANDROID) - # special case begin - set_source_files_properties( - ${CMAKE_CURRENT_BINARY_DIR}/../libmylib.so - PROPERTIES QT_RESOURCE_TARGET_DEPENDENCY mylib - ) - set_source_files_properties( - ${CMAKE_CURRENT_BINARY_DIR}/../libmylib.so2 - ${CMAKE_CURRENT_BINARY_DIR}/../system.qt.test.mylib.so - PROPERTIES QT_RESOURCE_TARGET_DEPENDENCY mylib2 - ) - # special case end - # Resources: - set(qmake_libs_resource_files - # special case begin - #libmylib.prl - libmylib.so - libmylib.so2 - system.qt.test.mylib.so - # special case end - ) - - list(TRANSFORM qmake_libs_resource_files PREPEND "${CMAKE_CURRENT_BINARY_DIR}/../") - - qt_internal_add_resource(tst_qlibrary "qmake_libs" - PREFIX - "android_test_data" - BASE - "${CMAKE_CURRENT_BINARY_DIR}/.." - FILES - ${qmake_libs_resource_files} - ) + list(APPEND extra_libs + "${CMAKE_CURRENT_BINARY_DIR}/../libmylib.so") + list(APPEND extra_libs + "${CMAKE_CURRENT_BINARY_DIR}/../libsystem.qt.test.mylib.so") + set_target_properties(tst_qlibrary PROPERTIES + QT_ANDROID_EXTRA_LIBS "${extra_libs}") endif() diff --git a/tests/auto/corelib/plugin/qlibrary/tst_qlibrary.cpp b/tests/auto/corelib/plugin/qlibrary/tst_qlibrary.cpp index 6ecbf393e2..e59752f2fb 100644 --- a/tests/auto/corelib/plugin/qlibrary/tst_qlibrary.cpp +++ b/tests/auto/corelib/plugin/qlibrary/tst_qlibrary.cpp @@ -104,9 +104,6 @@ enum QLibraryOperation { QString sys_qualifiedLibraryName(const QString &fileName); QString directory; -#ifdef Q_OS_ANDROID - QSharedPointer temporaryDir; -#endif private slots: void initTestCase(); @@ -141,24 +138,9 @@ typedef int (*VersionFunction)(void); void tst_QLibrary::initTestCase() { #ifdef Q_OS_ANDROID - auto tempDir = QEXTRACTTESTDATA("android_test_data"); - - QVERIFY2(QDir::setCurrent(tempDir->path()), qPrintable("Could not chdir to " + tempDir->path())); - - // copy :/library_path into ./library_path - QVERIFY(QDir().mkdir("library_path")); - QDirIterator iterator(":/library_path", QDirIterator::Subdirectories); - while (iterator.hasNext()) { - iterator.next(); - QFileInfo sourceFileInfo(iterator.path()); - QFileInfo targetFileInfo("./library_path/" + sourceFileInfo.fileName()); - if (!targetFileInfo.exists()) { - QDir().mkpath(targetFileInfo.path()); - QVERIFY(QFile::copy(sourceFileInfo.filePath(), targetFileInfo.filePath())); - } - } - directory = tempDir->path(); - temporaryDir = std::move(tempDir); + const QStringList paths = QCoreApplication::libraryPaths(); + QVERIFY(!paths.isEmpty()); + directory = paths.first(); #else // chdir to our testdata directory, and use relative paths in some tests. QString testdatadir = QFileInfo(QFINDTESTDATA("library_path")).absolutePath(); @@ -224,7 +206,10 @@ void tst_QLibrary::load_data() QTest::newRow( "ok03 (with many dots)" ) << appDir + "/system.qt.test.mylib.dll" << true; # elif defined Q_OS_UNIX QTest::newRow( "ok01 (with suffix)" ) << appDir + "/libmylib" SUFFIX << true; +#ifndef Q_OS_ANDROID + // We do not support non-standard suffixes on Android QTest::newRow( "ok02 (with non-standard suffix)" ) << appDir + "/libmylib.so2" << true; +#endif QTest::newRow( "ok03 (with many dots)" ) << appDir + "/system.qt.test.mylib.so" << true; # endif // Q_OS_UNIX } @@ -438,7 +423,10 @@ void tst_QLibrary::loadHints_data() QTest::newRow( "ok03 (with many dots)" ) << appDir + "/system.qt.test.mylib.dll" << int(lh) << true; # elif defined Q_OS_UNIX QTest::newRow( "ok01 (with suffix)" ) << appDir + "/libmylib" SUFFIX << int(lh) << true; +#ifndef Q_OS_ANDROID + // We do not support non-standard suffixes on Android QTest::newRow( "ok02 (with non-standard suffix)" ) << appDir + "/libmylib.so2" << int(lh) << true; +#endif QTest::newRow( "ok03 (with many dots)" ) << appDir + "/system.qt.test.mylib.so" << int(lh) << true; # endif // Q_OS_UNIX }