Skip to content

test: Adds conformance test suite and improves empty frame handling#246

Draft
hellobertrand wants to merge 5 commits into
mainfrom
test/conformance-suite
Draft

test: Adds conformance test suite and improves empty frame handling#246
hellobertrand wants to merge 5 commits into
mainfrom
test/conformance-suite

Conversation

@hellobertrand
Copy link
Copy Markdown
Owner

  • Introduces a comprehensive conformance test suite to validate zxc decompression behavior against a range of valid and invalid compressed data streams.
  • The suite iterates through .zxc files in conformance/valid and conformance/invalid directories, comparing decompressed output for valid files against .expected files and ensuring invalid files are correctly rejected.
  • Improves how zxc_compress and zxc_decompress handle empty frames. Compressing an empty source buffer now produces a valid, minimal ZXC frame.
  • The decompressor is also updated to correctly handle empty frames when provided with a NULL or zero-capacity destination buffer, returning 0 bytes decompressed rather than an error.
  • Updates existing buffer API and seekable unit tests to reflect these changes in empty frame handling.

The `zxc_compress` function now gracefully handles `src_size == 0` inputs, including when `src` is `NULL`, by producing a valid empty compressed frame. Previously, this scenario resulted in `ZXC_ERROR_NULL_INPUT`.

Correspondingly, `zxc_decompress` is updated to allow `dst=NULL` and `dst_capacity=0` when processing an empty frame, returning success (0) in such cases. This enables callers to query the decompressed size of an empty frame without providing a destination buffer, aligning behavior with common buffer API patterns.
This suite comprises a collection of valid ZXC streams and deliberately
malformed inputs, along with a C test driver. It automatically verifies
that the decompressor correctly decodes valid streams and robustly
rejects invalid ones, enhancing spec adherence and preventing regressions.
Comment thread conformance/test_conformance.c Dismissed
Comment thread conformance/test_conformance.c Dismissed
Comment thread conformance/test_conformance.c Dismissed
The conformance test suite is updated to run on Windows. This involves:
- Conditional compilation using `_WIN32` for platform-specific headers and APIs (e.g., `windows.h`, `GetFileAttributesA`, `FindFirstFileA`).
- Introducing portable `file_exists` and `list_zxc_files` helper functions to abstract file system interactions.
- Updating string duplication to use `_strdup` on Windows.
- Increasing path buffer sizes for improved robustness against long file paths.

Additionally, `test_invalid_vector` now caps the maximum requested
decompressed size to 1MB for invalid inputs, preventing excessive memory
allocation during testing.
Introduces a CMake option to link the conformance test executable with the `--coverage` flag, allowing for code coverage analysis.

Also incorporates minor code cleanups in the conformance test source file.
This README provides essential documentation for the ZXC Decoder
Conformance Suite. It details the suite's file structure, explains how
to validate a decoder, offers a quick shell script for execution, and
outlines the various test vector categories and their coverage.

This significantly improves the usability and understanding of the
conformance tests for developers and users.
@codecov
Copy link
Copy Markdown

codecov Bot commented May 26, 2026

Codecov Report

❌ Patch coverage is 71.42857% with 2 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/lib/zxc_dispatch.c 71.42% 2 Missing ⚠️

📢 Thoughts on this report? Let us know!

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