16-04-2013, 02: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.
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