==> tests/toml.c <==1/* Every probe on the manifests' real shapes. */
2#include "mesh/catalog_toml.h"
3#include "mesh/check.h"
4
5int main(void) {
6 const char *gpu = "# hello: arg * 3 + 7\nname = \"hello\"\nabi = 6\nbackends = [\"cuda\", \"metal\", \"wasm\"]\n";
7 const char *native = "# hash-also: crates/mesh-host programs/gpt2x\n# build-os: Darwin\nname=\"ane\"\nbackends = [\"native\"]\nnodes = 1\n";
8 const char *spaced = "name = \"x\"\nbackends = [ \"native\" ] # comment\n";
9 const char *none = "name = \"tick-big\"\n";
10 char n[64];
11 CHECK(mesh_catalog_toml_name(gpu, n, sizeof n));
12 CHECK_S(n, "hello");
13 CHECK(mesh_catalog_toml_name(native, n, sizeof n));
14 CHECK_S(n, "ane");
15 CHECK(!mesh_catalog_toml_name("abi = 6\n", n, sizeof n));
16 CHECK(!mesh_catalog_toml_name("names = \"x\"\n", n, sizeof n));
17 CHECK(!mesh_catalog_toml_native(gpu));
18 CHECK(mesh_catalog_toml_native(native));
19 CHECK(mesh_catalog_toml_native(spaced));
20 CHECK(!mesh_catalog_toml_native("backends = [\"native\", \"wasm\"]\n"));
21 CHECK(mesh_catalog_toml_has_backends(gpu));
22 CHECK(!mesh_catalog_toml_has_backends(none));
23 CHECK(mesh_catalog_toml_backend(gpu, "wasm"));
24 CHECK(mesh_catalog_toml_backend(gpu, "cuda"));
25 CHECK(!mesh_catalog_toml_backend(native, "cuda"));
26 CHECK(!mesh_catalog_toml_backend(gpu, "was"));
27 char c[128];
28 CHECK(mesh_catalog_toml_comment(native, "hash-also", c, sizeof c));
29 CHECK_S(c, "crates/mesh-host programs/gpt2x");
30 CHECK(mesh_catalog_toml_comment(native, "build-os", c, sizeof c));
31 CHECK_S(c, "Darwin");
32 CHECK(!mesh_catalog_toml_comment(gpu, "build-os", c, sizeof c));
33 CHECK_S(c, "");
34 return mesh_check_done();
35}