diff options
Diffstat (limited to 'tests/auto/corelib/io')
22 files changed, 337 insertions, 68 deletions
diff --git a/tests/auto/corelib/io/CMakeLists.txt b/tests/auto/corelib/io/CMakeLists.txt index 7fdf4b52b0..1e66aa8956 100644 --- a/tests/auto/corelib/io/CMakeLists.txt +++ b/tests/auto/corelib/io/CMakeLists.txt @@ -25,7 +25,7 @@ add_subdirectory(qloggingcategory) add_subdirectory(qnodebug) add_subdirectory(qsavefile) add_subdirectory(qstandardpaths) -if(NOT QNX) +if(NOT QNX AND NOT VXWORKS) add_subdirectory(qstorageinfo) endif() add_subdirectory(qtemporarydir) @@ -68,3 +68,9 @@ endif() if(QT_FEATURE_private_tests) add_subdirectory(qzip) endif() +if(NOT (MACOS AND "$ENV{QT_BUILD_ENVIRONMENT}" STREQUAL "ci")) + # On macOS the new features require at least macOS 13.3, + # but we also run the tests on older OS versions. + # So just skip macOS on CI for now. + add_subdirectory(qfloat16format) +endif() diff --git a/tests/auto/corelib/io/largefile/tst_largefile.cpp b/tests/auto/corelib/io/largefile/tst_largefile.cpp index 6fa3569c4f..f5af3bde63 100644 --- a/tests/auto/corelib/io/largefile/tst_largefile.cpp +++ b/tests/auto/corelib/io/largefile/tst_largefile.cpp @@ -46,6 +46,10 @@ public: // This means that files are limited to 2 GB − 1 bytes. // Limit max size to 256MB maxSizeBits = 28; // 256 MiB + #elif defined(Q_OS_VXWORKS) + // VxWorks doesn't support sparse files, also, default /tmp directory is a RAM-disk which + // limits its capacity. + maxSizeBits = 28; // 256 MiB #elif defined (Q_OS_WASM) maxSizeBits = 28; // 256 MiB #elif defined(QT_LARGEFILE_SUPPORT) @@ -494,6 +498,7 @@ void tst_LargeFile::mapFile() // 32-bit: limited to 44-bit offsets (when sizeof(off_t) == 8) //Windows: memory-mapping beyond EOF is not allowed //wasm: as for linux +//VxWorks: memory-mapping beyond EOF is not allowed void tst_LargeFile::mapOffsetOverflow() { enum { @@ -506,6 +511,9 @@ void tst_LargeFile::mapOffsetOverflow() #elif (defined(Q_OS_LINUX) || defined(Q_OS_ANDROID)) && (Q_PROCESSOR_WORDSIZE == 4) Succeeds = true, MaxOffset = sizeof(QT_OFF_T) > 4 ? 43 : 30 +#elif defined(Q_OS_VXWORKS) + Succeeds = false, + MaxOffset = 8 * sizeof(QT_OFF_T) - 1 #else Succeeds = true, MaxOffset = 8 * sizeof(QT_OFF_T) - 1 diff --git a/tests/auto/corelib/io/qdir/tst_qdir.cpp b/tests/auto/corelib/io/qdir/tst_qdir.cpp index b19f158746..7b05a88e81 100644 --- a/tests/auto/corelib/io/qdir/tst_qdir.cpp +++ b/tests/auto/corelib/io/qdir/tst_qdir.cpp @@ -438,7 +438,7 @@ void tst_QDir::mkdirOnSymlink() // create our structure: dir.mkpath("two/three"); - ::symlink("two/three", "symlink"); + QCOMPARE(::symlink("two/three", "symlink"), 0); // try it: QString path = "symlink/../four/five"; @@ -2285,6 +2285,8 @@ void tst_QDir::equalityOperator_data() QString pathinroot("/system/.."); #elif defined(Q_OS_HAIKU) QString pathinroot("/boot/.."); +#elif defined(Q_OS_VXWORKS) + QString pathinroot("/tmp/.."); #else QString pathinroot("/usr/.."); #endif diff --git a/tests/auto/corelib/io/qdirlisting/tst_qdirlisting.cpp b/tests/auto/corelib/io/qdirlisting/tst_qdirlisting.cpp index bb4e1b30d2..e2ac1858da 100644 --- a/tests/auto/corelib/io/qdirlisting/tst_qdirlisting.cpp +++ b/tests/auto/corelib/io/qdirlisting/tst_qdirlisting.cpp @@ -85,9 +85,12 @@ private slots: void uncPaths(); #endif #ifndef Q_OS_WIN - void hiddenDirs_hiddenFiles(); + void hiddenFiles(); + void hiddenDirs(); #endif + void withStdAlgorithms(); + private: QSharedPointer<QTemporaryDir> m_dataDir; }; @@ -173,10 +176,10 @@ void tst_QDirListing::initTestCase() createFile("hiddenDirs_hiddenFiles/normalDirectory/.hiddenFile"); createFile("hiddenDirs_hiddenFiles/.hiddenDirectory/normalFile"); createFile("hiddenDirs_hiddenFiles/.hiddenDirectory/.hiddenFile"); - createDirectory("hiddenDirs_hiddenFiles/normalDirectory/normalDirectory"); - createDirectory("hiddenDirs_hiddenFiles/normalDirectory/.hiddenDirectory"); - createDirectory("hiddenDirs_hiddenFiles/.hiddenDirectory/normalDirectory"); - createDirectory("hiddenDirs_hiddenFiles/.hiddenDirectory/.hiddenDirectory"); + createDirectory("hiddenDirs_hiddenFiles/normalDirectory/subdir"); + createDirectory("hiddenDirs_hiddenFiles/normalDirectory/.hidden-subdir"); + createDirectory("hiddenDirs_hiddenFiles/.hiddenDirectory/subdir"); + createDirectory("hiddenDirs_hiddenFiles/.hiddenDirectory/.hidden-subdir"); #endif } @@ -571,40 +574,77 @@ void tst_QDirListing::uncPaths() // In Unix it is easy to create hidden files, but in Windows it requires // a special call since hidden files need to be "marked" while in Unix // anything starting by a '.' is a hidden file. -// For that reason this test is not run in Windows. -void tst_QDirListing::hiddenDirs_hiddenFiles() +// For that reason these two tests aren't run on Windows. + +void tst_QDirListing::hiddenFiles() { - // Only files - { - int matches = 0; - int failures = 0; - constexpr auto filters = QDir::Files | QDir::Hidden | QDir::NoDotAndDotDot; - for (const auto &dirEntry : QDirListing(u"hiddenDirs_hiddenFiles"_s, filters, - ItFlag::Recursive)) { - ++matches; - if (dirEntry.isDir()) - ++failures; // search was only supposed to find files - } - QCOMPARE(matches, 6); - QCOMPARE(failures, 0); + QStringList expected = { + "hiddenDirs_hiddenFiles/normalFile"_L1, + "hiddenDirs_hiddenFiles/.hiddenFile"_L1, + "hiddenDirs_hiddenFiles/normalDirectory/normalFile"_L1, + "hiddenDirs_hiddenFiles/normalDirectory/.hiddenFile"_L1, + "hiddenDirs_hiddenFiles/.hiddenDirectory/normalFile"_L1, + "hiddenDirs_hiddenFiles/.hiddenDirectory/.hiddenFile"_L1, + }; + expected.sort(); + + constexpr auto filters = QDir::Files | QDir::Hidden | QDir::NoDotAndDotDot; + QStringList list; + list.reserve(expected.size()); + for (const auto &dirEntry : QDirListing(u"hiddenDirs_hiddenFiles"_s, filters, + ItFlag::Recursive)) { + QVERIFY(dirEntry.isFile()); + list.emplace_back(dirEntry.filePath()); } - // Only directories - { - int matches = 0; - int failures = 0; - constexpr auto filters = QDir::Dirs | QDir::Hidden | QDir::NoDotAndDotDot; - for (const auto &dirEntry : QDirListing(u"hiddenDirs_hiddenFiles"_s, filters, - ItFlag::Recursive)) { - ++matches; - if (!dirEntry.isDir()) - ++failures; // search was only supposed to find files - } - QCOMPARE(matches, 6); - QCOMPARE(failures, 0); + + list.sort(); + + QCOMPARE_EQ(list, expected); +} + +void tst_QDirListing::hiddenDirs() +{ + QStringList expected = { + "hiddenDirs_hiddenFiles/normalDirectory"_L1, + "hiddenDirs_hiddenFiles/normalDirectory/subdir"_L1, + "hiddenDirs_hiddenFiles/normalDirectory/.hidden-subdir"_L1, + "hiddenDirs_hiddenFiles/.hiddenDirectory"_L1, + "hiddenDirs_hiddenFiles/.hiddenDirectory/subdir"_L1, + "hiddenDirs_hiddenFiles/.hiddenDirectory/.hidden-subdir"_L1, + }; + expected.sort(); + + constexpr auto filters = QDir::Dirs | QDir::Hidden | QDir::NoDotAndDotDot; + QStringList list; + list.reserve(expected.size()); + for (const auto &dirEntry : QDirListing(u"hiddenDirs_hiddenFiles"_s, filters, + ItFlag::Recursive)) { + QVERIFY(dirEntry.isDir()); + list.emplace_back(dirEntry.filePath()); } + list.sort(); + + QCOMPARE_EQ(list, expected); } + #endif // Q_OS_WIN +void tst_QDirListing::withStdAlgorithms() +{ + QDirListing dirList(u"entrylist"_s, QDir::AllEntries | QDir::NoDotAndDotDot, ItFlag::Recursive); + + std::for_each(dirList.cbegin(), dirList.cend(), [](const auto &dirEntry) { + QVERIFY(dirEntry.absoluteFilePath().contains("entrylist")); + }); + + const auto fileName = "dummy"_L1; + auto it = std::find_if(dirList.cbegin(), dirList.cend(), [fileName](const auto &dirEntry) { + return dirEntry.fileName() == fileName; + }); + QVERIFY(it != dirList.cend()); + QCOMPARE(it->fileName(), fileName); +} + QTEST_MAIN(tst_QDirListing) #include "tst_qdirlisting.moc" diff --git a/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp b/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp index f7d531f61f..563e4c2a83 100644 --- a/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp +++ b/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp @@ -1217,9 +1217,16 @@ void tst_QFileInfo::setFileTimes() QCOMPARE(file.write(data), data.size()); QCOMPARE(file.size(), data.size()); - const QDateTime before = QDateTime::currentDateTimeUtc().addMSecs(-5000); + QDateTime before = QDateTime::currentDateTimeUtc().addMSecs(-5000); + QVERIFY(file.setFileTime(before, QFile::FileModificationTime)); const QDateTime mtime = file.fileTime(QFile::FileModificationTime).toUTC(); + if (mtime.time().msec() == 0) + { + const QTime beforeTime = before.time(); + const QTime beforeTimeWithMSCutOff{beforeTime.hour(), beforeTime.minute(), beforeTime.second(), 0}; + before.setTime(beforeTimeWithMSCutOff); + } QCOMPARE(mtime, before); } diff --git a/tests/auto/corelib/io/qfileselector/CMakeLists.txt b/tests/auto/corelib/io/qfileselector/CMakeLists.txt index c27c4f4f96..aafdddb595 100644 --- a/tests/auto/corelib/io/qfileselector/CMakeLists.txt +++ b/tests/auto/corelib/io/qfileselector/CMakeLists.txt @@ -47,8 +47,11 @@ set(qfileselector_resource_files "platforms/+unix/+haiku/test" "platforms/+unix/+linux/test" "platforms/+unix/+qnx/test" + "platforms/+unix/+vxworks/test" "platforms/+unix/test" "platforms/+unix/test3" + "platforms/+vxworks/test" + "platforms/+vxworks/test2" "platforms/+wince/test" "platforms/+wince/test2" "platforms/+windows/+wince/test" diff --git a/tests/auto/corelib/io/qfileselector/platforms/+unix/+vxworks/test b/tests/auto/corelib/io/qfileselector/platforms/+unix/+vxworks/test new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/tests/auto/corelib/io/qfileselector/platforms/+unix/+vxworks/test diff --git a/tests/auto/corelib/io/qfileselector/platforms/+vxworks/test b/tests/auto/corelib/io/qfileselector/platforms/+vxworks/test new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/tests/auto/corelib/io/qfileselector/platforms/+vxworks/test diff --git a/tests/auto/corelib/io/qfileselector/platforms/+vxworks/test2 b/tests/auto/corelib/io/qfileselector/platforms/+vxworks/test2 new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/tests/auto/corelib/io/qfileselector/platforms/+vxworks/test2 diff --git a/tests/auto/corelib/io/qfileselector/tst_qfileselector.cpp b/tests/auto/corelib/io/qfileselector/tst_qfileselector.cpp index 626166c8b8..82c9d5ef37 100644 --- a/tests/auto/corelib/io/qfileselector/tst_qfileselector.cpp +++ b/tests/auto/corelib/io/qfileselector/tst_qfileselector.cpp @@ -61,7 +61,7 @@ void tst_QFileSelector::basicTest_data() QString expectedPlatform2File(""); //Only the last selector QString expectedPlatform3File; // Only the first selector (the family) #if defined(Q_OS_UNIX) && !defined(Q_OS_ANDROID) && !defined(Q_OS_WASM) && \ - !defined(Q_OS_DARWIN) && !defined(Q_OS_LINUX) && !defined(Q_OS_HAIKU) && !defined(Q_OS_QNX) + !defined(Q_OS_DARWIN) && !defined(Q_OS_LINUX) && !defined(Q_OS_HAIKU) && !defined(Q_OS_QNX) && !defined(Q_OS_VXWORKS) /* We are only aware of specific unixes, and do not have test files for any of the others. However those unixes can get a selector added from the result of a uname call, so this will lead to a case where we don't have that file so we can't expect the concatenation of platform diff --git a/tests/auto/corelib/io/qfilesystemwatcher/tst_qfilesystemwatcher.cpp b/tests/auto/corelib/io/qfilesystemwatcher/tst_qfilesystemwatcher.cpp index a5b0087f9c..184eef3f15 100644 --- a/tests/auto/corelib/io/qfilesystemwatcher/tst_qfilesystemwatcher.cpp +++ b/tests/auto/corelib/io/qfilesystemwatcher/tst_qfilesystemwatcher.cpp @@ -26,14 +26,18 @@ using namespace std::chrono_literals; #if defined(Q_OS_QNX) -// Longer polling times on QNX, otherwise the tests fail on the CI +constexpr bool isQNX = true; +#else +constexpr bool isQNX = false; +#endif + +#if defined(Q_OS_QNX) || defined(Q_OS_VXWORKS) +// Longer polling times on QNX and VxWorks, otherwise the tests fail on the CI constexpr auto nativeEngineTimeout = 1s; constexpr auto pollingEngineTimeout = 1s; -constexpr bool isQNX = true; #else constexpr auto nativeEngineTimeout = 0ms; constexpr auto pollingEngineTimeout = 20ms; -constexpr bool isQNX = false; #endif /* All tests need to run in temporary directories not used diff --git a/tests/auto/corelib/io/qfloat16format/CMakeLists.txt b/tests/auto/corelib/io/qfloat16format/CMakeLists.txt new file mode 100644 index 0000000000..88c47d8de3 --- /dev/null +++ b/tests/auto/corelib/io/qfloat16format/CMakeLists.txt @@ -0,0 +1,23 @@ +# Copyright (C) 2024 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_qfloat16format LANGUAGES CXX) + find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST) +endif() + +set(CMAKE_OSX_DEPLOYMENT_TARGET 13.3) + +qt_internal_add_test(tst_qfloat16format + SOURCES + tst_qfloat16format.cpp +) + +if(NOT VXWORKS) + set_target_properties(tst_qfloat16format + PROPERTIES + CXX_STANDARD 20 + CXX_STANDARD_REQUIRED OFF + ) +endif() diff --git a/tests/auto/corelib/io/qfloat16format/tst_qfloat16format.cpp b/tests/auto/corelib/io/qfloat16format/tst_qfloat16format.cpp new file mode 100644 index 0000000000..ea07b327af --- /dev/null +++ b/tests/auto/corelib/io/qfloat16format/tst_qfloat16format.cpp @@ -0,0 +1,157 @@ +// Copyright (C) 2024 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +#include <QTest> + +#include <QtCore/qcompilerdetection.h> +#include <QtCore/qdebug.h> +#include <QtCore/qfloat16format.h> +#include <QtCore/qstring.h> + +using namespace Qt::StringLiterals; + +class tst_QFloat16Format : public QObject +{ + Q_OBJECT + +private slots: + void initTestCase(); + void formatCompileTime(); + void format_data(); + void format(); + void formatMultiArg(); +}; + +void tst_QFloat16Format::initTestCase() +{ +#ifndef QT_SUPPORTS_STD_FORMAT + QSKIP("This test requires std::format support!"); +#endif +} + +void tst_QFloat16Format::formatCompileTime() +{ +#ifdef QT_SUPPORTS_STD_FORMAT + // Starting from __cpp_lib_format == 202106L, + // std::format requires the format string to be evaluated at compile-time, + // so check it here. + + const qfloat16 val{1.234f}; + std::locale loc{"C"}; + + // char + std::string buffer; + std::format_to(std::back_inserter(buffer), "{}", val); + std::format_to(std::back_inserter(buffer), "{:*>15.7f}", val); + std::format_to(std::back_inserter(buffer), "{:*^+#15.7g}", val); + std::format_to(std::back_inserter(buffer), "{:*<-#15.7A}", val); + std::format_to(std::back_inserter(buffer), "{:*^ 15.7e}", val); + std::format_to(std::back_inserter(buffer), loc, "{:*^10.3Lf}", val); + std::format_to(std::back_inserter(buffer), loc, "{:*< 10.7LE}", val); + + // wchar_t + std::wstring wbuffer; + std::format_to(std::back_inserter(wbuffer), L"{}", val); + std::format_to(std::back_inserter(wbuffer), L"{:*>15.7f}", val); + std::format_to(std::back_inserter(wbuffer), L"{:*^+#15.7g}", val); + std::format_to(std::back_inserter(wbuffer), L"{:*<-#15.7A}", val); + std::format_to(std::back_inserter(wbuffer), L"{:*^ 15.7e}", val); + std::format_to(std::back_inserter(wbuffer), loc, L"{:*^10.3Lf}", val); + std::format_to(std::back_inserter(wbuffer), loc, L"{:*< 10.7LE}", val); +#endif // QT_SUPPORTS_STD_FORMAT +} + +void tst_QFloat16Format::format_data() +{ +#ifdef QT_SUPPORTS_STD_FORMAT + QTest::addColumn<QString>("format"); + QTest::addColumn<qfloat16>("value"); + QTest::addColumn<std::locale>("locale"); + QTest::addColumn<QString>("expectedString"); + + auto row = [](const QString &format, qfloat16 val, const QString &expected, + const std::locale &loc = std::locale::classic()) + { + QTest::addRow("%s:%s", loc.name().c_str(), qPrintable(format)) + << format << val << loc << expected; + }; + + row(u"{}"_s, qfloat16(1.f), u"1"_s); + row(u"{:#}"_s, qfloat16(1.f), u"1."_s); + row(u"{:f}"_s, qfloat16(1.f), u"1.000000"_s); + row(u"{:*>10.2a}"_s, qfloat16(-1.23f), u"**-1.3bp+0"_s); + + try { + // check if this locale is a) valid and b) works as expected +#if defined(Q_CC_MSVC) + std::locale loc("de-DE"); +#else + std::locale loc("de_DE"); +#endif + if (std::format(loc, "{:L}", 1.25) == "1,25") { + row(u"{:+Lf}"_s, qfloat16(1.f), u"+1,000000"_s, loc); + row(u"{:*^10.3LF}"_s, qfloat16(-0.1234f), u"**-0,123**"_s, loc); + row(u"{:*^#10.4Lg}"_s, qfloat16(-1.f), u"**-1,000**"_s, loc); + row(u"{:*<14.3LE}"_s, qfloat16(-0.1234f), u"-1,234E-01****"_s, loc); + } + } catch (const std::runtime_error &) { + // locale doesn't exist (std::locale constructor threw) + } +#endif // QT_SUPPORTS_STD_FORMAT +} + +void tst_QFloat16Format::format() +{ +#ifdef QT_SUPPORTS_STD_FORMAT + QFETCH(const QString, format); + QFETCH(const qfloat16, value); + QFETCH(const std::locale, locale); + QFETCH(const QString, expectedString); + + // char + { + std::string buffer; + const auto formatStr = format.toStdString(); + std::vformat_to(std::back_inserter(buffer), locale, formatStr, + std::make_format_args(value)); + const QString actualString = QString::fromStdString(buffer); + QCOMPARE_EQ(actualString, expectedString); + } + + // wchar_t + { + std::wstring buffer; + const auto formatStr = format.toStdWString(); + std::vformat_to(std::back_inserter(buffer), locale, formatStr, + std::make_wformat_args(value)); + const QString actualString = QString::fromStdWString(buffer); + QCOMPARE_EQ(actualString, expectedString); + } +#endif // QT_SUPPORTS_STD_FORMAT +} + +void tst_QFloat16Format::formatMultiArg() +{ +#ifdef QT_SUPPORTS_STD_FORMAT + const qfloat16 v1{-0.1234f}; + const qfloat16 v2{5.67f}; + + const QString expectedString = u"**+5.67**_*****-1.234E-01"_s; + // char + { + std::string buffer; + std::format_to(std::back_inserter(buffer), "{1:*^+9.2f}_{0:*>15.3E}", v1, v2); + QCOMPARE_EQ(QString::fromStdString(buffer), expectedString); + } + + // wchar_t + { + std::wstring buffer; + std::format_to(std::back_inserter(buffer), L"{1:*^+9.2f}_{0:*>15.3E}", v1, v2); + QCOMPARE_EQ(QString::fromStdWString(buffer), expectedString); + } +#endif // QT_SUPPORTS_STD_FORMAT +} + +QTEST_MAIN(tst_QFloat16Format) +#include "tst_qfloat16format.moc" diff --git a/tests/auto/corelib/io/qprocess/crasher.h b/tests/auto/corelib/io/qprocess/crasher.h index 7d55bf980f..f1ca82a86b 100644 --- a/tests/auto/corelib/io/qprocess/crasher.h +++ b/tests/auto/corelib/io/qprocess/crasher.h @@ -45,6 +45,8 @@ void crash() { #if defined(_MSC_VER) && (defined(_M_IX86) || defined(_M_X64)) __ud2(); +#elif defined(_MSC_VER) && defined(_M_ARM64) + __debugbreak(); #elif __has_builtin(__builtin_trap) __builtin_trap(); #elif defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__)) diff --git a/tests/auto/corelib/io/qprocess/tst_qprocess.cpp b/tests/auto/corelib/io/qprocess/tst_qprocess.cpp index 5f35732979..316c388bc8 100644 --- a/tests/auto/corelib/io/qprocess/tst_qprocess.cpp +++ b/tests/auto/corelib/io/qprocess/tst_qprocess.cpp @@ -1715,7 +1715,7 @@ void tst_QProcess::raiseInChildProcessModifier() sa.sa_flags = SA_RESETHAND; sa.sa_handler = [](int) { static const char msg[] = "SIGUSR1 handler was run"; - write(STDERR_FILENO, msg, strlen(msg)); + (void)write(STDERR_FILENO, msg, strlen(msg)); raise(SIGUSR1); // re-raise }; sigaction(SIGUSR1, &sa, nullptr); @@ -1897,8 +1897,8 @@ void tst_QProcess::unixProcessParametersAndChildModifier() process.setChildProcessModifier([=, &vforkControl] { const char *pgidmsg = "PGID mismatch. "; if (getpgrp() != oldpgid) - write(pipes[1], pgidmsg, strlen(pgidmsg)); - write(pipes[1], message, strlen(message)); + (void)write(pipes[1], pgidmsg, strlen(pgidmsg)); + (void)write(pipes[1], message, strlen(message)); vforkControl.storeRelaxed(1); }); auto flags = QProcess::UnixProcessFlag::CloseFileDescriptors | diff --git a/tests/auto/corelib/io/qprocessenvironment/tst_qprocessenvironment.cpp b/tests/auto/corelib/io/qprocessenvironment/tst_qprocessenvironment.cpp index 6a2a3daaa2..560d4196b2 100644 --- a/tests/auto/corelib/io/qprocessenvironment/tst_qprocessenvironment.cpp +++ b/tests/auto/corelib/io/qprocessenvironment/tst_qprocessenvironment.cpp @@ -257,6 +257,9 @@ void tst_QProcessEnvironment::caseSensitivity() void tst_QProcessEnvironment::systemEnvironment() { +#ifdef Q_OS_VXWORKS + QSKIP("VxWorks do not have PATH environment variable"); +#endif static const char envname[] = "THIS_ENVIRONMENT_VARIABLE_HOPEFULLY_DOESNT_EXIST"; QByteArray path = qgetenv("PATH"); QByteArray nonexistant = qgetenv(envname); diff --git a/tests/auto/corelib/io/qresourceengine/generateResources.sh b/tests/auto/corelib/io/qresourceengine/generateResources.sh index 18d1e0b80f..ab05f1c35a 100755 --- a/tests/auto/corelib/io/qresourceengine/generateResources.sh +++ b/tests/auto/corelib/io/qresourceengine/generateResources.sh @@ -1,6 +1,6 @@ +#!/bin/sh # Copyright (C) 2016 Intel Corporation. # SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 -#!/bin/sh count=`awk '/ZERO_FILE_LEN/ { print $3 }' tst_qresourceengine.cpp` dd if=/dev/zero of=zero.txt bs=1 count=$count rcc --binary -o uncompressed.rcc --no-compress compressed.qrc diff --git a/tests/auto/corelib/io/qresourceengine/staticplugin/main.cpp b/tests/auto/corelib/io/qresourceengine/staticplugin/main.cpp index 39a3a1e012..c7b0fe7ea1 100644 --- a/tests/auto/corelib/io/qresourceengine/staticplugin/main.cpp +++ b/tests/auto/corelib/io/qresourceengine/staticplugin/main.cpp @@ -1,3 +1,5 @@ +// Copyright (C) 2024 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include <QObject> class PluginClass : public QObject diff --git a/tests/auto/corelib/io/qresourceengine/tst_qresourceengine.cpp b/tests/auto/corelib/io/qresourceengine/tst_qresourceengine.cpp index f0dab35f81..00a8cc4d72 100644 --- a/tests/auto/corelib/io/qresourceengine/tst_qresourceengine.cpp +++ b/tests/auto/corelib/io/qresourceengine/tst_qresourceengine.cpp @@ -201,7 +201,6 @@ void tst_QResourceEngine::checkStructure_data() << (QStringList() #if defined(BUILTIN_TESTDATA) << "parentdir.txt" - << "runtime_resource.rcc" #endif << "search_file.txt" #if defined(BUILTIN_TESTDATA) diff --git a/tests/auto/corelib/io/qstorageinfo/tst_qstorageinfo.cpp b/tests/auto/corelib/io/qstorageinfo/tst_qstorageinfo.cpp index 5242988fd1..f96cd48900 100644 --- a/tests/auto/corelib/io/qstorageinfo/tst_qstorageinfo.cpp +++ b/tests/auto/corelib/io/qstorageinfo/tst_qstorageinfo.cpp @@ -24,6 +24,8 @@ # include "../../../../../src/corelib/io/qstorageinfo_linux_p.h" #endif +using namespace Qt::StringLiterals; + class tst_QStorageInfo : public QObject { Q_OBJECT @@ -137,8 +139,10 @@ void tst_QStorageInfo::root() QVERIFY(storage.isReady()); QCOMPARE(storage.rootPath(), QDir::rootPath()); QVERIFY(storage.isRoot()); +#ifndef Q_OS_WASM QVERIFY(!storage.device().isEmpty()); QVERIFY(!storage.fileSystemType().isEmpty()); +#endif #ifndef Q_OS_HAIKU QCOMPARE_GE(storage.bytesTotal(), 0); QCOMPARE_GE(storage.bytesFree(), 0); @@ -149,6 +153,9 @@ void tst_QStorageInfo::root() void tst_QStorageInfo::currentStorage() { QString appPath = QCoreApplication::applicationFilePath(); + if (appPath.isEmpty()) + QSKIP("No applicationFilePath(), cannot test"); + QStorageInfo storage(appPath); QVERIFY(storage.isValid()); QVERIFY(storage.isReady()); @@ -308,7 +315,10 @@ void tst_QStorageInfo::freeSpaceUpdate() QCOMPARE(free, storage2.bytesFree()); storage2.refresh(); QCOMPARE(storage1, storage2); + +#ifndef Q_OS_WASM QCOMPARE_NE(free, storage2.bytesFree()); +#endif } #if defined(Q_OS_LINUX) && defined(QT_BUILD_INTERNAL) @@ -319,64 +329,64 @@ void tst_QStorageInfo::testParseMountInfo_data() QTest::newRow("tmpfs") << "17 25 0:18 / /dev rw,nosuid,relatime shared:2 - tmpfs tmpfs rw,seclabel,mode=755\n"_ba - << MountInfo{"/dev", "tmpfs", "tmpfs", "", makedev(0, 18)}; + << MountInfo{"/dev", "tmpfs", "tmpfs", "", makedev(0, 18), 17}; QTest::newRow("proc") << "23 66 0:21 / /proc rw,nosuid,nodev,noexec,relatime shared:12 - proc proc rw\n"_ba - << MountInfo{"/proc", "proc", "proc", "", makedev(0, 21)}; + << MountInfo{"/proc", "proc", "proc", "", makedev(0, 21), 23}; // E.g. on Android QTest::newRow("rootfs") << "618 618 0:1 / / ro,relatime master:1 - rootfs rootfs ro,seclabel\n"_ba - << MountInfo{"/", "rootfs", "rootfs", "", makedev(0, 1)}; + << MountInfo{"/", "rootfs", "rootfs", "", makedev(0, 1), 618}; QTest::newRow("ext4") << "47 66 8:3 / /home rw,relatime shared:50 - ext4 /dev/sda3 rw,stripe=32736\n"_ba - << MountInfo{"/home", "ext4", "/dev/sda3", "", makedev(8, 3)}; + << MountInfo{"/home", "ext4", "/dev/sda3", "", makedev(8, 3), 47}; QTest::newRow("empty-optional-field") << "23 25 0:22 / /apex rw,nosuid,nodev,noexec,relatime - tmpfs tmpfs rw,seclabel,mode=755\n"_ba - << MountInfo{"/apex", "tmpfs", "tmpfs", "", makedev(0, 22)}; + << MountInfo{"/apex", "tmpfs", "tmpfs", "", makedev(0, 22), 23}; QTest::newRow("one-optional-field") << "47 66 8:3 / /home rw,relatime shared:50 - ext4 /dev/sda3 rw,stripe=32736\n"_ba - << MountInfo{"/home", "ext4", "/dev/sda3", "", makedev(8, 3)}; + << MountInfo{"/home", "ext4", "/dev/sda3", "", makedev(8, 3), 47}; QTest::newRow("multiple-optional-fields") << "47 66 8:3 / /home rw,relatime shared:142 master:111 - ext4 /dev/sda3 rw,stripe=32736\n"_ba - << MountInfo{"/home", "ext4", "/dev/sda3", "", makedev(8, 3)}; + << MountInfo{"/home", "ext4", "/dev/sda3", "", makedev(8, 3), 47}; QTest::newRow("mountdir-with-utf8") << "129 66 8:51 / /mnt/lab\xC3\xA9l rw,relatime shared:234 - ext4 /dev/sdd3 rw\n"_ba - << MountInfo{"/mnt/labél", "ext4", "/dev/sdd3", "", makedev(8, 51)}; + << MountInfo{"/mnt/labél", "ext4", "/dev/sdd3", "", makedev(8, 51), 129}; QTest::newRow("mountdir-with-space") << "129 66 8:51 / /mnt/labe\\040l rw,relatime shared:234 - ext4 /dev/sdd3 rw\n"_ba - << MountInfo{"/mnt/labe l", "ext4", "/dev/sdd3", "", makedev(8, 51)}; + << MountInfo{"/mnt/labe l", "ext4", "/dev/sdd3", "", makedev(8, 51), 129}; QTest::newRow("mountdir-with-tab") << "129 66 8:51 / /mnt/labe\\011l rw,relatime shared:234 - ext4 /dev/sdd3 rw\n"_ba - << MountInfo{"/mnt/labe\tl", "ext4", "/dev/sdd3", "", makedev(8, 51)}; + << MountInfo{"/mnt/labe\tl", "ext4", "/dev/sdd3", "", makedev(8, 51), 129}; QTest::newRow("mountdir-with-backslash") << "129 66 8:51 / /mnt/labe\\134l rw,relatime shared:234 - ext4 /dev/sdd3 rw\n"_ba - << MountInfo{"/mnt/labe\\l", "ext4", "/dev/sdd3", "", makedev(8, 51)}; + << MountInfo{"/mnt/labe\\l", "ext4", "/dev/sdd3", "", makedev(8, 51), 129}; QTest::newRow("mountdir-with-newline") << "129 66 8:51 / /mnt/labe\\012l rw,relatime shared:234 - ext4 /dev/sdd3 rw\n"_ba - << MountInfo{"/mnt/labe\nl", "ext4", "/dev/sdd3", "", makedev(8, 51)}; + << MountInfo{"/mnt/labe\nl", "ext4", "/dev/sdd3", "", makedev(8, 51), 129}; QTest::newRow("btrfs-subvol") << "775 503 0:49 /foo/bar / rw,relatime shared:142 master:111 - btrfs " "/dev/mapper/vg0-stuff rw,ssd,discard,space_cache,subvolid=272,subvol=/foo/bar\n"_ba - << MountInfo{"/", "btrfs", "/dev/mapper/vg0-stuff", "/foo/bar", makedev(0, 49)}; + << MountInfo{"/", "btrfs", "/dev/mapper/vg0-stuff", "/foo/bar", makedev(0, 49), 775}; QTest::newRow("bind-mount") << "59 47 8:17 /rpmbuild /home/user/rpmbuild rw,relatime shared:48 - ext4 /dev/sdb1 rw\n"_ba - << MountInfo{"/home/user/rpmbuild", "ext4", "/dev/sdb1", "/rpmbuild", makedev(8, 17)}; + << MountInfo{"/home/user/rpmbuild", "ext4", "/dev/sdb1", "/rpmbuild", makedev(8, 17), 59}; QTest::newRow("space-dash-space") << "47 66 8:3 / /home\\040-\\040dir rw,relatime shared:50 - ext4 /dev/sda3 rw,stripe=32736\n"_ba - << MountInfo{"/home - dir", "ext4", "/dev/sda3", "", makedev(8, 3)}; + << MountInfo{"/home - dir", "ext4", "/dev/sda3", "", makedev(8, 3), 47}; QTest::newRow("btrfs-mount-bind-file") << "1799 1778 0:49 " @@ -385,7 +395,7 @@ void tst_QStorageInfo::testParseMountInfo_data() "rw,ssd,discard,space_cache,subvolid=1773,subvol=/var_lib_docker\n"_ba << MountInfo{"/etc/resolv.conf", "btrfs", "/dev/mapper/vg0-stuff", "/var_lib_docker/containers/81fde0fec3dd3d99765c3f7fd9cf1ab121b6ffcfd05d5d7ff434db933fe9d795/resolv.conf", - makedev(0, 49)}; + makedev(0, 49), 1799}; QTest::newRow("very-long-line-QTBUG-77059") << "727 26 0:52 / " @@ -402,13 +412,13 @@ void tst_QStorageInfo::testParseMountInfo_data() "workdir=/var/lib/docker/overlay2/f3fbad5eedef71145f00729f0826ea8c44defcfec8c92c58aee0aa2c5ea3fa3a/work," "index=off,xino=off\n"_ba << MountInfo{"/var/lib/docker/overlay2/f3fbad5eedef71145f00729f0826ea8c44defcfec8c92c58aee0aa2c5ea3fa3a/merged", - "overlay", "overlay", "", makedev(0, 52)}; + "overlay", "overlay", "", makedev(0, 52), 727}; QTest::newRow("sshfs-src-device-not-start-with-slash") << "128 92 0:64 / /mnt-point rw,nosuid,nodev,relatime shared:234 - " "fuse.sshfs admin@192.168.1.2:/storage/emulated/0 rw,user_id=1000,group_id=1000\n"_ba << MountInfo{"/mnt-point", "fuse.sshfs", - "admin@192.168.1.2:/storage/emulated/0", "", makedev(0, 64)}; + "admin@192.168.1.2:/storage/emulated/0", "", makedev(0, 64), 128}; } void tst_QStorageInfo::testParseMountInfo() @@ -424,6 +434,7 @@ void tst_QStorageInfo::testParseMountInfo() QCOMPARE(a.device, expected.device); QCOMPARE(a.fsRoot, expected.fsRoot); QCOMPARE(a.stDev, expected.stDev); + QCOMPARE(a.mntid, expected.mntid); } void tst_QStorageInfo::testParseMountInfo_filtered_data() diff --git a/tests/auto/corelib/io/qtemporaryfile/tst_qtemporaryfile.cpp b/tests/auto/corelib/io/qtemporaryfile/tst_qtemporaryfile.cpp index 579e6d5511..1419f06f86 100644 --- a/tests/auto/corelib/io/qtemporaryfile/tst_qtemporaryfile.cpp +++ b/tests/auto/corelib/io/qtemporaryfile/tst_qtemporaryfile.cpp @@ -592,7 +592,9 @@ void tst_QTemporaryFile::rename() void tst_QTemporaryFile::renameFdLeak() { #if defined(Q_OS_UNIX) && !defined(Q_OS_ANDROID) - const QByteArray sourceFile = QFile::encodeName(QFINDTESTDATA("CMakeLists.txt")); + QTemporaryFile file; + QVERIFY(file.open()); + const QByteArray sourceFile = QFile::encodeName(file.fileName()); QVERIFY(!sourceFile.isEmpty()); // Test this on Unix only diff --git a/tests/auto/corelib/io/qurl/tst_qurl.cpp b/tests/auto/corelib/io/qurl/tst_qurl.cpp index bd454fb695..2024968435 100644 --- a/tests/auto/corelib/io/qurl/tst_qurl.cpp +++ b/tests/auto/corelib/io/qurl/tst_qurl.cpp @@ -3776,13 +3776,13 @@ void tst_QUrl::setComponents_data() << PrettyDecoded << QString() << "foo:/path"; QTest::newRow("host-empty") << QUrl("foo://example.com/path") << int(Host) << "" << Tolerant << true - << PrettyDecoded << QString() << "foo:///path"; + << PrettyDecoded << "" << "foo:///path"; QTest::newRow("authority-null") << QUrl("foo://example.com/path") << int(Authority) << QString() << Tolerant << true << PrettyDecoded << QString() << "foo:/path"; QTest::newRow("authority-empty") << QUrl("foo://example.com/path") << int(Authority) << "" << Tolerant << true - << PrettyDecoded << QString() << "foo:///path"; + << PrettyDecoded << "" << "foo:///path"; QTest::newRow("query-null") << QUrl("http://example.com/?q=foo") << int(Query) << QString() << Tolerant << true << PrettyDecoded << QString() << "http://example.com/"; @@ -3840,10 +3840,10 @@ void tst_QUrl::setComponents_data() << PrettyDecoded << QString() << QString(); QTest::newRow("invalid-authority-1") << QUrl("http://example.com") << int(Authority) << "-not-valid-" << Tolerant << false - << PrettyDecoded << QString() << QString(); + << PrettyDecoded << "" << QString(); QTest::newRow("invalid-authority-2") << QUrl("http://example.com") << int(Authority) << "%31%30.%30.%30.%31" << Strict << false - << PrettyDecoded << QString() << QString(); + << PrettyDecoded << "" << QString(); QTest::newRow("invalid-path-0") << QUrl("http://example.com") << int(Path) << "{}" << Strict << false |