summaryrefslogtreecommitdiffstats
path: root/tests/benchmarks/corelib
diff options
context:
space:
mode:
authorEdward Welbourne <edward.welbourne@qt.io>2021-07-02 15:40:35 +0200
committerEdward Welbourne <edward.welbourne@qt.io>2021-07-06 13:50:55 +0200
commit74e9b77f4f3bd823d836a2a1a557b294582bac5e (patch)
tree3b04111c9772b7ae2c121ec81782e9d3dd947364 /tests/benchmarks/corelib
parent03272e601ce0b03c36717dac0a60c2fdd8987bee (diff)
Fix QDirIterator benchmark to actually find its test data
The benchmark had a hard-coded path on MS and needed an environment variable set otherwise; neither sounds like a good approach, when testlib defines a variable that tells us the test's source directory, a clearly superior way to find things in our source directories. In the process, replace exit()ing on failure to get a path with a QSKIP() so that the test at least fails gracefully if it ever can't find its data. (Using QFAIL() left it with no rows but still trying to run the test, leading to an assert failure.) Pick-to: 6.2 6.1 5.15 Task-number: QTBUG-91713 Change-Id: I1bd5561971239bb838bcf6c24bcdf1d07c81a657 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Diffstat (limited to 'tests/benchmarks/corelib')
-rw-r--r--tests/benchmarks/corelib/io/qdiriterator/main.cpp28
1 files changed, 13 insertions, 15 deletions
diff --git a/tests/benchmarks/corelib/io/qdiriterator/main.cpp b/tests/benchmarks/corelib/io/qdiriterator/main.cpp
index 367913338f..8c180f8757 100644
--- a/tests/benchmarks/corelib/io/qdiriterator/main.cpp
+++ b/tests/benchmarks/corelib/io/qdiriterator/main.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2021 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the test suite of the Qt Toolkit.
@@ -64,24 +64,22 @@ private slots:
void stdRecursiveDirectoryIterator_data() { data(); }
};
-
void tst_qdiriterator::data()
{
-#if defined(Q_OS_WIN)
- const char *qtdir = "C:\\depot\\qt\\main";
-#else
- const char *qtdir = ::getenv("QTDIR");
-#endif
- if (!qtdir) {
- fprintf(stderr, "QTDIR not set\n");
- exit(1);
- }
+ const char hereRelative[] = "tests/benchmarks/corelib/io/qdiriterator";
+ QByteArray dir(QT_TESTCASE_SOURCEDIR);
+ // qDebug("Source dir: %s", dir.constData());
+ dir.chop(sizeof(hereRelative)); // Counts the '\0', making up for the omitted leading '/'
+ // qDebug("Root dir: %s", dir.constData());
QTest::addColumn<QByteArray>("dirpath");
- QByteArray ba = QByteArray(qtdir) + "/src/corelib";
- QByteArray ba1 = ba + "/io";
- QTest::newRow(ba) << ba;
- //QTest::newRow(ba1) << ba1;
+ const QByteArray ba = dir + "/src/corelib";
+
+ if (!QFileInfo(QString::fromLocal8Bit(ba)).isDir())
+ QSKIP("Missing Qt directory");
+
+ QTest::newRow("corelib") << ba;
+ QTest::newRow("corelib/io") << (ba + "/io");
}
#ifdef Q_OS_WIN