Add C tests for all BIT STRING Data Elements and fix template bugs#6
Merged
Conversation
- 14 new Unity test suites (155 tests) for all BIT STRING DE types - Fix non-extensible RAW_READ referenced undefined MAX_WIRE_BITS - Fix non-extensible SIZE added phantom extension-marker bit - Fix non-extensible Doxygen emitted wrong wire format - Fix extensible GET_ALL/GET_ONE: 1U → 1ULL to prevent UB at 32-bit - Suppress unused-parameter warnings via (void)(buf) comma pattern - Update 4 Jinja2 templates for extensible vs non-extensible paths - Register all 15 DE headers + DF_ApproachOrLane in J2735_api.h - Add 6 Python tests for template changes Signed-off-by: Yogev Neumann <xqgex@users.noreply.github.com>
Contributor
Python CI ReportCommit: Python TestsTest Output✅ All tests passed Coverage: 98%Per-file coverage (53 modules)
Details (3399 statements, 57 missed)
Python Static Analysis
mypypylintflake8ruffcodespell |
Contributor
CI ReportCommit: Static Analysis
cppcheckClick to expandclang-tidyClick to expandSanitizersValgrind |
There was a problem hiding this comment.
Pull request overview
This PR adds comprehensive C test coverage for all BIT STRING Data Element types and fixes three categories of bugs in the Jinja2 code generation templates.
Changes:
- Template fixes for 7 non-extensible BIT STRING types: corrected
RAW_READto useROOT_SIZEinstead of undefinedMAX_WIRE_BITS, fixedSIZEmacro to returnROOT_SIZEdirectly, and corrected Doxygen wire format docs to eliminate phantom extension bits. - Extensible type hardening: changed
1Uto1ULLin bit-mask shift operations for 8 extensible types to prevent undefined behavior when shift width approaches 32 bits. - 14 new C test suites (155 test functions) covering all BIT STRING DE types, plus 6 new Python template output tests.
Reviewed changes
Copilot reviewed 52 out of 52 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
tools/templates/bitstring/bitstring_internal_raw_read.j2 |
Bug fix: non-extensible path now reads ROOT_SIZE bits instead of undefined MAX_WIRE_BITS |
tools/templates/bitstring/bitstring_is_extended.j2 |
Suppress -Wunused-parameter for non-extensible IS_EXTENDED via (void)(buf) |
tools/templates/bitstring/bitstring_size.j2 |
Bug fix: non-extensible SIZE now returns ROOT_SIZE directly, without EXTENSION_MARKER_BITS |
tools/templates/assemble_de_bitstring.j2 |
Bug fix: Doxygen wire format docs are now conditional on extensibility |
src/J2735_api.h |
Exposes all 15 DE headers and DF_ApproachOrLane.h |
src/J2735_internal_DE_AllowedManeuvers.h |
Apply all three non-extensible bug fixes |
src/J2735_internal_DE_BrakeAppliedStatus.h |
Apply all three non-extensible bug fixes |
src/J2735_internal_DE_GNSSstatus.h |
Apply all three non-extensible bug fixes |
src/J2735_internal_DE_LaneDirection.h |
Apply all three non-extensible bug fixes |
src/J2735_internal_DE_LaneSharing.h |
Apply all three non-extensible bug fixes |
src/J2735_internal_DE_TransitStatus.h |
Apply all three non-extensible bug fixes |
src/J2735_internal_DE_VerticalAccelerationThreshold.h |
Apply all three non-extensible bug fixes |
src/J2735_internal_DE_ExteriorLights.h |
1U→1ULL hardening for extensible type |
src/J2735_internal_DE_PersonalAssistive.h |
1U→1ULL hardening for extensible type |
src/J2735_internal_DE_PersonalDeviceUsageState.h |
1U→1ULL hardening for extensible type |
src/J2735_internal_DE_PublicSafetyAndRoadWorkerActivity.h |
1U→1ULL hardening for extensible type |
src/J2735_internal_DE_PublicSafetyDirectingTrafficSubType.h |
1U→1ULL hardening for extensible type |
src/J2735_internal_DE_TrafficLightOperationStatus.h |
1U→1ULL hardening for extensible type |
src/J2735_internal_DE_UserSizeAndBehaviour.h |
1U→1ULL hardening for extensible type |
tests/J2735_run_tests.c |
Adds all new test suite registrations |
tests/J2735_internal_DE_*_test.{c,h} |
14 new C test suites with full wire-format documentation |
tools/tests/c_generator/test_assemble_de_bitstring.py |
New Python tests for assembly template correctness |
tools/tests/c_generator/test_bitstring_internal_raw_read.py |
Updated/extended Python tests for RAW_READ template |
tools/tests/c_generator/test_bitstring_size.py |
Extended Python tests for SIZE template correctness |
.github/copilot-instructions.md |
Adds git add to the list of prohibited commands |
…ct.toml Signed-off-by: Yogev Neumann <xqgex@users.noreply.github.com>
Contributor
Python CI ReportCommit: Python TestsTest Output✅ All tests passed Coverage: 96%Per-file coverage (9 modules)
Details (908 statements, 37 missed)
Python Static Analysis
mypypylintflake8ruffcodespell |
Contributor
CI ReportCommit: Static Analysis
cppcheckClick to expandclang-tidyClick to expandSanitizers (ASan + UBSan)Test Output✅ No issues detected Valgrind Memory CheckTest Output✅ No memory issues detected |
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.
Pull Request
Description
Add comprehensive C test suites for all BIT STRING Data Element types and fix template bugs discovered during test development.
C test coverage: 14 new test suites (155 test functions) for every BIT STRING DE type that previously had zero C test coverage.
Each suite covers all-zeros, all-ones, alternating patterns, single-bit isolation, SIZE, IS_EXTENDED, and misaligned access.
Template fixes (7 non-extensible types): Three Jinja2 template bugs produced broken C code for non-extensible BIT STRING types (
AllowedManeuvers,BrakeAppliedStatus,GNSSstatus,LaneDirection,LaneSharing,TransitStatus,VerticalAccelerationThreshold). These were invisible because onlyVehicleEventFlags(extensible) was included inJ2735_api.h:RAW_READreferenced undefinedJ2735_INTERNAL_MAX_WIRE_BITS_*macro (only extensible types define it); now readsROOT_SIZEbits.SIZEmacro added a phantom extension-marker bit — e.g.LaneDirectionreported3Uinstead of correct2U; now returnsROOT_SIZEdirectly.garbage bits: -1; template now conditionally generates correct documentation.Extensible header hardening (8 types): Bit-mask shifts in
GET_ALLandGET_ONEinternal helpers changed from1Uto1ULLto prevent undefined behavior when shift width approaches or equals 32 bits.Affected types:
ExteriorLights,PersonalAssistive,PersonalDeviceUsageState,PublicSafetyAndRoadWorkerActivity,PublicSafetyDirectingTrafficSubType,TrafficLightOperationStatus,UserSizeAndBehaviour,VehicleEventFlags.Unused-parameter warnings: Non-extensible
IS_EXTENDEDandSIZEmacros changed from(0)/ multiline expression to((void)(buf), value)comma-operator pattern, suppressing-Wunused-parametercleanly.Template changes: Updated 4 Jinja2 templates (
assemble_de_bitstring,bitstring_internal_raw_read,bitstring_is_extended,bitstring_size) to conditionally generate correct code paths for extensible vs non-extensible BIT STRING types.Added 6 Python tests verifying the template output for both variants.
API header:
J2735_api.hnow includes all 15 DE headers andDF_ApproachOrLane.h(previously onlyDE_VehicleEventFlags.hand 3 DFheaders were included).
Related Issue
N/A
Additional Notes
N/A
Type of Change
Checklist
make pre-pushand all checks passgit commit -s