I have different applications written in C# and C++ that communicate between each other. I would like to test this environment with some scenarios that I wrote.
Each scenario runs for different hours.
Is there a way to accelerate everything in order to have the scenarios run in minutes.
The applications may contains some Thread.Sleep(...) or equivalent in C++.
My idea is that a Thread.Sleep(2000) would wait for 2 seconds normally but when accelerated it should only wait for 200 ms.
Unfortunately I cannot change or refactor the code of the applications.
A first idea I have is to run the applications in an “accelerated Windows” system. A sort of wrapper of the OS where time run faster. But I have no idea on how to achieve this.
So any new idea or solution would be great.
Thanx
I don’t think “making Windows run faster” is practical, but I would consider intercepting the Sleep() method calls and short-circuiting them. I haven’t looked, but Thread.Sleep() will probably thunk down somewhere to a Win32 API or an NT API (http://msdn.microsoft.com/en-us/library/windows/desktop/ms686298(v=vs.85).aspx).
You can use depends.exe from the Windows SDK and a debugger to see what your code uses, but I suspect (unless you know otherwise) that it won’t simply be a Sleep() call, it’ll more likely be a call waiting on some system object, I/O or a trigger, using WaitForMultipleObjectsEx() and friends.
Have a look at Detours from Microsoft Research for API interception http://msdn.microsoft.com/en-us/library/windows/desktop/ms686298(v=vs.85).aspx
There are are also various writings by Jeffry Richter and Matt Pietrek on the subject. In fact here’s a codeproject article inspired by one of those;
http://www.codeproject.com/Articles/5178/DLL-Injection-and-function-interception-tutorial