diff options
author | Thiago Macieira <thiago.macieira@intel.com> | 2016-04-12 15:58:32 -0700 |
---|---|---|
committer | Thiago Macieira <thiago.macieira@intel.com> | 2016-05-14 01:21:27 +0000 |
commit | a26435d65ceac5d714d5cc7d5af2326e162d7a41 (patch) | |
tree | a82e2dbc48030a0113db31920577a186bdef89b1 /tests/auto | |
parent | 56b5706ce05895d2acab8de55abf5b7d3f69e80f (diff) |
Print the QStorageInfo dump on test start
So we know what we're looking at if there's a test failure. This is like
QNetworkInterface.
Change-Id: Id75834dab9ed466e94c7ffff1444bf51f615e944
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'tests/auto')
-rw-r--r-- | tests/auto/corelib/io/qstorageinfo/tst_qstorageinfo.cpp | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/tests/auto/corelib/io/qstorageinfo/tst_qstorageinfo.cpp b/tests/auto/corelib/io/qstorageinfo/tst_qstorageinfo.cpp index 1afcf05135..004ace4e2e 100644 --- a/tests/auto/corelib/io/qstorageinfo/tst_qstorageinfo.cpp +++ b/tests/auto/corelib/io/qstorageinfo/tst_qstorageinfo.cpp @@ -32,14 +32,18 @@ ****************************************************************************/ #include <QtTest/QtTest> - #include <QStorageInfo> +#include <stdarg.h> + +#include "../../../../manual/qstorageinfo/printvolumes.cpp" + class tst_QStorageInfo : public QObject { Q_OBJECT private slots: void defaultValues(); + void dump(); void operatorEqual(); #ifndef Q_OS_WINRT void operatorNotEqual(); @@ -66,6 +70,33 @@ void tst_QStorageInfo::defaultValues() QVERIFY(storage.bytesAvailable() == -1); } +static int qInfoPrinter(const char *format, ...) +{ + static char buf[1024]; + static size_t bufuse = 0; + + va_list ap; + va_start(ap, format); // use variable arg list + int n = qvsnprintf(buf + bufuse, sizeof(buf) - bufuse, format, ap); + va_end(ap); + + bufuse += n; + if (bufuse >= sizeof(buf) - 1 || format[strlen(format) - 1] == '\n') { + // flush + QtMessageHandler qt_message_print = qInstallMessageHandler(0); + qInstallMessageHandler(qt_message_print); // restore the handler + qt_message_print(QtInfoMsg, QMessageLogContext(), QString::fromLocal8Bit(buf)); + bufuse = 0; + } + + return 1; +} + +void tst_QStorageInfo::dump() +{ + printVolumes(QStorageInfo::mountedVolumes(), qInfoPrinter); +} + void tst_QStorageInfo::operatorEqual() { { |