Skip to content

Conversation

yanivagman
Copy link
Collaborator

  • bitwise: 0.0% → 100.0%
  • murmur: 0.0% → 100.0%
  • set: 0.0% → 100.0%
  • logger: 0.0% → 92.9%
  • tests: 0.0% → 91.7%
  • digest: 13.0% → 94.8%
  • sharedobjs: 50.0% → 89.2%
  • fileutil: 6.1% → 81.6%
  • elf: 18.4% → 78.1%
  • timeutil: 0.0% → 70.9%
  • mount: 9.9% → 66.7%
  • stringutil: 44.4% → 100.0%
  • parsers: 41.4% → 58.6%
  • environment: 61.8% → 77.3%

@Copilot Copilot AI review requested due to automatic review settings September 16, 2025 15:59
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR significantly improves test coverage across 14 common module packages, adding comprehensive unit tests that increase coverage from 0% to over 90% for most packages. The tests cover critical functionality including time utilities, string manipulation, network parsing, file operations, logging infrastructure, set operations, hashing, and more.

Key Changes

  • Added comprehensive test coverage for previously untested packages (bitwise, murmur, set, logger, tests)
  • Enhanced existing test suites with additional edge cases and error conditions
  • Created mock implementations and helper functions to enable thorough testing of complex functionality

Reviewed Changes

Copilot reviewed 18 out of 18 changed files in this pull request and generated no comments.

Show a summary per file
File Description
common/timeutil/time_test.go Tests for time conversion functions, system clock utilities, and Init functionality
common/tests/helpers_test.go Tests for test helper utilities including file generation and struct analysis
common/stringutil/stringutil_test.go Enhanced tests for string reversal and NUL trimming with additional edge cases
common/sharedobjs/host_symbols_loader_test.go Tests for symbol loading, caching, and ELF parsing functionality
common/set/set_test.go Comprehensive tests for generic set operations and thread-safe wrappers
common/parsers/data_parsers_test.go Additional tests for network parsing and file operation detection
common/murmur/murmur_test.go Complete test suite for MurmurHash implementation with consistency checks
common/mount/mount_test.go Tests for mount operations, filesystem support checking, and directory management
common/logger/logger_test.go Comprehensive logging infrastructure tests including filters and aggregation
common/logger/filter_test.go Tests for logging filter functionality with various filter types
common/logger/callerinfo_test.go Tests for runtime caller information extraction
common/fileutil/fileutil_test.go Extensive tests for file operations using Unix system calls
common/environment/osinfo_test.go Additional tests for OS information parsing and system state detection
common/environment/amount_test.go Tests for CPU and memory amount detection functionality
common/elf/analyzer_test.go Enhanced ELF analysis tests with real binary testing
common/digest/hash_test.go Complete test suite for file hashing and cache functionality
common/bitwise/bitwise_test.go Comprehensive tests for bitwise operations with edge cases

@yanivagman yanivagman force-pushed the common_tests branch 2 times, most recently from c2516cf to bc56e8b Compare September 17, 2025 06:08
- Achieve 100% test coverage for bitwise package
- Add tests for HasBit, SetBit, ClearBit, and ClearBits functions
- Achieve 100% test coverage (from 0%)
- Test Murmur32 and HashU32AndU64 functions
- Include edge cases, consistency, and performance tests
- Achieve 100% test coverage (from 0%)
- Test both SimpleSet and thread-safe Set implementations
- Cover generics, custom hash functions, and edge cases
- Achieve 91.7% test coverage (from 0%)
- Test GenerateTimestampFileName with various inputs and validation
- Test PrintStructSizes with different struct types and writers
- Test CreateTempFile with various content types and edge cases
- Include integration tests and benchmarks
- Increase coverage from 6.1% to 81.6%
- Add comprehensive tests for all filesystem operations:
  OpenExistingDir, OpenAt, RemoveAt, MkdirAt/MkdirAtExist/MkdirAllAtExist,
  CreateAt, Dup, RenameAt, CopyRegularFileByPath/CopyRegularFileByRelativePath, IsDirEmpty
- Test both success and error cases with temporary files/directories
- Validate file operations, directory manipulations, and edge cases
- Increase coverage from 9.9% to 66.7%
- Add comprehensive tests for NewMountHostOnce with force/non-force modes
- Test all MountHostOnce methods: IsMounted, GetMountpoint, GetMountpointInode, Umount
- Add tests for IsFileSystemSupported with various filesystem types
- Test SearchMountpointFromHost with real system mounts (proc, sysfs, tmpfs)
- Include config validation, integration tests, and benchmarks
- Handle test environment limitations gracefully
- Increase coverage from 44.4% to 100.0%
- Add comprehensive tests for ReverseString (previously untested)
- Test various input types: ASCII, Unicode, emojis, special chars, edge cases
- Add memory property tests and integration tests
- Enhance TrimTrailingNUL tests with additional edge cases
- Include boundary conditions and performance considerations
Copy link
Member

@geyslan geyslan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. I skimmed over it, but asked claude to do a double check. Put some thoughts and approved to unblock you.

- Increase coverage from 13.0% to 94.8%
- Add comprehensive tests for ComputeFileHashAtPath (previously 0% coverage)
- Add full test suite for Cache functionality with mock path resolver
- Test all CalcHashesOption modes: none, inode, dev-inode, digest-inode
- Add complete Key creation and method tests
- Cover cache miss/hit scenarios and invalidation logic
- Test error cases: empty keys, path resolution failures, unknown modes
- Include edge cases: empty files, non-existent files, directories
- Increase coverage from 18.4% to 78.1%
- Add comprehensive tests for ELF analysis functions
- Create generic findElfBinary() helper using common POSIX paths
- Remove distribution-specific dependencies (busybox, etc.)
- Work across Alpine, Ubuntu, RHEL and other Linux distributions
- Increase coverage from 0.0% to 70.9%
- Test time conversions, system calls (CGO/syscalls), and error handling
- Handle system-dependent behaviors with graceful fallbacks
- Increase coverage from 0.0% to 92.9%
- Add comprehensive tests for logging functionality, filters, and caller info
- Test package-level functions, configuration, and aggregation features
- Handle edge cases in runtime caller information extraction
- Increase coverage from 41.4% to 58.6% (+17.2 percentage points)
- Add comprehensive tests for file parser functions (IsFileWrite, IsFileRead, IsMemoryPath)
- Add comprehensive tests for network parser functions (ParseUint32IP, Parse16BytesSliceIP, GetFamilyFromRawAddr, IsInternetFamily, IsUnixFamily, GetIPFromRawAddr, GetPortFromRawAddr, GetPathFromRawAddr)
- Test error conditions and edge cases for network address parsing
- Increase coverage from 50.0% to 89.2% (+39.2 percentage points)
- Add tests for InitHostSymbolsLoader function with various cache sizes
- Add comprehensive tests for GetLocalSymbols (both success and error cases)
- Add tests for LRU cache operations (Get, Add) with cache hits/misses
- Add tests for loadSharedObjectDynamicSymbols with various file types and error conditions
- Add tests for parseSymbols edge cases (local symbols, mixed symbol types)
- Add tests for error types (UnsupportedFileError, Error, Unwrap methods)
- Add tests for utility functions (NewSOSymbols, copyMap)
- Increase coverage from 61.8% to 77.3% (+15.5 percentage points)
- Add comprehensive tests for CPU and memory amount functions
- Add tests for CPU parsing logic with various input formats (single CPU, ranges, error cases)
- Add tests for OS release field string methods and OSInfo methods
- Add tests for system feature detection (OSBTFEnabled, FtraceEnabled, Lockdown)
- Test edge cases and system-dependent functions with graceful fallbacks
- stringutil: rename 'bytes' variable to 'buf' to avoid shadowing bytes package
- digest: fix CalcHashesInode String() method to return 'inode' instead of 'pathname'
@yanivagman yanivagman merged commit 249d773 into aquasecurity:main Sep 18, 2025
18 checks passed
@yanivagman yanivagman deleted the common_tests branch September 18, 2025 07:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants