Code Coverage

Discussions about product bugs & problems!
Note: This is no replacement for the Official ETM Support!
12 posts • Page 1 of 2
ewoenne
Posts:62
Joined: Thu May 12, 2016 10:35 am

Code Coverage

Post by ewoenne »

Has anyone used the control code coverage? I have it working as per the help file but I would like to automate the process into a script instead of manually using the console. The instructions in the help are:
1. Add in the console a new CTRL manager to your project which shall load a specific script (command line option: .ctl).

2. Start the CTRL manager.

3. Press the key combination Ctrl+D and set for the CTRL manager the debug parameters -coveragereportfile coverage.xml -report CTRL_COVERAGE.
I cannot find a way to run no. 3 from a script. It looks like the only way to activate a debug flag on a running manager is to use the Console. Even running the library script (pmonDebugManager in pmon.ctl) requires a variable defined in console.pnl (gTcpFileDescriptor2).

fmulder
Posts:330
Joined: Wed Feb 03, 2010 9:46 am

Re: Code Coverage

Post by fmulder »

There are two possible solutions.

1) Look in the help file for 'Details on the Pmon'. You'll see that the pmon has a port. You can easily create a script that connects to the pmon (via tcpOpen) and then send the appropriate string commands to it. It should be fairly simple to send the "DEBUG' command directly to the pmon
2) Open the Console panel and look at the script code and do the same as the panel does.

I would say that option 1 is probably easier (and far more fun). Look at the script functions tcpOpen and tcpWrite.

Gertjan van Schijndel
Posts:634
Joined: Mon Aug 02, 2010 10:37 am

Re: Code Coverage

Post by Gertjan van Schijndel »

Just start the manager with these options. And perhaps the option '-dumpCoverageOnExit' is also handy.

ewoenne
Posts:62
Joined: Thu May 12, 2016 10:35 am

Re: Code Coverage

Post by ewoenne »

Starting the manager with the options '-coveragereportfile coverage.xml -report CTRL_COVERAGE' doesn't create the report file, though including '-dumpCoverageOnExit' does create the report when the manager is stopped.

mkoller
Posts:741
Joined: Fri Sep 17, 2010 9:03 am

Re: Code Coverage

Post by mkoller »

Just to explain things: The "-report XXX" thingy is a one-time "signal" to a running manager and will trigger a one-time action.
Therefore, you shall NEVER add "-report XXX" to the commandline when starting a manager.
Note that "-dbg XXX" is a different thing - it will enable a debug flag for the whole liefetime of a manager.

The CTRL interpreter ALWAYS counts the executed statements. It's just a matter of telling it WHEN to dump that
information to a file - which you can do either by sending it the "-report CTRL_COVERAGE" signal or let it
dump that information automatically when it finishes by using -dumpCoverageOnExit

You can also send the "-report CTRL_COVERAGE" signal from some other script by using the killdbg shell script,
e.g. killdbg -report CTRL_COVERAGE

ewoenne
Posts:62
Joined: Thu May 12, 2016 10:35 am

Re: Code Coverage

Post by ewoenne »

Thanks all, I ended up using the following:

The same code as pmonDebugManager() in pmon.ctl except for pmon_command with the option to open a new TCP connection
eg pmon_command(str, host, port, true, true);

Martin, I couldn't find any info in the help on using the killdbg shell script, how do you run this?

mkoller
Posts:741
Joined: Fri Sep 17, 2010 9:03 am

Re: Code Coverage

Post by mkoller »

You use killdbg as I wrote above:
killdbg PID OPTIONS
e.g.
killdbg 1234 -report CTRL_COVERAGE
You need to know the PID of the CTRL Manager, which you can get on the same machine with the CTRL function
pmonGetPID() or via a shell command, e.g.ps -ef|grep ctrl
And you need to have set the env variable PVSS_II to the config file of your project, e.g.
export PVSS_II=/home/projects/myproject/config/config

ewoenne
Posts:62
Joined: Thu May 12, 2016 10:35 am

Re: Code Coverage

Post by ewoenne »

Thanks Martin, is this also possible using Windows?

mkoller
Posts:741
Joined: Fri Sep 17, 2010 9:03 am

Re: Code Coverage

Post by mkoller »

yes, there is also a killdbg.cmd on windoze

ewoenne
Posts:62
Joined: Thu May 12, 2016 10:35 am

Re: Code Coverage

Post by ewoenne »

Hi Frenk, I found the below script you posted in the Lab which helped a lot with using the functions in pmon.ctl.

Thanks!

https://portal.etm.at/index.php?option= ... &Itemid=79

12 posts • Page 1 of 2