tests: Get tod driver name from env variable

This commit is contained in:
Marco Trevisan (Treviño)
2020-12-04 02:06:54 +01:00
parent 1613c0de43
commit 7b0df77c49
4 changed files with 11 additions and 5 deletions
+1
View File
@@ -200,6 +200,7 @@ if get_option('tod')
tod_envs.set('FP_TOD_KEEP_MODULES_OPEN', 'TRUE') tod_envs.set('FP_TOD_KEEP_MODULES_OPEN', 'TRUE')
tod_envs.set('FP_VIRTUAL_FAKE_DEVICE', 'yes') tod_envs.set('FP_VIRTUAL_FAKE_DEVICE', 'yes')
tod_envs.append('FP_DRIVERS_WHITELIST', 'fake_test_dev_tod') 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 = [ tod_c_args = [
'-DTEST_TOD_DRIVER=1', '-DTEST_TOD_DRIVER=1',
] ]
+3 -1
View File
@@ -48,10 +48,12 @@ test_context_has_fake_device (void)
g_autoptr(FpContext) context = NULL; g_autoptr(FpContext) context = NULL;
FpDevice *fake_device = NULL; FpDevice *fake_device = NULL;
GPtrArray *devices; GPtrArray *devices;
const char *tod_name;
unsigned int i; unsigned int i;
context = fp_context_new (); context = fp_context_new ();
devices = fp_context_get_devices (context); devices = fp_context_get_devices (context);
tod_name = g_getenv ("FP_TOD_TEST_DRIVER_NAME");
g_assert_nonnull (devices); g_assert_nonnull (devices);
g_assert_cmpuint (devices->len, ==, 1); g_assert_cmpuint (devices->len, ==, 1);
@@ -60,7 +62,7 @@ test_context_has_fake_device (void)
{ {
FpDevice *device = devices->pdata[i]; 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; fake_device = device;
break; break;
+3 -3
View File
@@ -100,7 +100,7 @@ test_device_open_sync_notify (void)
g_autoptr(FptContext) tctx = fpt_context_new_with_fake_dev (); g_autoptr(FptContext) tctx = fpt_context_new_with_fake_dev ();
g_signal_connect (tctx->device, "notify::open", G_CALLBACK (on_open_notify), tctx); 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_no_error (error);
g_assert_true (GPOINTER_TO_INT (tctx->user_data)); 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 (); g_autoptr(FptContext) tctx = fpt_context_new_with_fake_dev ();
fp_device_open_sync (tctx->device, NULL, NULL); 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 static void
@@ -156,7 +156,7 @@ test_device_get_device_id (void)
g_autoptr(FptContext) tctx = fpt_context_new_with_fake_dev (); g_autoptr(FptContext) tctx = fpt_context_new_with_fake_dev ();
fp_device_open_sync (tctx->device, NULL, NULL); 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 static void
+4 -1
View File
@@ -28,11 +28,14 @@ fpt_context_new_with_fake_dev (void)
{ {
FptContext *tctx; FptContext *tctx;
GPtrArray *devices; GPtrArray *devices;
const char *tod_name;
unsigned int i; unsigned int i;
tctx = fpt_context_new (); tctx = fpt_context_new ();
devices = fp_context_get_devices (tctx->fp_context); 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_nonnull (devices);
g_assert_cmpuint (devices->len, ==, 1); g_assert_cmpuint (devices->len, ==, 1);
@@ -40,7 +43,7 @@ fpt_context_new_with_fake_dev (void)
{ {
FpDevice *device = devices->pdata[i]; 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; tctx->device = device;
break; break;