This requires inventing some KPIs that the low-level PCPU code
will call in the _KERNEL_UT case. I've built a kernel with and
without this change and confirmed that the kernel is bit-for-bit
identical.
Details
- Reviewers
vangyzen
Diff Detail
- Repository
- rS FreeBSD src repository - subversion
- Lint
Lint Passed - Unit
No Test Coverage - Build Status
Buildable 44091 Build 40979: arc lint + arc unit
Event Timeline
I should have explained this a bit more clearly in the first review. _KERNEL and _KERNEL_UT aren't mutually exclusive. When compiling kernel sources for linking into a unit test, I set both _KERNEL and _KERNEL_UT. This way the kernel code gets access to KPIs that can't be exposed to userland due to symbol conflicts (e.g. log(9) or malloc(9)). When compiling the unit test itself (or userland libraries that support the unit test by, for example, implementing a KPI), I set only _KERNEL_UT.
So ifndef _KERNEL_UT is correct thing to test as I want both the kernel code under test and the test itself to see the same symbol declarations.
In the __curthread case I could do #ifdef _KERNEL_UT ... #else ... but I thought it might be clearer to have the real kernel definition first and the unit test hook second.
sys/amd64/include/pcpu.h | ||
---|---|---|
255 | Indentation looks different on this line versus line 250. |
glebius@ has requested a different approach where unit tests define _KERNEL and opt out of the KPI symbols that they don't want, rather than opting into the symbols that they do want.