test_telemetry.c is about 120 lines, and it makes a strong claim: if it prints Telemetry checks passed, every promise in the brief holds for the inputs it covers. A claim like that is only worth something if you can point to the assertion behind each promise. This lesson walks through the suite in order and maps each block to the contract it defends, then to the mutation it kills. Open the file in the playground at the end and follow along.
The suite, block by block
Allocator probe. The probe starts with fail set, so the first decoder_create must return NULL with zero live blocks. The second create must succeed with one live block after two calls. The call count is saved in allocations. Contract: create fails cleanly and makes one allocation.
Encoder. Invalid records and a 9-byte capacity must be rejected with written still 77 and the output still filled with 0xaa. Then sensor 1, value 25 must encode to exactly the fixture. Contract: validate before writing; bytes match the specification. This guards write_u16; the manifest's byte-order mutation targets read_u16 instead.
Empty feed.NULL with size 0 returns NEED_MORE, consumes 0, leaves the sentinel, and finish reports STREAM_END. Contract: empty input is a valid stream.
Two frames in chunk sizes 1 to 20, through decode_chunks, which asserts that every call makes progress and never exceeds what it was given. Kills "wrong progress count", and also "reverse field byte order": a little-endian read_u16 reads the length 00 04 as 1024, so the very first frame fails its header check.
All 512 partitions of one frame, with exact consumed counts and sentinel checks.
Every truncated prefix must fail at finish and then refuse further input. Kills "accept truncated end".
Every single-byte corruption must be rejected and stay rejected. Kills "ignore checksum".
Metadata changes with repaired checksums, so header rules are proven independently. Kills "accept unsupported version" and "accept unsupported type".
A domain-invalid payload with a correct checksum.
The round-trip grid and the 4095/10000 endpoint.
Allocation accounting.probe.calls == allocations proves that everything above ran without allocating, then destroy must bring live to 0. Kills "omit owned release".
Where is "reset leaves partial count" killed? decoder_create itself calls decoder_reset, so with that mutation a brand-new decoder already believes it holds one byte, and the finish in block 3 reports DECODE_ERROR instead of STREAM_END. Every later block resets too, so several of them would also catch it. A suite only needs one block to kill each mutant, but overlapping coverage means one deleted test rarely lets a mutant survive.
Predict and run
Read the program before pressing Run. Predict the output, then name the extra assertion that proves the existing allocation was released, not just that no new one was made.
An unchanged call count shows that feeding did not allocate. It says nothing about release: a destroy that does nothing leaves the count unchanged too. The suite therefore also tracks live blocks and asserts probe.live == 0 after decoder_destroy. The release callback adds a third check, probe->live == 1 && storage != NULL, which fails if destroy runs twice or passes a different pointer.
What the suite does not prove
Precise claims include their limits. The suite covers one fixture's partitions, a grid of valid readings, and single-byte corruptions; it does not cover every possible byte stream. A checksum that passes is not authentication. And the tests exercise behavior, not memory safety: an out-of-bounds read that happens to return a harmless byte passes every assertion. That is why the course's checker can also build the suite with -fsanitize=address,undefined. AddressSanitizer stops on invalid memory access and leaks, and UndefinedBehaviorSanitizer stops on problems such as signed overflow and invalid shifts, the Day 2 hazards. Sanitizers only see code paths that actually run, so they multiply the value of a suite with good coverage rather than replacing it.
Finally, the suite uses assert, which compiles to nothing when NDEBUG is defined. Build the tests without NDEBUG, or the suite will pass by checking nothing.
Practice
Exercise
Your turn
Write const char *audit(size_t created, size_t destroyed, size_t *leaked) that returns "balanced", "leak" with the number of live resources stored in *leaked, or "inconsistent" when more were destroyed than created. It must not compute created - destroyed before checking that it cannot wrap. Print:
Text
created 1, destroyed 1: balancedcreated 1, destroyed 0: leak of 1created 1, destroyed 2: inconsistentcreated 3, destroyed 1: leak of 2
Your workspaceC
#include <stdio.h>
#include <string.h>
int main(void) {
const size_t cases[4][2] = {{1, 1}, {1, 0}, {1, 2}, {3, 1}};
/* Write audit above, then print one line per case. */
(void)cases;
return 0;
}
Hint 1: the idea
"More destroyed than created" is the double-free signal, and it must be detected before subtracting, because 1 - 2 on size_t wraps to a huge number that would look like a giant leak.
Hint 2: a first step
Write the three return statements first, with their conditions still to fill in, and decide their order: which case must be ruled out before created - destroyed is safe to compute?
created 1, destroyed 1: balancedcreated 1, destroyed 0: leak of 1created 1, destroyed 2: inconsistentcreated 3, destroyed 1: leak of 2
The inconsistent case is the important one. A plain created - destroyed == 0 test would report a double free as a leak of SIZE_MAX, pointing you at the wrong bug. The project's probe gets the same protection from its assert(probe->live == 1 ...) in the release callback. Now run the real suite below and then try a mutation.
Pick one mutation from manifest.json, predict which numbered block above will fail first, then apply it in telemetry.c and run. For "wrong progress count", the first failure is in decode_chunks with chunk size 1, at the assertion on result.consumed. Restore the original line before trying the next one, and do not rely on the exact wording of assertion messages, which differs between C libraries.
Completion is saved in this browser only. It does not measure mastery.