CHAPTER 10 Asserting Expectations

Observation alone is not enough for debugging. One must compare the observed facts with the expected program behavior. In this chapter, we discuss how to automate such comparisons, using well-known assertion techniques. We also show how to ensure the sanity of important system components such as memory.

10.1 AUTOMATING OBSERVATION

Observing what is going on in a program can be a burden for a programmer. First, there are many states and events that can and must be observed. Second, for each new run (or each new defect) the same items must be observed again. The burden is not so much the observation itself but the act of judging whether the observed state is sane or not—which of course multiplies with the amount ...

Get Why Programs Fail, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.