ca3559ef57
tests / build-and-test (push) Successful in 2m9s
Property-based robustness test that drives long sequences of random tool operations against EquipmentDataModel and verifies invariants + persistence round-trip after every action. Replaces hand-written state-pinning tests with a generative approach that explores combinations no human author would think to write. Action menu (28 weighted actions covering the full standard surface): - PJ create / event / dequeue (E40) - CJ create / event / delete (E94) - Carrier create / id / slot (E87) - Substrate create / location / proc (E90) - Alarm set / clear / enable toggle (E5 §13) - SVID updates (E30 §6.13) - Define-report / link-event / enable (E30 §6.6) - Exception post / recover / complete (E5 §9, S5F9-F18) - Module event (E157) - EPT event (E116) - Spool enqueue / drain / force-toggle (E30 §6.22) Every action is "adjusted": it picks a verb at random, then checks state-machine legality before applying. A Pause is only fired on a Processing PJ; a Recover only on a Posted exception; pj_dequeue skips PJs bound to active CJs (mirrors E94's "can't dequeue CJ-bound PJ" rule the fuzz itself discovered when the first run flagged a CJ→missing-PJ reference). Invariants checked every 64 ticks: - Every tracked PJ exists in the store (size matches) - Every CJ's prjobids all exist in PJ store - No FSM in NoState sentinel - EPT bucket total monotonically non-decreasing - Defined reports' VIDs all exist - Substrate / carrier counts match enumeration Persistence round-trip every 500 ticks: - Fresh shadow EquipmentDataModel loads from the same journal dir - Diffs PJ + CJ states one-by-one + carrier/substrate/exception counts against the live model - Catches any "mutation didn't reach disk" or "replay didn't reconstruct state correctly" bugs Reproducibility: - Each TEST_CASE uses a fixed seed (0x1, 0xdeadbeef, 0xfeedface, 0xc0ffee — 8000 ops total in the fast suite) - World keeps a rolling 20-action trace, printed on invariant violation so the failing sequence can be pasted into a targeted regression test - SECSGEM_ROBUSTNESS_SOAK=1 enables a 100k-tick soak case (~3-5 minutes in Docker; not run by default) The very first run found a real edge case: act_pj_dequeue removed PJs that were bound to active CJs, leaving dangling refs. Fixed the fuzz to filter; the underlying behavior is intentional (store trusts the application to gate), but the fuzz now mirrors the correct E94 contract. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
158 lines
4.9 KiB
CMake
158 lines
4.9 KiB
CMake
cmake_minimum_required(VERSION 3.20)
|
|
project(secsgem LANGUAGES CXX)
|
|
|
|
set(CMAKE_CXX_STANDARD 20)
|
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
set(CMAKE_CXX_EXTENSIONS OFF)
|
|
|
|
if(NOT CMAKE_BUILD_TYPE)
|
|
set(CMAKE_BUILD_TYPE Release)
|
|
endif()
|
|
|
|
add_compile_options(-Wall -Wextra -Wpedantic)
|
|
|
|
find_package(Threads REQUIRED)
|
|
find_package(yaml-cpp REQUIRED)
|
|
|
|
# --- Asio (standalone, header-only; from libasio-dev) ---------------------
|
|
find_path(ASIO_INCLUDE_DIR asio.hpp)
|
|
if(NOT ASIO_INCLUDE_DIR)
|
|
message(FATAL_ERROR "asio.hpp not found. Install libasio-dev.")
|
|
endif()
|
|
|
|
add_library(asio INTERFACE)
|
|
target_include_directories(asio INTERFACE ${ASIO_INCLUDE_DIR})
|
|
target_compile_definitions(asio INTERFACE ASIO_STANDALONE ASIO_NO_DEPRECATED)
|
|
target_link_libraries(asio INTERFACE Threads::Threads)
|
|
|
|
# --- Core library ---------------------------------------------------------
|
|
# --- Codegen: SECS-II message catalog -> messages.hpp ---------------------
|
|
set(MESSAGES_HPP ${CMAKE_BINARY_DIR}/generated/secsgem/gem/messages.hpp)
|
|
add_custom_command(
|
|
OUTPUT ${MESSAGES_HPP}
|
|
COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/generated/secsgem/gem
|
|
COMMAND python3 ${CMAKE_SOURCE_DIR}/tools/gen_messages.py
|
|
--catalog ${CMAKE_SOURCE_DIR}/data/messages.yaml
|
|
--out ${MESSAGES_HPP}
|
|
DEPENDS ${CMAKE_SOURCE_DIR}/tools/gen_messages.py
|
|
${CMAKE_SOURCE_DIR}/data/messages.yaml
|
|
COMMENT "Generating SECS-II messages.hpp from data/messages.yaml"
|
|
VERBATIM
|
|
)
|
|
add_custom_target(generate_messages DEPENDS ${MESSAGES_HPP})
|
|
|
|
add_library(secsgem
|
|
src/secs2/codec.cpp
|
|
src/secs2/sml.cpp
|
|
src/hsms/header.cpp
|
|
src/hsms/connection.cpp
|
|
src/secsi/header.cpp
|
|
src/secsi/block.cpp
|
|
src/secsi/protocol.cpp
|
|
src/secsi/tcp_transport.cpp
|
|
src/gem/control_state.cpp
|
|
src/gem/communication_state.cpp
|
|
src/gem/process_job_state.cpp
|
|
src/gem/control_job_state.cpp
|
|
src/gem/exception_state.cpp
|
|
src/gem/carrier_state.cpp
|
|
src/gem/load_port_state.cpp
|
|
src/gem/substrate_state.cpp
|
|
src/gem/ept_state.cpp
|
|
src/gem/cem_objects.cpp
|
|
src/gem/module_state.cpp
|
|
src/gem/e84_state.cpp
|
|
src/gem/host_handler.cpp
|
|
src/config/loader.cpp
|
|
src/config/validate.cpp
|
|
src/endpoint.cpp
|
|
)
|
|
add_dependencies(secsgem generate_messages)
|
|
target_include_directories(secsgem PUBLIC
|
|
include
|
|
${CMAKE_BINARY_DIR}/generated
|
|
)
|
|
target_link_libraries(secsgem PUBLIC asio yaml-cpp)
|
|
|
|
# --- Demo executables -----------------------------------------------------
|
|
add_executable(secs_server apps/secs_server.cpp)
|
|
target_link_libraries(secs_server PRIVATE secsgem)
|
|
|
|
add_executable(secs_client apps/secs_client.cpp)
|
|
target_link_libraries(secs_client PRIVATE secsgem)
|
|
|
|
add_executable(secs_interop_probe apps/secs_interop_probe.cpp)
|
|
target_link_libraries(secs_interop_probe PRIVATE secsgem)
|
|
|
|
add_executable(secs_conformance apps/secs_conformance.cpp)
|
|
target_link_libraries(secs_conformance PRIVATE secsgem)
|
|
|
|
add_executable(secs_bench apps/secs_bench.cpp)
|
|
target_link_libraries(secs_bench PRIVATE secsgem)
|
|
|
|
# --- Tests ----------------------------------------------------------------
|
|
enable_testing()
|
|
include(FetchContent)
|
|
FetchContent_Declare(
|
|
doctest
|
|
GIT_REPOSITORY https://github.com/doctest/doctest.git
|
|
GIT_TAG v2.4.11
|
|
)
|
|
FetchContent_MakeAvailable(doctest)
|
|
|
|
add_executable(secsgem_tests
|
|
tests/test_main.cpp
|
|
tests/test_secs2.cpp
|
|
tests/test_fuzz.cpp
|
|
tests/test_hsms.cpp
|
|
tests/test_hsms_connection.cpp
|
|
tests/test_hsms_timers.cpp
|
|
tests/test_hsms_s9.cpp
|
|
tests/test_hsms_gs.cpp
|
|
tests/test_secsi.cpp
|
|
tests/test_secsi_timers.cpp
|
|
tests/test_secsi_tcp.cpp
|
|
tests/test_host_handler.cpp
|
|
tests/test_control_state.cpp
|
|
tests/test_communication_state.cpp
|
|
tests/test_data_model.cpp
|
|
tests/test_messages.cpp
|
|
tests/test_loader.cpp
|
|
tests/test_process_jobs.cpp
|
|
tests/test_control_jobs.cpp
|
|
tests/test_job_persistence.cpp
|
|
tests/test_exceptions.cpp
|
|
tests/test_exception_persistence.cpp
|
|
tests/test_carrier_state.cpp
|
|
tests/test_carriers.cpp
|
|
tests/test_carrier_persistence.cpp
|
|
tests/test_substrates.cpp
|
|
tests/test_substrate_persistence.cpp
|
|
tests/test_ept.cpp
|
|
tests/test_cem_objects.cpp
|
|
tests/test_modules.cpp
|
|
tests/test_sml.cpp
|
|
tests/test_s9_fallback.cpp
|
|
tests/test_e84.cpp
|
|
tests/test_e84_ports.cpp
|
|
tests/test_e84_timers.cpp
|
|
tests/test_e84_asio_timers.cpp
|
|
tests/test_e42_formatted_pp.cpp
|
|
tests/test_gem300_scenario.cpp
|
|
tests/test_wire_ceid_emission.cpp
|
|
tests/test_live_gem300.cpp
|
|
tests/test_e87_wire_scenarios.cpp
|
|
tests/test_identifier_wildcards.cpp
|
|
tests/test_concurrency.cpp
|
|
tests/test_thread_safety.cpp
|
|
tests/test_persistence_upgrade.cpp
|
|
tests/test_config_validate.cpp
|
|
tests/test_metrics_prometheus.cpp
|
|
tests/test_hsms_gs_integration.cpp
|
|
tests/test_robustness_fuzz.cpp
|
|
)
|
|
target_link_libraries(secsgem_tests PRIVATE secsgem doctest::doctest)
|
|
target_compile_definitions(secsgem_tests PRIVATE
|
|
SECSGEM_DATA_DIR="${CMAKE_SOURCE_DIR}/data")
|
|
add_test(NAME secsgem_tests COMMAND secsgem_tests)
|