Skip to content

Fixes and tests#15

Merged
lacraig2 merged 4 commits intomainfrom
fixes
Mar 11, 2026
Merged

Fixes and tests#15
lacraig2 merged 4 commits intomainfrom
fixes

Conversation

@lacraig2
Copy link
Contributor

This pull request introduces several improvements and new tests to the dwarffi project, focusing on correctness, robustness, and coverage of edge cases. The changes include bug fixes in core library logic and the addition of comprehensive tests for backend interaction, bitfield invariants, zero-copy buffer handling, and type normalization.

Bug fixes and logic improvements:

  • Improved symbol acceptability logic in _is_acceptable by requiring a non-zero address instead of allowing either a valid address or type info. This tightens the criteria for accepting symbols.
  • Enhanced robustness of constant data decoding in get_decoded_constant_data by explicitly checking for None and enabling strict validation in base64.b64decode.

New and enhanced test coverage:

Backend and memory interaction:

  • Added test_backend_read_write_sizes_and_addresses to verify that backend read and write operations are called with correct addresses and sizes, using a custom RecordingBackend.

Bitfield and struct invariants:

  • Introduced test_bitfield_preserves_other_bits_across_patterns to ensure that setting bitfields does not affect unrelated bits in the containing struct, across a variety of initial patterns.

Zero-copy and buffer handling:

  • Added tests in test_zero_copy.py to confirm that zero-copy views share underlying data correctly and that read-only buffers are properly rejected when writable access is required.

Type normalization and packing:

  • Added tests to verify that type string normalization is consistent (e.g., whitespace and prefixes) and that manual byte packing matches the output of ffi.new.

@lacraig2 lacraig2 merged commit d23bf7a into main Mar 11, 2026
3 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.

1 participant