From 6c3d6fd21a0f8b847cea5faa55ae6a5fd4f57363 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Otto=20Kek=C3=A4l=C3=A4inen?= Date: Sat, 8 Apr 2023 18:09:17 -0700 Subject: [PATCH] Salsa-CI: Add MariaDB Connector C ABI version validation The libmariadb3.symbols already checks that the ABI is stable in terms of symbols/functions. Add extra test to ensure that the version functions also continue to output expected strings. This helps avoid issues such as the one happened in MariaDB 10.3.38/10.5.19 and for which upstream still has submission open: https://github.com/mariadb-corporation/mariadb-connector-c/pull/219 Example output: $ g++ b1031863.cpp -l mariadb && ./a.out MARIADB_VERSION_ID: 30304 MYSQL_VERSION_ID: 30304 mysql_get_client_version(): 30304 mysql_get_client_info(): 3.3.4 On failure it might say: ERROR: MARIADB_VERSION_ID started with 100338 instead of the expected 303! --- debian/salsa-ci.yml | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/debian/salsa-ci.yml b/debian/salsa-ci.yml index d8d7b83d94534..2928fed175efd 100644 --- a/debian/salsa-ci.yml +++ b/debian/salsa-ci.yml @@ -270,6 +270,38 @@ blhc: echo "Testing -l mariadbclient" g++ b933063.cpp -l mariadbclient && ./a.out | tee result if grep --quiet latin result; then echo "ERROR: Charset latin found!"; exit 1; fi + - | + # Build a test binary to verify API version strings + cat > b1031863.cpp < + #include + #include + using namespace std; + + void test_if_starts_with(const string expected, const string tested, const string name) { + int r = strncmp(tested.c_str(), expected.c_str(), expected.size()); + if (r == 0) { + cout << name << ": " << tested << "\n"; + } else { + cout << "ERROR: " << name << " started with " << tested << " instead of the expected " << expected << "!\n"; + exit(1); + } + } + + int main() + { + MYSQL h; + // Constants refer to server version + test_if_starts_with("1011", to_string(MARIADB_VERSION_ID), "MARIADB_VERSION_ID"); + test_if_starts_with("1011", to_string(MYSQL_VERSION_ID), "MYSQL_VERSION_ID"); + // Client ABI returns connector version + test_if_starts_with("303", to_string(mysql_get_client_version()), "mysql_get_client_version()"); + test_if_starts_with("3.3", mysql_get_client_info(), "mysql_get_client_info()"); + return 0; + } + EOF + g++ b1031863.cpp -l mysqlclient && ./a.out + fresh install: stage: test