test: split the library version test out

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
Peter Hutterer 2019-03-06 13:56:01 +10:00
parent 4e0a362803
commit c0f4ede0c2
3 changed files with 30 additions and 25 deletions

View file

@ -800,6 +800,13 @@ if get_option('tests')
install : false) install : false)
test('test-litest-selftest', test_litest_selftest) test('test-litest-selftest', test_litest_selftest)
def_LT_VERSION = '-DLIBINPUT_LT_VERSION="@0@:@1@:@2@"'.format(libinput_lt_c, libinput_lt_r, libinput_lt_a)
test_library_version = executable('test-library-version',
['test/test-library-version.c'],
c_args : [ def_LT_VERSION ],
install : false)
test('test-library-version', test_library_version)
libinput_test_runner_sources = litest_sources + [ libinput_test_runner_sources = litest_sources + [
'src/libinput-util.h', 'src/libinput-util.h',
'src/libinput-util.c', 'src/libinput-util.c',
@ -822,12 +829,10 @@ if get_option('tests')
'test/test-switch.c', 'test/test-switch.c',
'test/test-quirks.c', 'test/test-quirks.c',
] ]
def_LT_VERSION = '-DLIBINPUT_LT_VERSION="@0@:@1@:@2@"'.format(libinput_lt_c, libinput_lt_r, libinput_lt_a)
libinput_test_runner = executable('libinput-test-suite-runner', libinput_test_runner = executable('libinput-test-suite-runner',
libinput_test_runner_sources, libinput_test_runner_sources,
include_directories : [includes_src, includes_include], include_directories : [includes_src, includes_include],
dependencies : deps_litest, dependencies : deps_litest,
c_args : [ def_LT_VERSION ],
install : false) install : false)
test('libinput-test-suite-runner', test('libinput-test-suite-runner',
libinput_test_runner, libinput_test_runner,

View file

@ -0,0 +1,23 @@
#include <assert.h>
#include <stdio.h>
int main(void) {
const char *version = LIBINPUT_LT_VERSION;
int C, R, A;
int rc;
rc = sscanf(version, "%d:%d:%d", &C, &R, &A);
assert(rc == 3);
assert(C >= 17);
assert(R >= 0);
assert(A >= 7);
/* Binary compatibility broken? */
assert(R != 0 || A != 0);
/* The first stable API in 0.12 had 10:0:0 */
assert(C - A == 10);
return 0;
}

View file

@ -1569,27 +1569,6 @@ START_TEST(fd_no_event_leak)
} }
END_TEST END_TEST
START_TEST(library_version)
{
const char *version = LIBINPUT_LT_VERSION;
int C, R, A;
int rc;
rc = sscanf(version, "%d:%d:%d", &C, &R, &A);
ck_assert_int_eq(rc, 3);
ck_assert_int_ge(C, 17);
ck_assert_int_ge(R, 0);
ck_assert_int_ge(A, 7);
/* Binary compatibility broken? */
ck_assert(R != 0 || A != 0);
/* The first stable API in 0.12 had 10:0:0 */
ck_assert_int_eq(C - A, 10);
}
END_TEST
static void timer_offset_warning(struct libinput *libinput, static void timer_offset_warning(struct libinput *libinput,
enum libinput_log_priority priority, enum libinput_log_priority priority,
const char *format, const char *format,
@ -1818,8 +1797,6 @@ TEST_COLLECTION(misc)
litest_add_no_device("misc:fd", fd_no_event_leak); litest_add_no_device("misc:fd", fd_no_event_leak);
litest_add_deviceless("misc:library_version", library_version);
litest_add_deviceless("misc:list", list_test_insert); litest_add_deviceless("misc:list", list_test_insert);
litest_add_deviceless("misc:list", list_test_append); litest_add_deviceless("misc:list", list_test_append);
litest_add_deviceless("misc:versionsort", strverscmp_test); litest_add_deviceless("misc:versionsort", strverscmp_test);