MIRSA-C, Line/Branch and MC/DC Coverage - Automotive Software

MIRSA-C, Line/Branch and MC/DC Coverage - Automotive Software

As the automotive industry becomes more and more connected and smart, there are millions of lines of code written to make this happen. As per the industry standard, any software or hardware that goes in to automotive, has to adhere to specific standards like #ISO26262 #SOTIF. Now to comply with these standards, developers need to write their source code following certain guidelines. In this step by step blog we will touch-base with few of such coding styles and standards like #MISRAC #MCDC #LineBranchCoverage.


Familiarize Yourself with MISRA C Guidelines:

  • Read and understand the MISRA C:2012 guidelines thoroughly. https://www.misra.org.uk/
  • Take note of the specific rules and recommendations relevant to the automotive software development context.

Choose an Appropriate Coding Standard:

  • Select a coding standard that aligns with the MISRA C guidelines, such as MISRA C:2012 or a derivative specific to your organization.
  • Ensure that the chosen coding standard is applicable to your target platform and compiler.

Use a Linting Tool:

  • Employ a static code analysis tool or a dedicated MISRA C checker to enforce compliance with the guidelines. Examples: #PARASOFT #LDRA #VECTOR
  • Integrate the tool into your development environment and configure it to check the code automatically during the build process.

Enable Compiler Warnings:

  • Enable and pay attention to compiler warnings related to potential MISRA C violations.
  • Address and resolve these warnings promptly to maintain compliance.

Maintain Consistent Coding Style:

  • Adopt a consistent coding style across the entire codebase to improve readability and ease of maintenance.
  • Ensure that the coding style aligns with the MISRA C guidelines and the chosen coding standard.

Avoid Undefined Behavior:

  • Understand the consequences of undefined behavior in the C language.
  • Design and write code that avoids invoking undefined behavior, as it can lead to unpredictable results and non-compliance with MISRA C guidelines.

Perform Code Reviews:

  • Conduct regular code reviews to identify and rectify potential violations of the MISRA C guidelines.
  • Involve experienced developers familiar with the guidelines to ensure comprehensive coverage.

Write Testable Code:

  • Structure the code to facilitate unit testing and verification.
  • Aim for smaller functions with well-defined inputs, outputs, and testable boundaries.

Implement Unit Tests:

  • Develop a comprehensive suite of unit tests to exercise different aspects of the code.
  • Ensure that the tests cover both the normal and boundary cases to achieve maximum code coverage.

Measure Line and Branch Coverage:

  • Utilize code coverage tools to measure the line and branch coverage achieved by your tests.
  • Aim for high coverage percentages to increase the likelihood of identifying potential issues and ensuring the reliability of the software.

Achieve MC/DC Coverage:

  • MC/DC (Modified Condition/Decision Coverage) is a higher level of coverage that requires each decision in the code to be tested independently.
  • Develop test cases that exercise all possible outcomes of each decision, ensuring that each condition and decision has been tested independently.

Automate Testing and Code Coverage Analysis:

  • Integrate automated testing and code coverage analysis into your build and continuous integration processes.
  • This helps ensure that every change to the code is thoroughly tested and coverage metrics are constantly monitored.

Continuously Improve:

  • Regularly review and refine your coding practices based on the feedback from static analysis, code reviews, and test coverage analysis.
  • Maintain a culture of continuous improvement to enhance code quality and adherence to the MISRA C guidelines.


Reach out to our experts for your requirements on automotive software development and testing:

Website: https://www.sibraintech.com/

Email: [email protected]




要查看或添加评论,请登录

SiBrain Technologies Pvt Ltd的更多文章

社区洞察

其他会员也浏览了