From 8d38e0eae2d59f7dc56c4ce3fc27785dd8a96680 Mon Sep 17 00:00:00 2001 From: Sjoerd Simons Date: Fri, 6 Apr 2018 21:29:35 +0200 Subject: [PATCH] synapticsmst: Fix self test A test run should really fail if it cannot find the test data, rather then reporting success (thus masking that it never ran). Fix the test to find it data (probably broken with the port to meson) and make it fail if it cannot find its data. Signed-off-by: Sjoerd Simons --- plugins/synapticsmst/fu-self-test.c | 43 +++++++++++++++-------------- plugins/synapticsmst/meson.build | 1 + 2 files changed, 24 insertions(+), 20 deletions(-) diff --git a/plugins/synapticsmst/fu-self-test.c b/plugins/synapticsmst/fu-self-test.c index c8c3aa0e0..a2e3074fe 100644 --- a/plugins/synapticsmst/fu-self-test.c +++ b/plugins/synapticsmst/fu-self-test.c @@ -60,29 +60,32 @@ fu_plugin_synapticsmst_func (void) g_assert (ret); /* Test with no Synaptics MST devices */ - test_directory = "./tests/no_devices"; - if (g_file_test (test_directory, G_FILE_TEST_IS_DIR)) { - g_setenv ("FWUPD_SYNAPTICSMST_FW_DIR", test_directory, TRUE); - ret = fu_plugin_runner_coldplug (plugin, &error); - g_assert_no_error (error); - g_assert (ret); - } + test_directory = SOURCEDIR "/tests/no_devices"; + g_assert(g_file_test (test_directory, G_FILE_TEST_IS_DIR)); + + g_setenv ("FWUPD_SYNAPTICSMST_FW_DIR", test_directory, TRUE); + ret = fu_plugin_runner_coldplug (plugin, &error); + g_assert_no_error (error); + g_assert (ret); /* Emulate adding/removing a Dell TB16 dock */ - test_directory = "./tests/tb16_dock"; - if (g_file_test (test_directory, G_FILE_TEST_IS_DIR)) { - g_setenv ("FWUPD_SYNAPTICSMST_FW_DIR", test_directory, TRUE); - ret = fu_plugin_runner_coldplug (plugin, &error); - g_assert_no_error (error); - g_assert (ret); + test_directory = SOURCEDIR "/tests/tb16_dock"; - device_count = devices->len; - for (guint i = 0; i < device_count; i++) { - device = g_ptr_array_index (devices, i); - g_assert_cmpstr (fu_device_get_version (device), ==, "3.10.002"); - g_ptr_array_remove (devices, device); - fu_plugin_device_remove (plugin, device); - } + g_assert (g_file_test (test_directory, G_FILE_TEST_IS_DIR)); + + g_setenv ("FWUPD_SYNAPTICSMST_FW_DIR", test_directory, TRUE); + ret = fu_plugin_runner_coldplug (plugin, &error); + g_assert_no_error (error); + g_assert (ret); + + device_count = devices->len; + g_assert_cmpuint (device_count, ==, 2); + + for (guint i = 0; i < device_count; i++) { + device = g_ptr_array_index (devices, i); + g_assert_cmpstr (fu_device_get_version (device), ==, "3.10.002"); + g_ptr_array_remove (devices, device); + fu_plugin_device_remove (plugin, device); } g_ptr_array_unref (devices); } diff --git a/plugins/synapticsmst/meson.build b/plugins/synapticsmst/meson.build index 516517bfe..5828b7d12 100644 --- a/plugins/synapticsmst/meson.build +++ b/plugins/synapticsmst/meson.build @@ -52,6 +52,7 @@ executable( if get_option('tests') cargs += '-DFU_OFFLINE_DESTDIR="/tmp/fwupd-self-test"' cargs += '-DPLUGINBUILDDIR="' + meson.current_build_dir() + '"' + cargs += '-DSOURCEDIR="' + meson.current_source_dir() + '"' e = executable( 'synapticsmst-self-test', sources : [