mirror of
https://git.proxmox.com/git/fwupd
synced 2025-08-06 04:57:59 +00:00
trivial: Use a different SYSFSFIRMWAREDIR for self tests
This means we can drop some self-test specific code in fu_smbios_setup().
This commit is contained in:
parent
e7c6bcab3a
commit
820dac7fde
@ -2813,7 +2813,7 @@ fu_engine_load (FuEngine *self, GError **error)
|
||||
}
|
||||
|
||||
/* load SMBIOS and the hwids */
|
||||
if (!fu_smbios_setup (self->smbios, NULL, &error_smbios))
|
||||
if (!fu_smbios_setup (self->smbios, &error_smbios))
|
||||
g_warning ("Failed to load SMBIOS: %s", error_smbios->message);
|
||||
if (!fu_hwids_setup (self->hwids, self->smbios, &error_hwids))
|
||||
g_warning ("Failed to load HWIDs: %s", error_hwids->message);
|
||||
|
@ -81,15 +81,11 @@ fu_smbios_func (void)
|
||||
const gchar *str;
|
||||
gboolean ret;
|
||||
g_autofree gchar *dump = NULL;
|
||||
g_autofree gchar *sysfsdir = NULL;
|
||||
g_autoptr(FuSmbios) smbios = NULL;
|
||||
g_autoptr(GError) error = NULL;
|
||||
|
||||
sysfsdir = fu_test_get_filename (TESTDATADIR, ".");
|
||||
g_assert (sysfsdir != NULL);
|
||||
|
||||
smbios = fu_smbios_new ();
|
||||
ret = fu_smbios_setup (smbios, sysfsdir, &error);
|
||||
ret = fu_smbios_setup (smbios, &error);
|
||||
g_assert_no_error (error);
|
||||
g_assert (ret);
|
||||
dump = fu_smbios_to_string (smbios);
|
||||
@ -120,7 +116,6 @@ fu_hwids_func (void)
|
||||
g_autoptr(FuHwids) hwids = NULL;
|
||||
g_autoptr(FuSmbios) smbios = NULL;
|
||||
g_autoptr(GError) error = NULL;
|
||||
g_autofree gchar *sysfsdir = NULL;
|
||||
gboolean ret;
|
||||
|
||||
struct {
|
||||
@ -146,11 +141,8 @@ fu_hwids_func (void)
|
||||
{ NULL, NULL }
|
||||
};
|
||||
|
||||
sysfsdir = fu_test_get_filename (TESTDATADIR, ".");
|
||||
g_assert (sysfsdir != NULL);
|
||||
|
||||
smbios = fu_smbios_new ();
|
||||
ret = fu_smbios_setup (smbios, sysfsdir, &error);
|
||||
ret = fu_smbios_setup (smbios, &error);
|
||||
g_assert_no_error (error);
|
||||
g_assert (ret);
|
||||
|
||||
|
@ -138,7 +138,6 @@ fu_smbios_setup_from_file (FuSmbios *self, const gchar *filename, GError **error
|
||||
/**
|
||||
* fu_smbios_setup:
|
||||
* @self: A #FuSmbios
|
||||
* @sysfsdir: A file path, e.g. '/sys/firmware' or %NULL
|
||||
* @error: A #GError or %NULL
|
||||
*
|
||||
* Reads all the SMBIOS values from the hardware.
|
||||
@ -146,7 +145,7 @@ fu_smbios_setup_from_file (FuSmbios *self, const gchar *filename, GError **error
|
||||
* Returns: %TRUE for success
|
||||
**/
|
||||
gboolean
|
||||
fu_smbios_setup (FuSmbios *self, const gchar *sysfsdir, GError **error)
|
||||
fu_smbios_setup (FuSmbios *self, GError **error)
|
||||
{
|
||||
FuSmbiosStructureEntryPoint *ep;
|
||||
gsize sz = 0;
|
||||
@ -158,12 +157,8 @@ fu_smbios_setup (FuSmbios *self, const gchar *sysfsdir, GError **error)
|
||||
|
||||
g_return_val_if_fail (FU_IS_SMBIOS (self), FALSE);
|
||||
|
||||
/* default value */
|
||||
if (sysfsdir == NULL)
|
||||
sysfsdir = "/sys/firmware";
|
||||
|
||||
/* get the smbios entry point */
|
||||
ep_fn = g_build_filename (sysfsdir, "dmi", "tables", "smbios_entry_point", NULL);
|
||||
ep_fn = g_build_filename (SYSFSFIRMWAREDIR, "dmi", "tables", "smbios_entry_point", NULL);
|
||||
if (!g_file_get_contents (ep_fn, &ep_raw, &sz, error))
|
||||
return FALSE;
|
||||
if (sz != sizeof(FuSmbiosStructureEntryPoint)) {
|
||||
@ -215,7 +210,7 @@ fu_smbios_setup (FuSmbios *self, const gchar *sysfsdir, GError **error)
|
||||
ep->smbios_minor_ver);
|
||||
|
||||
/* get the DMI data */
|
||||
dmi_fn = g_build_filename (sysfsdir, "dmi", "tables", "DMI", NULL);
|
||||
dmi_fn = g_build_filename (SYSFSFIRMWAREDIR, "dmi", "tables", "DMI", NULL);
|
||||
if (!g_file_get_contents (dmi_fn, &dmi_raw, &sz, error))
|
||||
return FALSE;
|
||||
if (sz != GUINT16_FROM_LE (ep->structure_table_len)) {
|
||||
|
@ -38,7 +38,6 @@ FuSmbios *fu_smbios_new (void);
|
||||
#define FU_SMBIOS_STRUCTURE_TYPE_CHASSIS 0x03
|
||||
|
||||
gboolean fu_smbios_setup (FuSmbios *self,
|
||||
const gchar *sysfsdir,
|
||||
GError **error);
|
||||
gboolean fu_smbios_setup_from_file (FuSmbios *self,
|
||||
const gchar *filename,
|
||||
|
@ -1496,7 +1496,7 @@ fu_util_hwids (FuUtilPrivate *priv, gchar **values, GError **error)
|
||||
NULL };
|
||||
|
||||
/* read DMI data */
|
||||
if (!fu_smbios_setup (smbios, g_getenv ("SYSFSPATH"), error))
|
||||
if (!fu_smbios_setup (smbios, error))
|
||||
return FALSE;
|
||||
if (!fu_hwids_setup (hwids, smbios, error))
|
||||
return FALSE;
|
||||
|
@ -48,6 +48,7 @@ libfwupdprivate = static_library(
|
||||
c_args : [
|
||||
cargs,
|
||||
'-DLOCALSTATEDIR="' + localstatedir + '"',
|
||||
'-DSYSFSFIRMWAREDIR="/sys/firmware"',
|
||||
'-DFU_OFFLINE_DESTDIR=""',
|
||||
],
|
||||
)
|
||||
@ -134,6 +135,7 @@ executable(
|
||||
cargs,
|
||||
'-DLOCALSTATEDIR="' + localstatedir + '"',
|
||||
'-DPLUGINDIR="' + plugin_dir + '"',
|
||||
'-DSYSFSFIRMWAREDIR="/sys/firmware"',
|
||||
'-DFU_OFFLINE_DESTDIR=""',
|
||||
],
|
||||
install : true,
|
||||
@ -193,6 +195,7 @@ if get_option('enable-tests')
|
||||
'-DPLUGINBUILDDIR="' + pluginbuilddir + '"',
|
||||
'-DFU_OFFLINE_DESTDIR="/tmp/fwupd-self-test"',
|
||||
'-DPLUGINDIR="' + testdatadir_src + '"',
|
||||
'-DSYSFSFIRMWAREDIR="' + testdatadir_src + '"',
|
||||
],
|
||||
)
|
||||
test('fu-self-test', e, is_parallel:false)
|
||||
|
Loading…
Reference in New Issue
Block a user