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

Function cli_scope_fixture_finish

tests/test_cli.c:1955–1994  ·  view source on GitHub ↗

Returns the host child's exit status: 0 released intact, * CLI_SCOPE_HOST_DRAINED when an activation drained it, -1 unknown. */

Source from the content-addressed store, hash-verified

1953/* Returns the host child's exit status: 0 released intact,
1954 * CLI_SCOPE_HOST_DRAINED when an activation drained it, -1 unknown. */
1955static int cli_scope_fixture_finish(cli_scope_fixture_t *fixture) {
1956 if (fixture->client) {
1957 (void)cbm_daemon_runtime_client_close(fixture->client, CLI_SCOPE_TIMEOUT_MS);
1958 fixture->client = NULL;
1959 }
1960 if (fixture->release_fd >= 0) {
1961 /* Closing the write end is the signal (the child's poll sees POLLHUP);
1962 * a write would raise SIGPIPE once a drained child is already gone. */
1963 close(fixture->release_fd);
1964 fixture->release_fd = -1;
1965 }
1966 int host_exit = -1;
1967 if (fixture->host > 0) {
1968 host_exit = cli_scope_reap_host(fixture->host);
1969 fixture->host = -1;
1970 }
1971 cbm_daemon_ipc_endpoint_free(fixture->endpoint);
1972 fixture->endpoint = NULL;
1973 if (fixture->previous_supervisor_build[0]) {
1974 cbm_index_supervisor_set_build_fingerprint_for_test(fixture->previous_supervisor_build);
1975 }
1976 /* Restore only what start saved: a setup that failed before saving left
1977 * HOME, CBM_CACHE_DIR and SHELL untouched, and restoring "nothing saved"
1978 * would unset them for every later test in the suite. */
1979 if (fixture->env_saved) {
1980 if (fixture->old_shell) {
1981 cbm_setenv("SHELL", fixture->old_shell, 1);
1982 } else {
1983 cbm_unsetenv("SHELL");
1984 }
1985 cli_activation_restore_env(fixture->old_home, fixture->old_cache);
1986 fixture->env_saved = false;
1987 }
1988 free(fixture->old_shell);
1989 fixture->old_shell = NULL;
1990 fixture->old_home = NULL;
1991 fixture->old_cache = NULL;
1992 test_rmdir_r(fixture->tmpdir);
1993 return host_exit;
1994}
1995
1996static void cli_scope_foreign_paths(const cli_scope_fixture_t *fixture, char home[512],
1997 char cache[576], char bin_dir[640], char activation_log[704]) {

Callers 1

test_cli.cFile · 0.85

Calls 9

cli_scope_reap_hostFunction · 0.85
cbm_setenvFunction · 0.85
cbm_unsetenvFunction · 0.85
test_rmdir_rFunction · 0.85
closeFunction · 0.50

Tested by

no test coverage detected