Run callgrind analysis
(self)
| 456 | return False |
| 457 | |
| 458 | def run_callgrind(self) -> bool: |
| 459 | """Run callgrind analysis""" |
| 460 | print("\nRunning callgrind analysis...") |
| 461 | |
| 462 | if self.use_docker: |
| 463 | # Docker mode: Run callgrind using test system infrastructure |
| 464 | # The test system uses Docker volumes, so we need to use test.py to access them |
| 465 | print("🐳 Running callgrind inside Docker container...") |
| 466 | try: |
| 467 | # Run a custom callgrind wrapper script inside Docker |
| 468 | # Use test.py's Docker infrastructure to ensure volume access |
| 469 | callgrind_script = f""" |
| 470 | #!/bin/bash |
| 471 | set -e |
| 472 | cd /fastled |
| 473 | BINARY=.build/meson-{self.build_mode}/tests/profile/{self.test_name} |
| 474 | if [ ! -f "$BINARY" ]; then |
| 475 | echo "Error: Binary not found at $BINARY" |
| 476 | ls -la .build/meson-{self.build_mode}/tests/profile/ || true |
| 477 | exit 1 |
| 478 | fi |
| 479 | echo "Running callgrind on $BINARY..." |
| 480 | echo "Build mode: {self.build_mode} (DWARF4 debug symbols for Valgrind 3.19 compatibility)" |
| 481 | # Run callgrind directly on binary with DWARF4 symbols |
| 482 | valgrind --tool=callgrind \\ |
| 483 | --callgrind-out-file=/fastled/callgrind.out \\ |
| 484 | "$BINARY" baseline |
| 485 | echo "Callgrind complete! Output: callgrind.out" |
| 486 | ls -lh /fastled/callgrind.out |
| 487 | """ |
| 488 | # Write script to temp file with Unix line endings (LF only) |
| 489 | script_path = Path("_callgrind_temp.sh") |
| 490 | script_path.write_text(callgrind_script, newline="\n") |
| 491 | |
| 492 | # Run via Docker with same volumes as test system |
| 493 | print( |
| 494 | f" Docker volume: fastled-docker-build-{self._get_project_hash()}" |
| 495 | ) |
| 496 | result = subprocess.run( |
| 497 | [ |
| 498 | "docker", |
| 499 | "run", |
| 500 | "--rm", |
| 501 | "-v", |
| 502 | f"{Path.cwd().as_posix()}:/fastled", |
| 503 | "-v", |
| 504 | f"fastled-docker-build-{self._get_project_hash()}:/fastled/.build", |
| 505 | "fastled-unit-tests", |
| 506 | "bash", |
| 507 | "/fastled/_callgrind_temp.sh", |
| 508 | ], |
| 509 | capture_output=False, # Show output in real-time |
| 510 | check=False, |
| 511 | timeout=300, |
| 512 | ) |
| 513 | |
| 514 | # Cleanup temp script (keep on error for debugging) |
| 515 | if result.returncode == 0: |
no test coverage detected