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

Function main

tests/test_daemon_smoke.py:692–2391  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

690
691
692def main():
693 if os.name == "nt" or sys.platform.startswith(("cygwin", "msys")):
694 if os.environ.get("CBM_DAEMON_SMOKE_REQUIRE_RUN") == "1":
695 raise SmokeFailure(
696 "required daemon smoke is POSIX-only; Windows needs a separate "
697 "real-binary named-pipe/Job Object smoke"
698 )
699 print("SKIP: daemon smoke currently validates POSIX socket/lock lifecycle only")
700 return 0
701
702 root = Path(__file__).resolve().parent.parent
703 binary = Path(sys.argv[1] if len(sys.argv) > 1 else root / "build/c/codebase-memory-mcp")
704 binary = binary.resolve()
705 check(binary.is_file() and os.access(binary, os.X_OK), "missing executable: " + str(binary))
706
707 runtime_parent = Path("/private/tmp" if sys.platform == "darwin" else "/tmp")
708 runtime_dir = runtime_parent / ("cbm-daemon-" + str(os.geteuid()))
709 socket_path = runtime_dir / ("cbm-" + RENDEZVOUS_KEY + ".sock")
710 startup_lock = runtime_dir / ("cbm-" + RENDEZVOUS_KEY + ".lock")
711 lifetime_lock = runtime_dir / ("cbm-" + RENDEZVOUS_KEY + ".lifetime.lock")
712 cohort_admission_lock = runtime_dir / "cbm-version-cohort-admission-v1.lock"
713 cohort_lifetime_lock = runtime_dir / "cbm-version-cohort-lifetime-v1.lock"
714 cohort_maintenance_lock = runtime_dir / "cbm-version-cohort-maintenance-v1.lock"
715 cohort_daemon_lock = runtime_dir / "cbm-version-cohort-daemon-v1.lock"
716 coordination_locks = (
717 (startup_lock, False),
718 (lifetime_lock, True),
719 (cohort_admission_lock, True),
720 (cohort_lifetime_lock, True),
721 (cohort_maintenance_lock, True),
722 (cohort_daemon_lock, True),
723 )
724
725 coordination_before = [
726 (path, lock_status(path, record_lock))
727 for path, record_lock in coordination_locks
728 ]
729 if any(status == "held" for _, status in coordination_before):
730 if os.environ.get("CBM_DAEMON_SMOKE_REQUIRE_RUN") == "1":
731 raise SmokeFailure(
732 "another CBM process or activation is active or starting; "
733 "required smoke needs a clean account-wide rendezvous"
734 )
735 print("SKIP: another CBM process or activation is active or starting")
736 return 0
737 for path, status in coordination_before:
738 check(status == "free", "unsafe coordination lock {}: {}".format(path, status))
739
740 clients = []
741 with tempfile.TemporaryDirectory(prefix="cbm-daemon-smoke-") as raw_tmpdir:
742 tmpdir = Path(raw_tmpdir)
743 home = tmpdir / "home"
744 cache = tmpdir / "cache"
745 cache_alias = tmpdir / "cache-alias"
746 mismatched_cache = tmpdir / "mismatched-cache"
747 retargeted_cache = tmpdir / "retargeted-cache"
748 repo = tmpdir / "repo"
749 success_repo = tmpdir / "success-repo"

Callers 1

Calls 15

sendMethod · 0.95
wait_responseMethod · 0.95
has_responseMethod · 0.95
close_inputMethod · 0.95
waitMethod · 0.95
lock_statusFunction · 0.85
McpClientClass · 0.85
assert_rpc_successFunction · 0.85
wait_untilFunction · 0.85
json_eventsFunction · 0.85
process_gone_or_zombieFunction · 0.85

Tested by

no test coverage detected