Commit dfbcf877 authored by Christian Kellner's avatar Christian Kellner
Browse files

test/mock-sysfs: ability to remove the host

Add a new method that allows to remove a host device, i.e. unplug
the device and remove it from the associated domain.
parent de337834
......@@ -790,6 +790,48 @@ mock_sysfs_host_add (MockSysfs *ms,
return device->idstr;
}
void
mock_sysfs_host_remove (MockSysfs *ms,
const char *host)
{
GHashTableIter iter;
gpointer k, v;
MockDevice *dev;
MockDomain *domain = NULL;
g_return_if_fail (MOCK_IS_SYSFS (ms));
g_return_if_fail (host != NULL);
dev = g_hash_table_lookup (ms->devices, host);
if (dev == NULL)
{
g_error ("Device not found for %s", host);
return;
}
g_hash_table_iter_init (&iter, ms->domains);
while (g_hash_table_iter_next (&iter, &k, &v))
{
MockDomain *d = v;
if (d->host == dev)
{
domain = d;
break;
}
}
if (!domain)
{
g_error ("domain not found for host: %s", host);
return;
}
mock_sysfs_device_unplug (ms, dev);
domain->host = NULL;
}
const char *
mock_sysfs_device_add (MockSysfs *ms,
const char *parent,
......
......@@ -87,6 +87,9 @@ const char * mock_sysfs_host_add (MockSysfs *ms,
const char *domain,
MockDevId *id);
void mock_sysfs_host_remove (MockSysfs *ms,
const char *host);
const char * mock_sysfs_device_add (MockSysfs *ms,
const char *parent,
MockDevId *id,
......@@ -107,4 +110,5 @@ gboolean mock_sysfs_device_remove (MockSysfs *ms,
gboolean mock_sysfs_set_osrelease (MockSysfs *ms,
const char *version);
G_END_DECLS
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment