Conservative SmartOS global-zone memory pressure guard with dry-run-first policy and SMF integration.
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.
 
 
 
 

755 řádky
39 KiB

  1. /* Exercise the actual daemon selection/action path. Native backend NOT linked. */
  2. #define main guard_program_main
  3. #include "../src/main.c"
  4. #undef main
  5. static double fake_now = 100;
  6. static double refresh_age, dispatch_delay;
  7. static sample_t fake_sample;
  8. static process_t fixtures[32];
  9. static unsigned nfixtures, real_requests, validation_requests, walk_requests, checks;
  10. static int fail_validation, fail_sample, partial, invalid_pid;
  11. typedef struct { int priority; char message[1536]; } syslog_record_t;
  12. static syslog_record_t syslog_records[64];
  13. static unsigned syslog_count, syslog_open_count, syslog_close_count;
  14. static int syslog_facility, fail_syslog;
  15. static double syslog_delay_seconds;
  16. static char syslog_ident[64];
  17. #define CHECK(x) do { if (!(x)) { fprintf(stderr, "FAIL runtime line %d: %s\n", __LINE__, #x); exit(1); } checks++; } while (0)
  18. double monotime(void) { return fake_now; }
  19. int secure_file(const char *p, int flags, unsigned mode)
  20. { (void)p; (void)flags; (void)mode; errno = EPERM; return -1; }
  21. int secure_directory(const char *p) { (void)p; return -1; }
  22. int platform_init(void) { return 0; }
  23. void platform_fini(void) { }
  24. int platform_syslog_open(const char *ident, int facility)
  25. {
  26. syslog_open_count++; syslog_facility = facility;
  27. snprintf(syslog_ident, sizeof (syslog_ident), "%s", ident);
  28. return fail_syslog ? -1 : 0;
  29. }
  30. int platform_syslog_write(int priority, const char *message)
  31. {
  32. if (fail_syslog) { errno = EIO; return -1; }
  33. fake_now += syslog_delay_seconds;
  34. CHECK(syslog_count < sizeof (syslog_records) / sizeof (syslog_records[0]));
  35. syslog_records[syslog_count].priority = priority;
  36. snprintf(syslog_records[syslog_count].message,
  37. sizeof (syslog_records[syslog_count].message), "%s", message);
  38. syslog_count++;
  39. return 0;
  40. }
  41. void platform_syslog_close(void) { syslog_close_count++; }
  42. int platform_sample(sample_t *s)
  43. { *s = fake_sample; s->at = fake_now - refresh_age;
  44. if (fail_sample) { memset(s, 0, sizeof (*s)); errno = EIO; return -1; }
  45. return 0; }
  46. int platform_walk(int (*fn)(const process_t *, void *), void *arg, unsigned budget)
  47. {
  48. unsigned j; (void)budget;
  49. walk_requests++;
  50. for (j = 0; j < nfixtures; j++) if (fn(&fixtures[j], arg)) return -1;
  51. return partial ? -1 : 0;
  52. }
  53. static int mock_signal_errno, mock_validation_errno, mock_timeout_pid;
  54. static int mock_ticket_pid;
  55. int validation_start(void) { return 0; }
  56. int validation_handle(int ticket) { return ticket; }
  57. void validation_release(int ticket) { (void)ticket; }
  58. int validation_acquire(const config_t *c, const process_t *p, int real,
  59. uint64_t ceiling, unsigned budget_ms, int *ticket, validation_t *timing)
  60. {
  61. unsigned j; int found = 0;
  62. (void)real; (void)ceiling;
  63. memset(timing, 0, sizeof (*timing));
  64. CHECK(!protected_process(c, p));
  65. for (j = 0; j < nfixtures; j++)
  66. if (fixtures[j].pid == p->pid && same_process(&fixtures[j], p)) { found = 1; break; }
  67. validation_requests++;
  68. if (p->pid == mock_timeout_pid) {
  69. fake_now += budget_ms / 1000.0; timing->total_ms = budget_ms;
  70. errno = ETIMEDOUT; return -1;
  71. }
  72. if (fail_validation || p->pid == invalid_pid || !found) { errno = ESTALE; return -1; }
  73. *ticket = p->pid; mock_ticket_pid = p->pid; errno = mock_validation_errno;
  74. return 0; /* This test backend cannot send any signal. */
  75. }
  76. void platform_dispatch(int handle, enum action action, signal_result_t *out)
  77. {
  78. CHECK(handle == mock_ticket_pid && (action == TERM || action == KILL));
  79. real_requests++;
  80. memset(out, 0, sizeof (*out)); out->attempted = 1;
  81. out->attempt = fake_now; fake_now += dispatch_delay; out->returned = fake_now;
  82. out->write_ms = out->total_ms = 1000 * dispatch_delay;
  83. out->rc = mock_signal_errno ? -1 : (long)(2 * sizeof (long));
  84. out->error = mock_signal_errno;
  85. }
  86. static void reset(void)
  87. {
  88. defaults(&cfg); cfg.log_mib = 100;
  89. cfg.nzones = 2;
  90. strcpy(cfg.zones[0].uuid, "11111111-1111-4111-8111-111111111111");
  91. strcpy(cfg.zones[0].alias, "web-a"); cfg.zones[0].policy = ALLOW;
  92. strcpy(cfg.zones[1].uuid, "22222222-2222-4222-8222-222222222222");
  93. strcpy(cfg.zones[1].alias, "web-b"); cfg.zones[1].policy = ALLOW;
  94. memset(processes, 0, sizeof (processes)); memset(zone_stats, 0, sizeof (zone_stats));
  95. memset(candidate_cache, 0, sizeof (candidate_cache));
  96. memset(published_cache, 0, sizeof (published_cache));
  97. memset(rejected_identity, 0, sizeof (rejected_identity));
  98. rejected_identity_next = rejected_identity_count = 0;
  99. logged_override_stage = action_rejected_entries = 0;
  100. logged_deadman_risk = 0; override_blocked_logged_at = -1;
  101. memset(metrics, 0, sizeof (metrics));
  102. memset(&controller, 0, sizeof (controller)); memset(fixtures, 0, sizeof (fixtures));
  103. engine_init(&engine); engine.state = CRITICAL; engine.danger = 1;
  104. stopping = 0; started = 0; log_ok = 1; log_bytes = 0;
  105. async_logging = scanner_async = 0;
  106. event_head = event_tail = event_count = dropped_events = 0;
  107. event_sequence = 0; scan_requested = scan_snapshot_requested = 0;
  108. syslog_ready = syslog_init_failed = 0;
  109. syslog_count = syslog_open_count = syslog_close_count = 0;
  110. syslog_facility = -1; fail_syslog = 0; syslog_ident[0] = 0;
  111. syslog_delay_seconds = 0;
  112. refresh_age = dispatch_delay = 0;
  113. mock_signal_errno = mock_validation_errno = mock_timeout_pid = 0;
  114. scan_generation = 0; scan_complete = published_scan_complete = 0;
  115. scanner_latest_complete_scan_at = latest_complete_scan_at = 0;
  116. published_latest_complete_scan_at = 0;
  117. fake_now = 100; partial = fail_sample = fail_validation = invalid_pid = 0;
  118. real_requests = validation_requests = walk_requests = 0;
  119. memset(&fake_sample, 0, sizeof (fake_sample)); fake_sample.at = fake_now;
  120. fake_sample.free = 60000; fake_sample.lots = 130875;
  121. fake_sample.des = 65437; fake_sample.min = 49077;
  122. fixtures[0].pid = 123; fixtures[0].ppid = 100; fixtures[0].zid = 9;
  123. fixtures[0].initpid = 99; fixtures[0].nlwp = 1; fixtures[0].start_sec = 1000;
  124. fixtures[0].zone_generation = 20; fixtures[0].rss_kib = 100000;
  125. strcpy(fixtures[0].uuid, cfg.zones[0].uuid); strcpy(fixtures[0].name, "php-fpm");
  126. nfixtures = 1;
  127. scan_processes(0);
  128. }
  129. static void populate_many_candidates(unsigned count)
  130. {
  131. unsigned i;
  132. reset();
  133. CHECK(count <= sizeof (fixtures) / sizeof (fixtures[0]));
  134. for (i = 0; i < count; i++) {
  135. fixtures[i] = fixtures[0]; fixtures[i].pid = 1000 + (int)i;
  136. fixtures[i].start_sec += i; fixtures[i].start_nsec += i;
  137. fixtures[i].rss_kib = 2000000 - 1000 * i;
  138. }
  139. nfixtures = count; fake_now = 101; scan_processes(0);
  140. for (i = 0; i < count; i++) CHECK(candidate_cache[i].valid);
  141. }
  142. static int queued_contains(const char *text)
  143. {
  144. unsigned i;
  145. for (i = 0; i < event_count; i++) {
  146. unsigned slot = (event_head + i) % EVENT_QUEUE_SIZE;
  147. if (strstr(event_queue[slot].body, text)) return 1;
  148. }
  149. return 0;
  150. }
  151. static void panic33_fixture(void)
  152. {
  153. FILE *f;
  154. char line[256];
  155. unsigned seconds, incomplete, expected, j, rows = 0;
  156. uint64_t free_pages;
  157. delta_t d = {1, 5, 100};
  158. int removed = 0;
  159. populate_many_candidates(16);
  160. cfg.armed = 1; async_logging = 1;
  161. engine_init(&engine);
  162. f = fopen("tests/fixtures/panic33_persistent_floor_budget_exhaustion_2026_10_08.csv", "r");
  163. CHECK(f != NULL);
  164. while (fgets(line, sizeof (line), f)) {
  165. if (line[0] == '#') continue;
  166. CHECK(sscanf(line, "%" SCNu64 ",%u,%u,%u", &free_pages, &seconds, &incomplete, &expected) == 4);
  167. for (j = 0; j < seconds; j++) {
  168. fake_now++; fake_sample.at = fake_now; fake_sample.free = free_pages;
  169. fake_sample.scan = 1000000; fake_sample.pageout_ok = 1;
  170. if (incomplete && !removed) {
  171. /* Cached PID disappeared; its replacement is smaller than survivors. */
  172. fixtures[8].pid = 2000; fixtures[8].start_sec++;
  173. fixtures[8].rss_kib = 100000; removed = 1;
  174. }
  175. engine_step(&engine, &cfg, &fake_sample, d, d, d);
  176. refresh_candidate_cache();
  177. act(&fake_sample);
  178. partial = (int)incomplete;
  179. scan_processes(0);
  180. }
  181. CHECK(controller.nvictims == expected);
  182. rows++;
  183. }
  184. fclose(f);
  185. CHECK(rows == 7 && !scan_complete);
  186. CHECK(queued_contains("reason=emergency_victim_budget_exhausted"));
  187. CHECK(queued_contains("event=budget_override reason=persistent_floor"));
  188. CHECK(queued_contains("event=victim_budget tier=hard_floor used=16 limit=16 remaining=0"));
  189. CHECK(was_victim(&controller, &fixtures[8]));
  190. CHECK(real_requests > 16); /* TERM escalation plus direct FLOOR KILL. */
  191. fake_sample.free = 6513; fake_sample.at = ++fake_now;
  192. act(&fake_sample);
  193. CHECK(queued_contains("reason=hard_floor_victim_budget_exhausted"));
  194. CHECK(controller.nvictims == 16);
  195. puts("PASS panic33: partial recoveries, budgets, dead PID replacement, incomplete scan, hard ceiling16");
  196. }
  197. static void panic34_fixture(void)
  198. {
  199. FILE *f;
  200. char line[256];
  201. unsigned i, rows = 0, walks, before;
  202. delta_t none = {0, 0, 0};
  203. populate_many_candidates(16); cfg.armed = 1; async_logging = 1;
  204. for (i = 0; i < 8; i++) controller.victims[i] = fixtures[i];
  205. controller.nvictims = 8;
  206. scan_complete = 0; latest_complete_scan_at = 123;
  207. walks = walk_requests; engine_init(&engine);
  208. f = fopen("tests/fixtures/panic34_persistent_minfree_budget_exhaustion_2026_10_09.csv", "r");
  209. CHECK(f != NULL);
  210. while (fgets(line, sizeof (line), f)) {
  211. int acted = 0;
  212. if (line[0] == '#') continue;
  213. CHECK(sscanf(line, "%lf,%" SCNu64 ",%" SCNu64 ",%" SCNu64 ",%" SCNu64,
  214. &fake_now, &fake_sample.free, &fake_sample.scan,
  215. &fake_sample.anon_pageout_pages, &fake_sample.swap_physical_used_bytes) == 5);
  216. fake_sample.at = fake_now; fake_sample.pageout_ok = fake_sample.swap_physical_ok = 1;
  217. /* Same order as production: retained rescue before the next engine step. */
  218. if (engine.danger) { act(&fake_sample); acted = 1; }
  219. engine_step(&engine, &cfg, &fake_sample, none, none, none);
  220. if (engine.danger && !acted) act(&fake_sample);
  221. log_deadman_status(&fake_sample);
  222. CHECK(!engine.floor && !scan_complete && fake_now - latest_complete_scan_at > 376);
  223. CHECK(engine.risk.ready == (rows >= 5));
  224. CHECK(controller.override_stage == (rows < 6 ? 0u : rows < 9 ? 1u : 2u));
  225. CHECK(controller.nvictims <= 16 && walk_requests == walks);
  226. rows++;
  227. }
  228. fclose(f);
  229. CHECK(rows == 24 && controller.nvictims == 16 && real_requests == 16);
  230. CHECK(queued_contains("reason=persistent_minfree_deadman_risk from_limit=8 to_limit=12"));
  231. CHECK(queued_contains("reason=persistent_minfree_deadman_risk_continues from_limit=12 to_limit=16"));
  232. CHECK(queued_contains("event=deadman_risk active=1"));
  233. CHECK(queued_contains("proc_scanner_complete=0"));
  234. CHECK(queued_contains("episode_victims_total=16 current_budget_tier=absolute current_limit=16"));
  235. before = event_count; log_deadman_status(&fake_sample); CHECK(event_count == before);
  236. /* No usable candidates is distinct from exhausted budget. */
  237. controller.nvictims = 8; controller.has_pending = 0;
  238. memset(candidate_cache, 0, sizeof (candidate_cache));
  239. act(&fake_sample);
  240. CHECK(queued_contains("reason=no_revalidatable_candidate"));
  241. CHECK(queued_contains("cache_entries=0 rejected_entries=0 proc_scan_complete=0"));
  242. reset(); cfg.armed = 1; async_logging = 1; controller.nvictims = 12;
  243. fake_sample.free = 100; fake_sample.pageout_ok = 1; fake_sample.scan = 1000000;
  244. engine_step(&engine, &cfg, &fake_sample, none, none, none);
  245. act(&fake_sample);
  246. CHECK(engine.floor && real_requests == 0 && controller.nvictims == 12);
  247. CHECK(action_limit(&controller, &cfg, &engine, &fake_sample) == 12);
  248. puts("PASS panic34 real-loop order: intermittent VM scanner, stale proc cache,8->12->16, finite and deduplicated");
  249. }
  250. static void partial_cache_tests(void)
  251. {
  252. process_t replacement, survivor;
  253. unsigned i;
  254. int found = 0;
  255. populate_many_candidates(16);
  256. survivor = candidate_cache[1].p;
  257. invalidate_candidate(&candidate_cache[0].p);
  258. scanner_async = 1;
  259. replacement = fixtures[0]; replacement.pid = 9000; replacement.start_sec++;
  260. replacement.rss_kib = 70000;
  261. scan_at = ++fake_now; scan_generation++;
  262. /* Callback publishes before platform_walk returns (or blocks). */
  263. CHECK(visit(&replacement, NULL) == 0);
  264. refresh_candidate_cache();
  265. for (i = 0; i < CACHED_CANDIDATES; i++)
  266. if (candidate_cache[i].valid && same_process(&candidate_cache[i].p, &replacement)) found = 1;
  267. CHECK(found && !scan_complete);
  268. CHECK(same_process(&candidate_cache[0].p, &survivor));
  269. CHECK(pthread_mutex_lock(&cache_mutex) == 0);
  270. refresh_candidate_cache(); /* trylock only: must return while scanner holds lock. */
  271. CHECK(pthread_mutex_unlock(&cache_mutex) == 0);
  272. replacement.pid = 9001; replacement.rss_kib = 65536;
  273. CHECK(visit(&replacement, NULL) == 0);
  274. refresh_candidate_cache();
  275. CHECK(same_process(&candidate_cache[0].p, &survivor));
  276. CHECK(candidate_cache[15].p.pid == 9000);
  277. scanner_async = 0;
  278. puts("PASS incremental pre-return publication, survivor ordering, bounded merge and nonblocking handoff");
  279. }
  280. static void critical_path_faults(void)
  281. {
  282. struct timespec before, after; double elapsed_ms; unsigned walks;
  283. struct stat st_before, st_after;
  284. {
  285. FILE *fixture; char line[160], event[64];
  286. unsigned seconds, rows = 0, decision_at = 0, sent_at = 0;
  287. uint64_t free_pages, nscan;
  288. fixture = fopen("tests/fixtures/panic32_daemon_stall_2026_09_22.csv", "r");
  289. CHECK(fixture != NULL); CHECK(fgets(line, sizeof (line), fixture) != NULL);
  290. while (fscanf(fixture, "%u,%" SCNu64 ",%" SCNu64 ",%63s",
  291. &seconds, &free_pages, &nscan, event) == 4) {
  292. rows++;
  293. if (!strcmp(event, "kill_decision")) decision_at = seconds;
  294. if (!strcmp(event, "kill_sent_after_145s")) sent_at = seconds;
  295. }
  296. fclose(fixture);
  297. CHECK(rows == 7 && sent_at - decision_at == 145);
  298. }
  299. {
  300. queued_event_t event;
  301. reset(); async_logging = 1; syslog_ready = 1;
  302. syslog_delay_seconds = 0.200;
  303. memset(&event, 0, sizeof (event));
  304. strcpy(event.body, "event=test_syslog_stall");
  305. event.wall_time = time(NULL); event.mono_time = fake_now;
  306. event.syslog_channel = 1; event.priority = LOG_WARNING; event.sequence = 1;
  307. CHECK(write_event_now(&event) == 0);
  308. CHECK(queued_contains("event=logging_stall"));
  309. CHECK(queued_contains("channel=syslog"));
  310. CHECK(queued_contains("syslog_latency_ms=200.000"));
  311. }
  312. populate_many_candidates(16); cfg.armed = 1; engine.state = EMERGENCY;
  313. engine.danger = 1; fake_sample.free = 40000; fake_now += 180;
  314. async_logging = 1; fail_syslog = 1;
  315. CHECK(fstat(logfd, &st_before) == 0); walks = walk_requests;
  316. clock_gettime(CLOCK_MONOTONIC, &before); act(&fake_sample);
  317. clock_gettime(CLOCK_MONOTONIC, &after);
  318. elapsed_ms = 1000.0 * (after.tv_sec - before.tv_sec) +
  319. (after.tv_nsec - before.tv_nsec) / 1000000.0;
  320. CHECK(real_requests == 1 && validation_requests == 1);
  321. CHECK(elapsed_ms < 100.0 && walk_requests == walks && syslog_count == 0);
  322. CHECK(fstat(logfd, &st_after) == 0 && st_after.st_size == st_before.st_size);
  323. CHECK(queued_contains("candidate_source=stale_cache_revalidated"));
  324. CHECK(queued_contains("dispatch_latency_ms="));
  325. CHECK(queued_contains("candidate_validate_latency_ms="));
  326. CHECK(queued_contains("kill_latency_ms="));
  327. CHECK(queued_contains("log_enqueue_latency_ms="));
  328. fake_now += cfg.emergency_term_s;
  329. clock_gettime(CLOCK_MONOTONIC, &before); act(&fake_sample);
  330. clock_gettime(CLOCK_MONOTONIC, &after);
  331. elapsed_ms = 1000.0 * (after.tv_sec - before.tv_sec) +
  332. (after.tv_nsec - before.tv_nsec) / 1000000.0;
  333. CHECK(real_requests == 2 && validation_requests == 2 && elapsed_ms < 100.0);
  334. CHECK(queued_contains("signal=SIGKILL"));
  335. puts("PASS panic32 fault: logger/syslog stopped 180s, stale cache revalidated, signal dispatch <100ms");
  336. populate_many_candidates(16); cfg.armed = 1; engine.state = EMERGENCY;
  337. engine.danger = 1; fake_sample.free = 40000; async_logging = scanner_async = 1;
  338. scan_requested = 1; walks = walk_requests;
  339. act(&fake_sample);
  340. CHECK(real_requests == 1 && walk_requests == walks);
  341. puts("PASS stalled/incomplete scanner cannot delay or trigger a rescue-path proc scan");
  342. populate_many_candidates(16); cfg.armed = 1; engine.state = EMERGENCY;
  343. engine.danger = 1; fake_sample.free = 40000; async_logging = 1;
  344. walks = walk_requests;
  345. while (controller.nvictims < cfg.max_emergency_victims) {
  346. act(&fake_sample);
  347. if (controller.has_pending) { fake_now += cfg.emergency_term_s; act(&fake_sample); }
  348. fake_now += 0.01;
  349. }
  350. CHECK(controller.nvictims == 8 && real_requests == 16 && walk_requests == walks);
  351. act(&fake_sample); CHECK(real_requests == 16);
  352. puts("PASS 16-entry stale rescue cache supplies all 8 EMERGENCY victims without scan");
  353. populate_many_candidates(16); cfg.armed = 1; engine.state = EMERGENCY;
  354. engine.danger = engine.floor = 1; fake_sample.free = 20000; async_logging = 1;
  355. walks = walk_requests;
  356. while (controller.nvictims < cfg.max_floor_victims) {
  357. act(&fake_sample); fake_now += 0.01;
  358. }
  359. CHECK(controller.nvictims == 12 && real_requests == 12 && walk_requests == walks);
  360. act(&fake_sample); CHECK(real_requests == 12);
  361. puts("PASS 16-entry stale rescue cache supplies all 12 FLOOR victims without scan");
  362. populate_many_candidates(16); cfg.armed = 1; engine.state = EMERGENCY;
  363. engine.danger = 1; fake_sample.free = 40000; async_logging = 1;
  364. CHECK(pthread_mutex_lock(&event_mutex) == 0);
  365. clock_gettime(CLOCK_MONOTONIC, &before); act(&fake_sample);
  366. clock_gettime(CLOCK_MONOTONIC, &after);
  367. CHECK(pthread_mutex_unlock(&event_mutex) == 0);
  368. elapsed_ms = 1000.0 * (after.tv_sec - before.tv_sec) +
  369. (after.tv_nsec - before.tv_nsec) / 1000000.0;
  370. CHECK(real_requests == 1 && elapsed_ms < 100.0 && dropped_events > 0);
  371. puts("PASS saturated/locked event queue drops telemetry without delaying the signal");
  372. }
  373. static void floor_errno_fixture(void)
  374. {
  375. FILE *f; char line[160], event[80];
  376. unsigned seconds, rows = 0, i, j;
  377. uint64_t free_pages, scans;
  378. delta_t zero = {0, 0, 0};
  379. const int prior[] = {EAGAIN, ENOMEM};
  380. const int errors[] = {0, ESRCH, EPERM, EINVAL, EAGAIN};
  381. populate_many_candidates(16); cfg.armed = 1; async_logging = 1;
  382. engine_init(&engine);
  383. f = fopen("tests/fixtures/floor_free_pages_486_2026_09_23.csv", "r");
  384. CHECK(f != NULL && fgets(line, sizeof (line), f) != NULL);
  385. while (fscanf(f, "%u,%" SCNu64 ",%" SCNu64 ",%79s", &seconds,
  386. &free_pages, &scans, event) == 4) {
  387. fake_now = 200 + seconds; fake_sample.at = fake_now;
  388. fake_sample.free = free_pages; fake_sample.scan = scans;
  389. engine_step(&engine, &cfg, &fake_sample, zero, zero, zero);
  390. if (seconds == 1) {
  391. CHECK(engine.state == EMERGENCY && engine.floor);
  392. mock_timeout_pid = candidate_cache[0].p.pid;
  393. act(&fake_sample);
  394. CHECK(real_requests == 1 && mock_ticket_pid == candidate_cache[1].p.pid);
  395. CHECK(queued_contains("reason=validation_timeout rank=1 latency_ms=50.000"));
  396. CHECK(queued_contains("rank=2"));
  397. CHECK(fake_now - fake_sample.at < 0.100);
  398. }
  399. rows++;
  400. }
  401. fclose(f); CHECK(rows == 3 && engine.state == RECOVERY);
  402. for (i = 0; i < 2; i++) for (j = 0; j < 5; j++) {
  403. char expected[120];
  404. reset(); cfg.armed = 1; async_logging = 1;
  405. mock_validation_errno = prior[i]; mock_signal_errno = errors[j];
  406. act(&fake_sample);
  407. snprintf(expected, sizeof (expected), "result=%s errno=%d syscall=write operation=PCKILL attempted=1 rc=%ld errno_name=%s",
  408. errors[j] ? "failed" : "sent", errors[j],
  409. errors[j] ? -1L : (long)(2 * sizeof (long)), signal_errno_name(errors[j]));
  410. CHECK(queued_contains(expected));
  411. CHECK(queued_contains("event=signal_sent") == (errors[j] == 0));
  412. CHECK(queued_contains("validate_start_time_ms="));
  413. }
  414. puts("PASS floor486 fixture, 50ms timeout fallback rank1->2, syscall errno attribution and validation substep logs");
  415. }
  416. static void diagnostic_fixtures(void)
  417. {
  418. FILE *f; char line[128], stamp[32], expected[128];
  419. unsigned signals, failure, rows = 0; uint64_t free_pages; double ms;
  420. reset(); cfg.armed = 1; async_logging = 1; engine.state = EMERGENCY;
  421. f = fopen("tests/fixtures/refresh_recovery_and_failure.csv", "r");
  422. CHECK(f && fgets(line, sizeof (line), f));
  423. while (fscanf(f, "%" SCNu64 ",%u,%u", &free_pages, &failure, &signals) == 3) {
  424. fake_sample.free = free_pages; fail_sample = (int)failure;
  425. act(&fake_sample); CHECK(real_requests == signals); rows++;
  426. }
  427. fclose(f); CHECK(rows == 3);
  428. CHECK(queued_contains("reason=free_above_desfree state=EMERGENCY free_pages=70000 desfree=65437 minfree=49077 refresh_ok=1"));
  429. CHECK(queued_contains("reason=refresh_failed state=EMERGENCY free_pages=20000 desfree=65437 minfree=49077 refresh_ok=0"));
  430. CHECK(queued_contains("refresh_errno=5 refresh_error=EIO"));
  431. reset(); cfg.armed = 1; async_logging = 1; refresh_age = 2.1;
  432. act(&fake_sample); CHECK(real_requests == 0);
  433. CHECK(queued_contains("reason=refresh_failed")); CHECK(queued_contains("refresh_error=stale_sample"));
  434. reset(); cfg.armed = 1; async_logging = 1; fake_sample.free = fake_sample.des;
  435. act(&fake_sample); CHECK(real_requests == 0 && queued_contains("reason=free_above_desfree"));
  436. f = fopen("tests/fixtures/pckill_latency_2026_09_28.csv", "r");
  437. CHECK(f && fgets(line, sizeof (line), f)); rows = 0;
  438. while (fscanf(f, "%31[^,],%lf\n", stamp, &ms) == 2) {
  439. reset(); cfg.armed = 1; async_logging = 1; fake_sample.free = 486;
  440. engine.state = EMERGENCY; dispatch_delay = ms / 1000;
  441. act(&fake_sample);
  442. CHECK(real_requests == 1 && queued_contains("event=signal_sent"));
  443. CHECK(queued_contains("event=signal_dispatch_slow signal=SIGKILL"));
  444. snprintf(expected, sizeof (expected), "pckill_write_latency_ms=%.3f", ms);
  445. CHECK(queued_contains(expected)); rows++;
  446. }
  447. fclose(f); CHECK(rows == 5);
  448. reset(); cfg.armed = 1; async_logging = 1; dispatch_delay = .000010;
  449. act(&fake_sample); CHECK(queued_contains("pckill_write_latency_ms=0.010"));
  450. CHECK(!queued_contains("event=signal_dispatch_slow"));
  451. reset(); cfg.armed = 1; async_logging = 1; dispatch_delay = .100;
  452. act(&fake_sample); CHECK(!queued_contains("event=signal_dispatch_slow"));
  453. reset(); cfg.armed = 1; async_logging = 1; dispatch_delay = .101;
  454. act(&fake_sample); CHECK(queued_contains("event=signal_dispatch_slow signal=SIGTERM"));
  455. puts("PASS recovery/failure/stale refresh reasons, desfree equality, no second victim, PCKILL subphases and slow-event threshold");
  456. }
  457. static void load_global_ranking_fixture(void)
  458. {
  459. FILE *f;
  460. char line[256], uuid[64], alias[64], name[32];
  461. int zid, pid;
  462. uint64_t generation, rss;
  463. reset();
  464. cfg.nzones = cfg.nnames = 0;
  465. strcpy(cfg.protected_names[cfg.nnames++], "mysqld");
  466. strcpy(cfg.protected_names[cfg.nnames++], "zone-overhead");
  467. memset(processes, 0, sizeof (processes));
  468. memset(zone_stats, 0, sizeof (zone_stats));
  469. memset(candidate_cache, 0, sizeof (candidate_cache));
  470. memset(&controller, 0, sizeof (controller));
  471. memset(fixtures, 0, sizeof (fixtures));
  472. scan_generation = 0; scan_complete = 0; latest_complete_scan_at = 0;
  473. nfixtures = 0; fake_now = 100;
  474. f = fopen("tests/fixtures/global_victim_ranking_smartos_2026_09.csv", "r");
  475. CHECK(f != NULL); CHECK(fgets(line, sizeof (line), f) != NULL);
  476. while (fscanf(f, " %63[^,],%63[^,],%d,%" SCNu64 ",%d,%31[^,],%" SCNu64,
  477. uuid, alias, &zid, &generation, &pid, name, &rss) == 7) {
  478. process_t *p;
  479. const zone_rule_t *rule = zone_rule(&cfg, uuid);
  480. CHECK(nfixtures < sizeof (fixtures) / sizeof (fixtures[0]));
  481. if (!rule) {
  482. zone_rule_t *z;
  483. CHECK(cfg.nzones < MAX_ZONES); z = &cfg.zones[cfg.nzones++];
  484. strcpy(z->uuid, uuid); strcpy(z->alias, alias); z->policy = ALLOW;
  485. }
  486. p = &fixtures[nfixtures++];
  487. p->pid = pid; p->ppid = 100; p->zid = zid; p->initpid = 9000 + zid;
  488. p->nlwp = 1; p->start_sec = 1000 + pid; p->start_nsec = pid;
  489. p->zone_generation = generation; p->rss_kib = rss;
  490. strcpy(p->uuid, uuid); strcpy(p->name, name);
  491. }
  492. fclose(f); CHECK(nfixtures == 16 && cfg.nzones == 5);
  493. scan_processes(1);
  494. }
  495. int main(void)
  496. {
  497. FILE *log = tmpfile(); char contents[65536]; size_t n;
  498. const process_t *chosen;
  499. unsigned second;
  500. CHECK(log != NULL); logfd = fileno(log);
  501. reset(); act(&fake_sample);
  502. CHECK(real_requests == 0 && validation_requests == 1 && controller.has_pending);
  503. fake_now += 5; scan_processes(0); act(&fake_sample);
  504. CHECK(real_requests == 0 && !controller.has_pending);
  505. rewind(log); n = fread(contents, 1, sizeof (contents) - 1, log); contents[n] = 0;
  506. CHECK(strstr(contents, "WOULD_ACTION=SIGTERM") != NULL);
  507. CHECK(strstr(contents, "WOULD_ACTION=SIGKILL") != NULL);
  508. CHECK(strstr(contents, "ACTION_INTENT=") == NULL);
  509. CHECK(fseek(log, 0, SEEK_END) == 0);
  510. puts("PASS actual daemon dry-run path records WOULD_ACTION=SIGTERM/SIGKILL; zero real requests");
  511. reset();
  512. fake_sample.arc_ok = 1;
  513. fake_sample.swap_virtual_ok = fake_sample.swap_physical_ok = fake_sample.pageout_ok = 1;
  514. for (second = 0; second <= 60; second++) {
  515. fake_sample.at = 100 + second;
  516. fake_sample.arc = UINT64_C(6000000000) + 1000 * second;
  517. fake_sample.swap_alloc = 7000000 + 3 * second;
  518. fake_sample.swap_reserved = 480000 + 2 * second;
  519. fake_sample.swap_available = 6200000 - second;
  520. fake_sample.swap_physical_used_bytes = UINT64_C(4143648768) + 4096 * second;
  521. fake_sample.anon_pageout_pages = 1000 + 2 * second;
  522. record_pressure_metrics(&fake_sample);
  523. record_auxiliary_metrics(&fake_sample);
  524. }
  525. log_sample(&fake_sample);
  526. CHECK(fflush(log) == 0 && fseek(log, 0, SEEK_SET) == 0);
  527. n = fread(contents, 1, sizeof (contents) - 1, log); contents[n] = 0;
  528. CHECK(strstr(contents, "swap_committed_ok=1 swap_committed_pages=7480300") != NULL);
  529. CHECK(strstr(contents, "swap_physical_used_ok=1 swap_physical_used_bytes=4143894528") != NULL);
  530. CHECK(strstr(contents, "anon_pageout_ok=1 anon_pageout_pages=1120") != NULL);
  531. CHECK(strstr(contents, "swap_alloc_pages=7000180 swap_reserved_pages=480120 swap_available_pages=6199940") != NULL);
  532. CHECK(strstr(contents, "metric=swap_committed_pages d5=+25@5.00s d15=+75@15.00s d60=+300@60.00s") != NULL);
  533. CHECK(strstr(contents, "metric=swap_physical_used_bytes d5=+20480@5.00s d15=+61440@15.00s d60=+245760@60.00s") != NULL);
  534. CHECK(strstr(contents, "metric=anon_pageout_pages d5=+10@5.00s d15=+30@15.00s d60=+120@60.00s") != NULL);
  535. CHECK(strstr(contents, "swap_used_pages") == NULL);
  536. CHECK(fseek(log, 0, SEEK_END) == 0);
  537. puts("PASS continuous sample contract and 5/15/60 deltas for commitment, physical swap and pageout");
  538. reset(); cfg.armed = 1; act(&fake_sample);
  539. CHECK(real_requests == 1);
  540. fake_now += 5; scan_processes(0); act(&fake_sample); CHECK(real_requests == 2);
  541. reset(); cfg.armed = 1; started = 80; fake_now = 101; scan_processes(0);
  542. CHECK(candidate_cache[0].valid && engine.danger && walk_requests == 2);
  543. act(&fake_sample); CHECK(real_requests == 0 && candidate_cache[0].valid);
  544. CHECK(fflush(log) == 0 && fseek(log, 0, SEEK_SET) == 0);
  545. n = fread(contents, 1, sizeof (contents) - 1, log); contents[n] = 0;
  546. CHECK(strstr(contents, "event=action_blocked reason=armed_warmup") != NULL);
  547. CHECK(fseek(log, 0, SEEK_END) == 0);
  548. reset(); cfg.armed = 1; log_ok = 0; act(&fake_sample); CHECK(real_requests == 1);
  549. reset(); cfg.armed = 1; partial = 1; fake_now++; scan_processes(0);
  550. act(&fake_sample); CHECK(real_requests == 1 && !scan_complete);
  551. reset(); cfg.armed = 1; fail_sample = 1; act(&fake_sample); CHECK(real_requests == 0);
  552. reset(); cfg.armed = 1; fail_validation = 1; act(&fake_sample); CHECK(real_requests == 0);
  553. reset(); cfg.armed = 1; fake_sample.free = 150000; act(&fake_sample); CHECK(real_requests == 0);
  554. reset(); cfg.armed = 1; fake_now += 16; act(&fake_sample); CHECK(real_requests == 1);
  555. reset(); cfg.armed = 1; stopping = 1; act(&fake_sample); CHECK(real_requests == 0);
  556. reset(); fake_sample.free = 20000; act(&fake_sample);
  557. CHECK(!controller.has_pending && controller.nvictims == 1);
  558. puts("PASS armed-path mock requests, explicit warmup, stale cache, logging/sampling failures, stop and fresh floor");
  559. reset(); fixtures[1] = fixtures[0]; fixtures[1].pid = 124;
  560. fixtures[1].rss_kib = 900000; fixtures[1].zid = 10;
  561. strcpy(fixtures[1].uuid, cfg.zones[1].uuid); nfixtures = 2;
  562. fake_now = 101; scan_processes(0); chosen = candidate(); CHECK(chosen && chosen->pid == 124);
  563. /* Small zone grows fast enough to outweigh a larger steady zone. */
  564. fixtures[0].rss_kib = 600000; fake_now = 161; scan_processes(0);
  565. chosen = candidate(); CHECK(chosen && chosen->pid == 123);
  566. cfg.zones[0].policy = PROTECT; fake_now = 162; scan_processes(0);
  567. chosen = candidate(); CHECK(chosen && chosen->pid == 124);
  568. fixtures[1].zid = 0; fake_now = 163; scan_processes(0); CHECK(candidate() == NULL);
  569. puts("PASS global score uses process RSS/growth; protected zones and global zone excluded");
  570. load_global_ranking_fixture();
  571. CHECK(candidate_cache[0].valid && candidate_cache[1].valid && candidate_cache[2].valid);
  572. CHECK(!strcmp(candidate_cache[0].p.name, "clamd"));
  573. CHECK(!strcmp(candidate_cache[1].p.name, "clamd"));
  574. CHECK(!strcmp(candidate_cache[2].p.name, "clamd"));
  575. CHECK(candidate_cache[0].p.rss_kib > 1300000 &&
  576. candidate_cache[2].p.rss_kib > 1300000);
  577. CHECK(strcmp(candidate_cache[0].p.uuid, candidate_cache[1].p.uuid));
  578. CHECK(strcmp(candidate_cache[1].p.uuid, candidate_cache[2].p.uuid));
  579. for (second = 0; second < CACHED_CANDIDATES; second++) {
  580. CHECK(strcmp(candidate_cache[second].p.name, "mysqld"));
  581. CHECK(strcmp(candidate_cache[second].p.name, "zone-overhead"));
  582. }
  583. for (second = 0; second < nfixtures; second++)
  584. if (!strcmp(fixtures[second].name, "mysqld"))
  585. CHECK(protected_process(&cfg, &fixtures[second]));
  586. CHECK(fflush(log) == 0 && fseek(log, 0, SEEK_SET) == 0);
  587. n = fread(contents, 1, sizeof (contents) - 1, log); contents[n] = 0;
  588. {
  589. char *mysql = strstr(contents, "comm=mysqld");
  590. char *ineligible = mysql ? strstr(mysql, "eligible=0") : NULL;
  591. char *line_end = mysql ? strchr(mysql, '\n') : NULL;
  592. CHECK(mysql && ineligible && line_end && ineligible < line_end);
  593. }
  594. CHECK(fseek(log, 0, SEEK_END) == 0);
  595. fixtures[nfixtures] = fixtures[0]; fixtures[nfixtures].pid = 9001;
  596. fixtures[nfixtures].zid = 90; fixtures[nfixtures].zone_generation = 900;
  597. fixtures[nfixtures].rss_kib = UINT64_C(9000000);
  598. strcpy(fixtures[nfixtures].uuid, "66666666-6666-4666-8666-666666666666");
  599. strcpy(fixtures[nfixtures].name, "unmapped-hog"); nfixtures++;
  600. fixtures[nfixtures] = fixtures[0]; fixtures[nfixtures].pid = 9002;
  601. fixtures[nfixtures].zid = 0; fixtures[nfixtures].rss_kib = UINT64_C(11000000);
  602. strcpy(fixtures[nfixtures].name, "global-hog"); nfixtures++;
  603. fake_now = 101; scan_processes(0);
  604. for (second = 0; second < CACHED_CANDIDATES; second++)
  605. CHECK(candidate_cache[second].p.pid != 9001 && candidate_cache[second].p.pid != 9002);
  606. for (second = 0; second < nfixtures; second++)
  607. if (fixtures[second].pid == 1103) fixtures[second].rss_kib = 600000;
  608. fake_now = 106; scan_processes(0);
  609. CHECK(candidate_cache[0].p.pid == 1103);
  610. CHECK(candidate_cache[0].growth5_component > 0 &&
  611. candidate_cache[0].total_score > candidate_cache[1].total_score);
  612. {
  613. cached_candidate_t scored;
  614. zone_t zone;
  615. memset(&scored, 0, sizeof (scored)); memset(&zone, 0, sizeof (zone));
  616. scored.p.rss_kib = 100000; scored.d5.valid = scored.d15.valid = 1;
  617. scored.d60.valid = 1; scored.d5.value = 1000;
  618. scored.d15.value = 2000; scored.d60.value = 3000;
  619. scan_at = 60; history_add(&zone.history, 0, 1000000);
  620. history_add(&zone.history, 60, 1100000); zone.rss = 1100000;
  621. score_candidate(&scored, &zone);
  622. CHECK(scored.growth5_component == 4000);
  623. CHECK(scored.growth15_component == 4000);
  624. CHECK(scored.growth60_component == 3000);
  625. CHECK(scored.zone_component <= scored.p.rss_kib / 4);
  626. }
  627. CHECK(fflush(log) == 0 && fseek(log, 0, SEEK_SET) == 0);
  628. n = fread(contents, 1, sizeof (contents) - 1, log); contents[n] = 0;
  629. CHECK(strstr(contents, "rss_component=") != NULL);
  630. CHECK(strstr(contents, "growth5_component=") != NULL);
  631. CHECK(strstr(contents, "growth15_component=") != NULL);
  632. CHECK(strstr(contents, "growth60_component=") != NULL);
  633. CHECK(strstr(contents, "zone_component=") != NULL);
  634. CHECK(strstr(contents, "total_score=") != NULL);
  635. CHECK(fseek(log, 0, SEEK_END) == 0);
  636. puts("PASS SmartOS fixture produces a global cross-zone top-3 and bounded zone context");
  637. reset(); fixtures[1] = fixtures[0]; fixtures[1].pid = 124;
  638. fixtures[1].rss_kib = 900000; fixtures[1].zid = 10;
  639. strcpy(fixtures[1].uuid, cfg.zones[1].uuid);
  640. fixtures[2] = fixtures[0]; fixtures[2].pid = 125; fixtures[2].rss_kib = 800000;
  641. nfixtures = 3; fake_now = 101; scan_processes(0);
  642. CHECK(candidate_cache[0].valid && candidate_cache[1].valid && candidate_cache[2].valid);
  643. invalid_pid = candidate_cache[0].p.pid;
  644. partial = 1; fake_now = 102; scan_processes(0);
  645. CHECK(!scan_complete && candidate_cache[0].p.pid == invalid_pid);
  646. {
  647. unsigned walks_before = walk_requests;
  648. engine.state = EMERGENCY; engine.danger = 1; fake_sample.free = 40000;
  649. act(&fake_sample);
  650. CHECK(walk_requests == walks_before); /* O(1): no /proc walk in action path. */
  651. CHECK(controller.has_pending && controller.pending.pid != invalid_pid);
  652. CHECK(validation_requests >= 2 && real_requests == 0);
  653. }
  654. CHECK(fflush(log) == 0 && fseek(log, 0, SEEK_SET) == 0);
  655. n = fread(contents, 1, sizeof (contents) - 1, log); contents[n] = 0;
  656. CHECK(strstr(contents, "candidate_source=fallback_candidate") != NULL);
  657. CHECK(strstr(contents, "scan_complete=0") != NULL);
  658. CHECK(fseek(log, 0, SEEK_END) == 0);
  659. puts("PASS incomplete scan preserves cache; emergency uses O(1) fallback without a new walk");
  660. reset(); fixtures[1] = fixtures[0]; fixtures[1].pid = 124;
  661. fixtures[1].rss_kib = 900000; fixtures[1].zid = 10;
  662. strcpy(fixtures[1].uuid, cfg.zones[1].uuid); nfixtures = 2;
  663. fake_now = 101; scan_processes(0);
  664. for (second = 0; second < nfixtures; second++)
  665. if (fixtures[second].pid == candidate_cache[0].p.pid) fixtures[second].start_nsec++;
  666. engine.state = EMERGENCY; engine.danger = 1; fake_sample.free = 40000;
  667. act(&fake_sample);
  668. CHECK(controller.has_pending && !same_process(&controller.pending, &candidate_cache[0].p));
  669. puts("PASS PID/start-time reuse rejects rank 1 and selects cached fallback");
  670. reset();
  671. CHECK(platform_syslog_open("o6h-memory-guard", cfg.syslog_facility) == 0);
  672. syslog_ready = 1;
  673. CHECK(!strcmp(syslog_ident, "o6h-memory-guard") && syslog_facility == 5 &&
  674. syslog_open_count == 1);
  675. emit_important(LOG_INFO, "event=start version=%s mode=dry-run", VERSION);
  676. CHECK(syslog_count == 1 && syslog_records[0].priority == LOG_INFO &&
  677. strstr(syslog_records[0].message, "event=start version=" VERSION) != NULL);
  678. log_sample(&fake_sample); scan_processes(0);
  679. CHECK(syslog_count == 1); /* High-volume sample/delta/proc/cache events stay local. */
  680. {
  681. char message[512]; sample_t s = fake_sample;
  682. s.free = s.min;
  683. CHECK(!transition_message(message, sizeof (message), NORMAL, EMERGENCY, &s, 1));
  684. CHECK(strstr(message, "reason=threshold_jump") != NULL);
  685. CHECK(strstr(message, "skipped_states=PRE-PRESSURE,PRESSURE,CRITICAL") != NULL);
  686. syslog_event(state_priority(EMERGENCY, 0), "%s", message);
  687. CHECK(syslog_count == 2 && syslog_records[1].priority == LOG_CRIT);
  688. }
  689. cfg.armed = 0; act(&fake_sample);
  690. CHECK(syslog_count == 3 && real_requests == 0);
  691. reset(); cfg.armed = 1; started = 80; fake_now = 100;
  692. CHECK(platform_syslog_open("o6h-memory-guard", cfg.syslog_facility) == 0);
  693. syslog_ready = 1; act(&fake_sample);
  694. CHECK(real_requests == 0 && syslog_count == 1 &&
  695. syslog_records[0].priority == LOG_WARNING &&
  696. strstr(syslog_records[0].message, "event=action_blocked reason=armed_warmup") != NULL);
  697. reset(); cfg.armed = 1;
  698. CHECK(platform_syslog_open("o6h-memory-guard", cfg.syslog_facility) == 0);
  699. syslog_ready = 1; act(&fake_sample);
  700. CHECK(real_requests == 1 && syslog_count == 3);
  701. CHECK(strstr(syslog_records[0].message, "event=victim_budget tier=normal") != NULL);
  702. CHECK(syslog_records[1].priority == LOG_ERR &&
  703. strstr(syslog_records[1].message, "event=action_decision state=CRITICAL") != NULL &&
  704. strstr(syslog_records[1].message, "result=sent") != NULL);
  705. CHECK(syslog_records[2].priority == LOG_ERR &&
  706. strstr(syslog_records[2].message, "event=signal_sent state=CRITICAL") != NULL &&
  707. strstr(syslog_records[2].message, "signal=SIGTERM") != NULL &&
  708. strstr(syslog_records[2].message, "UUID=") != NULL &&
  709. strstr(syslog_records[2].message, "alias=web-a") != NULL &&
  710. strstr(syslog_records[2].message, "pid=123") != NULL &&
  711. strstr(syslog_records[2].message, "comm=php-fpm") != NULL &&
  712. strstr(syslog_records[2].message, "rss_kib=100000") != NULL &&
  713. strstr(syslog_records[2].message, "free_pages=60000") != NULL);
  714. reset(); cfg.armed = 1; fail_syslog = 1; syslog_ready = 1;
  715. act(&fake_sample); CHECK(real_requests == 1 && controller.has_pending);
  716. reset(); cfg.syslog_enabled = 0; syslog_ready = 0;
  717. emit_important(LOG_INFO, "event=start disabled_test=yes"); CHECK(syslog_count == 0);
  718. CHECK(state_priority(PRE_PRESSURE, 0) == LOG_NOTICE);
  719. CHECK(state_priority(PRESSURE, 0) == LOG_WARNING);
  720. CHECK(state_priority(CRITICAL, 0) == LOG_ERR);
  721. CHECK(state_priority(EMERGENCY, 0) == LOG_CRIT);
  722. CHECK(state_priority(RECOVERY, 0) == LOG_INFO);
  723. CHECK(state_priority(NORMAL, 1) == LOG_CRIT);
  724. log_sampling_overrun(4.459, &fake_sample);
  725. CHECK(fflush(log) == 0 && fseek(log, 0, SEEK_SET) == 0);
  726. n = fread(contents, 1, sizeof (contents) - 1, log); contents[n] = 0;
  727. CHECK(strstr(contents, "event=sampling_overrun late_seconds=4.459 state=CRITICAL free_pages=60000") != NULL);
  728. puts("PASS selective native syslog ident/facility/severity, exclusions, signal ordering, disable and failure isolation");
  729. critical_path_faults();
  730. floor_errno_fixture();
  731. diagnostic_fixtures();
  732. panic33_fixture();
  733. partial_cache_tests();
  734. panic34_fixture();
  735. fclose(log);
  736. printf("PASS %u runtime checks; all platform calls mocked, no signals sent\n", checks);
  737. return 0;
  738. }