Overview
Direct Instruction Injection is described in the cited TestRIG paper as part of randomized testing for RISC-V CPUs. In that workflow, it enables the testing engine to rely primarily on QuickCheck's built-in shrinking strategies for failing instruction sequences, with extra domain-specific shrinking logic added on top.
Role in shrinking counterexamples
After QCVEngine finds a counterexample, QuickCheck applies list shrinking by removing subsequences and retesting. The paper states that the authors augmented this with smart shrinking functions that not only eliminate instructions but also transform them to simplify the sequence.
One concrete example in the paper shows a failing instruction sequence being reduced first by ordinary list shrinking and then further minimized by propagating an instruction's output register to a later operand. That transformation enables another shrinking pass and produces a smaller failing program.
The paper also mentions a library of simplifications used during shrinking to remove esoteric instructions that perform mundane functions and obscure the root cause of a failure.
Sequence annotations
The cited evidence describes two important controls on injected sequences:
- Non-shrinkable sequences can be used to preserve required initialization. The paper gives an example where one implementation did not initialize floating-point registers, and a non-shrinkable initialization sequence prevented trivial counterexamples so testing could reach more interesting divergences.
- Assertions can be embedded in sequences. The paper says these make it possible for a sequence to fail without a divergence, and that sequences with assertions do not require tandem verification to detect such a failure.
In TestRIG
The evidence places Direct Instruction Injection within TestRIG's QCVEngine-based testing flow for RISC-V CPUs, especially in how counterexamples are discovered and reduced.