1

I have a process running several threads communicating with software and hardware components.

Simulation of disconnect and timeout is required for testing purposes. Process execution hold simulates communication timeout of all sub components. Currently this can be done by running in debug mode and setting a break point. While in break point, all threads are held from execution and all timeouts occur. But in automated test, breakpoints are not an option.

How can the whole process including all running threads be held for x seconds?

Edit #1: I'm looking for a generic way to hold execution of the whole process including all running tasks (threads) - a true break point behavior without a break point. And than an automated way to resume process.

Edit #2: This question's answer might work. Seems that some adjustments required.

Ilya Dan
  • 301
  • 1
  • 8
  • x-y Question. It should really be "How to induce timeouts on purpose for testing". – Fildor Aug 31 '20 at 07:41
  • "How to induce timeouts on purpose for testing" question has many answers. Best is to create a mock that will cause timeout when required. Sadly it's not an option for me. Closing processes/ports can cause disconnect, but then the recovery will be different / impossible. I'm looking for more universal solution. – Ilya Dan Aug 31 '20 at 13:32

1 Answers1

0

For debugging purposes, in Visual studio, you can easily do this using Debug>Windows>Threads window. There you can freeze and thaw treads as you like.

Edit: For Doing this while unit testing, you need to build your own freeze mechanism assuming every thread has a run loop in which you can check for some global freeze state to pause execution.

Cosmin Sontu
  • 1,034
  • 11
  • 16
  • Thank you for your answer. As the threads are in "await" for communication answers, I can't implement freeze there. I need a more global stop - same as breakpoints behavior. – Ilya Dan Aug 31 '20 at 08:47