From 4361c0ee846fb5574a05534186a01779a5e0bb82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A5rten=20Nordheim?= Date: Mon, 18 Jun 2018 15:14:19 +0200 Subject: findtestdata: test 'relative to test source'-fix Before the fix is applied this test fails because QFINDTESTDATA will return "/usr/" instead of the folder with the same name in the current directory. The 'usr' folder can't be located 'next to' the application since this does not trigger the issue (QFINDTESTDATA looks for the folder next to the executable early on). So we put it in a subdirectory and change the current working directory to its parent directory. Change-Id: I627679dcb6f2f6954264e23bfc1a71de3bff7203 Reviewed-by: Jesus Fernandez --- .../selftests/findtestdata/findtestdata.cpp | 24 ++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'tests/auto/testlib') diff --git a/tests/auto/testlib/selftests/findtestdata/findtestdata.cpp b/tests/auto/testlib/selftests/findtestdata/findtestdata.cpp index a775bc1ee5..7d5857faa0 100644 --- a/tests/auto/testlib/selftests/findtestdata/findtestdata.cpp +++ b/tests/auto/testlib/selftests/findtestdata/findtestdata.cpp @@ -134,6 +134,30 @@ void FindTestData::paths() #endif QVERIFY(QFile(testfile_path3).remove()); +#if !defined(Q_OS_WIN) + struct ChdirOnReturn + { + ~ChdirOnReturn() { QDir::setCurrent(dir); } + QString dir; + }; + + // When cross-compiling from Windows to a *nix system the __FILE__ path's canonical path is an + // empty string, which, when used as a prefix, would cause QFINDTESTDATA to look for files in + // root ('/') when trying to look for files relative to the test source. + QString usrPath = app_path + "/temp/usr/"; + QVERIFY(QDir().mkpath(usrPath)); + { + ChdirOnReturn chdirObject{QDir::currentPath()}; + QDir::setCurrent(app_path + "/temp"); + QCOMPARE(QTest::qFindTestData("usr/", + "C:\\path\\to\\source\\source.cpp", + __LINE__, + "C:\\path\\to\\build\\").toLower(), + usrPath.toLower()); + } + QVERIFY(QDir().rmpath(usrPath)); +#endif + // Note, this is expected to generate a warning. // We can't use ignoreMessage, because the warning comes from testlib, // not via a "normal" qWarning. But it's OK, our caller (tst_selftests) -- cgit v1.2.3 From c3059391fea326b7115cf038ecdad8e820a0c2d5 Mon Sep 17 00:00:00 2001 From: Liang Qi Date: Wed, 9 May 2018 13:38:34 +0200 Subject: Make tests compile for Android MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This only enables compilation, it doesn't fix any test. Qt on Android supports process, but not TEST_HELPER_INSTALLS. See also acdd57cb for winrt. android-ndk-r10e is used to compile, see http://doc-snapshots.qt.io/qt5-5.11/androidgs.html . corelib/io/{qdir,qresourceengine} need to be fixed later. Done-with: Frederik Gladhorn Done-with: MÃ¥rten Nordheim Change-Id: I34b924c8ae5d46d6835b8f0a6606450920f4423b Reviewed-by: Thiago Macieira Reviewed-by: Frederik Gladhorn --- tests/auto/testlib/selftests/test/test.pro | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/auto/testlib') diff --git a/tests/auto/testlib/selftests/test/test.pro b/tests/auto/testlib/selftests/test/test.pro index a7487736b3..bd2366f3e8 100644 --- a/tests/auto/testlib/selftests/test/test.pro +++ b/tests/auto/testlib/selftests/test/test.pro @@ -15,5 +15,5 @@ win32 { RESOURCES += ../selftests.qrc include(../selftests.pri) -!winrt: for(file, SUBPROGRAMS): TEST_HELPER_INSTALLS += "../$${file}/$${file}" +!android:!winrt: for(file, SUBPROGRAMS): TEST_HELPER_INSTALLS += "../$${file}/$${file}" -- cgit v1.2.3