From 9cbb3e5f55620233e9175d1f4f26b49c0f64f419 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Thu, 3 Dec 2020 04:34:17 +0100 Subject: [PATCH] tests: Isolate more the TOD tests so that we build the driver without clashes --- tests/meson.build | 16 ++++++++++++---- tests/test-device-fake.c | 4 ++++ tests/test-fp-context-tod.c | 2 +- tests/test-fp-device-tod.c | 4 ++-- tests/test-utils-tod.c | 2 +- 5 files changed, 20 insertions(+), 8 deletions(-) diff --git a/tests/meson.build b/tests/meson.build index 0d2f3cd9..cc6992ea 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -199,14 +199,18 @@ if get_option('tod') tod_envs.set('FP_TOD_DRIVERS_DIR', meson.current_build_dir()) tod_envs.set('FP_TOD_KEEP_MODULES_OPEN', 'TRUE') tod_envs.set('FP_VIRTUAL_FAKE_DEVICE', 'yes') - tod_envs.append('FP_DRIVERS_WHITELIST', 'fake_test_dev') + tod_envs.append('FP_DRIVERS_WHITELIST', 'fake_test_dev_tod') + tod_c_args = [ + '-DTEST_TOD_DRIVER=1', + ] fake_driver = shared_module('device-fake-tod-driver', sources: [ + 'test-device-fake.c', 'test-device-fake-tod.c', ], + c_args: tod_c_args, link_with: [ - test_utils, libfprint_tod, ], include_directories: include_directories('../libfprint'), @@ -216,10 +220,10 @@ if get_option('tod') test_utils_tod = static_library('fprint-test-utils-tod', sources: [ + 'test-utils.c', 'test-utils-tod.c', ], dependencies: libfprint_private_dep, - link_with: test_utils, install: false) tod_unit_tests = [ @@ -232,7 +236,10 @@ if get_option('tod') test_exe = executable(basename, sources: basename + '.c', dependencies: libfprint_private_dep, - c_args: common_cflags, + c_args: [ + common_cflags, + tod_c_args, + ], link_with: test_utils_tod, ) test(test_name, @@ -240,6 +247,7 @@ if get_option('tod') suite: ['unit-tests', 'tod'], args: [test_exe], env: tod_envs, + depends: fake_driver, ) endforeach endif diff --git a/tests/test-device-fake.c b/tests/test-device-fake.c index 23415812..84b63b70 100644 --- a/tests/test-device-fake.c +++ b/tests/test-device-fake.c @@ -18,7 +18,11 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#ifdef TEST_TOD_DRIVER +#define FP_COMPONENT "fake_test_dev_tod" +#else #define FP_COMPONENT "fake_test_dev" +#endif #include "test-device-fake.h" diff --git a/tests/test-fp-context-tod.c b/tests/test-fp-context-tod.c index abafc62d..6ee9ae24 100644 --- a/tests/test-fp-context-tod.c +++ b/tests/test-fp-context-tod.c @@ -60,7 +60,7 @@ test_context_has_fake_device (void) { FpDevice *device = devices->pdata[i]; - if (g_strcmp0 (fp_device_get_driver (device), "fake_test_dev") == 0) + if (g_strcmp0 (fp_device_get_driver (device), "fake_test_dev_tod") == 0) { fake_device = device; break; diff --git a/tests/test-fp-device-tod.c b/tests/test-fp-device-tod.c index 25253e6e..e2f36131 100644 --- a/tests/test-fp-device-tod.c +++ b/tests/test-fp-device-tod.c @@ -147,7 +147,7 @@ test_device_get_driver (void) g_autoptr(FptContext) tctx = fpt_context_new_with_fake_dev (); fp_device_open_sync (tctx->device, NULL, NULL); - g_assert_cmpstr (fp_device_get_driver (tctx->device), ==, "fake_test_dev"); + g_assert_cmpstr (fp_device_get_driver (tctx->device), ==, "fake_test_dev_tod"); } static void @@ -156,7 +156,7 @@ test_device_get_device_id (void) g_autoptr(FptContext) tctx = fpt_context_new_with_fake_dev (); fp_device_open_sync (tctx->device, NULL, NULL); - g_assert_cmpstr (fp_device_get_device_id (tctx->device), ==, "fake_test_dev"); + g_assert_cmpstr (fp_device_get_device_id (tctx->device), ==, "fake_test_dev_tod"); } static void diff --git a/tests/test-utils-tod.c b/tests/test-utils-tod.c index d8fbb37c..d5ca5037 100644 --- a/tests/test-utils-tod.c +++ b/tests/test-utils-tod.c @@ -38,7 +38,7 @@ fpt_context_new_with_fake_dev (void) { FpDevice *device = devices->pdata[i]; - if (g_strcmp0 (fp_device_get_driver (device), "fake_test_dev") == 0) + if (g_strcmp0 (fp_device_get_driver (device), "fake_test_dev_tod") == 0) { tctx->device = device; break;