feat: add load_primary_config(), myconf_fini(); remove static cf global from myconf.c

- load_primary_config(): resolves conf/current, reads raw bytes, computes
  SHA-256 tag, decodes Cap'n Proto via load_cluster_config_from_file(),
  checks reserved names, sets config_generation, checks staleness
- myconf_fini(): frees conffile and cluster_config (calls free_ClusterConfig)
- Remove static cf global from myconf.c; get_default_conf() now uses a
  local struct cluster_configuration* via load_cluster_config()
- Add load_primary_config_for_test() under XCE_TESTING in config_repl.c
  to test path resolution without triggering FATAL
- Add xce/cluster_def.h include to config_repl.c and test_config_repl.c
  so cluster_t is complete when XCE_TESTING is active
- TDD: test_load_primary_config_missing_returns_error passes (18/18)
This commit is contained in:
Rongsong Shen 2026-05-13 16:06:18 +00:00
parent ce62406f2c
commit cd02cf40d2
4 changed files with 192 additions and 7 deletions

View file

@ -90,3 +90,13 @@ int config_contains_reserved_name(cluster_config_t *cfg);
* Returns pointer to the static buffer. NOT thread-safe (static storage).
*/
char *sanitise_cn(const char *src, size_t maxlen);
#ifdef XCE_TESTING
/*
* load_primary_config_for_test: test-only wrapper that exercises the path
* resolution logic of load_primary_config() without calling FATAL.
* Returns 0 if conf/current resolves to a valid filename, negative errno
* otherwise. Does NOT perform Cap'n Proto decode or SHA-256 computation.
*/
int load_primary_config_for_test(cluster_t *c);
#endif