From 7b0df77c4964f3d1a4db7374a347c612e3f1d9ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Fri, 4 Dec 2020 02:06:54 +0100 Subject: [PATCH] tests: Get tod driver name from env variable --- tests/meson.build | 1 + tests/test-fp-context-tod.c | 4 +++- tests/test-fp-device-tod.c | 6 +++--- tests/test-utils-tod.c | 5 ++++- 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/tests/meson.build b/tests/meson.build index 52ded3eb..0c900fb0 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -200,6 +200,7 @@ if get_option('tod') 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') + tod_envs.set('FP_TOD_TEST_DRIVER_NAME', 'fake_test_dev_tod') tod_c_args = [ '-DTEST_TOD_DRIVER=1', ] diff --git a/tests/test-fp-context-tod.c b/tests/test-fp-context-tod.c index 6ee9ae24..f25a31dc 100644 --- a/tests/test-fp-context-tod.c +++ b/tests/test-fp-context-tod.c @@ -48,10 +48,12 @@ test_context_has_fake_device (void) g_autoptr(FpContext) context = NULL; FpDevice *fake_device = NULL; GPtrArray *devices; + const char *tod_name; unsigned int i; context = fp_context_new (); devices = fp_context_get_devices (context); + tod_name = g_getenv ("FP_TOD_TEST_DRIVER_NAME"); g_assert_nonnull (devices); g_assert_cmpuint (devices->len, ==, 1); @@ -60,7 +62,7 @@ test_context_has_fake_device (void) { FpDevice *device = devices->pdata[i]; - if (g_strcmp0 (fp_device_get_driver (device), "fake_test_dev_tod") == 0) + if (g_strcmp0 (fp_device_get_driver (device), tod_name) == 0) { fake_device = device; break; diff --git a/tests/test-fp-device-tod.c b/tests/test-fp-device-tod.c index e2f36131..d134d1e1 100644 --- a/tests/test-fp-device-tod.c +++ b/tests/test-fp-device-tod.c @@ -100,7 +100,7 @@ test_device_open_sync_notify (void) g_autoptr(FptContext) tctx = fpt_context_new_with_fake_dev (); g_signal_connect (tctx->device, "notify::open", G_CALLBACK (on_open_notify), tctx); - fp_device_open_sync (tctx->device, NULL, &error); + g_assert_true (fp_device_open_sync (tctx->device, NULL, &error)); g_assert_no_error (error); g_assert_true (GPOINTER_TO_INT (tctx->user_data)); } @@ -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_tod"); + g_assert_cmpstr (fp_device_get_driver (tctx->device), ==, g_getenv ("FP_TOD_TEST_DRIVER_NAME")); } 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_tod"); + g_assert_cmpstr (fp_device_get_device_id (tctx->device), ==, g_getenv ("FP_TOD_TEST_DRIVER_NAME")); } static void diff --git a/tests/test-utils-tod.c b/tests/test-utils-tod.c index cab61ebb..cf606fc9 100644 --- a/tests/test-utils-tod.c +++ b/tests/test-utils-tod.c @@ -28,11 +28,14 @@ fpt_context_new_with_fake_dev (void) { FptContext *tctx; GPtrArray *devices; + const char *tod_name; unsigned int i; tctx = fpt_context_new (); devices = fp_context_get_devices (tctx->fp_context); + tod_name = g_getenv ("FP_TOD_TEST_DRIVER_NAME"); + g_assert_nonnull (tod_name); g_assert_nonnull (devices); g_assert_cmpuint (devices->len, ==, 1); @@ -40,7 +43,7 @@ fpt_context_new_with_fake_dev (void) { FpDevice *device = devices->pdata[i]; - if (g_strcmp0 (fp_device_get_driver (device), "fake_test_dev_tod") == 0) + if (g_strcmp0 (fp_device_get_driver (device), tod_name) == 0) { tctx->device = device; break;