liveBook · Manning

Concurrent testing

As explained in C++ Concurrency in Action, Second Edition

Testing software for defects that arise when multiple threads or computations execute concurrently.

Concurrent testing checks multithreaded code for defects that depend on thread scheduling. The same input can succeed in one run and expose a race condition in another, because scheduling is indeterminate. section 11.2.2

Make tests easier to interpret by:

  • Testing the smallest relevant piece of code; for a concurrent queue, test concurrent pushes and pops directly rather than through a larger application path. section 11.2.2
  • Removing concurrency when possible. If the problem persists in a single-threaded test, it is a general bug rather than a concurrency-related one. section 11.2.2

How C++ Concurrency in Action, Second Edition covers it

How deep it goes
Recommends minimal tests and single-threaded checks, without specifying a detailed testing procedure.
Examples
Tests concurrent queue pushes and pops directly, then compares multithreaded behavior with a single-threaded run.
What you can do after
Diagnose/debug with it by isolating the smallest suspect code path and checking whether the defect remains without concurrency.
How it connects
Connects race conditions with testability and debugging multithreaded applications.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of C++ Concurrency in Action, Second Edition. The section links point to the parts of the book it draws on.