Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Copyright Notice
This document contains proprietary information of HCL Technologies Ltd. No part of this document may be reproduced, stored, copied, or transmitted in any form or by means of electronic, mechanical, photocopying or otherwise, without the express consent of HCL Technologies. This document is intended for internal circulation only and not meant for external distribution.
Summary
Vector Cast/C++ is an integrated software test solution that significantly reduces the time, effort, and cost associated with testing C/C++ software components necessary for validating safety- and mission-critical embedded systems. A one month Vector cast license was procured from Vector cast to evaluate the product for the 33FJ128MC804 PIC controller Firmware and the details are in this report.
Contents
1 RELEASE CONTROL RECORD............................................................................................4 2 DEFINITIONS............................................................................................................................5 3 REFERENCE DOCUMENT.....................................................................................................6 4 PURPOSE....................................................................................................................................6 5 SCOPE OF THE ANALYSIS....................................................................................................6 5.1 PROBLEM DESCRIPTION...............................................................................................................6 5.2 TYPE OF ANALYSIS.....................................................................................................................6 5.3 ANALYSIS CRITERIA, ACCEPTANCE LEVEL.....................................................................................6 5.4 TOOLS USED .............................................................................................................................7 6 ANALYSIS APPROACH ASSUMPTIONS.............................................................................7 7 ANALYSIS APPROACH...........................................................................................................7 7.1 INSTALLATION PROCEDURE (VECTORCAST ON THE LICENSE SERVER)..............................................7 7.2 BUILDING ENVIRONMENT.............................................................................................................8 7.3 EXECUTING THE APPLICATION FOR CODE COVERAGE ........................................................................8 7.4 CREATING THE TEST CASES .......................................................................................................21 8 RESULT VALIDATION..........................................................................................................23 9 OBSERVATION ......................................................................................................................23 10 SUMMARY / CONCLUSIONS /RECOMMENDATIONS................................................23
Tables
TABLE 1 : RELEASE CONTROL RECORD...........................................................................4 TABLE 2 : DEFINITIONS...........................................................................................................5
Date of Issue
0.1 0.2
Initial Version 21 Sep 2010 Updated for compiler 12 Jan 2012 template customization
2 Definitions
Table 2 : Definitions
Definition
3 Reference Document
1. Vector Cast getting started document (vcast_getting_started.pdf) 2. Vector Cast tool usage (vecchelp.pdf)
4 Purpose
The purpose of this document is to describe the Vector CAST tool feasibility analysis for 33FJ128MC804 PIC controller Firmware unit testing and code coverage. This document describes the analysis performed and the result of the analysis.
VectorCAST for PIC controller Time taken to create and execute the unit test cases compared to manual unit testing. Accuracy and completeness of the basic path and the branches identified with a sample source code.
5.4
Tools used The following tools were used Windows OS PC PIC Module Controller Microchip MP LAB and C30 Compiler VectorCAST C/C++
7 Analysis Approach
7.1 Installation Procedure (VectorCAST on the License Server)
1. Insert the VectorCAST distribution CD into the CD drive, or unzip the VectorCAST distribution file (vcast.win32.version.zip). 2. Double-click on the Setup.exe icon. The VectorCAST software displays a welcome page. 3. Click Next and select an installation mode: Typical: Select this option if you will be running VectorCAST on the License Server. All VectorCAST and FLEXlm files will be installed in a specified directory (next step) on the local computer. FLEXlm Server Only: Select this option if you will NOT be running VectorCAST on the License Server. 4. Click Next and select an installation directory. The default directory (C:\VCAST) is recommended. Note: The directory path you use must not include spaces or international accent marks or diacritics. 5. Click Next. 6. Select the program folder. "VectorCAST" is the default program folder. 7. Click Next. VectorCAST begins installing the licensed software.
installing_VectorCAS T_51.pdf
7.2
Building Environment 1. Under User Variables: Variable Name: LM_LICENSE_FILE Variable Value: C:\FLEXlm\license.dat 2. Under User Variables: Variable Name: VCAST_MICROCHIP_INSTALL_DIR Variable Value: C:\Program Files\Microchip\MPLAB C 30 3. Under System Variables: Variable Name: VECTORCAST__DIR Variable Value: C:\VCAST\
7.3
Executing the application for Code coverage 1. Copy the content of attached file and append into compiler list data file (C_TEMPLATE.DATA) in the vector CAST installation path C:\VCAST\DATA.
2. Verify that the Vector Cast License is valid. (License .dat file to be verified for date) 3. Open the FLEXlm Server
5. Verify that the Server Started Successfully 6. Start the VectorCast Application
7. Make sure that the config file is copied in to the working folder.
CCAST_.CFG
8. Setup Working Directory e.g.: C:\vcast_tutorial\My_804_SPI-DAC_P 9. From Menu bar select -> File and open New c/c++ Environment 10. Automatically this configuration is loaded with the Config file
11. All other configurations will be automatically loaded, if we place this config file in working directory. 12. By clicking Next , we see the following, and Enter a Project name say: My_Test123 13. Click Next and select the first option Traditional Unit Testing 14. Click Next and select Coverage Type: None 15. Click Next and Set the Current working folders for source and headers
17. Click Next and again Next , we see the following summary
19. Once built successfully, will load the individual functions of main and are populated such a way
VectorCAST for PIC controller 20. If we need to Test and Cover the function OSCCONFIG, right click and Insert TestCase. And on Coverage tab select Branch coverage
21. Right click on the Test Case and select Execute with Debug and also with coverage.
22. Just press OK and continue. It opens MPLAB IDE by itself. Select FileImport
23. By this time, there will be a .cof file created in the working folder just import that
25. Just ignore it, DONT abort or close , Make sure that the Debugger is selected for Simulator
VectorCAST for PIC controller 27. It displays the following message and select option NO
28. Now we can see that the control stops at a location in the file.
29. Now close the MPLAB IDE, It will display the following message
30. May select Yes /No , select Yes 31. In the VectorCast IDE, we may see that the tests executed successfully
VectorCAST for PIC controller 32. By clicking on the check box before the test case, we may see the code covered and red shows not covered and Green shows covered. Also may see that the Braches are covered as 46%
VectorCAST for PIC controller 34. Will generate the report in the .html format.
FullReport1.htm l
7.4
Once the environment is created the Vector cast will do the complexity analysis and will provide the details regarding the number of test cases for each function in the module. Also the details regarding the flow of each basic path will be generated by Vector cast which will be taken as an input for assigning input values for variables for test case execution The following procedure was followed for creating and executing test cases o In Vector cast, in the test case tree window, select the function for which the test case need to be inserted and then right click, and click Insert Test case o Double click on the newly inserted test case. The test case sheet will be opened in the MDI window. o The values for required variables will be entered to execute the required test path and click the execute button to execute the test cases Report generated by verifying the Test case
FullReport2.htm l
Sl No 1 2 3 4 5 6
Step Building the environment Executing the Code Coverage for complete test stub Design the test cases for each basic path Develop Test Cases/ each test case Verify the correctness of the test stub/ test case Execute the test cases and generate the report / test case
Sl No 1 2 3 4 5 6 7 8
Step Construct the flow graph from the source code or flow charts. Complete Test Stub Identify independent paths for complete test stub. Calculate Cyclomatic Complexity, V(G). Design the test cases for each basic path
Update the source code and add the required stubs and driver code for each test case testable through UART (serial connection) Verify the correctness of the stubs and the driver code Execute the Test cases /each test case Prepare the Execution report/test case Total time 12 Hrs
8 Result Validation
The Vector CAST tool unit testing effort comparison with manual testing is given in below.
Effort in Hrs for Unit testing using Vector Cast 6 hrs 10 min Effort in Hrs for Unit testing Manually 12 hrs
9 Observation
Vector CAST supports fully for lower version of PIC controller and hence the batch execution of test case could feasible. Since Vector CAST is customized for 33FJ128MC804, it could not load the *.cof file directly. Hence, each test case has to be executed with Debug option. This might take little more time for test case execution.