diff --git a/contrib/ci/build_and_install_rpms.sh b/contrib/ci/build_and_install_rpms.sh index 41025418b..6bdea4081 100755 --- a/contrib/ci/build_and_install_rpms.sh +++ b/contrib/ci/build_and_install_rpms.sh @@ -8,6 +8,7 @@ meson .. \ -Denable-doc=true \ -Denable-man=true \ -Denable-tests=true \ + -Denable-dummy=true \ -Denable-thunderbolt=false \ -Denable-uefi=true \ -Denable-dell=true \ @@ -24,6 +25,7 @@ sed "s,#VERSION#,$VERSION,; s,#BUILD#,1,; s,#LONGDATE#,`date '+%a %b %d %Y'`,; s,#ALPHATAG#,alpha,; + s,enable_dummy 0,enable_dummy 1,; s,Source0.*,Source0:\tfwupd-$VERSION.tar.xz," \ contrib/fwupd.spec.in > build/fwupd.spec diff --git a/contrib/debian/rules b/contrib/debian/rules index f934ebb93..f37fe6c3b 100755 --- a/contrib/debian/rules +++ b/contrib/debian/rules @@ -25,7 +25,7 @@ override_dh_auto_configure: else \ export DELL="-Denable-dell=false"; \ fi; \ - dh_auto_configure -- $$UEFI $$DELL --libexecdir=/usr/lib + dh_auto_configure -- $$UEFI $$DELL -Denable-dummy=true --libexecdir=/usr/lib override_dh_install: find debian/tmp/usr -type f -name "*a" -print | xargs rm -f diff --git a/contrib/fwupd.spec.in b/contrib/fwupd.spec.in index cdc3ffc0d..7a01e0766 100644 --- a/contrib/fwupd.spec.in +++ b/contrib/fwupd.spec.in @@ -7,6 +7,7 @@ %define alphatag #ALPHATAG# %global enable_tests 1 +%global enable_dummy 1 %ifarch x86_64 %{ix86} %global have_smbios 1 @@ -128,6 +129,11 @@ Data files for installed tests. -Denable-tests=true \ %else -Denable-tests=false \ +%endif +%if 0%{?enable_dummy} + -Denable-dummy=true \ +%else + -Denable-dummy=false \ %endif -Denable-thunderbolt=false \ %if 0%{?have_uefi} @@ -213,7 +219,9 @@ mkdir -p --mode=0700 $RPM_BUILD_ROOT%{_localstatedir}/lib/fwupd/gnupg %if 0%{?have_smbios} %{_libdir}/fwupd-plugins-2/libfu_plugin_synapticsmst.so %endif +%if 0%{?enable_dummy} %{_libdir}/fwupd-plugins-2/libfu_plugin_test.so +%endif %{_libdir}/fwupd-plugins-2/libfu_plugin_udev.so %if 0%{?have_uefi} %{_libdir}/fwupd-plugins-2/libfu_plugin_uefi.so diff --git a/data/installed-tests/fwupdmgr-verify.test.in b/data/installed-tests/fwupdmgr-verify.test.in new file mode 100644 index 000000000..c50c779a4 --- /dev/null +++ b/data/installed-tests/fwupdmgr-verify.test.in @@ -0,0 +1,3 @@ +[Test] +Type=session +Exec=sh -c "@bindir@/fwupdmgr verify-update && @bindir@/fwupdmgr verify" diff --git a/data/installed-tests/meson.build b/data/installed-tests/meson.build index 6b9551fdf..95d9417e6 100644 --- a/data/installed-tests/meson.build +++ b/data/installed-tests/meson.build @@ -12,6 +12,7 @@ testfiles = [ 'fwupdmgr-get-updates.test', 'fwupdmgr-refresh-offline.test', 'fwupdmgr-refresh.test', + 'fwupdmgr-verify.test', ] foreach arg: testfiles diff --git a/meson_options.txt b/meson_options.txt index 3b65561d3..4969da312 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -9,4 +9,5 @@ option('enable-dell', type : 'boolean', value : true, description : 'enable Dell option('enable-thunderbolt', type : 'boolean', value : true, description : 'enable Thunderbolt support') option('enable-systemd', type : 'boolean', value : true, description : 'enable systemd support') option('enable-consolekit', type : 'boolean', value : true, description : 'enable ConsoleKit support') +option('enable-dummy', type : 'boolean', value : false, description : 'enable the dummy device') option('with-bootdir', type : 'string', value : '/boot/efi', description : 'Directory for EFI system partition') diff --git a/plugins/test/fu-plugin-test.c b/plugins/test/fu-plugin-test.c index 84d490fd7..fc10c8b67 100644 --- a/plugins/test/fu-plugin-test.c +++ b/plugins/test/fu-plugin-test.c @@ -32,12 +32,6 @@ void fu_plugin_init (FuPlugin *plugin) { fu_plugin_alloc_data (plugin, sizeof (FuPluginData)); - - /* only enable when testing */ - if (g_getenv ("FWUPD_ENABLE_TEST_PLUGIN") == NULL) { - fu_plugin_set_enabled (plugin, FALSE); - return; - } g_debug ("init"); } @@ -61,12 +55,40 @@ fu_plugin_coldplug (FuPlugin *plugin, GError **error) g_autoptr(FuDevice) device = NULL; device = fu_device_new (); fu_device_set_id (device, "FakeDevice"); - fu_device_add_guid (device, "00000000-0000-0000-0000-000000000000"); + fu_device_add_guid (device, "b585990a-003e-5270-89d5-3705a17f9a43"); fu_device_set_name (device, "Integrated_Webcam(TM)"); + fu_device_add_flag (device, FWUPD_DEVICE_FLAG_ALLOW_ONLINE); + fu_device_set_description (device, "A fake webcam"); + fu_device_set_vendor (device, "ACME Corp."); + fu_device_set_vendor_id (device, "USB:0x046D"); + fu_device_set_version_bootloader (device, "0.1.2"); + fu_device_set_version (device, "1.2.3"); + fu_device_set_version_lowest (device, "1.2.0"); fu_plugin_device_add (plugin, device); return TRUE; } +gboolean +fu_plugin_verify (FuPlugin *plugin, + FuDevice *device, + FuPluginVerifyFlags flags, + GError **error) +{ + if (g_strcmp0 (fu_device_get_version (device), "1.2.3") == 0) { + fu_device_add_checksum (device, "13fad4329b7e9cc8d0fe05afb5573f328d362f4f"); + return TRUE; + } + if (g_strcmp0 (fu_device_get_version (device), "1.2.4") == 0) { + fu_device_add_checksum (device, "81bc8b33c2cefb1afdbe294b912d20a92c7d0968"); + return TRUE; + } + g_set_error (error, + FWUPD_ERROR, + FWUPD_ERROR_NOT_SUPPORTED, + "no checksum for %s", fu_device_get_version (device)); + return FALSE; +} + gboolean fu_plugin_update_online (FuPlugin *plugin, FuDevice *device, @@ -81,6 +103,20 @@ fu_plugin_update_online (FuPlugin *plugin, "cannot handle offline"); } fu_plugin_set_status (plugin, FWUPD_STATUS_DECOMPRESSING); + for (guint i = 1; i <= 100; i++) { + g_usleep (1000); + fu_plugin_set_percentage (plugin, i); + } fu_plugin_set_status (plugin, FWUPD_STATUS_DEVICE_WRITE); + for (guint i = 1; i <= 100; i++) { + g_usleep (1000); + fu_plugin_set_percentage (plugin, i); + } + fu_plugin_set_status (plugin, FWUPD_STATUS_DEVICE_VERIFY); + for (guint i = 1; i <= 100; i++) { + g_usleep (1000); + fu_plugin_set_percentage (plugin, i); + } + fu_device_set_version (device, "1.2.4"); return TRUE; } diff --git a/plugins/test/meson.build b/plugins/test/meson.build index 9a77c3219..329f80ee0 100644 --- a/plugins/test/meson.build +++ b/plugins/test/meson.build @@ -1,5 +1,10 @@ cargs = ['-DG_LOG_DOMAIN="FuPluginTest"'] +install_dummy = false +if get_option('enable-dummy') + install_dummy = true +endif + shared_module('fu_plugin_test', sources : [ 'fu-plugin-test.c', @@ -9,7 +14,7 @@ shared_module('fu_plugin_test', include_directories('../../src'), include_directories('../../libfwupd'), ], - install : true, + install : install_dummy, install_dir: plugin_dir, c_args : cargs, dependencies : [ diff --git a/src/fu-self-test.c b/src/fu-self-test.c index 5a323c3ac..d89d17805 100644 --- a/src/fu-self-test.c +++ b/src/fu-self-test.c @@ -178,8 +178,6 @@ fu_plugin_module_func (void) g_autoptr(GBytes) blob_cab = NULL; g_autoptr(GMappedFile) mapped_file = NULL; - g_setenv ("FWUPD_ENABLE_TEST_PLUGIN", "1", TRUE); - /* create a fake device */ plugin = fu_plugin_new (); ret = fu_plugin_open (plugin, PLUGINBUILDDIR "/libfu_plugin_test.so", &error); @@ -202,8 +200,11 @@ fu_plugin_module_func (void) g_assert_cmpint (cnt, ==, 0); g_assert (device != NULL); g_assert_cmpstr (fu_device_get_id (device), ==, "FakeDevice"); + g_assert_cmpstr (fu_device_get_version_lowest (device), ==, "1.2.0"); + g_assert_cmpstr (fu_device_get_version (device), ==, "1.2.3"); + g_assert_cmpstr (fu_device_get_version_bootloader (device), ==, "0.1.2"); g_assert_cmpstr (fu_device_get_guid_default (device), ==, - "00000000-0000-0000-0000-000000000000"); + "b585990a-003e-5270-89d5-3705a17f9a43"); g_assert_cmpstr (fu_device_get_name (device), ==, "Integrated Webcam™"); @@ -214,7 +215,7 @@ fu_plugin_module_func (void) g_assert (mapped_file != NULL); blob_cab = g_mapped_file_get_bytes (mapped_file); ret = fu_plugin_runner_update (plugin, device, blob_cab, NULL, - FWUPD_INSTALL_FLAG_OFFLINE, &error); + FWUPD_INSTALL_FLAG_OFFLINE, &error); g_assert_no_error (error); g_assert (ret); g_assert_cmpint (cnt, ==, 1); @@ -234,10 +235,14 @@ fu_plugin_module_func (void) /* lets do this online */ ret = fu_plugin_runner_update (plugin, device, blob_cab, NULL, - FWUPD_INSTALL_FLAG_NONE, &error); + FWUPD_INSTALL_FLAG_NONE, &error); g_assert_no_error (error); g_assert (ret); - g_assert_cmpint (cnt, ==, 3); + g_assert_cmpint (cnt, ==, 4); + + /* check the new version */ + g_assert_cmpstr (fu_device_get_version (device), ==, "1.2.4"); + g_assert_cmpstr (fu_device_get_version_bootloader (device), ==, "0.1.2"); /* lets check the pending */ res = fu_pending_get_device (pending, fu_device_get_id (device), &error);