Check requirements traceability
Report requirements that no test verifies, and tests that point at requirements that do not exist. A medium embedded C problem (Requirements and design…
medium · Requirements and design notes · requirements · traceability · strings
A release check reads the list of requirement IDs and the links from tests to requirements, and reports problems. Write trace_report(reqs, n_reqs, links, n_links), which prints:
untested: <id>for each requirement that no link points at, in the order ofreqs,unknown: <test> -> <id>for each link whose requirement is not inreqs, in the order oflinks,- a final line
covered <k>/<n_reqs>, wherekis the number of requirements with at least one test.
A requirement may be verified by several tests, and a test may verify several requirements (one link each). IDs match exactly, case included.
Starter code
void trace_report(const char *const *reqs, int n_reqs, const trace_t *links, int n_links) {
printf("covered %d/%d\n", n_links, n_reqs);
}Example tests
One requirement without a test
trace_t links[] = {
{ "test_low_warning", "REQ-1" },
{ "test_hysteresis", "REQ-2" },
{ "test_invalid_sample", "REQ-4" },
};
trace_report(REQS, 4, links, 3);Expected output:
untested: REQ-3
covered 3/4Learn it first
- Requirements and design notes · Testable requirements, traceability, one-page design notes and the documents a firmware team keeps.
More Requirements and design notes problems
- Implement to the requirements · A battery monitor specified by four numbered requirements, graded by tests named after them.