[CI] Link the version string and RNG stub into the test targets

The distribution libgtest.a now used by the Linux images makes the linker
pull more translation units out of libcockatrice_network than the fetched
googletest did. Those units reference VERSION_STRING and the global rng,
which several test targets never defined, so the instrumented Ubuntu 26.04
legs failed at link:

  undefined reference to `VERSION_STRING'
  undefined reference to `rng'

Add the generated version string source wherever a test links the network
umbrella, and define the rng stub in the tests that pull the server game
classes without declaring it. This matches what the neighbouring server
tests already do.

A full Debug build and ctest suite in the ci-ubuntu2604 image (system
libgtest.a) is green: 841 tests pass.

Fixes the nightly failures introduced by #6894.
This commit is contained in:
Lukas Brübach 2026-11-08 15:07:51 +01:00
parent b445f81c9d
commit 218e3da75b
4 changed files with 19 additions and 0 deletions

View file

@ -300,6 +300,7 @@ cockatrice_add_test(
NAME NAME
server_card_counter_test server_card_counter_test
SOURCES SOURCES
${VERSION_STRING_CPP}
server_card_counter_test.cpp server_card_counter_test.cpp
LIBS LIBS
libcockatrice_network libcockatrice_network
@ -310,6 +311,7 @@ cockatrice_add_test(
NAME NAME
server_dump_zone_test server_dump_zone_test
SOURCES SOURCES
${VERSION_STRING_CPP}
server_dump_zone_test.cpp server_dump_zone_test.cpp
LIBS LIBS
libcockatrice_rng libcockatrice_rng
@ -321,6 +323,7 @@ cockatrice_add_test(
NAME NAME
server_counter_test server_counter_test
SOURCES SOURCES
${VERSION_STRING_CPP}
server_counter_test.cpp server_counter_test.cpp
LIBS LIBS
libcockatrice_network libcockatrice_network
@ -332,6 +335,7 @@ cockatrice_add_test(
server_developer_role_test server_developer_role_test
NO_SANITIZE NO_SANITIZE
SOURCES SOURCES
${VERSION_STRING_CPP}
server_developer_role_test.cpp server_developer_role_test.cpp
LIBS LIBS
libcockatrice_network libcockatrice_network
@ -344,6 +348,7 @@ cockatrice_add_test(
server_moderator_role_test server_moderator_role_test
NO_SANITIZE NO_SANITIZE
SOURCES SOURCES
${VERSION_STRING_CPP}
server_moderator_role_test.cpp server_moderator_role_test.cpp
LIBS LIBS
libcockatrice_network libcockatrice_network
@ -390,6 +395,7 @@ cockatrice_add_test(
NAME NAME
local_client_lifetime_test local_client_lifetime_test
SOURCES SOURCES
${VERSION_STRING_CPP}
local_client_lifetime_test.cpp local_client_lifetime_test.cpp
LIBS LIBS
libcockatrice_network libcockatrice_network
@ -411,6 +417,7 @@ cockatrice_add_test(
NAME NAME
latency_tracker_test latency_tracker_test
SOURCES SOURCES
${VERSION_STRING_CPP}
latency_tracker_test.cpp latency_tracker_test.cpp
LIBS LIBS
libcockatrice_network libcockatrice_network

View file

@ -13,6 +13,10 @@
#include <QMetaObject> #include <QMetaObject>
#include <QString> #include <QString>
#include <gtest/gtest.h> #include <gtest/gtest.h>
#include <libcockatrice/rng/rng_abstract.h>
// Referenced by other translation units in the server_remote library.
RNG_Abstract *rng = nullptr;
namespace namespace
{ {

View file

@ -7,8 +7,12 @@
#include <climits> #include <climits>
#include <gtest/gtest.h> #include <gtest/gtest.h>
#include <libcockatrice/network/server/remote/game/dump_zone_range.h> #include <libcockatrice/network/server/remote/game/dump_zone_range.h>
#include <libcockatrice/rng/rng_abstract.h>
#include <vector> #include <vector>
// Referenced by other translation units in the server_remote library.
RNG_Abstract *rng = nullptr;
namespace namespace
{ {
/// Indices a dump request resolves to, as the handler would walk them. /// Indices a dump request resolves to, as the handler would walk them.

View file

@ -9,12 +9,16 @@
#include <QStringLiteral> #include <QStringLiteral>
#include <QTemporaryDir> #include <QTemporaryDir>
#include <gtest/gtest.h> #include <gtest/gtest.h>
#include <libcockatrice/rng/rng_abstract.h>
#include <string> #include <string>
// Owned by main.cpp in the real application; pixel_map_generator.cpp references // Owned by main.cpp in the real application; pixel_map_generator.cpp references
// it, so the test binary needs a definition even though it never renders. // it, so the test binary needs a definition even though it never renders.
ThemeManager *themeManager = nullptr; ThemeManager *themeManager = nullptr;
// Referenced by other translation units in the server_remote library.
RNG_Abstract *rng = nullptr;
namespace namespace
{ {
const QString LEGACY = QStringLiteral("Default"); const QString LEGACY = QStringLiteral("Default");