 So welcome you to the next session of embedded software testing practical demonstration today we will study on the other tool called understand for CC++ this is used for static analysis purpose so we will try to go through samples you code how to configure the project and using we will try to select some of the metrics and analyze them and finally we will generate the report and how we can see the report so we can use the static analysis of example with understand for the PC purpose okay so we will try to invoke the tool so the tool be installed something like this understand this tool is static analysis from scientific tool worth doting so you can also get a evaluation version of this and we can use for 15 days for practicing and this can be downloaded free okay so we know that so what are things that we do in static analysis like we know the difference between dynamic and the static analysis in dynamic analysis what we do use we will do the testing of embedded software when the software is running on the target whereas in the static testing static analysis are testing we do not need to run the embedded software that is of testing interest basically what we do is in offline or statically we try to run the various test cases or the various aspects of the embedded software so one of the important thing that we need to be going about static analysis that we know that so no need of target execution need the inputs based on the test strategy which basically requires the manual inputs in a sense these inputs could be source code of course test cases of scenarios we need then we need low level design document or requirement document say and a strategy what is that scenario what we have told so wherever we need that static analysis type of testing that is required for example we have a control coupling data coupling right so this is one of the static analysis aspects of verification methodology we will see the flow graph of the embedded software with the help of control coupling where the part tree is getting generated and we will see who is calling whom and whether the code is there the object is there etc so with that help of the control flow we do the control coupling so that the being verified with that the other way is the interface between the various variables between different functions we use the method called data coupling okay okay so we have a understand for CC clusters it is from SCA tools we can get more information about this that is called SCA tech or SCA tools.com let us try to look into their website so that more information we can get SCA tools.com okay so we connect before that we did not understand here we have a couple of windows available these are the standard windows you know items in terms of file selecting the new file or creating a new file creating a project for understand CC clusters how understand CC clusters what is basically it creates a project of the source the embedded software source and it will configure and it will have mechanism such a way that it will try to understand the source and generate the report similarly we have a edit search project project has a configuring of various type of a matrix that we want to do in terms of other and if we add more files we can analyze further the change files only and check for any updates of the files the source files we can do with this we can generate the reports with this and matrix summary of the entire project or the entire file can be seen here matrix export can be exported to format as such as a CSV file or HTML for that complete report is available with the appropriate links we can run through command also and we can add a pulse script as a additional thing and any user tools which has configuration and all that it is part of the SCM or the software configuration all that we can use this option of course the standard options are available in terms of what files what type of a environment we are going to use we will go through this when we select a few sample okay so let's try to open up a file called test.udc the name of the project it uses is udc and this is a sample part created called the main.c and as soon as we select that it is adding to the project of this own on this time CC++ and displaying all the details that are required inside the file that I have chosen so based on that I may see several options is going to generate the various items such as it defines the file the path where it is defined the globals that are used the functions global functions there is a delay function there is a main function there is a nothing add different line numbers you can see and in total matrix of this file it is shown you can see count line code count line command count line inactive like on executable executable line and commented line etc so all this based on the matrix that you have chosen is going to show similarly we have a different type of options here CC++ you can use global objects who is calling all these options can be seen okay so we have chosen the project we have selected the file probably we try to reconfigure it so what we do is I will let you get a new one so we have this path we will try to create a new project so it is the current project that is close we create a ES team test we have a source sample source for this class same path we are going to generate okay now as soon as you are created the project it is showing the project configuration how this project is static analysis understand what is this tool can be configured so in the source you have to tell that source where you should pick you can select the source like sample C code we have we will try to see that so there is a C file created for example it is some embedded software or simple example which has a main which has some declarations such as in tie volatile some registers basically it is a toggle GPO toggle project which uses simple functions in terms of outputting the value in a segment seven segments of a display we can see that 3a of display 0 is initializing basically to start with and you know any embedded software will run while one look that is the life of that embedded software and you can see there are different functionalities that are getting done in this so let us not bother about what it does but so different sort of life we have structure we have a sub function called we have a for loop so there is a assignment statement etc so there is a delay function there is output function so what it does is this will display 0 1 2 3 continuously so that is a function within the while one loop so it is continuously going so it is going to call different sub functions such as delay let us say what this delay does for i equal to for 0 to some one lakh is going to run so based on the processor clock and all that much delay it is going to happen typically they use this is calculated off-hand then there is a function called nothing so nothing just does nothing it can return or return 0 since it is not doing anything we will say this so having two sub functions and one main function simplest main.c we will try to configure in our static analysis so while filter what are the types of files that I have selected star.cpp but you can have nothing wrong with that if you select assembly file some compilers will produce a star.list file c++ based extensions cc files header file h file c file etc so it is going to add that with this so that is what we do with the sources so next we have options so based on what sort of analysis we need we can select these options so any local object reclamation you want we can use it so we have some local circuit we can select it parameter reference any parameters we are passing it we can use it and in this case we do not need so any nested commands are there we can use it it is giving a information saying that nested commands are not standard because of physical force usually it is better to avoid that enabling nested commands support can produce so he is asking not to enable it so better we will not use the nested commands associate commands so commands particularly the right about the source code right so let us see whether we have written any command let us try to put some commands in our command and probably STA embedded testing program I declaration similarly register declare mode register or register so of course we can see this comment is right to this but it is advised not to have this here ready to have the source line the timing will keep it here may the project will understand the commands which are above or below like so we have commands as well for each of the line so that is about associating the commands so we are saying that commands before definition longest command before or off definition so we just say commands before definition of the variables or usage of that below one is the compiler basically yes does not do the compile but what should have a compiler we are using we need to use why because it is going to generate the report for a type of C language and what sort of a compiler that we use for embedded software is needed in terms of understanding what we are trying to generate so we can use anything for example or alphax, HPX, IAR etc. KLC like as we have let us say to choose Boreland C++ so any pass compiler separately you want to add it you can add the path there is the option here okay next one is the include we know that include is required for other file or any process specific kind of file you want to add it we can add with this in this case we do not have any other file it is for time being we will leave it up so sometimes what will happen is there are standard libraries like std.io.h, con.io.h which are part of the compiler inbuilt within the library and we are not able to explicitly show the path in that case what we can do is you can ignore that particular include files so that it does not take care of that okay next one is the macros any macros that you want to use it across the project you can name that and define where it is that we can add it next one is the MSVC so is for VC plus VC positive we do not need that file types what are the types of files that I use including header file in my project is what we have to tell we have C plus to start type C type makes C C plus to start so safe is to use mixed C C plus to start so I will choose C because we have on the dot C file and once you use the C plus plus or C you can select CPP extensions the C plus extension C extensions it uses C otherwise default it uses C and header file whatever header file sometimes it will be used in general we can mention it so all the things we have done so we are going to add now the particular C code and we can see the path it is showing and it has chosen with that cross mark so the main is chosen here after all these options are being done so I am going to say this so project configuration has changed that means I have changed some configuration in order to incorporate change it is recommended with all the refiles so rebuild now that means what are the options we have given the project is going to be rebuild with these options I will say yes you can see the project is added and the new project with the database let it create it here complicated successfully you can see there is something it could have created all the test EST test UDC and similarly when we generate the project it will show up all the specific files under this folder not this folder because this was for the previous one I was going to create EST test folder under that all the specific report files will be stored okay now the first job we have done by doing the project creation and adding all the files now let us try to configure the project which we have done let us try to change some file change analyzed analyze change the files so it will do if any changes have been done it will re-analyze and if any changes are required to be analyzed just analyze without configuration it can do it analyze all files so it will also check for update files all one source file unchanged that means one to one source file and you can see if you press this file just put a space and close it it will do your analysis because we have to check for update files so it is showing that one of one file problem this file has got changed and again we need to analyze all files multiple files to be analyzing now you can create the report of this source with several options like HTML report is on or text report we can do now it is not enabled why because we are yet to generate the report once we generate the report we can view it in HTML of text other thing is matrix export is on the important option what we do is what sort of a matrix that we move is all we are going to have it okay so cyclometric complexity is one of the important you know that it is just the complexity of the program it is going to do so those parts which are of your own interest we will add it so there is a cyclometric basically selected matrix to generate already added many things so what we do is we will select all and remove it and we will select again whatever is needed we need a cyclometric we need lines lines of code I mean lines of comments are there declaration calls function classes it is all of C plus a specific methods are also not required count line may be you can take out this you can add whatever we have a page let us take we have count line count line how many blank lines are there code declared how much as the code executable how much is there count line comment how much is there count line code is already there we will add it statement executable cyclometric so every cyclometric we just have you can also select the maximum cyclometric function this pile which we have selected we can have it that different types of cyclometric is a script modified etc a nesting that we want we can do rest the ratio of comment code how much percent usually expected to be 100 percent let us see how much is there in this we will add that now once we have all this we can select other options like where I want to generate is a matrix dot text so we will select something like matrix ESD test dot text then we will say okay so it will be saved it is not generated it we will generate it and okay for generating the project report so there are several options so those options are something like text type of output or you want to generate HTML or both is up to you how you want to generate it let us try to generate both and see and HTML also you can have a single one bundle HTML it can be alphabetic every n entities you want to generate like number of HTML let us try to put a alphabetic so that it should be readable and that will be good so allow scripts if you want allow scripts you can that links and all that will be created similarly we will try to generate the text also in the path is going to generate like ESD, TST dot text and there are certain options like generate time on report like time stamp you can have it what time this project complexity or the project analysis report have been generated with the all will be done so the reports the kind of reports that we want we can have it we can it is a multiple file projects good to have file matrix class over matrix which we do not need unused objects project matrix unused functions that code what all sound call is this only we can select all this and we can say okay like there is a file contents data dictionary based on the objects and the data that is available to the source macro reference anything is there function clause reference include file of the application tree was very important for the control flow and control coupling function complexity all this will be generated you can say okay so now selecting all that like path and everything we can have generate so I will try to generate now so there is no directory called this one is going to create it let's try to generate yes generate with you because it is simple one file we can see here in this path it has generated generating report and all that invocation tree and everything okay that will see after some other thing like we can see you can select what are the files available you and this file you can see the main delay functions are there main thing like these three are there can see count line is 11 etc so let's try to see the report now you can see it is enabled because we are configured and generated the report we can generate again and again how many times you want you can do it is going to generate the report and you can export the matrix that we have done we can see the summary of the project you can see where the project report is available how many classes there is no class 0 how many files 1 there are 3 functions total number of lines is 111 there are 31 blank lines there are 76 line numbers of code is there there are 53 lines of comment is there inactive means it is not used it is not there you can see ratio comment versus score is 0.70 is 70% so it is expected that every line of code is behind one comment so that it is 1.0 or 100% okay now let's try to see the view either you can see from directly from this folder let's try to see the folder this we have created this folder all the reports you can see this different HTML files let's see index or title let's try to open this okay so you can see it is very good that it has reported in nice way in HTML whatever we have seen the tool this can be reported and sent to the customer for justification saying that this is what the code is there this is what the input is likewise okay same thing can be seen all this report whatever we have generated the tool also with the option report you can see on the right hand side the option is available in terms of a final report and website you can see the table of contents like a documentation it does you can select the index what you want to see you can select the report similar to whatever we have a browsing same way you can see the report data dictionary summary report we can show what are the data dictionary that is available we can see A, B, C is disabled because there is no data available with that data let's try to click on D because it is available what it is yeah there is a function called delay we know that so that data it is displaying this language is a function and it is under the main.c 96 line that is all so it is something like a good linking report it generates that is about data dictionary summary you can see the file contents report what are the files that in a nutshell it is available under main.c similarly it will list completely for the entire project since here only one file is there showing the below global functions the three functions you can see delay main nothing object clause reference you can see there are these many objects local objects set use modify set use modify how many are there each line of the file delay also has about three set use and modify so there is no clause or reference report function clause reference report let's try to see so these are the functions main nothing delay in deletionally along with this additional thing data which is nothing but output registers you can see here okay next one we will try to see the invocation pre-report so delay then nothing this delay is calling nothing this is the invocation of course main should be calling delay that also we see you can see that for main delay is getting called similarly nothing is independent it is not calling so whatever the clause are there it will show main is calling at the higher level one level as delay this is the report the below one is a same thing function complexity this is interesting we will try to see what it does function complexity is that what complexity level it is there so cyclometric it is two we know that delay has two edges let us try to quickly understand delay where it is so there is a this one and this one it can take two path right one is with this one is with this for loop is one and this is a normal state map so it is why that is why it is showing a cyclometric code two is one testing we have seen that right each function matrix is going to show it so for delay total number of lines is 10 comment is one comment is one yeah is one comment right delay it is showing here total number of blank lines are two etc so the rate here is very bad they show comment versus code let us try to make it 100% when we reexecute this again later similarly we can select other functions like main we can see total number of lines is 9 code comment is 51 blank line is 26 there is no inactive 63 lines of code is there line executable is 55 line declared is 78 statement executable is 78 statement declared is 7 so 80% is the 81% is the ratio of the comment versus code we can see definition of each of this measure of complexity of a function mission support the cyclometric complex also a number of basis are dependent paths through a model we know this because we have studied about the cyclometric of one of the embedded software testing class so all the definitions of comment line all this matrix that we have generated is showing here file matrix entire files like this we have more it will show as many files as we have total number of lines similarly whatever we have seen at the functional level it is showing at the file level file average matrix entire project matrix if we have seen the VCC report here same thing it is displayed here unused functions anything is there it is interesting so what is unused so there are three unused functions are there unused it is basically variable or anything mode register 1 mode register 2 mode register 3 let us see mode register 1 is assigned best is never used anywhere it is showing here unused so it is defined and declared here is never used so likewise you can get for the complex just imagine program is having 10,000 minutes of code very difficult to see manually so we just use the project matrix to analyze how good shape it is what is that it is available okay so the other thing that we can see it is told is that calling of course source file here also you can edit also yes you can edit you can do like editor this project as well similarly it has linked you can see various options for each function you can find where it is used what is the line what is the property likewise you can see the details you can go forth and back for the different tools let us try to understand other options like each function you can change case you can edit source it will open the source still there is no separate linked function you can use this if it says edit source it will go away because we try to edit this now let us see the information on the left hand side you can see the parameters there is nothing you can type integer by default let us see component the other one is the call wise overall calling this guy delay is calling and delay is getting inter called by main the delay is called similarly references called delay main define main.c it is available on 07 line number it is showing and matrix how many number of lines are there in this 1 2 3 4 5 so that is how simplistically we can use this now static analysis as I was showing one of the embedded class testing class there is a call tree with this option you can see call by declaration by this you can see called by and what it returns similarly declaration file this is a file main.c there are other functions also it is showing click on anyone it will show that function and we have invocation in disable because it is not invoking any other function just return whereas higher functions we can see call by we can see total calling it should show delay and delay should be called by main we can see nicely main is calling delay we can see individual also call by showing the same we can select the levels how many levels we have it is calling again calling let us try to see for delay call by just a main and similarly it is calling invocation is enabled right delay is getting invoking nothing also so like this it is very useful to have a control graph value to have this kind of report for static analysis easy for review finding the bugs anything is static that is how we can use this understand for C++ effectively in general okay so preferences anything we have missed we can have logs timestamp and all that line colors these are all standards that we can use there are lot of options but basic options what we have studied is about waiting the project configuring it selecting the kind of report now let us try to see form this one independently you can see the first report it is showing the first file I will just activate so you enable it because there could be some links you can see automatically all links main if you click it will show that what are the new etc it is in the second window it is showing along with the line numbers similarly click on anything else it is showing the function it is referred by main and it is used here similarly I if you see I is declared here and how I is used that also it is shown it is defined here set in here use it here modify here so it is very important to understand how the variable is that is what data coupling so now we have seen this anything else you want to try probably we will try to ratio as 100% wherever the executable lines is there comment just for example I will see how it is fixed suppose this bug total projects 20% try to make it 100% by adding the missing command here we have to call this function also something like this value we will have here comment write a good comment is already comment is there written also as a comment this should show as 100% written 0 you can add a comment something like written nothing okay for time being okay so every line of code we have a comment let us make sure anything we have missed put a line you can see there is a comment suppose 20% violation is used as if we are developer we are trying to put the commands we do not need to put the first one so once it is done better we need to save it and definitely analyze all files check for update files there is a file change now analyze the change files so let us try to analyze it it is completed successfully there is a error or something linking or now pressure to see the summary improvement is there from 70 to 88% it has improved still that means well it has missed it is about 12 lines we have missed to read the comment so that you can take it as a exercise and fix it and we can read on this next session or you want you can try yourself likewise we can have a complex projects I have few other sample projects try to see it is just for reference close the current project and all this see any other project is available one more example try to see more complex project here it is one of the sample program you can see there are files this many files are there and there is a comment that the ratio was less it was not sure that more comments are there so it is more than one also is there so chance are that that also can happen why because you would output more comments for each of the line there is a reason it is showing more than 1.0 so you can see one example this one try to see it is not showing call we will see it can show this it is not showing call it is in a real model it is basically a dot h file likewise we can develop a complex project so that is how we can do the static analysis generating the report and configuring and analyzing the embedded software program so basically what we need is we need to define the matrix understand the standards what we need and try to okay so now let us try to put an exercise exercise 6.1 I will say so currently we have 0.88 as comment versus ratio code please fix this to make sure that it is 100% this it should be 1.0 another exercise could be after doing this add another dummy function and call the main generate the make a way complexity and see that it is well within 10 of course we have a simpler program that means complexity of any project should not be more than 10 that is what is the meaning so we need to do the exercise for the given code I will share the code and the same code we can use configuring the project under understand process select the matrix make a way lines of code executable lines comments function references objects control flow call tree we can use this data flow or data coupling you can do it or data dictionary all these reports you can generate with the help of this understand for c++ generate the project report analyze the report and provide a summary you can using HTML or using the tool sometimes tool may not be available what we will do is if customer does not have a tool generate the HTML and see we can also see in text file little tricky to understand HTML is a better way same report generated HTML you can see object cross references and each file how it is set each of the registers of the output local variables there are objects means the referred variables you can see for this cyclometric modifiers there are various types of cyclometric complexity so that anyway we have understood about basic cyclometric complexity and each functions you can see the reports lines, comments, etc for delay main and nothing these functions that is the file matrix report average matrix report also you can see unused function report there is a three unused objects that are used because that is what report how we can generate and use it so with that we will and understand for this tool will go through we will if required we can touch base of this tool and understand more about more complex topics that you can take it as an exercise and we can touch base that and next exercise we will take a study about other aspects test case management defect management using test link and bugzilla and also in one of the exercise except for target based execution how it can be used and we have seen the LDRA cover in one of the earlier sessions also we need to see about test case generation traceability and checklist filling the next session with that I will end the today's class thank you bye