TestLib: Wrap raw strings in QStringLiteral for QT_NO_CAST_FROM_ASCII

This enables testing of qmltc with QT_NO_CAST_FROM_ASCII.

Change-Id: I0a6655522b0edaa79dc606b70c263b83ad14ee0b
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
(cherry picked from commit 33a80b27b343fb02d365520a352843a84dd851fd)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Olivier De Cannière 2024-10-30 15:30:36 +01:00 committed by Qt Cherry-pick Bot
parent 28a5486d53
commit a6f4af0921

View File

@ -63,11 +63,13 @@ static bool isReportedArchitectureX86(void);
*/ */
static bool isX86SpecificFileAvailable() static bool isX86SpecificFileAvailable()
{ {
using namespace Qt::StringLiterals;
// MTRR (Memory Type Range Registers) are a feature of the x86 architecture // MTRR (Memory Type Range Registers) are a feature of the x86 architecture
// and /proc/mtrr is only present (on Linux) for that family. // and /proc/mtrr is only present (on Linux) for that family.
// However, it's an optional kernel feature, so the absence of the file is // However, it's an optional kernel feature, so the absence of the file is
// not sufficient to conclude we're on real hardware. // not sufficient to conclude we're on real hardware.
QFileInfo mtrr("/proc/mtrr"); QFileInfo mtrr(u"/proc/mtrr"_s);
if (mtrr.exists()) if (mtrr.exists())
return true; return true;
return false; return false;
@ -78,6 +80,8 @@ static bool isX86SpecificFileAvailable()
*/ */
static bool isReportedArchitectureX86(void) static bool isReportedArchitectureX86(void)
{ {
using namespace Qt::StringLiterals;
#if QT_CONFIG(process) && QT_CONFIG(regularexpression) #if QT_CONFIG(process) && QT_CONFIG(regularexpression)
QProcess unamer; QProcess unamer;
QString machineString; QString machineString;
@ -85,14 +89,14 @@ static bool isReportedArchitectureX86(void)
// Using syscall "uname" is not possible since that would be captured by // Using syscall "uname" is not possible since that would be captured by
// QEMU and result would be the architecture being emulated (e.g. armv7l). // QEMU and result would be the architecture being emulated (e.g. armv7l).
// By using QProcess we get the architecture used by the host. // By using QProcess we get the architecture used by the host.
unamer.start("uname -a"); unamer.start(u"uname -a"_s);
if (!unamer.waitForFinished()) { if (!unamer.waitForFinished()) {
return false; return false;
} }
machineString = unamer.readAll(); machineString = QString::fromLocal8Bit(unamer.readAll());
// Is our current host cpu x86? // Is our current host cpu x86?
if (machineString.contains(QRegularExpression("i386|i686|x86"))) { if (machineString.contains(QRegularExpression(u"i386|i686|x86"_s))) {
return true; return true;
} }
#endif #endif