More paths than seconds.
+ The questionWhy can't a team simply test every case before release?
Thirty decisions, a billion paths
A routine with 30 independent yes-or-no decisions has 1,073,741,824 distinct paths through it, because each decision doubles the number of paths that came before. A device program has thousands of decisions, many of them inside loops that can run any number of times, and each path can be taken with different data values and at different moments relative to other events. The number of distinct behaviors is therefore not just large. It is too large to count.
Suppose a program had only 100 independent decisions and a test rig could run a billion paths a second. Running every path once would take about 40 trillion years, nearly 3,000 times the age of the universe. Faster computers do not change the conclusion, because each extra decision doubles the work. The FDA's software validation guidance states the consequence without arithmetic: "Except for the simplest of programs, software cannot be exhaustively tested," and "path coverage is generally not achievable."
Presence, not absence
The computer scientist Edsger Dijkstra drew the conclusion that shaped software engineering. In his 1972 Turing Award lecture he said that program testing "can be a very effective way to show the presence of bugs, but is hopelessly inadequate for showing their absence." A test that passes shows that one path, with one set of values, gave the expected answer. It says nothing directly about the paths not taken.
Dijkstra's limit does not make testing useless. It makes testing a sample, and like any sample its value depends on how it was drawn. A test campaign chosen at random from the space of possible inputs would almost never reach the rare combinations that matter, such as the four simultaneous conditions of the HAMILTON-C6 recall in Chapter 2. A campaign chosen from what the software is required to do, and from the ways it could cause harm, reaches far more of them. The FDA's guidance states that testing alone "cannot fully verify that software is complete and correct." Part II therefore describes the rest of the evidence that a software lifecycle produces.
A coverage tool reports which statements of the code a test campaign executed, or which branches, the alternative outcomes of each decision. A campaign can execute every statement and still miss a wrong condition, because executing a line with one value does not test it with others. The FDA's guidance calls statement coverage "insufficient to provide confidence" on its own, and even full branch coverage leaves most paths unexercised.
How many failure-free runs prove a rate?
Statistics gives a precise answer to a narrower question: if a program runs many times without failing, how high could its failure rate still be? The rule of three answers it. When no failures are seen in a number of independent trials, the one-sided 95 percent upper confidence bound for the failure probability is about three divided by that number. That bound is the highest failure probability at which that many trials would still all succeed at least 5 percent of the time.
A team runs a function 300 times under realistic conditions and sees no failure. By the rule of three, the true failure probability could still be as high as 3 in 300, or 1 percent, at 95 percent confidence. To bring the bound down to 1 in 1,000, the team needs about 3,000 failure-free runs; to 1 in 1,000,000, about 3,000,000. A target used for life-critical aviation software is 1 failure in 1,000,000,000 hours. To show that rate, the team would need about 3,000,000,000 failure-free hours of realistic operation, which is about 342,000 years. NASA researchers Ricky Butler and George Finelli made the same point in 1993. Their target was 1 failure in 1,000,000,000 ten-hour missions, or 1 in 10,000,000,000 per hour, and they asked how long a test must run to expect even one failure at that rate: about 1.1 million years on one system, and 114 years even with 10,000 copies tested in parallel.
The bound holds only when the test runs resemble real use, so that the rare inputs of the field appear in the test as often as they do in practice. That condition is a second weakness of statistical testing for safety, after the number of runs it needs: by their nature, the inputs that cause harm are the ones nobody thought to make common in the test.
Choosing the inputs that matter
If testing cannot be complete, the question becomes which inputs to try. Three ideas guide most of that choice. Inputs can be grouped into classes the software should treat alike, with tests at the boundaries between classes, where off-by-one mistakes occur. Combinations of settings can be covered systematically rather than exhaustively. And the hazard analysis of Chapter 4 can name the specific sequences that would cause the most harm, such as the ventilator's four conditions, so that each becomes a deliberate test.
The second idea has unusually direct evidence from medical devices. NIST researchers Dolores Wallace and Richard Kuhn studied FDA recall reports from 1983 to 1997 and found 109 that described their failures in enough detail to show what triggered them. In all but 3 of those 109, testing every pair of parameter settings would have revealed the failure. That is 97 percent of them; the authors give 98 percent. The other 3 needed more than two conditions to occur together. The number of tests needed to cover all pairs of settings grows slowly as settings are added, so pairwise testing is affordable where testing all combinations is not.
The HAMILTON-C6 recall shows the limit of pairwise testing. Its failure needed four conditions, so a pairwise campaign would not have been sure to find it, and only an analysis of what happens when a sensor fails during suctioning would have pointed to that sequence. Testing, then, is necessary and never sufficient. The confidence a regulator accepts comes from testing chosen by requirements and risk, applied at several levels, repeated after every change, and backed by a process that makes faults less likely to be written in the first place. That process is the subject of the next part.
For each hazard the software could contribute to, list the inputs and sequences that could lead to it, including combinations of user actions, sensor states and timing. Make those deliberate tests; cover the remaining settings with boundary values and all-pairs combinations; and record which hazards rely on testing alone and which also rely on safeguards built into the design, so that a reviewer can see where the testing argument is weak.
- Paths through software multiply with every decision, so even modest programs have far more behaviors than any campaign can test.
- Testing can show that faults exist but cannot show their absence; coverage measures what ran, not whether it was right.
- By the rule of three, proving a very low failure rate by failure-free testing would take an impossible amount of realistic operation.
- Useful testing is a deliberate sample: input classes and boundaries, all pairs of settings, and sequences named by the hazard analysis.
Let's Talk