OS's Support for Testing a Driver

Hi all,
so far I have seen many discussions on driver development and debugging.

This mail is about “Driver Testing”
It is observed that Driver testing is somewhat different( because of some of
the restrictions, and hw dependencies) from other softwares.

Some of the restrictions are due to the fact that, “System Is in Charge” of
calling any piece of driver code one has written.

So experts,

I have a couple of questions here.
To test a DDI, is it possible to access them (by directly or indirectly)
To test an IOCTL, is possible to CreateFile for the device I’m testing.

Can you please let me know, what kind of support is provided by Windows for
“testing” a driver?


To be honest, I just don’t really understand what you are asking about…

A given piece of driver code gets invoked by the OS only in response to the appropriate event. For example, IRP_MJ_DEVICE_CONTROL may get invoked only as a result of DeviceIoControl() call to your device (or to the one it is attached to); AddDevice() routine of PnP driver may get invoked only when a device is added to the system; ISR may get invoked only when hardware interrupt occurs; etc,etc,etc…

Therefore, in order to test a given piece of code, you have to create a situation when it gets invoked - you just cannot tell the system “please call function X - I want to test it”…

Anton Bassov

Madhusudan Narayan wrote:

Can you please let me know, what kind of support is provided by Windows
for “testing” a driver?

Please have a look in the WDK “tools” section.

  • Static testing is available with PREfast
  • Limited dynamic testing is available with the PnP Driver Test Tool
    (- Later, to rule out common install problems, you can use chkinf for
    INF files.)

Everything else will probably require you

  • to build the “test scaffolding” yourself (load driver, send requests
    to it, check the responses), or to
  • hook up a kernel debugger, or to
  • use the WMI functions to implement driver monitoring functions and
    call them from your external monitoring application