|
||||||||||
Gathering Regression List for Structural Coverage AnalysisBy Shricharan Gaddam, eInfochips - An Arrow company Introduction: Structural coverage analysis is a method to ensure RBTs parse the code structure to verify every line of code for its correctness. RBTCA is used to determine the efficiency our tests verifying implementation of the software requirements. The intention is to check whether code and requirements are in sync. This analysis shows that:
RBT entails verifying that software meets application(s) requirements. Every requirement embraces set of tests signifying eminent realization of that requirement. In order to make our software bug-free, a measure of high-test coverage lowers chances of containing undetected software bug. If we keep the measure as 100% test coverage, then more percentage of source code is realized/executed while testing. The coverage criteria for measurement in category wise are as follows:
Let us understand briefly on each coverage mentioned above with the help of the source code below: int demoFunc (int x, int y) Function coverage analysis – This checks if each function (or subroutine) in the program is been called. Throughout the course of test suite execution, if subroutine 'demoFunc' is called no less than once, then subroutine coverage for this subroutine is fulfilled. Statement coverage analysis – This checks if every instruction in the source code has been executed no less than once. Statement coverage is achieved for demoFunc() when tests calls this function with x=1 and y=1 as inputs, covers every line in the function including z = x. Branch coverage analysis – This checks if every branch of every control structure (code statements as in ‘if’ and ‘switch case’ control statements) has to be executed. Let’s consider an instance, for an ‘if’ condition, true part and false part has to be realized. Tests with demoFunc(1,1), demoFunc(0,1) achieves branch coverage, in the initial test case, required conditions (x > 0), (y > 0) are achieved and z = x instruction is executed, where as in the later test case, condition (x > 0) is never achieved, and hence instruction z = x is never executed. Condition coverage analysis – This checks if every boolean sub-expression is verified for true and false conditions. Tests which call demoFunc(1,0) and demoFunc(0,1) will satisfy condition coverage. In the initial test case, (x > 0) evaluates to true, while (y > 0) evaluates to false; where as in the later test case, (x > 0) evaluates to false, while (y > 0) evaluates to true. Condition coverage might be inferred as branch coverage. To evaluate the difference let’s observe the source code instruction: "if p and q then" Condition coverage can be achieved by following test cases: p=true, q=false p=false, q=true In any of the above test cases branch coverage is not achieved since, none of the test cases achieves ‘if’ condition. However, it is necessary to inject faults to make sure that all conditions and branches that handles code exceptions are covered while testing. Decision coverage – All the entry and exit points of the source code are been verified and each decision in the source code is verified for all possible outcomes at least once. Modified condition/Decision coverage – The Structural Coverage Analysis verifies if all the entry and exit points of the source code are been verified, each decision in the source code is verified for all possible outcomes at least once, and it is ensured that each condition independently impacts the output of a decision. To elaborate the above-mentioned independence criteria an example is sown below, For instance, let’s observe the below source code instruction: if (p or q) and r then With below mentioned tests, the condition and decision coverage is achieved p=true, q=true, r=true p=false, q=false, r=false In any of the above-mentioned test cases modified condition/decision coverage is not achieved, it is vivid that the output is not influenced by either value of 'q' in the initial test case or by value of 'r' in the later test case. Hence the below mentioned test cases are required to achieve MC/DC: p=false, q=true, r=false p=false, q=true, r=true p=false, q=false, r=true p=true, q=false, r=true Objective: The objective of this paper is to discuss an approach or an idea for gathering the regression list to perform SCA for the modified or updated source code, but in the case of structural coverage analysis, the objective is to ensure that the source code is covered through the mentioned verification methods (test cases, analysis, inspection). Problem Statement: Many a times, SCA teams end up executing all the test cases/procedures for a regression activity, which in turn takes lot of time for execution and dependency of the target time (if any) increases. Required time to complete SCA activity increases which in turn increases cost of the project. For example, if we are monitoring different parts of a car, like the tire pressure monitoring system, fuel monitoring system, navigation systems, ambient lightning, ambient temperature, etc. Let’s assume that after delivering all the above mentioned systems monitoring applications. Later if one wants some updates in fuel monitoring system, the structural coverage analysis ensures that the system is well verified and all the test cases/procedures for that particular update are verifying the desired purpose of requirements. In order to perform the structural coverage analysis, there is no need to consider test cases for other systems. For e.g. the test cases of fuel monitoring system are more than enough and to be more specific test cases related to updated requirements are enough to ensure that requirements-based test cases exercised the code structure. Clarification(s):
Solution(s): Generally, for any modification or addition of the source code, a change request must be raised. This change request drives further the process of requirement gathering, validation, design, development, integration and verification. There are few methods to perform the SCA activity for this source code. Solution 1: Consider there are multiple change requests; based on each change request; using the requirements maintenance tool, we need to trace and identify the verification test cases and procedures; if the list of test cases/procedures is more some automation script can be written. Advantages of Solution 1:
All the above factors lead to cost reduction also. Solution 2: When a change request is driving a change only in a particular component or functionality, test cases related to that component are taken for execution on the instrumented build. Since the verification is performed based on the Requirement Based Test methodology, these component related test cases will be sufficient for performing structural coverage analysis. Here it is suggested or recommended that test cases and procedures are placed in the respective components folders. For example, let’s consider same example of development of monitoring different parts of a car; like the tire pressure monitoring system, fuel monitoring system, navigation systems, ambient lightning, ambient temperature, etc. and the change request is for updating fuel monitoring system. Then we must place the test cases and test procedures of fuel monitoring system in the respective folder only not in a different component folder. This helps in identifying the test cases and procedures quickly and easily for performing the structural coverage analysis. Advantages of Solution 2:
All the above factors lead to cost reduction also. Further Improvements: We can further filter/optimize these test cases based on identifying the changes driving in that component and choosing them to use the requirements maintenance tool. Solution 3: While purchasing an SCA tool (like Rapita or Vectorcast, etc...) we can ask for customizations in tool to include features for identifying list of test cases for any specific part of code or IDs (In SCA, while instrumenting the source code, IDs are assigned to file, function and statements). This may be possible based on mapping IDs to test cases. Advantages of Solution 3:
All the above factors lead to ‘Cost Reduction’ as well. Conclusion: It is preferred to use optimized or optimal test list for regression activity for structural coverage analysis instead of using whole test lists. This method leads to less ramp-up time for engineers, target required time is less, test procedures execution time on instrumented build is less. All these factors lead to cost reduction and less delivery time. eInfochips, an Arrow company, is a leading global provider of product engineering and semiconductor design services. With over 500+ products developed and 40M deployments in 140 countries, eInfochips continues to fuel technological innovations in multiple verticals. For more information connect with eInfochips today. Abbreviations: RBTCA: Requirement Based Test Coverage Analysis RBT: Requirement Based Test References: 1. https://en.wikipedia.org/wiki/Code_coverage 2. https://doc178b.blogspot.com/2013/08/do178b.html 3. https://www.rapitasystems.com/products/rapicover 4. https://www.vector.com/int/en/products/products-a-z/software/vectorcast/#c176623 About Author Shricharan Gaddam, works as Sr. Engineer at eInfochips -An Arrow company, holds a Master’s Degree in Digital Electronics and Communication Systems from JNTU Hyd. He has work experience on multiple embedded domains like Multimedia, Medical/Health Care devices, Avionics, Networking. His responsibilities incudes Requirement gathering, validating, development and verification in the software development life cycle. If you wish to download a copy of this white paper, click here
|
Home | Feedback | Register | Site Map |
All material on this site Copyright © 2017 Design And Reuse S.A. All rights reserved. |