Skip to content

wpdk/wdutf

Repository files navigation

Windows Driver Unit Test Framework

The Windows Driver Unit Test Framework (WDUTF) enables the unit testing of Windows kernel drivers using the Microsoft Unit Testing Framework for C++, which runs in user space.

Running unit tests against code written for the Windows Kernel environment is hard. There have been a few projects that try to embed a unit test framework in the kernel, but they suffer from the compexity of having to load a driver, collect the output and handle crashes. We wanted to do something better; to create a user space environment where kernel code can run unmodified and tests can be examined using the Visual Studio debugger.

The initial version of the project consisted of a user space library implementing portions of the kernel infrastructure. This has now been extended to allow binary code built for the kernel to be loaded into the unit test environment and executed. Much of the kernel functionality is stubbed out, but the framework is sufficient to allow credible tests to be performed.

Our experience has been that bringing the simplicity and flexibility of user space development to kernel drivers can significantly reduce development time and improve project outcomes. The project is being contributed to the Windows Platform Development Kit to enable others to benefit from it.

rtegrity is leading the ongoing development of the project, which grew out of work done by DataCore to develop and test a world class, high-performance, storage stack running on Windows.

In this ReadMe

Documentation

Further information about the design and implementation can be found in the project documentation. This is still a work in progress.

Basic sample code demonstrating the use of the unit test framework can be found in examples. The unit tests in test provide more advanced examples of using the framework.

Source Code

The source code can be obtained using git:

git clone --recurse-submodules https://github.com/wpdk/wdutf

Runtime Prerequisites

The Windows Driver Unit Test Framework has been tested on both x64 and arm64 with Visual Studio Community 2022.

The following Visual Studio workloads need to be installed:

  • Desktop development with C++
  • Windows application development
  • Linux and embedded development with C++

The following Visual Studio individual components are also needed (for either x64 or arm64 as appropriate):

  • MSVC v140 - VS 2015 build tools
  • MSVC v143 - VS 2022 C++ with Spectre Mitigations (latest)
  • C++ ATL for latest v143 build tools
  • C++ ATL for latest v143 build tools with Spectre Mitigations
  • C++ MFC for latest v143 build tools
  • C++ MFC for latest v143 build tools with Spectre Mitigations

The following are also required (installed in the following order):

The Windows Driver Unit Test Framework is known to work with earlier versions of the Windows Driver Kit and Visual Studio.

In order to build the example projects, a couple of executables need to be copied into tools\bin. The tools\bin\README contains details.

Getting Started

The project is designed to be used in conjunction with Visual Studio and the Windows Driver Kit.

Firstly, build the Detours library by opening a Developer Command Prompt for Visual Studio and running the following commands:

# Only on arm64: Ensure that the target is correctly set
VsDevCmd -arch=arm64

cd detours\src
nmake

The Windows Driver Unit Test Framework project can then be built using the Visual Studio solution WDUTF.sln. Ensure that the configuration is set to the correct processor architecture before building. The Test Explorer can be opened with the menu entry Test/Test Explorer.

Current Status

The project has been in use for many years. It is considered to be stable, but is currently limited to the kernel features required by DataCore's own driver stack.

Limitations

The scope of the project is currently limited to supporting the kernel features used by DataCore drivers, but it is being made available to the community as a resource that can be developed and further extended.

In particular:

  • Minimal support for the Kernel Mode Driver Framework.

Known Issues

  • None.

Unit Tests

The Windows Driver Unit Test Framework includes a set of unit test to validate the framework. These can be found in test.

Contributing

Contributions are welcome and needed! In these initial stages of the project, please email the maintainers directly.

Dependencies

There are currently no external dependencies.

Acknowledgements

rtegrity is leading the ongoing development of the Windows Driver Unit Test Framework, which has been contributed by DataCore.

Core Maintainers

The core maintainers primary responsibility is to provide technical oversight for the WDUTF Project. The current list includes:

About

Windows Driver Unit Test Framework

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published