= Coverage Analysis Theory = [[TOC(Developer/Coverage/CoverageAnalysisTheory, depth=2)]] The subject of Code Coverage Analysis is broad and has been written about many times over. This background material is not intented to summerize or rehash what can be read elsewhere. Instead, the focus here will be on the aspects of Code Coverage Analysis as they pertain to the [wiki:TBR/UserManual/RTEMS_Coverage_Analysis RTEMS Coverage Analysis] effort. The ultimate goal of Code Coverage Analysis is to ensure that a test suite adequately tests a particular body of code. In order to achieve this goal, several different coverage criteria may have to be examined. Let's consider the following criteria: * '''Object coverage''' - Has each line of generated assembly been executed? * '''Statement coverage''' - Has each line of the source code been executed? * '''Decision coverage''' (also known as Branch coverage) - Has each control structure (such as an if statement) evaluated both to true and false? * '''Condition coverage''' - Has each boolean sub-expression evaluated both to true and false (this does not necessarily imply decision coverage)? * '''Modified Condition/Decision Coverage|Modified Condition/Decision Coverage (MC/DC)''' - Has every condition in a decision taken on all possible outcomes at least once? Has each condition been shown to affect that decision outcome independently? Each of these criteria can be used independently to analyze the code in question. Application of any one criteria will likely improve the test suite to some degree. But each criteria has advantages and disadvantages. If we examine the criteria collectively, it can be seen that there are clear relationships between the different criteria as shown in the picture. If the test suite satisfies Statement Coverage, it will partially satisfy Decision Coverage and MC/DC. If the test suite satisfies Decision Coverage, it will completely satisfy Statement Coverage and partially satisfy MC/DC. There is also a complexity relationship where Statement Coverage is the least complex to satisfy and MC/DC is the most complex to satisfy. [[Image(CoverageCategories.png)]]]] If we consider the following example {{{ if (x || y) do something }}} and its psuedo object code {{{ cmp x, 0 branch if FALSE to do something }}} = Object Coverage = TBD = Statement Coverage = Statement coverage verifies that each line of source code in a source file is represented by generated assembly and that that assembly code is exercised. = Decision Coverage = TBD = MC/DC = This is also known as [http://en.wikipedia.org/wiki/Modified_Condition/Decision_Coverage Modified Condition/Decision Coverage].