SimpleKernel 1.17.0
Loading...
Searching...
No Matches
virtio_driver_test.cpp
Go to the documentation of this file.
1
4
5#include <gtest/gtest.h>
6
7TEST(VirtioDriverTest, GetEntryNameIsVirtio) {
8 const auto& entry = VirtioDriver::GetEntry();
9 EXPECT_STREQ(entry.name, "virtio");
10}
11
12TEST(VirtioDriverTest, MatchStaticReturnsFalseWhenNoMmioBase) {
13 DeviceNode node{};
14 node.mmio_base = 0;
16}
17
18TEST(VirtioDriverTest, MatchTableContainsVirtioMmio) {
19 const auto& entry = VirtioDriver::GetEntry();
20 bool found = false;
21 for (const auto& m : entry.match_table) {
22 if (m.bus_type == BusType::kPlatform &&
23 __builtin_strcmp(m.compatible, "virtio,mmio") == 0) {
24 found = true;
25 }
26 }
27 EXPECT_TRUE(found);
28}
static auto GetEntry() -> const DriverEntry &
返回驱动注册入口
static auto MatchStatic(DeviceNode &node) -> bool
硬件检测:验证 VirtIO magic number
单个设备的硬件资源描述。
uint64_t mmio_base
第一个 MMIO 区域(需要多 BAR 支持时扩展为数组)
#define EXPECT_TRUE(cond, msg)
#define EXPECT_FALSE(cond, msg)
TEST(VirtioDriverTest, GetEntryNameIsVirtio)