Add protocol error detection and improve test isolation#59
Merged
ruoso merged 1 commit intoPacktPublishing:mainfrom Dec 13, 2025
Merged
Add protocol error detection and improve test isolation#59ruoso merged 1 commit intoPacktPublishing:mainfrom
ruoso merged 1 commit intoPacktPublishing:mainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds protocol error detection capabilities to the generated state machines and improves test isolation for parallel execution. The code generator now tracks protocol mismatches when received data doesn't match expected message formats, and the libuv wrapper gracefully closes connections on errors.
Key Changes:
- Added
has_error_flag and detection logic to generated state machines to identify protocol violations - Enhanced libuv wrapper with error checking in I/O callbacks and graceful connection closure
- Implemented unique test directories using test name + PID to enable safe parallel test execution with
-j8
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
src/networkprotocoldsl/codegen/generate_state_machine.cpp |
Adds error detection logic that sets has_error_ when parsers fail to make progress on received data |
src/networkprotocoldsl/codegen/generate_runner.cpp |
Exposes has_error() method in ServerRunner to check protocol error state |
src/networkprotocoldsl_uv/generatedserverwrapper.hpp |
Adds has_error() to IConnectionRunner interface |
src/networkprotocoldsl_uv/generatedserverwrapper.cpp |
Implements protocol error checking in read/write callbacks with graceful connection closure |
tests/CMakeLists.txt |
Adds TEST_BUILD_DIR and library path definitions for test isolation |
tests/038-codegen-integration-test.cpp |
Creates unique test directories using test name + PID for parallel execution safety |
tests/037-codegen-compile-smtp.cpp |
Implements unique directory naming with timestamp for test isolation |
tests/data/codegen/test_full_email_transaction.cpp |
New integration test verifying complete SMTP email transaction flow |
tests/data/codegen/test_multi_connection.cpp |
New test validating concurrent connection handling with independent state machines |
tests/data/codegen/test_protocol_mismatch.cpp |
New test ensuring protocol errors are detected and connections closed gracefully |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Code Generator: - Add has_error_ flag to generated state machines to track protocol mismatches - Detect when received data doesn't match any expected message format - Add has_error() method to ServerRunner to expose error state libuv Wrapper: - Add has_error() to IConnectionRunner interface - Check for protocol errors in on_read and on_write_complete callbacks - Close connections gracefully when protocol errors are detected Test Infrastructure: - Update tests to use unique directories under build dir (TEST_BUILD_DIR) - Prevents conflicts when running tests in parallel with -j8 - Add NETWORKPROTOCOLDSL_UV_INCLUDE_DIR and NETWORKPROTOCOLDSL_UV_LIB_DIR New Integration Tests: - test_full_email_transaction: Complete SMTP email flow - test_multi_connection: Multiple concurrent connections - test_protocol_mismatch: Protocol error detection using GeneratedServerWrapper
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Code Generator:
libuv Wrapper:
Test Infrastructure:
New Integration Tests: