MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / main

Function main

tests/windows/test_daemon_stability.py:538–593  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

536
537
538def main():
539 if len(sys.argv) < 2:
540 print("usage: python test_daemon_stability.py <binary>")
541 return 2
542 binary = os.path.abspath(sys.argv[1])
543 if not os.path.exists(binary):
544 print("FAIL: binary not found: %s" % binary)
545 return 2
546
547 # POSIX is for local iteration only, and there the rendezvous is a Unix
548 # socket whose path is capped at 104 bytes on macOS (sun_path); the default
549 # TMPDIR is already ~50 bytes deep, so keep the whole namespace under /tmp.
550 # On Windows TEMP is the guard root the runner hardened; leave it alone.
551 work = tempfile.mkdtemp(prefix="cbm_daemon_stab_",
552 dir=None if os.name == "nt" else "/tmp")
553 sections = [
554 section_params,
555 section_hook_fail_open,
556 section_start_status_port,
557 section_start_port_waits_for_settings_writer,
558 section_stop_refuses_busy,
559 section_crash_recovery,
560 section_churn_stability,
561 section_cold_storm,
562 ]
563 failed = []
564 setup_failed = []
565 try:
566 for section in sections:
567 try:
568 ok = section(binary, work)
569 except SetupFailure as exc:
570 print("\nSETUP FAIL (%s): %s" % (section.__name__, exc))
571 setup_failed.append(section.__name__)
572 continue
573 except subprocess.TimeoutExpired as exc:
574 # The section's own finally already fired its kill backstop.
575 print("\nRED: %s hung -- %s timed out after %ss:\n%s"
576 % (section.__name__, exc.cmd, exc.timeout,
577 excerpt((exc.stdout or b"") + (exc.stderr or b""))))
578 ok = False
579 if not ok:
580 failed.append(section.__name__)
581 if failed:
582 print("\nRED (tests/windows/test_daemon_stability.py): %s failed"
583 % ", ".join(failed))
584 return 1
585 if setup_failed:
586 print("\nSETUP FAIL (tests/windows/test_daemon_stability.py): %s could not "
587 "run -- `daemon start` did not hold; the lifecycle guard owns that red"
588 % ", ".join(setup_failed))
589 return 2
590 print("\nGREEN: daemon stability, parameters, and failure modes behave.")
591 return 0
592 finally:
593 shutil.rmtree(work, ignore_errors=True)
594
595

Callers 1

Calls 2

excerptFunction · 0.85
sectionFunction · 0.50

Tested by

no test coverage detected