MISRA Discussion Forums
8.7 and design for testatbility - Printable Version

+- MISRA Discussion Forums (https://forum.misra.org.uk)
+-- Forum: MISRA C (https://forum.misra.org.uk/forumdisplay.php?fid=4)
+--- Forum: MISRA-C: 2004 rules (https://forum.misra.org.uk/forumdisplay.php?fid=17)
+---- Forum: 6.8 Declarations and Definitions (https://forum.misra.org.uk/forumdisplay.php?fid=35)
+---- Thread: 8.7 and design for testatbility (/showthread.php?tid=937)



8.7 and design for testatbility - ggentile - 24-01-2013

It seems that the 8.7 rule contradict design for testability.
Infact when you have a static variabile defined at block level, right now you have no way to perform any white box testing withot changing/adding code to copy the value to a global variable.

Let me know

Giacomo


Re: 8.7 and design for testatbility - misra-c - 16-04-2013

Apologies for the long delay in replying to this question - it managed to go unnoticed.

Yes, Rule 8.7 does make it impossible to conduct white box testing without either adding code such as you suggest or using other devious means such as finding the address of the block-scope static, e.g. from a linker map file, and modifying is by means of a pointer. Neither approach is very satisfactory.

If you need to conduct white box testing then you would have good grounds for deviating from this rule.

Note: the equivalent rule in the recently-released MISRA C:2012 is advisory rather than required; it recognises the need to perform unit testing as being good grounds for not following the rule.