Move QSKIP()s to _data() functions in QFile benchmark

Skipping once in the data function is the clean way to do this. Saves
setting up dummy data just so as to skip it, or setting up real data
and then skippin on each row.

Change-Id: I1666d134b6f206e8055fbbc5efd2e2116431a9c1
Reviewed-by: Jason McDonald <macadder1@gmail.com>
Reviewed-by: Andreas Buhr <andreas.buhr@qt.io>
This commit is contained in:
Edward Welbourne 2021-07-05 14:24:47 +02:00
parent 2300146085
commit 1cabfd1680

View File

@ -169,11 +169,7 @@ void tst_qfile::cleanupTestCase()
void tst_qfile::readBigFile_QFile() { readBigFile(); } void tst_qfile::readBigFile_QFile() { readBigFile(); }
void tst_qfile::readBigFile_QFSFileEngine() void tst_qfile::readBigFile_QFSFileEngine()
{ {
#ifdef QT_BUILD_INTERNAL
readBigFile(); readBigFile();
#else
QSKIP("This test requires -developer-build.");
#endif
} }
void tst_qfile::readBigFile_posix() void tst_qfile::readBigFile_posix()
{ {
@ -197,8 +193,7 @@ void tst_qfile::readBigFile_QFSFileEngine_data()
readBigFile_data(QFSFileEngineBenchmark, QIODevice::NotOpen, QIODevice::Unbuffered); readBigFile_data(QFSFileEngineBenchmark, QIODevice::NotOpen, QIODevice::Unbuffered);
readBigFile_data(QFSFileEngineBenchmark, QIODevice::Text, QIODevice::Unbuffered); readBigFile_data(QFSFileEngineBenchmark, QIODevice::Text, QIODevice::Unbuffered);
#else #else
QTest::addColumn<int>("dummy"); QSKIP("This test requires -developer-build.");
QTest::newRow("Test will be skipped") << -1;
#endif #endif
} }
@ -209,10 +204,13 @@ void tst_qfile::readBigFile_posix_data()
void tst_qfile::readBigFile_Win32_data() void tst_qfile::readBigFile_Win32_data()
{ {
#ifdef Q_OS_WIN
readBigFile_data(Win32Benchmark, QIODevice::NotOpen, QIODevice::NotOpen); readBigFile_data(Win32Benchmark, QIODevice::NotOpen, QIODevice::NotOpen);
#else
QSKIP("This is Windows only benchmark.");
#endif
} }
void tst_qfile::readBigFile_data(BenchmarkType type, QIODevice::OpenModeFlag t, QIODevice::OpenModeFlag b) void tst_qfile::readBigFile_data(BenchmarkType type, QIODevice::OpenModeFlag t, QIODevice::OpenModeFlag b)
{ {
QTest::addColumn<tst_qfile::BenchmarkType>("testType"); QTest::addColumn<tst_qfile::BenchmarkType>("testType");
@ -239,11 +237,6 @@ void tst_qfile::readBigFile()
QFETCH(QFile::OpenModeFlag, textMode); QFETCH(QFile::OpenModeFlag, textMode);
QFETCH(QFile::OpenModeFlag, bufferedMode); QFETCH(QFile::OpenModeFlag, bufferedMode);
#ifndef Q_OS_WIN
if (testType == Win32Benchmark)
QSKIP("This is Windows only benchmark.");
#endif
char *buffer = new char[BUFSIZE]; char *buffer = new char[BUFSIZE];
createFile(); createFile();
fillFile(); fillFile();
@ -493,11 +486,7 @@ void tst_qfile::open()
void tst_qfile::readSmallFiles_QFile() { readSmallFiles(); } void tst_qfile::readSmallFiles_QFile() { readSmallFiles(); }
void tst_qfile::readSmallFiles_QFSFileEngine() void tst_qfile::readSmallFiles_QFSFileEngine()
{ {
#ifdef QT_BUILD_INTERNAL
readSmallFiles(); readSmallFiles();
#else
QSKIP("This test requires -developer-build.");
#endif
} }
void tst_qfile::readSmallFiles_posix() void tst_qfile::readSmallFiles_posix()
{ {
@ -524,8 +513,7 @@ void tst_qfile::readSmallFiles_QFSFileEngine_data()
readSmallFiles_data(QFSFileEngineBenchmark, QIODevice::NotOpen, QIODevice::Unbuffered); readSmallFiles_data(QFSFileEngineBenchmark, QIODevice::NotOpen, QIODevice::Unbuffered);
readSmallFiles_data(QFSFileEngineBenchmark, QIODevice::Text, QIODevice::Unbuffered); readSmallFiles_data(QFSFileEngineBenchmark, QIODevice::Text, QIODevice::Unbuffered);
#else #else
QTest::addColumn<int>("dummy"); QSKIP("This test requires -developer-build.");
QTest::newRow("Test will be skipped") << -1;
#endif #endif
} }
@ -536,9 +524,13 @@ void tst_qfile::readSmallFiles_posix_data()
void tst_qfile::readSmallFiles_Win32_data() void tst_qfile::readSmallFiles_Win32_data()
{ {
readSmallFiles_data(Win32Benchmark, QIODevice::NotOpen, QIODevice::NotOpen);
}
#ifdef Q_OS_WIN
readSmallFiles_data(Win32Benchmark, QIODevice::NotOpen, QIODevice::NotOpen);
#else
QSKIP("This is Windows only benchmark.");
#endif
}
void tst_qfile::readSmallFiles_data(BenchmarkType type, QIODevice::OpenModeFlag t, QIODevice::OpenModeFlag b) void tst_qfile::readSmallFiles_data(BenchmarkType type, QIODevice::OpenModeFlag t, QIODevice::OpenModeFlag b)
{ {
@ -592,11 +584,6 @@ void tst_qfile::readSmallFiles()
QFETCH(QFile::OpenModeFlag, textMode); QFETCH(QFile::OpenModeFlag, textMode);
QFETCH(QFile::OpenModeFlag, bufferedMode); QFETCH(QFile::OpenModeFlag, bufferedMode);
#ifndef Q_OS_WIN
if (testType == Win32Benchmark)
QSKIP("This is Windows only benchmark.");
#endif
createSmallFiles(); createSmallFiles();
QDir dir(tmpDirName); QDir dir(tmpDirName);