6#include <QtCore/qglobal.h>
7#include <QtCore/qlibraryinfo.h>
9#include <QtTest/private/qtestlog_p.h>
10#include <QtTest/private/qxmltestlogger_p.h>
11#include <QtTest/private/qtestresult_p.h>
12#include <QtTest/private/qbenchmark_p.h>
13#include <QtTest/private/qbenchmarkmetric_p.h>
14#include <QtTest/qtestcase.h>
110 Q_ASSERT_X(
false,
"QXmlTestLogger::startLogging",
111 "Insanely long test-case name or OOM issue");
119 " <QtVersion>%s</QtVersion>\n"
120 " <QtBuild>%s</QtBuild>\n"
149 Q_ASSERT_X(
false,
"QXmlTestLogger::enterTestFunction",
150 "Insanely long test-function name or OOM issue");
158 " <Duration msecs=\"%s\"/>\n"
159 " </TestFunction>\n",
177 ?
" <Incident type=\"%s\" file=\"%s\" line=\"%d\" />\n"
178 :
" <Incident type=\"%s\" file=\"%s\" line=\"%d\">\n"
179 " <DataTag><![CDATA[%s%s%s%s]]></DataTag>\n"
183 ?
" <Incident type=\"%s\" file=\"%s\" line=\"%d\">\n"
184 " <Description><![CDATA[%s%s%s%s]]></Description>\n"
186 :
" <Incident type=\"%s\" file=\"%s\" line=\"%d\">\n"
187 " <DataTag><![CDATA[%s%s%s]]></DataTag>\n"
188 " <Description><![CDATA[%s]]></Description>\n"
194 return " <BenchmarkResult metric=\"%s\" tag=\"%s\" value=\"%.6g\" iterations=\"%d\" />\n";
201 return " <Message type=\"%s\" file=\"%s\" line=\"%d\" />\n";
203 return " <Message type=\"%s\" file=\"%s\" line=\"%d\">\n"
204 " <DataTag><![CDATA[%s%s%s%s]]></DataTag>\n"
208 return " <Message type=\"%s\" file=\"%s\" line=\"%d\">\n"
209 " <Description><![CDATA[%s%s%s%s]]></Description>\n"
212 return " <Message type=\"%s\" file=\"%s\" line=\"%d\">\n"
213 " <DataTag><![CDATA[%s%s%s]]></DataTag>\n"
214 " <Description><![CDATA[%s]]></Description>\n"
227 const char *filler = (
tag && gtag) ?
":" :
"";
238 &&
xmlCdata(&cdataDescription, description)) {
258 if (
xmlQuote("edMetric, benchmarkMetricName(
result.measurement.metric))
277 const char *filler = (
tag && gtag) ?
":" :
"";
307 char *dest = destBuf->
data();
315 char *
end = dest +
n;
320#define MAP_ENTITY(chr, ent) \
322 if (dest + sizeof(ent) < end) { \
324 dest += sizeof(ent) - 1; \
327 return dest + sizeof(ent) - begin; \
365 char *dest = destBuf->
data();
372 static char const CDATA_END[] =
"]]>";
373 static char const CDATA_END_ESCAPED[] =
"]]]><![CDATA[]>";
374 const size_t CDATA_END_LEN =
sizeof(CDATA_END) - 1;
377 char *
end = dest +
n;
384 if (!strncmp(
src, CDATA_END, CDATA_END_LEN)) {
385 if (dest +
sizeof(CDATA_END_ESCAPED) <
end) {
386 strcpy(dest, CDATA_END_ESCAPED);
387 src += CDATA_END_LEN;
388 dest +=
sizeof(CDATA_END_ESCAPED) - 1;
391 return dest +
sizeof(CDATA_END_ESCAPED) -
begin;
415 constexpr int MAXSIZE = 1024 * 1024 * 2;
428 }
while (size <= MAXSIZE && str->
reset(
size));
Base class for test loggers.
void outputString(const char *msg)
Convenience method to write msg to the output stream.
IncidentTypes
\value Pass The test ran to completion successfully.
virtual void startLogging()
Called before the start of a test run.
MessageTypes
The members whose names begin with Q describe messages that originate in calls, by the test or code u...
virtual void stopLogging()
Called after the end of a test run.
static const char * build() noexcept
Returns a string describing how this version of Qt was built.
\macro QT_RESTRICTED_CAST_FROM_ASCII
qsizetype size() const
Returns the number of characters in this string.
QChar * data()
Returns a pointer to the data stored in the QString.
static QString number(int, int base=10)
This is an overloaded member function, provided for convenience. It differs from the above function o...
static qreal msecsFunctionTime()
static qreal msecsTotalTime()
static const char * currentTestObjectName()
static const char * currentGlobalDataTag()
static const char * currentDataTag()
void startLogging() override
Called before the start of a test run.
void addIncident(IncidentTypes type, const char *description, const char *file=nullptr, int line=0) override
This virtual method is called when an event occurs that relates to the resolution of the test.
static bool xmlCdata(QTestCharBuffer *dest, char const *src)
void addBenchmarkResult(const QBenchmarkResult &result) override
This virtual method is called after a benchmark has been run enough times to produce usable data.
void addMessage(MessageTypes type, const QString &message, const char *file=nullptr, int line=0) override
This is an overloaded member function, provided for convenience. It differs from the above function o...
void enterTestFunction(const char *function) override
This virtual method is called before each test function is invoked.
void stopLogging() override
Called after the end of a test run.
static bool xmlQuote(QTestCharBuffer *dest, char const *src)
QXmlTestLogger(XmlMode mode, const char *filename)
void leaveTestFunction() override
This virtual method is called after a test function has completed, to match \l enterTestFunction().
Combined button and popup list for selecting options.
int qt_asprintf(QTestCharBuffer *str, const char *format,...)
static const char * xmlIncidentType2String(QAbstractTestLogger::IncidentTypes type)
static const char * incidentFormatString(bool noDescription, bool noTag)
static const char * benchmarkResultFormatString()
static bool isEmpty(const char *str)
static const char * xmlMessageType2String(QAbstractTestLogger::MessageTypes type)
static const char * messageFormatString(bool noDescription, bool noTag)
AudioChannelLayoutTag tag
DBusConnection const char DBusError DBusBusType DBusError return DBusConnection DBusHandleMessageFunction function
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLenum GLuint GLenum GLsizei const GLchar * buf
GLuint GLsizei const GLchar * message
#define Q_ASSERT_X(cond, x, msg)
QtPrivate::QRegularExpressionMatchIteratorRangeBasedForIterator begin(const QRegularExpressionMatchIterator &iterator)
#define QTEST_VERSION_STR
QT_BEGIN_NAMESPACE Q_CORE_EXPORT Q_DECL_CONST_FUNCTION const char * qVersion(void) Q_DECL_NOEXCEPT
int(* StringFormatFunction)(QTestCharBuffer *, char const *, qsizetype)
#define MAP_ENTITY(chr, ent)
static bool allocateStringFn(QTestCharBuffer *str, char const *src, StringFormatFunction func)
const char * constData() const