Commit e123fc06 authored by Maxime Perrotin's avatar Maxime Perrotin
Browse files

Better support coverage collection

parent 074adc01
......@@ -34,7 +34,7 @@
../binaries/peekpoke:
echo "cd @_LOWER:Name_@_GUI && ./peekpoke.py ../@_Partition_Name_@" > $@
chmod +x ../binaries/peekpoke
echo "ASSERT_IGNORE_GUI_ERRORS=1 ./@_Partition_Name_@ & sleep 1 ; ./peekpoke ; pkill @_Partition_Name_@" > ../binaries/run_@_Partition_Name_@_partition
echo "ASSERT_IGNORE_GUI_ERRORS=1 ./@_Partition_Name_@ & sleep 1 ; ./peekpoke ; pkill -INT @_Partition_Name_@" > ../binaries/run_@_Partition_Name_@_partition
chmod +x ../binaries/run_@_Partition_Name_@_partition
@@ELSIF@@ @_Language_@ = GUI
# Provide scripts to run the gui and its partition automatically
......@@ -44,7 +44,7 @@
../binaries/@_Name_@:
echo "cd @_LOWER:Name_@_GUI && taste-gui" > $@
chmod +x $@
echo "./@_Partition_Name_@ & sleep 1 ; ./@_Name_@ ; pkill @_Partition_Name_@" > ../binaries/run_@_Partition_Name_@_partition
echo "./@_Partition_Name_@ & sleep 1 ; ./@_Name_@ ; pkill -INT @_Partition_Name_@" > ../binaries/run_@_Partition_Name_@_partition
chmod +x ../binaries/run_@_Partition_Name_@_partition
@@ELSE@@
@_LOWER:Name_@:
......
......@@ -130,16 +130,19 @@ run_@_Name_@_binary:
# make sure the generated artefacts appear in space creator
touch ../../*.pro
cd ../binaries && taste-run-and-trace ./@_Name_@ || :
@@IF@@ @_Coverage_@
cd ../binaries && lcov --capture --directory .. --output-file coverage.info && genhtml coverage.info --output-directory coverage
@@END_IF@@
@@ELSE@@
cd ../binaries && ./@_Name_@ || :
@@END_IF@@
@@END_IF@@
@@TABLE@@
@@IF@@ @_Block_Languages_@ = GUI
run_@_Block_Names_@_gui:
cd ../binaries && ./@_Block_Names_@
# When GUI exits, kill the binary
pkill @_Name_@
# When GUI exits, kill the binary (-INT to allow coverage collection)
pkill -INT @_Name_@
@@END_IF@@
@@END_TABLE@@
@@ELSE@@
......@@ -150,6 +153,7 @@ run_@_Name_@_partition:
@@IF@@ @_Debug_Flag_@
# make sure the generated artefacts appear in space creator
touch ../../*.pro
# Coverage = @_Coverage_@
@@IF@@ @_Coverage_@
bash -c "trap 'cd ../binaries && lcov --capture --directory .. --output-file coverage.info && genhtml coverage.info --output-directory coverage' EXIT; cd ../binaries && taste-run-and-trace ./@_Name_@ || :"
@@ELSE@@
......
......@@ -26,12 +26,21 @@ extern "C"
{
#include <Broker.h>
#include <DriverHelper.h>
@@IF@@ @_Coverage_@ = TRUE
#include <gcov.h>
#include <unistd.h>
@@END_IF@@
}
@@IF@@ @_Coverage_@ = TRUE
static void ctrl_c_handler()
{
exit(0);
@@-- calling exit(0) does not stop the application, and
@@-- therefore atexit is not called, so coverage data is
@@-- not dumped. We can however do it manually and then
@@-- force the application to close with _exit.
__gcov_dump();
_exit(0);
}
@@END_IF@@
......@@ -97,7 +106,7 @@ taste::Lock @_LOWER:Bound_Functions_@_Mutex;
int main(void)
{
@@IF@@ @_Coverage_@ = TRUE
signal(SIGINT, ctrl_c_handler);
signal(SIGINT, (__sighandler_t)ctrl_c_handler);
@@END_IF@@
initializeDevices();
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment