Skip to content

Commit d1baaad

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 d1baaad

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

debian/salsa-ci.yml

+30
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,36 @@ 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+
test_if_starts_with("303", to_string(MARIADB_VERSION_ID), "MARIADB_VERSION_ID");
295+
test_if_starts_with("303", to_string(MYSQL_VERSION_ID), "MYSQL_VERSION_ID");
296+
test_if_starts_with("303", to_string(mysql_get_client_version()), "mysql_get_client_version()");
297+
test_if_starts_with("3.3", mysql_get_client_info(), "mysql_get_client_info()");
298+
return 0;
299+
}
300+
EOF
301+
g++ b1031863.cpp -l mysqlclient && ./a.out
302+
273303
274304
fresh install:
275305
stage: test

0 commit comments

Comments
 (0)