Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Build output
build/
build-*/

# Tool / editor state
.cache/
opencode.json

# Core dumps
core

# IDE / editor
.vscode/
Expand Down
7 changes: 3 additions & 4 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ CTest registers 7 suites, each a standalone greatest executable:
- `test_phev_register` (14 tests)
- `test_phev_config` (12 tests)

Total: 219 tests. 35 are SKIPped (pre-existing bugs from previously-unwired test functions).
Total: 219 tests. All pass (0 skipped).

## Single-Test Guidance
- greatest supports `-t <test_name>` CLI filtering, e.g. `./build/test/test_phev_core -t test_phev_core_simpleRequestMessage`.
Expand All @@ -106,7 +106,6 @@ cmake --preset dev && cmake --build --preset dev && ctest --preset dev
## Language and Build Conventions
- Target language is C11: `set(CMAKE_C_STANDARD 11)`.
- Two static library targets: `msg_core` (vendored messaging framework) and `phev` (links `msg_core` + `cjson`).
- Dead transport backends (`msg_gcp_mqtt`, `msg_mqtt_paho`) are gated behind `BUILD_TRANSPORT_BACKENDS` (OFF by default).
- Tests are only added when `BUILD_TESTS` is enabled.
- Public headers are installed from `include/msg/` and `include/phev/`.

Expand Down Expand Up @@ -176,5 +175,5 @@ cmake --preset dev && cmake --build --preset dev && ctest --preset dev

## Known Quirks To Respect
- Some code intentionally uses duplicated patterns, manual memory management, and verbose logging; preserve behavior first, elegance second.
- There are existing rough edges and probable bugs in the codebase; avoid opportunistic rewrites unless required for the task at hand.
- 35 of 219 test functions are SKIPped due to pre-existing bugs (never wired in the old Unity runners). See `TODO.md` for details.
- There are existing rough edges in the codebase; avoid opportunistic rewrites unless required for the task at hand.
- All 219 tests pass with 0 skips. See `TODO.md` for the full restructure history.
18 changes: 0 additions & 18 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,6 @@ if(WIN32)
target_link_libraries(msg_core PUBLIC mswsock advapi32 ws2_32)
endif()

# ---------- optional dead transport backends ----------
option(BUILD_TRANSPORT_BACKENDS "Build msg_gcp_mqtt and msg_mqtt_paho (requires external deps)" OFF)

if(BUILD_TRANSPORT_BACKENDS)
target_sources(msg_core PRIVATE
src/msg/msg_gcp_mqtt.c
src/msg/msg_mqtt_paho.c
)
endif()

# ---------- phev library ----------
add_library(phev STATIC
Expand Down Expand Up @@ -123,12 +114,3 @@ install(FILES
include/msg/logger.h
DESTINATION include/msg
)

if(BUILD_TRANSPORT_BACKENDS)
install(FILES
include/msg/msg_gcp_mqtt.h
include/msg/msg_mqtt_paho.h
include/msg/config.h
DESTINATION include/msg
)
endif()
54 changes: 51 additions & 3 deletions TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Tracks the multi-phase restructure of the phevcore build system and
project layout. Each phase is one PR.

## Phase 1 — Build modernization (this PR)
## Phase 1 — Build modernization

- [x] Add `CMakePresets.json` (dev / release / ci)
- [x] Remove `splint.cmake` stub
Expand All @@ -14,7 +14,7 @@ project layout. Each phase is one PR.
- [x] Add `.clang-format`
- [x] Update `AGENTS.md` to reflect changes

## Phase 2 — Test migration
## Phase 2 — Test migration

- [x] Choose test framework: **greatest** (v1.5.0)
- [x] Add framework via FetchContent
Expand All @@ -38,7 +38,7 @@ project layout. Each phase is one PR.
- Added missing `phev_core_validateChecksumXOR` declaration to `include/phev_core.h`
- Skipped `test_phev_service_jsonInputTransformer` — pre-existing segfault from NULL pipe context

## Phase 3 — Directory restructure
## Phase 3 — Directory restructure

- [x] Move `src/` into `src/msg/` + `src/phev/`
- [x] Move `include/` into `include/msg/` + `include/phev/`
Expand All @@ -49,3 +49,51 @@ project layout. Each phase is one PR.
- [x] Tests remain in `test/` (no msg-layer tests exist; all 7 suites test phev)
- [x] Dockerfile and CI already use presets — no changes needed
- [x] Update `AGENTS.md` to reflect restructure

## Phase 4 — Fix SKIPped tests (branch: `phase4/fix-skipped-tests`) ✓

Goal: fix all 36 tests that were SKIPped (pre-existing bugs from previously-unwired
test functions) and reduce the skip count to zero.

### Source fixes applied
- [x] `phev_core_getType()` — XOR-decode the type byte before classifying (`src/phev/phev_core.c`)
- [x] `phev_core_encodeMessage()` — apply XOR to encoded bytes (`src/phev/phev_core.c`)
- [x] `phev_service_jsonInputTransformer()` — guard against NULL `ctx->pipe` (`src/phev/phev_service.c`)
- [x] `phev_pipe_outputChainInputTransformer()` — use decoded `phevMessage->XOR` instead of `message->ctx` for XOR detection; return decoded message when XOR is active (`src/phev/phev_pipe.c`)
- [x] `phev_pipe_commandResponder()` — propagate XOR from `message->ctx` to `phevMsg.XOR` so response is correctly encoded (`src/phev/phev_pipe.c`)
- [x] `phev_core_xorDataOutbound()` / `phev_core_XOROutboundMessage()` — use `message->length` instead of `data[1]+2` to handle concatenated messages (`src/phev/phev_core.c`)
- [x] `phev_service_validateCommand()` — add missing "update" operation validation (`src/phev/phev_service.c`)

### test_phev_core.c — 16 SKIPs → 0 (all 82 pass)
- [x] Group 1 (4 tests): fix checksums and expected data for XOR-encoded messages
- [x] Group 2 (5 tests): fix expected XOR values and command/ack expectations
- [x] Group 3 (4 tests): fix expected ping constant (0xf6 → 0xf9)
- [x] Group 4 (3 tests): fix expected data arrays for XOR encoding

### test_phev_service.c — 10 SKIPs → 0 (all 70 pass)
- [x] Group 6 (5 tests): update expected data and checksum for XOR encoding
- [x] Group 7 (4 tests): fix expected bytes for service-layer encoding
- [x] Group 10 (1 test, line 263): `validateCommand()` missing "update" operation

### test_phev_pipe.c — 10 SKIPs → 0 (all 31 pass)
- [x] Group 5 (3 tests): `commandXOR` propagation through pipe context
- [x] Group 6 (2 tests): `outputChainInputTransformer` with XOR
- [x] Group 7 (1 test + 1 bonus): XOR handling with NULL pipe context / ping response
- [x] Group 8 (2 tests): `sendMac` / `start_my18` wiring — fix `xorDataOutbound` length
- [x] Group 9 (1 test): `waitForConnection` retry loop — add failing connect stub

### Summary
- Started: 36 SKIPped tests (16 + 10 + 10)
- Fixed: 36 (all)
- Remaining: 0
- All 219 tests pass across 7 suites, 0 fail, 0 skip

## Phase 5 — Cleanup ✓

- [x] Remove dead transport source files (`msg_gcp_mqtt.*`, `msg_mqtt_paho.*`)
- [x] Remove stale `config.h` (unused)
- [x] Remove `BUILD_TRANSPORT_BACKENDS` option and install block from `CMakeLists.txt`
- [x] Clean up stale remote branches (deleted 6: phase1-3, add-license-1, register_fix, robustxor)
- [x] Clean up stale local branches (deleted phase1-3)
- [x] Update `AGENTS.md` to reflect all-tests-passing and removal of transport backends
- [x] Final CI verification — dev preset build + all 219 tests pass, release preset builds clean
11 changes: 0 additions & 11 deletions include/msg/config.h

This file was deleted.

80 changes: 0 additions & 80 deletions include/msg/msg_gcp_mqtt.h

This file was deleted.

36 changes: 0 additions & 36 deletions include/msg/msg_mqtt_paho.h

This file was deleted.

119 changes: 0 additions & 119 deletions src/msg/msg_gcp_mqtt.c

This file was deleted.

Loading
Loading