Skip to content

Run frontier MoE models on hardware you already own — pure C, zero deps, experts streamed from disk. Tiny engine, immense model. 🐦

C

test(v4): make the expert-store registry test build on Windows

dajiaohuangde5886a8625c
diff --git a/c/test_expert_store_registry.c b/c/test_expert_store_registry.c
index a894ed02..bd34023b 100644
--- a/c/test_expert_store_registry.c
+++ b/c/test_expert_store_registry.c
@@ -19,6 +19,21 @@
#include <stdlib.h>
#include <string.h>
+/* Windows has no setenv/unsetenv at all -- MinGW fails this file at link time
+ * with "undefined reference to `setenv'". compat.h's SetEnvironmentVariableA
+ * shim fixes the link but not the test: coli_expert_store_backend_open_selected
+ * reads COLI_EXPERT_STORE with getenv(), and getenv() reads the CRT's own copy
+ * of the environment, which that shim does not update -- the same trap
+ * test_qwen36_ctx.c and test_inkling_shared_batch.c document. _putenv_s is the
+ * one that updates the copy getenv() reads. */
+#ifdef _WIN32
+static void env_set(const char *name, const char *value) { _putenv_s(name, value); }
+static void env_unset(const char *name) { _putenv_s(name, ""); }
+#else
+static void env_set(const char *name, const char *value) { setenv(name, value, 1); }
+static void env_unset(const char *name) { unsetenv(name); }
+#endif
+
static int g_auto_called = 0;
/* Stub for the built-in backend's open fn. */
@@ -51,7 +66,7 @@ int main(void) {
ColiExpertStore *out = NULL;
/* Unregistered backend selected by env -> clean error, no dispatch. */
- setenv("COLI_EXPERT_STORE", "example-not-linked", 1);
+ env_set("COLI_EXPERT_STORE", "example-not-linked");
g_auto_called = 0;
int rc = coli_expert_store_backend_open_selected(NULL, NULL, NULL, &out, err, sizeof(err));
if (rc == 0 || g_auto_called) {
@@ -66,7 +81,7 @@ int main(void) {
printf("unregistered backend -> clean error: %s\n", err);
/* Env unset -> default 'auto' -> dispatch to the stub. */
- unsetenv("COLI_EXPERT_STORE");
+ env_unset("COLI_EXPERT_STORE");
g_auto_called = 0;
err[0] = 0;
rc = coli_expert_store_backend_open_selected(NULL, NULL, NULL, &out, err, sizeof(err));
@@ -79,14 +94,14 @@ int main(void) {
printf("default (COLI_EXPERT_STORE unset) -> dispatched to 'auto'\n");
/* Explicit 'auto' also dispatches. */
- setenv("COLI_EXPERT_STORE", "auto", 1);
+ env_set("COLI_EXPERT_STORE", "auto");
g_auto_called = 0;
coli_expert_store_backend_open_selected(NULL, NULL, NULL, &out, err, sizeof(err));
if (!g_auto_called) {
printf("FAIL: explicit 'auto' did not dispatch\n");
return 1;
}
- unsetenv("COLI_EXPERT_STORE");
+ env_unset("COLI_EXPERT_STORE");
printf("explicit 'auto' -> dispatched to 'auto'\n");
printf("ALL OK\n");