Simvik

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:

  1. untested: <id> for each requirement that no link points at, in the order of reqs,
  2. unknown: <test> -> <id> for each link whose requirement is not in reqs, in the order of links,
  3. a final line covered <k>/<n_reqs>, where k is 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/4

Learn it first

More Requirements and design notes problems