自动化 Win32 驱动程序测试

发布于 2024-08-07 11:31:18 字数 413 浏览 14 评论 0原文

有人知道部分或完全自动化驱动程序测试安装的方法吗?

我是驱动程序开发的新手,并且习惯于使用高级语言进行更多的测试驱动方法,因此转向这样的环境:我不能轻易地进行测试,这对我来说是一个进步。我在测试环境中使用 Virtual PC,目前必须重置它,打开设备管理器,选择设备,单击一堆“您真的确定不想安装其中一个系统驱动程序吗?” em>” 类型对话框,然后最后在测试环境启动时重置测试环境,同时在主机中重新启动 WinDbg... 呃。

在重复这个过程很多很多次之后,肯定有更好的方法吗?商业驱动程序开发人员使用哪些工具/方法/技巧在测试环境中运行他们的驱动程序?

请注意,这与单元测试驱动程序无关,我还没有达到那个阶段,也不知道它是否可能。这只是启动附加了 WinDbg 的测试环境,以确保我可能所做的一些小更改符合我的预期。

Does anyone know ways of partially or fully automating driver test installation?

I am new to driver development and am used to more of a test-driven approach in higher level languages, so moving to the kind of environment where I can't easily test as I go has been a step up for me. I am using Virtual PC for my test environment and currently have to reset it, open device manager, choose the device, click through a bunch of "Are you really sure you wouldn't rather install one of these system drivers" type dialogs, then finally reset the test environment while restarting WinDbg in the host machine just as the test environment is booting up... argh.

After repeating this process many, many times already, surely there has to be a be a better way of doing this? What tools/methods/tricks do commercial driver developers use to run up their driver in a test environment?

Note, this isn't about unit testing drivers, I haven't got to that stage yet or know if it is even possible. This is just about firing up a test environment with WinDbg attached to make sure that some small change I may have done is doing what I expect.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

彩虹直至黑白 2024-08-14 11:31:18

在我看来,虚拟化软件+“模拟对象”(分层)方法(如建议的那样)作者:Aaron Digulla)+脚本(如 Sergius 建议)可以简化设备驱动程序开发。

但是,如果您使用 Visual Studio 开发用户级应用程序,则也可以通过 VisualDDK (+ VirtualKD 通过命名管道进行调试,这比通过虚拟 COM 端口更快),它解决了特别是您提到的烦恼;从其主页:

...这个项目带来了简单性和
Windows应用程序的便利性
开发到驱动程序开发
世界。不再需要手动创建
构建脚本,复制驱动程序
文件,从 INF 安装驱动程序,
在 WinDbg 和
源代码编辑器或等待几秒钟
由于速度过慢,每一步之后
虚拟 COM 端口。只需创建一个驱动程序
使用方便的驱动程序的项目
向导,选择一个虚拟机,然后
享受直接调试您的驱动程序的乐趣
来自视觉工作室。 想要测试
改变?通常只需按 Shift-F5,
修改你的驱动程序,重建它并
再次启动
。 VisualDDK将卸载
旧驱动,安装新驱动
并自动快速加载。
厌倦了 WinDbg 加载符号文件
几分钟并查找符号
秒?让VisualDDK优化就可以了
这为您使用自己的基于 DIA 的
符号引擎。在中使用 C++/STLPort
你的司机? VisualDDK 本身会
可视化所有 STL 容器并
字符串,与 Visual Studio 一样好
用于用户模式应用程序。 ...

It seems to me that a virtualization software + a "mock objects" (layering) approach (as suggested by Aaron Digulla) + scripts (as suggested by Sergius) can simplify device driver development.

But if you use Visual Studio to develop user-level applications, you can use it for kernel device driver development too with VisualDDK (+ VirtualKD to debug over a named pipe, which is faster than over a virtual COM port), which addresses specifically the annoyances that you mention; from its home page:

... This project brings the simplicity and
convenience of Windows application
development to the driver development
world. No more manual creation of
build scripts, copying of driver
files, installing drivers from INFs,
switching between WinDbg and the
source editor or waiting for seconds
after each step due to the extra-slow
virtual COM port. Just create a driver
project using a convenient Driver
Wizard, select a virtual machine, and
enjoy debugging your driver directly
from Visual Studio. Want to test a
change? Just normally press Shift-F5,
modify your driver, rebuild it and
launch again
. VisualDDK will unload
the old driver, install the new one
and load it automatically and quickly.
Bored with WinDbg loading symbol files
for minutes and looking up symbols for
seconds? Just let VisualDDK optimize
this for you using its own DIA-based
symbol engine. Using C++/STLPort in
your drivers? VisualDDK will natively
visualize all STL containers and
strings, as good as Visual Studio does
for user-mode applications. ...

云柯 2024-08-14 11:31:18

您可以编写一些 shell 脚本(使用 sc.exe 和 devcon.exe)来自动执行部署任务(无需打开设备管理器、单击按钮等)。并制作系统快照以供调试(无需等待系统启动)。

不要忘记使用 DriverVerifier 检查您的驱动程序!

我自己的脚本示例:)

sc create FsFilter type= filesys binPath= c:\FSFilterDrv.sys
sc start FsFilter
pause
sc stop FsFilter
sc delete FsFilter

You can write some shell scripts (using sc.exe and devcon.exe) to automate deployment tasks (no opening device manager, clicking on buttons, etc). And make snapshot of the system ready to debug (needn't wait for system boot).

Don't forget to check your driver with DriverVerifier!

Example of my own script :)

sc create FsFilter type= filesys binPath= c:\FSFilterDrv.sys
sc start FsFilter
pause
sc stop FsFilter
sc delete FsFilter
会傲 2024-08-14 11:31:18

请遵循我在此处提供的建议。基本上,尽可能少地使用真实系统进行测试。

对于您的情况,我还有另一个提示:虚拟 PC 使用虚拟硬盘(这可能是您真实硬盘上的文件)。

您无需安装驱动程序,只需替换虚拟硬盘中的新文件即可。这在正在运行的系统中通常是不可能的,但在虚拟系统中,您可以打开虚拟磁盘文件并更改它(因为 Windows 不会锁定其中的文件)。

我不确定 Virtual PC,但其他模拟器附带了处理虚拟磁盘映像的工具。如果 VPC 无法做到这一点,请查看 VirtualBox

Follow the advice I gave here. Basically, test as little as possible with the real system.

In your case, I've got another tip: Virtual PC is using a virtual hard disk (that's probably a file on your real hard disk).

You don't need to install your driver, you can simply replace the new files in the virtual hard disk. This is often not possible in the running system but in a virtual system, you can open the virtual disk file and change it (since Windows isn't locking the files in it).

I'm not sure about Virtual PC but other emulators come with tools to work with virtual disk images. If VPC can't do it, check out VirtualBox.

痕至 2024-08-14 11:31:18

这完全取决于您正在编写什么样的驱动程序。但在许多情况下,编写一个适当的 makefile(或类似的文件)来处理驱动程序安装、启动/停止和测试工具的启动已经足够了。

我还将所有测试计算机配置为自动登录 (AutoAdminLogon)、映射网络驱动器并在启动后启动适当的命令提示符。运行特定测试只需输入单个命令即可。

关于 VirtualPC 的一句话:VirtualPC 对于内核模式开发来说非常方便,但不要忘记它仅模拟单处理器机器——所以一定要定期在多处理器机器上测试代码。也就是说,VHD 技巧可能看起来很方便,但它在某种程度上将您与 Virtual PC 联系在一起——编写在 VirtualPC 上和在真实机器上同样工作的适当脚本,因此对我来说似乎是更好的方法。

最后,认为它是一个无耻的插件,但如果您正在寻找 Windows 内核模式代码的单元测试框架,我已经编写了一个: cfix

It all depends a little on what kind of driver you are writing. But in many cases, writing an appropriate makefile (or something similar) that handles driver installation, start/stop, and launching of a test harness can already be good enough.

I also configure all of my test machines to automatically logon (AutoAdminLogon), map net drives, and launch an appropriate command prompt after startup. Running a specific test is then a matter of typing in a single command only.

One word concerning VirtualPC: VirtualPC is very handy for kernel mode development, but do not forget that it emulates a uniprocessor machine only -- so be sure to regularly test the code on a multiprocessor machine as well. That said, the VHD trick may seem handy, but it somewhat ties you to Virtual PC -- writing appropriate scripts that equally work on VirtualPC as on a real machine therefore seems a better approach to me.

Finally, consider it a shameless plug, but if you are looking for a unit testing framework for Windows kernel mode code, I have written one: cfix.

空心↖ 2024-08-14 11:31:18

我认为 DevCon 实用程序(这篇 OSR Online 文章中描述)会对您有所帮助。您应该能够设置批处理文件,一键完成这项工作。

可以免费注册 osronline.com,并且您可能需要注册才能阅读该文章。如果您正在编写驱动程序,则需要注册。这些人已经这样做很长时间了,并且该网站上有很多非常好的信息。

I think the DevCon utility (described in this OSR Online article) will help you. You should be able to setup batch files that do the job on one click.

It's free to sign up with osronline.com, and you'll probably have to sign up to get to that article. And if you are writing drivers, you WANT to sign up. These guys have been doing this for a long time, and there's a LOT of really good info on that web site.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文