MCPcopy Create free account
hub / github.com/MemNixFS/MemNixFS / main

Function main

tests/c_api/c_api_smoke.cpp:30–184  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

28} while (0)
29
30int main(int argc, char** argv) {
31 if (argc < 2) {
32 fprintf(stderr, "usage: %s <dump_path> [<symbols_path>]\n", argv[0]);
33 return 2;
34 }
35 const char* dump = argv[1];
36 const char* syms = argc >= 3 ? argv[2] : NULL;
37
38 /* ---- version + last_error baseline ---- */
39 const char* v = lmpfs_version();
40 printf("== c_api_smoke: lmpfs_version=%s ==\n", v ? v : "(null)");
41 CHECK(v && v[0], "lmpfs_version returns non-empty");
42 CHECK(lmpfs_last_error()[0] == '\0', "last_error empty before any op");
43
44 /* ---- open ---- */
45 lmpfs_handle_t h = lmpfs_open(dump, syms);
46 if (!h) {
47 fprintf(stderr, "FAIL: lmpfs_open: %s\n", lmpfs_last_error());
48 return 1;
49 }
50 printf(" ok: lmpfs_open returned handle\n");
51
52 /* ---- kernel banner ---- */
53 char banner[1024];
54 int n = lmpfs_kernel_banner(h, banner, sizeof(banner));
55 CHECK(n > 0, "lmpfs_kernel_banner > 0 bytes");
56 printf(" kernel banner (truncated to first 80): %.80s%s\n",
57 banner, n > 80 ? "…" : "");
58
59 uint64_t dmap = lmpfs_kernel_direct_map_base(h);
60 CHECK(dmap != 0, "direct_map_base resolved");
61 printf(" direct_map_base = 0x%" PRIx64 "\n", dmap);
62
63 int64_t kaslr = lmpfs_kernel_kaslr_phys_shift(h);
64 printf(" kaslr_phys_shift = 0x%" PRIx64 "\n", (uint64_t)kaslr);
65
66 /* ---- process enumeration ---- */
67 int pc = lmpfs_process_count(h);
68 CHECK(pc > 0, "process_count > 0");
69 printf(" process_count = %d\n", pc);
70
71 lmpfs_process_t p;
72 int got_first = lmpfs_process_get(h, 0, &p);
73 CHECK(got_first, "process_get(0) succeeds");
74 if (got_first) {
75 printf(" proc[0]: pid=%u ppid=%u uid=%u comm=%s\n",
76 p.pid, p.ppid, p.uid, p.comm);
77 }
78
79 /* Out-of-range index → 0 + last_error set. */
80 lmpfs_process_t junk;
81 int oob = lmpfs_process_get(h, pc + 99, &junk);
82 CHECK(!oob, "process_get out-of-range returns 0");
83 CHECK(lmpfs_last_error()[0] != '\0', "last_error set after out-of-range");
84 printf(" (deliberate out-of-range error: %s)\n", lmpfs_last_error());
85
86 /* Find by comm — pid 1 is usually "systemd" on Linux desktops. */
87 if (lmpfs_process_find_by_name(h, "systemd", &p)) {

Callers

nothing calls this directly

Calls 15

lmpfs_versionFunction · 0.85
lmpfs_last_errorFunction · 0.85
lmpfs_openFunction · 0.85
lmpfs_kernel_bannerFunction · 0.85
lmpfs_process_countFunction · 0.85
lmpfs_process_getFunction · 0.85
lmpfs_vfs_listFunction · 0.85
lmpfs_vfs_list_freeFunction · 0.85

Tested by

no test coverage detected