Skip to content

Fix Problem When Running Unit Test With Util#11

Merged
DavidingPlus merged 5 commits intomasterfrom
feature-liuzx-cross-space
Mar 21, 2025
Merged

Fix Problem When Running Unit Test With Util#11
DavidingPlus merged 5 commits intomasterfrom
feature-liuzx-cross-space

Conversation

@DavidingPlus
Copy link
Owner

第一步,需要将代码分为内核态以及可跨内核态和用户态的两部分。内核态即包含内核头文件、数据结构以及类型的部分,跨内核和用户态的部分不能包含任何内核的东西,该部分可用于用户态测试(比如单元测试),比如本项目中本文件系统自己元数据的定义、宏的定义以及一些工具函数等。

第二步,建议将跨内核和用户态的代码打成一个库,这里我打成的是动态库,方便用户态测试。但注意,内核模块的编译不能依赖任何第三方库,必须使用内核自身的框架。所以在编译内核模块的时候这部分代码又会被编译一次,按照内核模块 Kbuild 或 XMake 编译内核模块的方式。

第三步,处理 C/C++ 符号兼容性的问题。这简单,在头文件中使用 extern "C" 即可,详见 https://blog.csdn.net/m0_46606290/article/details/119973574,本项目使用的是博客中的第四种方式。

@DavidingPlus DavidingPlus merged commit 186a99a into master Mar 21, 2025
3 checks passed
@DavidingPlus DavidingPlus deleted the feature-liuzx-cross-space branch March 21, 2025 09:15
@DavidingPlus DavidingPlus restored the feature-liuzx-cross-space branch March 21, 2025 16:14
@DavidingPlus
Copy link
Owner Author

#12

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


Continued #12.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants