Adds sel_const_fold_pass() — a single-pass bottom-up const-fold that
runs after the Phase 4c flatten loop in parse_select():
4d-1 EQ/NE with either operand SEL_ANY → SEL_TRUE / SEL_FALSE
(checks both child slots — commutativity sort makes SEL_ANY
position non-deterministic after makeSelectNode interning)
4d-2 Identity laws: TRUE&&X→X, X&&TRUE→X, FALSE||X→X, X||FALSE→X
4d-3 Annihilation laws: FALSE&&X→FALSE, TRUE||X→TRUE (symmetric)
4d-4 Complement laws: !TRUE→FALSE, !FALSE→TRUE
Memory semantics:
level==0 (API server): frees orphaned nodes via free_select_node /
sel_free_tree; OOM from makeSelectNode returns original node safely
level>0 (CSE/scheduler): never manually frees; annihilation folds
return the already-interned left/right singleton directly (no
redundant makeSelectNode call); OOM guard unconditional so CSE
mode also degrades gracefully instead of returning NULL
9 new TDD tests added to test_select.c (RED→GREEN verified).
All 166 tests pass (157 prior + 9 Phase 4d).
19 lines
787 B
C
19 lines
787 B
C
#if !defined(_TEST_RESMGR_FIXTURE_H_)
|
|
#define _TEST_RESMGR_FIXTURE_H_
|
|
|
|
#include <rtti.h>
|
|
|
|
/* Test resource indices — must match make_test_resmgr() registration order */
|
|
#define TEST_RES_TYPE_IDX 0 /* "type" — RES_TYPE_STRING */
|
|
#define TEST_RES_MEM_IDX 1 /* "mem" — RES_TYPE_NUMERIC */
|
|
#define TEST_RES_GPU_IDX 2 /* "gpu" — RES_TYPE_BOOL */
|
|
#define TEST_RES_NCPUS_IDX 3 /* "ncpus" — RES_TYPE_NUMERIC */
|
|
#define TEST_RES_ARCH_IDX 4 /* "arch" — RES_TYPE_STRING */
|
|
|
|
/* Create a test resmgr with 5 pre-registered resources.
|
|
* Returns a var (kvtab) that can be passed to parse_select / parse_resreq_primary.
|
|
* Caller must call free_test_resmgr() when done. */
|
|
extern var make_test_resmgr(void);
|
|
extern void free_test_resmgr(var resmgr);
|
|
|
|
#endif
|