Platform Mocking¶
This file documents platform mocking, mocking libraries that mock out platform specific features and aid in writing mocks for platform drivers and other low level kernel code.
Enable Platform Mocking¶
CONFIG_PLATFORM_MOCK
needs to be added to the .config (or kunitconfig) to
enable platform mocking.
Mocked IO Functions¶
The following functions have been mocked for convenience.
u8 readb(const volatile void __iomem *);
u16 readw(const volatile void __iomem *);
u32 readl(const volatile void __iomem *);
u64 readq(const volatile void __iomem *);
void writeb(u8, const volatile void __iomem *);
void writew(u16, const volatile void __iomem *);
void writel(u32, const volatile void __iomem *);
void writeq(u64, const volatile void __iomem *);
Note
These functions do not have any non-mocked behaviour in UML.
API¶
Parameters
struct test *test
the test to associate node with
const char *name
name of the node
Description
The struct device_node
returned is allocated as a root node with the given
name and otherwise behaves as a real struct device_node
.
Return
the faked struct device_node
-
struct platform_device *of_fake_probe_platform(struct test *test, struct platform_driver *driver, const char *node_name)¶
Parameters
struct test *test
the test to associate the fake platform device with
struct platform_driver *driver
driver to probe
const char *node_name
name of the device node created
Description
Creates a struct platform_device
and an associated struct device_node
,
probes the provided struct platform_driver
with the struct platform_device
.
Return
the struct platform_device
that was created
-
struct platform_device *of_fake_probe_platform_by_name(struct test *test, const char *driver_name, const char *node_name)¶
Parameters
struct test *test
the test to associate the fake platform device with
const char *driver_name
name of the driver to probe
const char *node_name
name of the device node created
Description
Same as of_fake_probe_platform()
but looks up the struct platform_driver
by
the provided name.
Return
the struct platform_device
that was created