tests: Explicitly check for pathconf(_PC_CASE_SENSITIVE) == 1

We use pathconf in some of our tests to determine if the file system
on Darwin is case sensitive. But pathconf returns -1 if the case
sensitivity can't be determined, with errno set to ENOTSUP.

The convention in this case is to treat the file system as not being
case sensitive (as reported by NSURLVolumeSupportsCaseSensitiveNamesKey
and VOL_CAP_FMT_CASE_SENSITIVE in equivalent APIs), so we need to check
explicitly for a return value of 1.

Change-Id: I1107e849babd8813da3b148c92494e8e35a32d36
Reviewed-by: Liang Qi <liang.qi@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit bd3aabf38454087a96a17ff0130d7f5c2b2b39a9)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
bb10
Tor Arne Vestbø 2024-09-19 12:00:11 +02:00 committed by Qt Cherry-pick Bot
parent df74e52578
commit e336111a5d
5 changed files with 5 additions and 5 deletions

View File

@ -1021,7 +1021,7 @@ static inline bool isCaseSensitiveFileSystem(const QString &path)
// file system mounted, wrongly capitalized drive letters will cause mismatches.
return false;
#elif defined(Q_OS_MACOS)
return pathconf(QFile::encodeName(path).constData(), _PC_CASE_SENSITIVE);
return pathconf(QFile::encodeName(path).constData(), _PC_CASE_SENSITIVE) == 1;
#else
return true;
#endif

View File

@ -3792,7 +3792,7 @@ void tst_QFile::caseSensitivity()
#if defined(Q_OS_WIN)
const bool caseSensitive = false;
#elif defined(Q_OS_DARWIN)
const bool caseSensitive = pathconf(QDir::currentPath().toLatin1().constData(), _PC_CASE_SENSITIVE);
const bool caseSensitive = pathconf(QDir::currentPath().toLatin1().constData(), _PC_CASE_SENSITIVE) == 1;
#else
const bool caseSensitive = true;
#endif

View File

@ -1027,7 +1027,7 @@ void tst_QFileInfo::compare_data()
#if defined(Q_OS_WIN)
<< true;
#elif defined(Q_OS_DARWIN)
<< !pathconf(QDir::currentPath().toLatin1().constData(), _PC_CASE_SENSITIVE);
<< (pathconf(QDir::currentPath().toLatin1().constData(), _PC_CASE_SENSITIVE) != 1);
#else
<< false;
#endif

View File

@ -547,7 +547,7 @@ void tst_QSettings::ctor()
// more details in QMacSettingsPrivate::QMacSettingsPrivate(), organization was comify()-ed
caseSensitive = settings5.fileName().contains("SoftWare.ORG");
} else {
caseSensitive = pathconf(settings5.fileName().toLatin1().constData(), _PC_CASE_SENSITIVE);
caseSensitive = pathconf(settings5.fileName().toLatin1().constData(), _PC_CASE_SENSITIVE) == 1;
}
#elif defined(Q_OS_WIN32)
caseSensitive = false;

View File

@ -53,7 +53,7 @@ static inline bool isCaseSensitiveFileSystem(const QString &path)
{
Q_UNUSED(path);
#if defined(Q_OS_MAC)
return pathconf(QFile::encodeName(path).constData(), _PC_CASE_SENSITIVE);
return pathconf(QFile::encodeName(path).constData(), _PC_CASE_SENSITIVE) == 1;
#elif defined(Q_OS_WIN)
return false;
#else