SimpleKernel 1.17.0
Loading...
Searching...
No Matches
virtio_driver_test.cpp File Reference
#include "virtio/virtio_driver.hpp"
#include <gtest/gtest.h>
Include dependency graph for virtio_driver_test.cpp:

Go to the source code of this file.

Functions

 TEST (VirtioDriverTest, GetEntryNameIsVirtio)
 
 TEST (VirtioDriverTest, MatchStaticReturnsFalseWhenNoMmioBase)
 
 TEST (VirtioDriverTest, MatchTableContainsVirtioMmio)
 

Function Documentation

◆ TEST() [1/3]

TEST ( VirtioDriverTest  ,
GetEntryNameIsVirtio   
)

Definition at line 7 of file virtio_driver_test.cpp.

7 {
8 const auto& entry = VirtioDriver::GetEntry();
9 EXPECT_STREQ(entry.name, "virtio");
10}
static auto GetEntry() -> const DriverEntry &
返回驱动注册入口
Here is the call graph for this function:

◆ TEST() [2/3]

TEST ( VirtioDriverTest  ,
MatchStaticReturnsFalseWhenNoMmioBase   
)

Definition at line 12 of file virtio_driver_test.cpp.

12 {
13 DeviceNode node{};
14 node.mmio_base = 0;
16}
static auto MatchStatic(DeviceNode &node) -> bool
硬件检测:验证 VirtIO magic number
单个设备的硬件资源描述。
uint64_t mmio_base
第一个 MMIO 区域(需要多 BAR 支持时扩展为数组)
#define EXPECT_FALSE(cond, msg)
Here is the call graph for this function:

◆ TEST() [3/3]

TEST ( VirtioDriverTest  ,
MatchTableContainsVirtioMmio   
)

Definition at line 18 of file virtio_driver_test.cpp.

18 {
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}
#define EXPECT_TRUE(cond, msg)
Here is the call graph for this function: