Skip to content

Commit

Permalink
Salsa-CI: Add MariaDB Connector C ABI version validation
Browse files Browse the repository at this point in the history
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!
  • Loading branch information
ottok committed May 15, 2023
1 parent b19f1f3 commit 6c3d6fd
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions debian/salsa-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 <<EOF
#include <cstring>
#include <iostream>
#include <mysql/mysql.h>
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
Expand Down

0 comments on commit 6c3d6fd

Please sign in to comment.