8.7 and design for testatbility

6.8 Declarations and Definitions

Moderators: misra-c, david ward

Post Reply
Posts: 16
Joined: Wed Nov 25, 2009 8:04 pm
Company: UTC UTRC

8.7 and design for testatbility

Post by ggentile » Thu Jan 24, 2013 3:08 pm

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


Posts: 572
Joined: Thu Jan 05, 2006 1:11 pm

Re: 8.7 and design for testatbility

Post by misra-c » Tue Apr 16, 2013 3:41 pm

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.
Posted by and on behalf of
the MISRA C Working Group

Post Reply

Return to “6.8 Declarations and Definitions”