Fix Problem When Running Unit Test With Util#11
Merged
DavidingPlus merged 5 commits intomasterfrom Mar 21, 2025
Merged
Conversation
Owner
Author
|
续 #12。 |
Continued #12. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
第一步,需要将代码分为内核态以及可跨内核态和用户态的两部分。内核态即包含内核头文件、数据结构以及类型的部分,跨内核和用户态的部分不能包含任何内核的东西,该部分可用于用户态测试(比如单元测试),比如本项目中本文件系统自己元数据的定义、宏的定义以及一些工具函数等。
第二步,建议将跨内核和用户态的代码打成一个库,这里我打成的是动态库,方便用户态测试。但注意,内核模块的编译不能依赖任何第三方库,必须使用内核自身的框架。所以在编译内核模块的时候这部分代码又会被编译一次,按照内核模块 Kbuild 或 XMake 编译内核模块的方式。
第三步,处理 C/C++ 符号兼容性的问题。这简单,在头文件中使用 extern "C" 即可,详见 https://blog.csdn.net/m0_46606290/article/details/119973574,本项目使用的是博客中的第四种方式。