test: run multi-process tests with one harness

- Add test::RunDevices(): starts the devices with the same session,
  transport, shm options and channel config, with a deadline per run
- Add the TestDevice base: Check() fails the device, Succeed() prints
  a marker with the transport name that the harness verifies
- Make the protocol, poller and transfer-timeout devices check their
  own results and drop the InitTask() sleeps
- Replace EXPECT_EXIT() and the copied launch code in the protocol,
  poller and transfer-timeout tests
- A device that uses the wrong transport now fails the test

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Claude
2026-11-03 14:27:11 +00:00
committed by Dennis Klein
parent f50b1f0e39
commit be400e4752
20 changed files with 446 additions and 800 deletions

View File

@@ -9,60 +9,32 @@
#ifndef FAIR_MQ_TEST_PUB_H
#define FAIR_MQ_TEST_PUB_H
#include <fairmq/Device.h>
#include <fairlogger/Logger.h>
#include <chrono>
#include <thread>
#include "TestDevice.h"
namespace fair::mq::test
{
class Pub : public Device
/// Publishes one message after both Sub devices report that they are ready,
/// then waits for an ack from each.
class Pub : public TestDevice
{
protected:
auto InitTask() -> void override
{
std::this_thread::sleep_for(std::chrono::milliseconds(200));
}
auto Run() -> void override
{
auto ready1 = NewMessage();
auto ready2 = NewMessage();
auto r1 = Receive(ready1, "control");
auto r2 = Receive(ready2, "control");
if (r1 >= 0 && r2 >= 0)
{
LOG(info) << "Received both ready signals, proceeding to publish data";
auto msg = NewMessage();
auto d1 = Send(msg, "data");
if (d1 >= 0)
{
LOG(info) << "Sent data: d1 = " << d1;
}
else
{
LOG(error) << "Failed sending data: d1 = " << d1;
}
auto ack1 = NewMessage();
auto ack2 = NewMessage();
auto a1 = Receive(ack1, "control");
auto a2 = Receive(ack2, "control");
if (a1 >= 0 && a2 >= 0)
{
LOG(info) << "PUB-SUB test successfull";
}
else
{
LOG(error) << "Failed receiving ack signal: a1 = " << a1 << ", a2 = " << a2;
}
for (int i = 0; i < 2; ++i) {
auto ready = NewMessage();
Check(Receive(ready, "control") >= 0, "receive ready signal");
}
else
{
LOG(error) << "Failed receiving ready signal: r1 = " << r1 << ", r2 = " << r2;
auto msg = NewMessage();
Check(Send(msg, "data") >= 0, "publish data");
for (int i = 0; i < 2; ++i) {
auto ack = NewMessage();
Check(Receive(ack, "control") >= 0, "receive ack");
}
Succeed();
}
};