/
Code Coverage Code Coverage Code Coverage Code Coverage

Code Coverage Code Coverage - PowerPoint Presentation

anastasia
anastasia . @anastasia
Follow
73 views
Uploaded On 2023-11-09

Code Coverage Code Coverage - PPT Presentation

Definition The amount of code within a program that is exercised Uses Important for discovering code within a program that is not being exercised by test cases Code coverage tools measure how thoroughly tests exercise programs ID: 1030802

code coverage data profile coverage code profile data view profiling path function project compiler line run ccs file active

Share:

Link:

Embed:

Download Presentation from below link

Download Presentation The PPT/PDF document "Code Coverage Code Coverage" is the property of its rightful owner. Permission is granted to download and print the materials on this web site for personal, non-commercial use only, and to display it on your personal computer provided you do not modify the materials and that you retain all copyright notices contained in the materials. By downloading content from our website, you accept the terms of this agreement.


Presentation Transcript

1. Code Coverage

2. Code CoverageDefinition: The amount of code within a program that is exercisedUses:Important for discovering code within a program that is not being exercised by test casesCode coverage tools measure how thoroughly tests exercise programs

3. Code Coverage Tools with CCSThere are two main techniques to obtain code coverage data with CCS for C6000 targetsSimulator Code Coverage Tool: Simulation based code coverage collectionCompiler Path Profiler Tool: Compiler instrumented profiling that can be used for code coverage collection

4. Simulation Code Coverage ToolGenerates code coverage data for applicationInstrumentation and collection handled by the simulator non-intrusivelyView function and line coverage dataEnable editor highlighting of line coverage data

5. LimitationsOnly supported on C6000 simulatorsNo support on hardware targets (tool is a simulator feature)

6. Compiler Code Coverage ToolGenerate code coverage data for applicationData is collected using the compiler Path Profiling capabilityPath profiler will add additional instrumentation code to the applicationView function and line coverage dataEnable editor highlighting of line coverage data (TBD)

7. Path ProfilingCode is instrumented to count number of times each section is enteredNot all sections are instrumentedPost processing computes counts for sections not instrumentedRun-time-support function writes the collected information into a profile data file called a PDAT fileThis file is written to the host using C I/OThe write occurs when the run-time-support exit() function is calledCan execute on any HW or simulation platformCollected profile data can be used for generating code coverage reports Learn more about Path Profiling in the C6000 Compiler User’s Guidehttp://www.ti.com/lit/ug/spru187u/spru187u.pdf (Section 3.8)

8. Path Profilingcl6x --gen_profile_infoapp.outExecutepprofout.pdatpdd6xtest.prfcl6x --use_profile_info=f.prfBuild and link to create instrumented executableExecute multiple times with different input dataRTS function writes pprofout.pdat via C I/OProfile data decoderSaves overhead on targetBuild and link to create optimized executable

9. Path Profiling – Generate Code Coveragecl6x --gen_profile_infoapp.outExecutepprofout.pdatpdd6xtest.prfcl6x -use_profile_info=test.prf --onlycodecovBuild and link to create instrumented executableRTS function writes pprofout.pdat via C I/OProfile data decoderSaves overhead on targetGenerates code coverage data

10. Path Profiling – Generate Code Coveragecl6x --gen_profile_infoapp.outExecutepprofout.pdatpdd6xtest.prfcl6x -use_profile_info=test.prf --onlycodecovBuild and link to create instrumented executableRTS function writes pprofout.pdat via C I/OProfile data decoderSaves overhead on targetGenerates code coverage dataHandled by CCS CodeGen Code Coverage processer

11. Profiling OverheadCompile Time OverheadAdditional compiler passes pprof6x.exe and pdd6x.exeActivated under --[gen|use]_profile_infoRuns between parser and optimizerHandles adding profile code, or using profile infoSlows build timeMemory Footprint OverheadAdditional instructions for collecting profile information.ppdata section contains memory for the profile informationRuntime OverheadAdditional instructions for collecting profile information

12. Profiling LimitationsPDAT file is written to the host when the run-time-support exit() function is calledApplication must terminate to reach the exit() functionRun-time-support library must be usedFollowing applications will need additional tweaking to support writing of path profiling dataNon-terminatingNo main()Custom boot/initialization routineNo run-time initialization model selected in the linker optionsJTAG connection required for C I/O call to write the PDAT file to the host (CCS uses JTAG to communicate to the target)Check the C6000 Compiler User’s Guide for more details on how to workaround these limitations:http://www.ti.com/lit/ug/spru187u/spru187u.pdf (Section 3.8)

13. Reduce Profile OverheadPath profile block counts also unaffected by compiler optionsThus, reduce profile overhead by choosing options that reduce code sizeFor instrumented build consider:-ms3: Smallest code size-mu: Disable software pipelining-o: Continue using optimization-oi0: Disable automatic inliningAvoid making the code so slow it takes too long to run the testsEspecially if using a simulator

14. LABS

15. LAB conventionsBefore starting, it is important to review some lab conventions that will ease your work…Lab steps are in black and numbered for easier reference……Explanations, notes, warnings are written in blueWarnings are shown with Information is marked with Tips and answers are marked with Questions are marked with

16. Simulation Code Coverage: Exercise SummaryKey ObjectivesImport/Build/Load MainSort.c exampleEnable CCS Code Coverage toolRun the program and view Code Coverage dataTools and Concepts CoveredImporting an existing CCS Eclipse projectCCS Code Coverage tool

17. Import/Build/Load ‘MainSort’ ProjectImport the MainSort project into CCS (Project -> Import Existing CCS Eclipse Project)Enable the option to Copy projects into workspaceIn the Project Explorer view, select the MainSort project (it should appear [Active – Debug]) to make it activeCheck to make sure that the c674x_cpu_sim_le.ccxml file is [Active]. If it is not [Active], right-click on the file and select Set as Active Target Configuration in the context menuClick on the Debug icon in the toolbar. This will build the project, start the debugger, load the program and run to main

18. Enable Code Coverage CollectionOpen the Profile Setup view (Tools-> Profile -> Setup Profile Data Collection)In the Profile Setup view:Press the Activate button to enable profiling/coverage collectionEnable the Collect Code Coverage and Exclusive Profile Data optionPress the Save button Code Coverage collection has been enabled

19. Collect Coverage Data and View ResultsPress the Resume button to run the programThe program should terminate on its ownView the collected coverage data in the Coverage views (Tools-> Profile -> Setup Profile Data Collection)Two views will be opened:Function Coverage view: Displays function coverage dataLine Coverage view: Displays line coverage dataIn the Line Coverage view, select the Highlight coverage info in editor button. This will highlight line coverage data in the editor – green for lines that were executed and red for lines not executed

20. View Function and Line Coverage Results

21. CGT Path Profiling Tool: Exercise SummaryKey ObjectivesEnable compiler path profiling collectionRun the program and view compiler Code Coverage dataTools and Concepts CoveredCompiler path profiling optionView path profiling based code coverage data in CCS

22. Enable Compiler Path Profiling CollectionIn the Project Explorer view, right-click on the MainSort project and select Properties in the context menu to open the MainSort project properties dialogNavigate to the Feedback Options (Build -> C6000 Compiler -> Advanced Options -> Feedback Options) and enable the option for Generate profile feedback dataHit OK to apply the changes

23. OPTIONAL: Change Active Target ConfigurationIn the Project Explorer view, select the MainSort project (it should appear [Active – Debug]) to make it activeRight-click on the EXPKITOMAPL138.ccxml file in the Project Explorer view and select Set as Active Target Configuration in the context menuThe below steps are for if you have an OMAP L138 Experimenter Kit and would like to run the Compiler Code Coverage lab on it. If you do not have this hardware, you can continue to run on the simulator and skip the steps in this slide

24. Collect Path Profile Data and View Code Coverage ResultsClick on the Debug icon in the toolbar to rebuild, load and run to mainNavigate to Tools -> Profile and enable the option for Generate profile feedback dataPress the Resume button to run the programThe program should terminate on its ownView the collected coverage data in the Coverage views (Tools-> Profile -> Process CodeGen Code Coverage)Two views will be opened:CodeGen Function Coverage view: Displays function coverage dataCodeGen Line Coverage view: Displays line coverage dataHit OK to apply the changes

25. CodeGen Line Code Coverage Results