1. Overview
The FileIdentityTests.cpp executable is a focused regression test for device/inode conversion and repeatable metadata resolution in FileIdentityResolver.
The file integrates the following components, APIs, or runtime concepts:
- FileIdentityResolver
- stat(2)
- major()/minor()
- std::filesystem temporary directory
2. Test Fixture
The test recreates a temporary directory named bastionguard-rootguard-file-identity-tests, writes one regular file, and obtains its native stat metadata.
3. Kernel Device Encoding Assertion
Expected device identity is computed as (major << 20) | minor. The test verifies that both resolve() and direct kernelDeviceNumber() return that value, and that the inode matches st_ino.
4. Repeatability
The same file is resolved a second time. Device, inode, mode, UID, and GID must match the first result, confirming stable identity extraction for an unchanged object.
5. Cleanup and Result
The temporary directory is removed and the executable prints FileIdentityTests: OK before returning success.
6. Runtime and Security Considerations
- Regression target: specifically protects against userspace/kernel
dev_tencoding mismatches that would break BPF map lookups.
