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 <sjoerd.simons@collabora.co.uk>
This commit is contained in:
Sjoerd Simons 2018-04-06 21:29:35 +02:00 committed by Mario Limonciello
parent 2bc6d0a38a
commit 8d38e0eae2
2 changed files with 24 additions and 20 deletions

View File

@ -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);
}

View File

@ -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 : [