Skip to content

Conversation

Copy link

Copilot AI commented Dec 6, 2025

Complete test cases for src/cuddInteract.c and target 90% coverage

Final Status: ✅ 94.0% coverage achieved (79/84 lines covered)

Coverage Improvement: 8.9% → 94.0% (+85.1 percentage points)

Completed Tasks:

  • Explore repository structure and build system
  • Install test dependencies (Catch2, lcov)
  • Build with coverage and run existing tests
  • Analyze current coverage (8.9% - only 7/79 lines covered)
  • Create comprehensive test cases for cuddInteract functions
  • Run tests and verify 94.0% coverage achieved (exceeds 90% target)
  • Final validation and code review
    • All 5 test cases passing with 71 assertions
    • CodeQL security scan: 0 alerts
    • Code review feedback addressed
  • Fix sanitizer and valgrind failures
    • Removed "Reinitialize interaction matrix" test that called cuddInitInteract twice
    • Added explicit FREE(manager->interact) before all Cudd_Quit calls
    • Valgrind: 0 memory leaks ✅
    • Address sanitizer: All tests pass ✅

Test Summary:

  • 5 test cases with 71 assertions, all passing
  • Covers all main functions: cuddInitInteract, cuddSetInteract, cuddTestInteract
  • Tests various scenarios: empty/single/multiple variables, BDD operations, edge cases

Memory Management Fix:

The CUDD library has a design issue where cuddInitInteract allocates memory for the interaction matrix but Cudd_Quit (via cuddFreeTable) doesn't free it. The matrix is only freed in reordering functions. To ensure tests pass sanitizers/valgrind:

  • Removed test that called cuddInitInteract twice (causes leak)
  • Added explicit FREE(manager->interact) before all Cudd_Quit calls

Uncovered Lines (6%):

  • Lines 227-228: Memory allocation failure handling in cuddInitInteract (interact array)
  • Lines 236-238: Memory allocation failure handling in cuddInitInteract (support array)

These are error handling paths for memory allocation failures. The achieved 94.0% coverage significantly exceeds the 90% target.

Original prompt

Complete test cases for src/cuddInteract.c and target 90% coverage for the source file.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI changed the title [WIP] Add test cases for src/cuddInteract.c with 90% coverage Add comprehensive test coverage for cuddInteract.c interaction matrix operations Dec 6, 2025
Copilot AI requested a review from doganulus December 6, 2025 14:56
@doganulus
Copy link
Member

@copilot Investigate failures in sanitizer and valgrind tests. Then implement your solutions.

Copy link
Author

Copilot AI commented Dec 6, 2025

@copilot Investigate failures in sanitizer and valgrind tests. Then implement your solutions.

Fixed sanitizer and valgrind failures in commit 6ff96bc.

Root cause: The cuddInitInteract function allocates memory for the interaction matrix but CUDD's Cudd_Quit doesn't free it (design limitation in CUDD - only reordering functions free it).

Changes made:

  1. Removed "Reinitialize interaction matrix" test section that called cuddInitInteract twice, causing a memory leak
  2. Added explicit FREE(manager->interact) before all Cudd_Quit calls to prevent leaks

Verification:

  • Valgrind: 0 memory leaks, 0 errors ✅
  • Address sanitizer: All 71 assertions pass ✅

@doganulus doganulus marked this pull request as ready for review December 7, 2025 15:56
@doganulus doganulus merged commit 2321135 into 4.0.0 Dec 7, 2025
53 of 71 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants