Skip to content

Commit 6c3d6fd

Browse files
committed
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: mariadb-corporation/mariadb-connector-c#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!
1 parent b19f1f3 commit 6c3d6fd

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

debian/salsa-ci.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,38 @@ blhc:
270270
echo "Testing -l mariadbclient"
271271
g++ b933063.cpp -l mariadbclient && ./a.out | tee result
272272
if grep --quiet latin result; then echo "ERROR: Charset latin found!"; exit 1; fi
273+
- |
274+
# Build a test binary to verify API version strings
275+
cat > b1031863.cpp <<EOF
276+
#include <cstring>
277+
#include <iostream>
278+
#include <mysql/mysql.h>
279+
using namespace std;
280+
281+
void test_if_starts_with(const string expected, const string tested, const string name) {
282+
int r = strncmp(tested.c_str(), expected.c_str(), expected.size());
283+
if (r == 0) {
284+
cout << name << ": " << tested << "\n";
285+
} else {
286+
cout << "ERROR: " << name << " started with " << tested << " instead of the expected " << expected << "!\n";
287+
exit(1);
288+
}
289+
}
290+
291+
int main()
292+
{
293+
MYSQL h;
294+
// Constants refer to server version
295+
test_if_starts_with("1011", to_string(MARIADB_VERSION_ID), "MARIADB_VERSION_ID");
296+
test_if_starts_with("1011", to_string(MYSQL_VERSION_ID), "MYSQL_VERSION_ID");
297+
// Client ABI returns connector version
298+
test_if_starts_with("303", to_string(mysql_get_client_version()), "mysql_get_client_version()");
299+
test_if_starts_with("3.3", mysql_get_client_info(), "mysql_get_client_info()");
300+
return 0;
301+
}
302+
EOF
303+
g++ b1031863.cpp -l mysqlclient && ./a.out
304+
273305
274306
fresh install:
275307
stage: test

0 commit comments

Comments
 (0)