mirror of
https://git.proxmox.com/git/fwupd
synced 2025-08-05 12:12:48 +00:00
trivial: Add a self tests for the broken metadata bug
This commit is contained in:
parent
820dac7fde
commit
882ab6b4d0
3
data/tests/remotes.d/broken.conf
Normal file
3
data/tests/remotes.d/broken.conf
Normal file
@ -0,0 +1,3 @@
|
||||
[fwupd Remote]
|
||||
Enabled=true
|
||||
MetadataURI=file:///tmp/fwupd-self-test/broken.xml.gz
|
@ -30,6 +30,7 @@
|
||||
#include <string.h>
|
||||
|
||||
#include "fu-device-private.h"
|
||||
#include "fu-engine.h"
|
||||
#include "fu-keyring.h"
|
||||
#include "fu-pending.h"
|
||||
#include "fu-plugin-private.h"
|
||||
@ -44,6 +45,29 @@
|
||||
#include "fu-keyring-pkcs7.h"
|
||||
#endif
|
||||
|
||||
static void
|
||||
fu_engine_func (void)
|
||||
{
|
||||
gboolean ret;
|
||||
g_autoptr(FuEngine) engine = fu_engine_new ();
|
||||
g_autoptr(GError) error = NULL;
|
||||
g_autofree gchar *testdatadir = NULL;
|
||||
|
||||
ret = g_file_set_contents ("/tmp/fwupd-self-test/broken.xml.gz",
|
||||
"this is not a valid", -1, &error);
|
||||
g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_WARNING,
|
||||
"failed to load remote broken: *");
|
||||
|
||||
testdatadir = fu_test_get_filename (TESTDATADIR, ".");
|
||||
g_assert (testdatadir != NULL);
|
||||
g_setenv ("FU_SELF_TEST_REMOTES_DIR", testdatadir, TRUE);
|
||||
ret = fu_engine_load (engine, &error);
|
||||
g_assert_no_error (error);
|
||||
g_assert (ret);
|
||||
g_assert_cmpint (fu_engine_get_status (engine), ==, FWUPD_STATUS_IDLE);
|
||||
g_test_assert_expected_messages ();
|
||||
}
|
||||
|
||||
static void
|
||||
fu_device_metadata_func (void)
|
||||
{
|
||||
@ -726,6 +750,7 @@ main (int argc, char **argv)
|
||||
g_test_add_func ("/fwupd/device-locker{success}", fu_device_locker_func);
|
||||
g_test_add_func ("/fwupd/device-locker{fail}", fu_device_locker_fail_func);
|
||||
g_test_add_func ("/fwupd/device{metadata}", fu_device_metadata_func);
|
||||
g_test_add_func ("/fwupd/engine", fu_engine_func);
|
||||
g_test_add_func ("/fwupd/hwids", fu_hwids_func);
|
||||
g_test_add_func ("/fwupd/smbios", fu_smbios_func);
|
||||
g_test_add_func ("/fwupd/pending", fu_pending_func);
|
||||
|
@ -155,6 +155,8 @@ if get_option('enable-tests')
|
||||
keyring_src,
|
||||
'fu-self-test.c',
|
||||
'fu-common.c',
|
||||
'fu-config.c',
|
||||
'fu-engine.c',
|
||||
'fu-keyring.c',
|
||||
'fu-hwids.c',
|
||||
'fu-device.c',
|
||||
|
Loading…
Reference in New Issue
Block a user