In WinCC OA we are able to create code coverage reports.
This can be done by adding "-coveragereportfile unittest_coverage_$DATE$_$TIME$_$MAN$.xml -dumpCoverageOnExit" to the process starting options.
So, when the process exists, a code coverage report will be written.
By setting a debug flag "-report CTRL_COVERAGE" the coverage report will be written to disk.
Now i want to create a code coverage report after my unit tests have run without user interaction, by simply calling an API for doing the same job, as if i - as a user - set the debug flag "-report CTRL_COVERAGE" on and on again.
Is this possible? And when yes, how?
With regards
Frank
How to record Code coverage using API call?
- leoknipp
- Posts:2928
- Joined: Tue Aug 24, 2010 7:28 pm
Re: How to record Code coverage using API call?
In the Lab section you will find an example (panel/script) which can be used to set a debug flag in ca cyclic interval.
Maybe you can some parts of the code to set the debug flag.
https://portal.etm.at/index.php?option= ... &Itemid=79
When sending a process the signal "-3", e.g. pkill -3 PID, the manager is reading the file "dbg" in the "log" directory of the project and uses the information given in this file as debug flag.
In the file you define the report/debug flag and a CR+LF, e.g -report dispatch.
The file is deleted afterwards by the manager who has received the signal -3.
Best Regards
Leopold Knipp
Senior Support Specialist
Maybe you can some parts of the code to set the debug flag.
https://portal.etm.at/index.php?option= ... &Itemid=79
When sending a process the signal "-3", e.g. pkill -3 PID, the manager is reading the file "dbg" in the "log" directory of the project and uses the information given in this file as debug flag.
In the file you define the report/debug flag and a CR+LF, e.g -report dispatch.
The file is deleted afterwards by the manager who has received the signal -3.
Best Regards
Leopold Knipp
Senior Support Specialist
- flindecke
- Posts:69
- Joined: Wed Jun 24, 2015 1:54 pm
Re: How to record Code coverage using API call?
I will take a look the next day for your proposal.
Seems to be a solution.
Seems to be a solution.
- flindecke
- Posts:69
- Joined: Wed Jun 24, 2015 1:54 pm
Re: How to record Code coverage using API call?
Hello Mr Knipp,
i have tried the "pkill" proposal and the code. Both versions do not work as expected.
For the "pkill" proposal i have tried to do it on the terminal like the following (assuming my process has the PID 21160)
In the WinCC OA log console i see, that the process receives the signal, but the output of the code coverage is missing.
Entering "-report CTRL_COVERAGE" by myself in Pmon as the debug flag works as expected.
The same when using the pmon Tcp API.
Is there another solution to create a code coverage report via API?
With regards
Frank Lindecke
i have tried the "pkill" proposal and the code. Both versions do not work as expected.
For the "pkill" proposal i have tried to do it on the terminal like the following (assuming my process has the PID 21160)
Code: Select all
> echo "-report CTRL_COVERAGE" >> log/dbg
> pkill -3 21160
Entering "-report CTRL_COVERAGE" by myself in Pmon as the debug flag works as expected.
The same when using the pmon Tcp API.
Is there another solution to create a code coverage report via API?
With regards
Frank Lindecke
- Gertjan van Schijndel
- Posts:634
- Joined: Mon Aug 02, 2010 10:37 am
Re: How to record Code coverage using API call?
Under windows 7 it works without the double quotes:
Code: Select all
echo -report CTRL_COVERAGE > log/dbg |pkill -3 - flindecke
- Posts:69
- Joined: Wed Jun 24, 2015 1:54 pm
Re: How to record Code coverage using API call?
Then the resulting dbg file content is as follows:
and i think, this is not the correct content (and it does not work)
Code: Select all
-report
CTRL_COVERAGE
- Gertjan van Schijndel
- Posts:634
- Joined: Mon Aug 02, 2010 10:37 am
Re: How to record Code coverage using API call?
Your echo command seems to be working differently compared to the ones I have tried (windows 7 and opensuse).
Does your 'dbg' file contain the carriage return and line feed? Does it work when manually create the 'dbg' file?
How did you see that the process has received the signal? I did not notice anything in the console.
Does your 'dbg' file contain the carriage return and line feed? Does it work when manually create the 'dbg' file?
How did you see that the process has received the signal? I did not notice anything in the console.
- flindecke
- Posts:69
- Joined: Wed Jun 24, 2015 1:54 pm
Re: How to record Code coverage using API call?
I am using Windows 10 64 bit.
To problem seems to be - using "echo ..." command on terminal - that there seems to be a UTF-8 byte encoding signature (two bytes FF, FE) before the ASCII characters of "-report CTRL_COVERAGE".
When i create in an editor, these two bytes are missing. So there seems to be a problem reading those files having a BOM (https://de.wikipedia.org/wiki/Byte_Order_Mark).
So this seems to be a problem of WinCC OA reading UTF-8 encoded files providing a BOM.
I have not tried creating the file by WinCC OA code, but it seems to be a possible workaround. IMHO it is a workaround, because i am not able to control which process reads this file (when concurrent processes gets a signal 3). So i have to write a component which serialize setting the debug flag (which seems to be the only way using the afformentioned solution).
Thanks for your effort trying to help myself.
With best regards
Frank Lindecke
To problem seems to be - using "echo ..." command on terminal - that there seems to be a UTF-8 byte encoding signature (two bytes FF, FE) before the ASCII characters of "-report CTRL_COVERAGE".
When i create in an editor, these two bytes are missing. So there seems to be a problem reading those files having a BOM (https://de.wikipedia.org/wiki/Byte_Order_Mark).
So this seems to be a problem of WinCC OA reading UTF-8 encoded files providing a BOM.
I have not tried creating the file by WinCC OA code, but it seems to be a possible workaround. IMHO it is a workaround, because i am not able to control which process reads this file (when concurrent processes gets a signal 3). So i have to write a component which serialize setting the debug flag (which seems to be the only way using the afformentioned solution).
Thanks for your effort trying to help myself.
With best regards
Frank Lindecke
- Gertjan van Schijndel
- Posts:634
- Joined: Mon Aug 02, 2010 10:37 am
Re: How to record Code coverage using API call?
Perhaps you could try to run it in an ansi terminal:
Code: Select all
cmd.exe /A echo -report CTRL_COVERAGE > log/dbg |pkill -3