Regressions, Seeds and the Life of a Bug
Run many tests with many seeds, and sort the failures into buckets. Report each bug so someone can fix it, and close it with a test that stays.
You Will Be Able To
- Say what a regression is and why it runs every night with new seeds.
- Sort failures into buckets by their first error, and find the condition they share.
- Write a bug report that someone else can replay: seed, tool, version and the shortest failing run.
- Close a bug with a test that stays in the regression.
- Lesson
- B4.3
- Time
- 22 min
- Runs on
- Your browser
- Check
- 5 questions
Eight seeds ran overnight, and three failed. Seed 303 lost byte 1, seed 606 and seed 909 lost byte 2, each with different values. It looks like three bugs, and it is one.
- Engine
- Result
- Storage
- Control / FSM
- Data
- Run everything
Overnight, every test runs with many seeds. Most pass.
- Collect the failures
Forty runs fail. Forty failures are rarely forty bugs.
- Sort them
Group failures by their first error message, not by test name.
- Report one bug per bucket
Pick the shortest failing run of each bucket and report it with its seed.
Read the diagram as text
- Nightly regression: every test, many seeds
- Forty failures: forty logs, forty seeds
- Bucket 1: frame error after a byte
- Bucket 2: timeout waiting for busy
- Buckets 3 and 4: other first errors
- One bug report per bucket: shortest seed, tool, version
- Nightly regression → Forty failures: morning
- Forty failures → Bucket 1: sorted by first error
- Forty failures → Bucket 2: sorted by first error
- Forty failures → Buckets 3 and 4: sorted by first error
- Bucket 1 → One bug report per bucket: one report
An idea drawing; the forty failures are an example, not a measured number. The lab below sorts three real failures.
Before You Start
Read Random and Constrained-Random Stimulus and The Verification Plan first. The transmitter and its plan come from The Verification Plan.
| Question | |
|---|---|
| 1 | What is a regression, and why does it run again and again? |
| 2 | Why do forty failures rarely mean forty bugs? |
| 3 | How do you find the condition that failing seeds share? |
| 4 | What goes into a bug report? |
| 5 | How is a bug closed so it cannot come back? |
The Idea: Run Everything, Again and Again
A design changes every day. Each change can break something that worked yesterday. So a project keeps a regression: every test of the plan, run again after every change, usually overnight. A test that passed yesterday and fails today points at today's change.
Random tests make the regression grow in a second direction. Each night they run with new seeds, so the same test explores new paths. A failure on night forty may come from a path that existed since day one. Neither direction is wasted. Old seeds guard against breakage; new seeds hunt for what nobody has seen.
Then comes the morning. Failures need sorting before anyone debugs anything, because one bug can fail many runs in many different-looking ways. This sorting is called triage. After triage, each bug lives a short life: reported, fixed, checked, and closed with a test that stays.
New Words
| Word | Meaning |
|---|---|
| Regression | The full set of tests, run again after changes to catch anything that broke. |
| Triage | Sorting failures into groups that share one cause, before debugging any of them. |
| Signature | What a failure looks like: its first error message, and the condition that led to it. |
| Bucket | A group of failures with the same signature, usually one bug. |
| Bug report | A note that lets someone else see the bug: what failed, the seed, the tool and its version, the shortest run. |
| Regression test | A test added when a bug is fixed, kept forever so the bug cannot return unseen. |
The Smallest Example: Sort Three Failures by Hand
Each seed of the lab sends five random bytes, with a random gap of 0 to 9 idle clocks before each one. Here are the three failures and the gaps their seeds drew.
| Seed | First bad byte | Gaps before bytes 0 to 4 |
|---|---|---|
| 303 | byte 1 | 5 0 9 3 8 |
| 606 | byte 2 | 0 4 0 2 8 |
| 909 | byte 2 | 6 7 0 2 8 |
The bytes differ and the positions differ. Look for what they share. In every case, the bad byte had a gap of 0 before it: it was sent straight after the previous byte finished. Seed 606 also drew a 0 before byte 0, but byte 0 has no byte before it.
The Rules
Rule 1: Run the regression after every change.
A test that passed yesterday and fails today points at today's change.
Rule 2: New seeds every night.
Old seeds guard against breakage; new seeds explore new paths.
Rule 3: Triage before debugging.
Sort failures by their first error and the condition behind it. One bucket is usually one bug.
Rule 4: Report so it can be replayed.
Seed, test, tool and version, and the shortest failing run. A bug that cannot be replayed cannot be fixed.
Rule 5: Close with a test that stays.
Add the failing case to the regression, with its seed, so the bug can never return unseen.
Sources for These Rules
Simulation regressions, and faster platforms when they are too slow: Mehta, section 2.2, item 11.
Many runs with different seeds, holes and minimal changes: Spear and Tumbush, section 1.6.
Verification through the product life cycle, from the test plan to functional and gate-level runs: Mehta, section 15.5.
The Lab: Eight Seeds, Three Failures, One Bug
The lab runs the transmitter with a planted bug under eight seeds. Each run sends five random bytes with random gaps and compares what a receiver model collected. The heart of one run.
seed = s; r = $urandom(seed); // this run's own sequence
for (int k = 0; k < 5; k++) begin
g = $urandom_range(9, 0); // idle clocks before this byte
d = $urandom; // the byte
wait_until_free(); repeat (g) @(negedge clk);
send(d);
endseed 101: PASS, 5 bytes
seed 202: PASS, 5 bytes
seed 303: FAIL, byte 1: got 3b, want 6f, 4 frame error(s)
seed 404: PASS, 5 bytes
seed 505: PASS, 5 bytes
seed 606: FAIL, byte 2: got 56, want 59, 2 frame error(s)
seed 707: PASS, 5 bytes
seed 909: FAIL, byte 2: got b4, want a2, 2 frame error(s)Three failures with three different messages. Rule 3 says: do not debug yet. Put the gaps beside them, as the table above did, and one condition stands out. Every first bad byte came straight after another byte.
That points at the end of a frame. In this transmitter, busy falls one bit too early, as the stop bit begins. With an idle gap after it, the line stays high and the short stop bit looks normal. With no gap, the next start bit cuts it short, and the receiver sees a frame error. Seeds 404 and 505 drew gaps of 1, which was just enough.
Fix the one line, and rule 5 adds a test: the back-to-back case, with seed 606, stays in the regression. After the fix: seed 909: PASS, 5 bytes, and all eight seeds pass.
Why Sort First and Keep the Test
Why sort failures before debugging them? Because debugging is the slowest work in verification. Three engineers debugging three messages from one bug waste two-thirds of their day. Ten minutes of sorting saves hours.
Why keep the failing seed as a test forever? Because the same mistake is easy to make again. A later change to the stop-bit logic would break the back-to-back case silently, unless a test is waiting for exactly that.
Traps
The first trap is debugging the first failure in the list. It may be the longest, messiest run of the bucket. Pick the shortest failing run of each bucket; it has the least noise between the cause and the error.
The second trap is a bug report nobody can replay. "The UART test failed last night" is not a report. The seed, the test name, the tool and its version, and the first error line are. Without them, the bug waits until chance brings it back.
The third trap is closing a bug without a test. The fix goes in, the failing seed passes, and nothing stays to guard it. Six months later a clean-up changes the same line, and the bug returns with nobody watching.
Where This Goes Next
Regressions and triage are daily work on every project. These pages go further.
| The idea from this page | Where it is taught |
|---|---|
| Following one failure back to its cause | Debugging: From a Failure to a Cause |
| Seeds and directed closure in a UVM regression | Seeds, Coverage and Directed Closure |
| Reports that support a verdict | Reports That Support a Verdict |
| Reproducible stress on a FIFO | Reset, Wrap and Reproducible Stress |
| Ending a chip test honestly, and sorting by reason | Ending a Test Honestly |
Try It
Run it: eight seeds of five random bytes each, on a transmitter with a planted bug.
In uart_tx, change bits == 2 back to bits == 1. Predict the line for seed 909.
Add seed 1212 to the list. Does it fail, and does the gap before its first bad byte fit the bucket?
seed 101: PASS, 5 bytes seed 202: PASS, 5 bytes seed 303: FAIL, byte 1: got 3b, want 6f, 4 frame error(s) seed 404: PASS, 5 bytes seed 505: PASS, 5 bytes seed 606: FAIL, byte 2: got 56, want 59, 2 frame error(s) seed 707: PASS, 5 bytes seed 909: FAIL, byte 2: got b4, want a2, 2 frame error(s)Check Yourself
Common Mistakes
Wrong Debug every failure separately, as soon as it appears.
One bug often fails many runs in different-looking ways.
Fix Sort failures into buckets first, and debug one per bucket.
Wrong Report a failure without its seed and tool version.
Nobody else can make it happen again.
Fix Report the seed, test, tool, version and the first error.
Wrong Close a bug once the failing seed passes.
Nothing guards against the same mistake later.
Fix Keep the failing case in the regression for good.
Remember
- A regression runs every test again after each change; random tests also get new seeds every night.
- Triage sorts failures by first error and shared condition; one bucket is usually one bug.
- A bug report gives the seed, test, tool, version and first error, with the shortest failing run.
- A bug is closed with a test that stays in the regression.