myxce/src/frontend/apiserver/backend/val_helpers.h
Rongsong Shen 86a65d640a test(apiserver): add integration tests for P0+P1 backend features
Covers ~30 integration tests across 8 sections from the
apiserver-backend-integration-test-plan:

- §1: Cluster config push (store population, merge semantics, zero-preserve)
- §2: Host control (OnHostUpdated merge, validateHost, preCheck, batch ops)
- §3: Resource value push (all 7 value types, nil/unknown discriminant, overwrite)
- §4: Heartbeat keep-alive (interval update, zero-preserve)
- §5: Cross-feature (config+heartbeat, config+host, worker+config field preservation)
- §6: RBAC (cluster_admin bypass, algorithm confusion, expired tokens, hostgroup bypass)
- §7: Store thread safety (concurrent config pushes, host control+config, resource values)
- §8: Input safety (hostname length, empty lists, malformed payloads)

All tests use CGO_ENABLED=0 with //go:build !cgo build tag.
§8.1 hostname-length skipped pending P1-2b implementation.
2026-04-18 11:56:31 +00:00

19 lines
No EOL
908 B
C

#ifndef VAL_HELPERS_H
#define VAL_HELPERS_H
#include "xce/types.h"
// Thin accessors for xce_val_t union fields.
// CGO cannot access C union fields by name (they appear as [N]byte in Go),
// so these helpers extract typed values without unsafe pointer arithmetic.
static inline int xce_val_which(xce_val_t *v) { return v->which; }
static inline int32_t xce_val_i32(xce_val_t *v) { return v->u.ivalue32; }
static inline int64_t xce_val_i64(xce_val_t *v) { return v->u.ivalue64; }
static inline uint32_t xce_val_u32(xce_val_t *v) { return v->u.uvalue32; }
static inline uint64_t xce_val_u64(xce_val_t *v) { return v->u.uvalue64; }
static inline double xce_val_fval(xce_val_t *v) { return v->u.fvalue; }
static inline char* xce_val_str(xce_val_t *v) { return v->u.svalue; }
static inline int xce_val_bool(xce_val_t *v) { return v->u.bvalue; }
#endif /* VAL_HELPERS_H */