Two bugs blocking PROTO's live-veloxd conformance check.
1. tasks.start_mode's CHECK was ('auto','now','queue','manual') — not the
contract's StartMode enum (['now','later','queue']) at all. 'later', a real
documented value (the File Info dialog's Download Later button), hit the CHECK
on every insert and surfaced as an unhandled -32603; 'auto'/'manual' were
never contract values to begin with.
Migration 0003 rebuilds tasks (SQLite can't ALTER a CHECK) with the contract's
values, remapping existing rows by what they actually meant: 'auto' -> 'now'
(eligible for the scheduler immediately), 'manual' -> 'later' (parked, matching
StartMode's own "lands the task in paused" description). store_migrations_test
covers the remap and that 'later' inserts clean while the retired spellings
are rejected.
dispatcher.cpp's on_download_add matched: default (absent startMode) is now
'now' instead of the invented 'auto'; 'later' actually lands the task in
`paused` (pause_reason 'user') instead of a dead 'manual' -> `new` branch that
spec.startMode (typed as the 3-value enum) could never even reach.
TaskRow::start_mode's in-memory default followed suit ('now').
2. main.cpp's single-instance guard bound an abstract socket named
"velox-daemon-<euid>" — one name per user, system-wide. XDG_RUNTIME_DIR
isolation never reached it: a leaked test veloxd held the lock for 4h40m and
locked out every other isolated instance with the same euid (PROTO, EXT, the
orchestrator), real daemon included.
Extracted rpc/single_instance.{hpp,cpp} (was a static in main.cpp, untestable)
and derived the abstract-socket name from a hash of the resolved runtime dir
path instead of euid alone. The real per-user daemon is still unique (its
runtime dir is unique to it); isolated instances pointed at their own runtime
dirs now coexist. main() resolves the runtime dir before acquiring the lock
(was the other way around). New single_instance_test covers same-dir refusal,
different-dir coexistence, and release-on-close.
Verified against real veloxd binaries, not just unit tests: startMode: "later"
via a live download.add lands in `paused`; two veloxd with different runtime
dirs run concurrently, two with the same one and the second refuses with the
runtime dir named in the error. Full ctest: 39/39.
Co-Authored-By: Claude Sonnet 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01GRDjHGgpYmMoPE2UFbe7pP
27 lines
1.3 KiB
CMake
27 lines
1.3 KiB
CMake
# daemon unit + integration tests. Registered with ctest; run via `ctest --preset dev`.
|
|
# No external test framework — each file is a small self-checking binary.
|
|
|
|
function(veloxd_test name)
|
|
cmake_parse_arguments(T "" "" "LIBS" ${ARGN})
|
|
add_executable(veloxd_${name}_test ${name}_test.cpp)
|
|
target_link_libraries(veloxd_${name}_test PRIVATE ${T_LIBS})
|
|
target_compile_options(veloxd_${name}_test PRIVATE -Wall -Wextra -Wpedantic -Werror)
|
|
add_test(NAME veloxd.${name} COMMAND veloxd_${name}_test)
|
|
set_tests_properties(veloxd.${name} PROPERTIES TIMEOUT 30)
|
|
endfunction()
|
|
|
|
veloxd_test(ndjson LIBS veloxd_rpc)
|
|
veloxd_test(uds_roundtrip LIBS veloxd_rpc veloxd_store)
|
|
veloxd_test(store_migrations LIBS veloxd_store)
|
|
veloxd_test(pairings LIBS veloxd_store veloxd_rpc)
|
|
veloxd_test(ws_frame LIBS veloxd_rpc)
|
|
veloxd_test(ws_server LIBS veloxd_rpc veloxd_store)
|
|
veloxd_test(sched_window LIBS veloxd_sched)
|
|
veloxd_test(sched_governor LIBS veloxd_sched)
|
|
veloxd_test(safepath LIBS veloxd_fs)
|
|
veloxd_test(store_tasks LIBS veloxd_store)
|
|
veloxd_test(sched_scheduler LIBS veloxd_sched veloxd_rpc)
|
|
veloxd_test(event_hub LIBS veloxd_rpc)
|
|
veloxd_test(store_categories_queues LIBS veloxd_store)
|
|
veloxd_test(single_instance LIBS veloxd_rpc)
|