Derive err_maxval's code set from the header, not a hardcoded list
The previous err_maxval hardcoded the list of AKERR_* codes, which silently rots the moment a code is added. Instead, parse the generated akerror.h at runtime: discover every "#define AKERR_<NAME> (AKERR_LAST_ERRNO_VALUE + N)", take the highest offset actually defined, and assert AKERR_MAX_ERR_VALUE covers it. A compile-time cross-check ties the parsed ceiling to the compiled macro so the test can't pass by reading a stale header. CMake injects the header path as AKERR_GENERATED_HEADER. Verified: the test fails (max_err_value >= highest_code) when pointed at a +15 header while AKERR_BADEXC is +17, and now also strengthens header mutation coverage. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -81,6 +81,11 @@ foreach(_test IN LISTS AKERR_TESTS)
|
||||
add_test(NAME ${_test} COMMAND test_${_test})
|
||||
endforeach()
|
||||
|
||||
# err_maxval parses the generated header to check AKERR_MAX_ERR_VALUE covers
|
||||
# every AKERR_* code, so it needs the path to the header it was built against.
|
||||
target_compile_definitions(test_err_maxval PRIVATE
|
||||
AKERR_GENERATED_HEADER="${GENERATED_AKERROR_H}")
|
||||
|
||||
set_tests_properties(
|
||||
${AKERR_WILL_FAIL_TESTS}
|
||||
PROPERTIES WILL_FAIL TRUE
|
||||
|
||||
Reference in New Issue
Block a user