59 lines
1.8 KiB
C
59 lines
1.8 KiB
C
|
|
/**
|
||
|
|
* @file version_check.c
|
||
|
|
* @brief Tests that the loaded dependencies match the headers we compiled against.
|
||
|
|
*
|
||
|
|
* The soname normally catches a mismatch at load time. This earns its keep when
|
||
|
|
* the soname is bypassed -- a 0.2.0 dropped in under the 0.1 filename loads
|
||
|
|
* happily, and only the check notices.
|
||
|
|
*/
|
||
|
|
|
||
|
|
#include <string.h>
|
||
|
|
|
||
|
|
#include <akstdlib.h>
|
||
|
|
|
||
|
|
#include <akbasic/error.h>
|
||
|
|
|
||
|
|
#include "testutil.h"
|
||
|
|
|
||
|
|
int main(void)
|
||
|
|
{
|
||
|
|
int major = 0;
|
||
|
|
int minor = 0;
|
||
|
|
int patch = 0;
|
||
|
|
|
||
|
|
TEST_REQUIRE_OK(akbasic_error_register());
|
||
|
|
|
||
|
|
/*
|
||
|
|
* AKSL_VERSION_CHECK() is a macro on purpose: it expands here so it captures
|
||
|
|
* the numbers *this* translation unit was built with, and compares them to
|
||
|
|
* the ones baked into the library that actually loaded.
|
||
|
|
*/
|
||
|
|
TEST_REQUIRE_OK(AKSL_VERSION_CHECK());
|
||
|
|
|
||
|
|
TEST_REQUIRE_OK(aksl_version(&major, &minor, &patch));
|
||
|
|
TEST_REQUIRE_INT(major, AKSL_VERSION_MAJOR);
|
||
|
|
TEST_REQUIRE_INT(minor, AKSL_VERSION_MINOR);
|
||
|
|
TEST_REQUIRE_STR(aksl_version_string(), AKSL_VERSION_STRING);
|
||
|
|
TEST_REQUIRE_STR(aksl_version_soname(), AKSL_VERSION_SONAME);
|
||
|
|
|
||
|
|
/*
|
||
|
|
* While libakstdlib's major is 0 the soname carries MAJOR.MINOR, so 0.1 and
|
||
|
|
* 0.2 are different ABIs. Asserting the shape here means a future 1.0 bump
|
||
|
|
* that forgets to change the soname rule fails a test rather than shipping.
|
||
|
|
*/
|
||
|
|
if ( major == 0 ) {
|
||
|
|
char expected[32];
|
||
|
|
snprintf(expected, sizeof(expected), "%d.%d", major, minor);
|
||
|
|
TEST_REQUIRE_STR(aksl_version_soname(), expected);
|
||
|
|
}
|
||
|
|
|
||
|
|
/*
|
||
|
|
* libakerror publishes no version macro at all, so there is nothing to
|
||
|
|
* compare. Its floor is the #error on AKERR_FIRST_CONSUMER_STATUS that
|
||
|
|
* akbasic/error.h carries -- if this file compiled, that guard passed.
|
||
|
|
*/
|
||
|
|
TEST_REQUIRE_INT(AKERR_FIRST_CONSUMER_STATUS, 256);
|
||
|
|
|
||
|
|
return akbasic_test_failures;
|
||
|
|
}
|