Skip to content

Commit

Permalink
BaselineProtocol: add FinalizeTesting command
Browse files Browse the repository at this point in the history
Also adds a helper function QBaselineTest::finalizeAndDisconnect()
that calls the finalize command, prints the optional report URL
and disconnects to the server.

Change-Id: Iabdba77f9eebad3e3f3fa67ab8977d1e49c49fb4
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
(cherry picked from commit 62b349c)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
  • Loading branch information
karjonas authored and Qt Cherry-pick Bot committed Nov 21, 2024
1 parent 505a277 commit 3ffc5ac
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 0 deletions.
5 changes: 5 additions & 0 deletions tests/baseline/shared/baselineprotocol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,11 @@ bool BaselineProtocol::submitMismatch(const ImageItem &item, QByteArray *serverM
return false;
}

bool BaselineProtocol::finalizeTesting(QByteArray *serverMsg)
{
Command cmd;
return sendBlock(Command::FinalizeTesting, {}) && receiveBlock(&cmd, serverMsg) && cmd == Ack;
}

bool BaselineProtocol::sendItem(Command cmd, const ImageItem &item)
{
Expand Down
2 changes: 2 additions & 0 deletions tests/baseline/shared/baselineprotocol.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ class BaselineProtocol
AcceptMatch = 3,
AcceptNewBaseline = 4,
AcceptMismatch = 5,
FinalizeTesting = 6,
// Responses
Ack = 128,
Abort = 129,
Expand All @@ -122,6 +123,7 @@ class BaselineProtocol
bool submitMatch(const ImageItem &item, QByteArray *serverMsg);
bool submitNewBaseline(const ImageItem &item, QByteArray *serverMsg);
bool submitMismatch(const ImageItem &item, QByteArray *serverMsg, bool *fuzzyMatch = nullptr);
bool finalizeTesting(QByteArray *serverMsg);

// For server:
bool acceptConnection(PlatformInfo *pi);
Expand Down
17 changes: 17 additions & 0 deletions tests/baseline/shared/qbaselinetest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,23 @@ bool connectToBaselineServer(QByteArray *msg)
return connect(msg ? msg : &dummyMsg, &dummy);
}

bool finalizeTesting(QByteArray *msg) {
QByteArray dummyMsg;
return proto.finalizeTesting(msg ? msg : &dummyMsg);
}

void finalizeAndDisconnect()
{
if (QByteArray msg; finalizeTesting(&msg)) {
if (msg.isEmpty())
qInfo() << "No baseline server report produced.";
else
qInfo() << "Baseline server report:" << msg.data();
}

disconnectFromBaselineServer();
}

void setAutoMode(bool mode)
{
customInfo.setAdHocRun(!mode);
Expand Down
2 changes: 2 additions & 0 deletions tests/baseline/shared/qbaselinetest.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,14 @@ void setProject(const QString &projectName); // Selects server config settings a
void setProjectImageKeys(const QStringList &keys); // Overrides the ItemPathKeys config setting
void addClientProperty(const QString& key, const QString& value);
bool connectToBaselineServer(QByteArray *msg = nullptr);
bool finalizeTesting(QByteArray *msg = nullptr);
bool checkImage(const QImage& img, const char *name, quint16 checksum, QByteArray *msg, bool *error, int manualdatatag = 0);
bool testImage(const QImage& img, QByteArray *msg, bool *error);
QTestData &newRow(const char *dataTag, quint16 checksum = 0);
bool isCurrentItemBlacklisted();
bool disconnectFromBaselineServer();
bool shouldAbortIfUnstable();
void finalizeAndDisconnect();
}

#define QBASELINE_CHECK_SUM(image, name, checksum)\
Expand Down

0 comments on commit 3ffc5ac

Please sign in to comment.