自动化 Win32 驱动程序测试
有人知道部分或完全自动化驱动程序测试安装的方法吗?
我是驱动程序开发的新手,并且习惯于使用高级语言进行更多的测试驱动方法,因此转向这样的环境:我不能轻易地进行测试,这对我来说是一个进步。我在测试环境中使用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
在我看来,虚拟化软件+“模拟对象”(分层)方法(如建议的那样)作者:Aaron Digulla)+脚本(如 Sergius 建议)可以简化设备驱动程序开发。
但是,如果您使用 Visual Studio 开发用户级应用程序,则也可以通过 VisualDDK (+ VirtualKD 通过命名管道进行调试,这比通过虚拟 COM 端口更快),它解决了特别是您提到的烦恼;从其主页:
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:
您可以编写一些 shell 脚本(使用 sc.exe 和 devcon.exe)来自动执行部署任务(无需打开设备管理器、单击按钮等)。并制作系统快照以供调试(无需等待系统启动)。
不要忘记使用 DriverVerifier 检查您的驱动程序!
我自己的脚本示例:)
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 :)
请遵循我在此处提供的建议。基本上,尽可能少地使用真实系统进行测试。
对于您的情况,我还有另一个提示:虚拟 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.
这完全取决于您正在编写什么样的驱动程序。但在许多情况下,编写一个适当的 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.
我认为 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.