Add branch coverage measurement for random simulation
This commit adds tooling to measure how many branches the random simulation reaches during execution, which helps understand code coverage and identify untested code paths. Changes: - Add coverage build target to Makefile with --coverage flags - Create measure_coverage.sh script to build, run, and report branch coverage - Add signal handlers (SIGINT/SIGTERM) to main_test.c for clean shutdown - Update clean target to remove coverage files (*.gcda, *.gcno) The script runs the simulation for a specified duration (default 5 seconds), then uses gcov to analyze which branches were executed. In a 3-second run, the simulation reaches approximately 32% of all branches (781/2431). Usage: ./measure_coverage.sh [duration_in_seconds] Example output shows per-file and total branch coverage statistics.
This commit is contained in:
+9
-1
@@ -8,12 +8,20 @@
|
||||
|
||||
static sig_atomic_t simulation_should_stop = false;
|
||||
|
||||
static void signal_handler(int signum)
|
||||
{
|
||||
(void)signum;
|
||||
simulation_should_stop = true;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
(void)argc;
|
||||
(void)argv;
|
||||
|
||||
// TODO: set simulation_should_stop=true on ctrl+C
|
||||
// Set up signal handlers for clean shutdown
|
||||
signal(SIGINT, signal_handler);
|
||||
signal(SIGTERM, signal_handler);
|
||||
|
||||
startup_simulation(2);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user