Add comprehensive unit tests for MergeUncoreGroups function #566
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds comprehensive unit tests for the
MergeUncoreGroupsfunction that was recently modified in commit cd5bcf2 to eliminate duplicate uncore events across groups. The duplicate event elimination prevents perf from misreporting event values when the same event appears in multiple groups.Changes
Added
cmd/metrics/loader_perfmon_group_uncore_test.gowith 7 test functions covering:Core Functionality Tests
TestMergeUncoreGroups_EliminateDuplicateEvents - Tests duplicate event removal in various scenarios:
TestMergeUncoreGroups_KeepsFirstOccurrence - Verifies that when duplicates are removed, the first occurrence is preserved and subsequent duplicates are eliminated
TestMergeUncoreGroups_MergingBehavior - Tests that:
TestMergeUncoreGroups_PreservesMetricNames - Ensures metric names from all groups are preserved during deduplication and merging
Edge Case Tests
Test Results
✅ All 7 new test functions pass (21 total sub-tests)
✅ All existing tests continue to pass
✅ Code quality checks pass:
make format- Code properly formattedmake check_format- No formatting issuesmake check_vet- No suspicious constructsmake check_static- No static analysis issuesmake check_license- License headers presentmake check_lint- No linting issuesmake check_vuln- No vulnerabilitiesmake test- All tests passTesting Methodology
Tests follow the project's established patterns:
github.com/stretchr/testifyfor assertions (consistent with existing tests)Related Issue
Addresses testing for commit cd5bcf2 (#565) which eliminated duplicate uncore events across groups.
🤖 Generated with Claude Code