summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp
diff options
context:
space:
mode:
authorFrederik Gladhorn <frederik.gladhorn@digia.com>2013-09-30 22:20:50 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-10-02 11:11:23 +0200
commit04acfea2d24c4b467e463741bdd6014aa2b6cca9 (patch)
treef142b65d73ecc1bbad295ea0544c4b6879032969 /tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp
parent35f8bcd4388f4f7c466d5e8d91c3cb6898f83602 (diff)
Fix QStandardPath test on some linuxes
On one suse box I have both /usr/bin/sh and /bin/sh which means that the test should prefer the one first in the path instead of random order. Change-Id: Ie94bf8404479fa42a36a8ee45e09986114693871 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp')
-rw-r--r--tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp13
1 files changed, 8 insertions, 5 deletions
diff --git a/tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp b/tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp
index b63dbc449c..9ac1526f07 100644
--- a/tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp
+++ b/tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp
@@ -308,13 +308,16 @@ void tst_qstandardpaths::testDataLocation()
#ifndef Q_OS_WIN
// Find "sh" on Unix.
+// It may exist twice, in /bin/sh and /usr/bin/sh, in that case use the PATH order.
static inline QFileInfo findSh()
{
- const char *shPaths[] = {"/bin/sh", "/usr/bin/sh", 0};
- for (const char **shPath = shPaths; *shPath; ++shPath) {
- const QFileInfo fi = QFileInfo(QLatin1String(*shPath));
- if (fi.exists())
- return fi;
+ QLatin1String sh("/sh");
+ QByteArray pEnv = qgetenv("PATH");
+ const QLatin1Char pathSep(':');
+ const QStringList rawPaths = QString::fromLocal8Bit(pEnv.constData()).split(pathSep, QString::SkipEmptyParts);
+ foreach (const QString &path, rawPaths) {
+ if (QFile::exists(path + sh))
+ return path + sh;
}
return QFileInfo();
}