Google Test on VxWorks 7: DKM and RTP Integration Guide
Unit testing in embedded systems is often overlooked due to tooling complexity and runtime constraints. However, integrating Google Test (gtest) into VxWorks 7 enables a modern, structured testing workflow across both kernel-space (DKM) and user-space (RTP) components.
This guide provides a practical, production-oriented approach to building and integrating Google Test into VxWorks projects.
๐ Overview #
Google Test support for VxWorks is delivered as a static library layer, which can be linked into:
- DKM (Dynamic Kernel Modules)
- RTP (Real-Time Processes)
The integration leverages VxWorks’ layer mechanism and standard build system, allowing test execution directly within the target environment.
Key Benefits #
- Consistent unit testing across kernel and user space
- Familiar C++ testing framework (fixtures, assertions, test runners)
- Improved code quality and regression detection
โ๏ธ Prerequisites #
Before integration, ensure the following environment is ready:
- VxWorks 7 (SR0610 or later)
- Git installed and accessible
- Network access to retrieve source packages
Required Package #
Download the VxWorks-compatible Google Test layer:
- Repository:
vxworks7-google-test(Wind River GitHub)
๐งฉ Environment Setup #
Configure Layer Path #
Set the WIND_LAYER_PATHS environment variable to include the downloaded package:
export WIND_LAYER_PATHS=/path/to/vxworks7-google-test
Verify Layer Availability #
Confirm that the Google Test layer is recognized:
vxprj vsb listAll
Expected entry:
GTEST_1_8_0_0
๐๏ธ Building VSB and VIP #
Google Test must be enabled at the VSB (source build) level and included in the runtime image (VIP).
Create and Configure VSB #
export WIND_WRTOOL_WORKSPACE=$HOME/WindRiver/workspace
cd $WIND_WRTOOL_WORKSPACE
wrtool prj vsb create -force -bsp vxsim_linux myVSB -S
cd myVSB
wrtool prj vsb config -w -add _WRS_CONFIG_GTEST=y
make -j$(nproc)
cd ..
Create VIP with Google Test #
wrtool prj vip create -force -vsb myVSB -profile PROFILE_STANDALONE_DEVELOPMENT vxsim_linux llvm myVIP
cd myVIP
wrtool prj vip component add INCLUDE_GTEST
cd ..
This ensures the gtest runtime is available in the target image.
๐งช Using Google Test in RTP Projects #
RTPs provide user-space isolation, making them ideal for most unit testing scenarios.
Steps #
- Create a
.cctest file - Write standard Google Test cases
- Link against the gtest static library
Linker Configuration #
-l ${VSB_DIR}/usr/*/common/libgtest.a
Build #
Compile the RTP project normally. The test entry point is automatically generated by gtest.
๐ง Using Google Test in DKM Projects #
DKMs run in kernel space, requiring explicit test initialization and cleanup.
Minimal Test Entry #
int main() {
int argc = 1;
char *argv = (char *)"dkm path";
::testing::InitGoogleTest(&argc, &argv);
return RUN_ALL_TESTS_AND_UNLOAD_SELF();
}
Linker Configuration #
-L $(VSB_DIR)/krnl/SIMLINUX/common
-l gtest
Key Constraints #
- Only one gtest instance can exist in kernel space
- Each DKM must be unloaded before running another test
โ ๏ธ DKM-Specific Considerations #
Namespace Limitations #
- Kernel space does not isolate symbols between modules
- Avoid multiple simultaneous test modules
Unloading Strategy #
Use helper macros:
GTEST_UNLOAD_SELFRUN_ALL_TESTS_AND_UNLOAD_SELF
Optional Result Handling #
int main() {
int argc = 1;
char *argv = (char *)"dkm path";
::testing::InitGoogleTest(&argc, &argv);
int ret = RUN_ALL_TESTS();
if (ret > 0) {
// Handle failures if needed
}
return GTEST_UNLOAD_SELF();
}
๐ Best Practices #
Test Placement #
- Use RTP for most unit tests (safer, isolated)
- Reserve DKM tests for kernel-specific logic
Build Strategy #
- Integrate gtest at VSB level for consistency
- Maintain separate test targets from production builds
Debugging #
- Use VxWorks shell and logging for runtime inspection
- Combine with system tools for deeper analysis
Maintainability #
- Organize tests by module or feature
- Use fixtures for reusable setup/teardown logic
โ๏ธ Licensing Notes #
Google Test is distributed under the BSD 3-Clause License, allowing flexible usage and redistribution. Some files may include additional license notices, which should be reviewed individually.
This VxWorks integration layer adapts Google Test for compatibility but is typically provided without official support, and should be validated within your development workflow.
๐ Conclusion #
Integrating Google Test into VxWorks 7 brings modern unit testing practices into embedded development. By supporting both RTP and DKM environments, developers gain flexibility in validating code across system boundaries.
With proper integration at the VSB level and disciplined test design, gtest can significantly improve code reliability, accelerate debugging, and enable scalable testing pipelines in VxWorks-based systems.