} END_TEST START_TEST(test_cc_oci_config_file_path) { gchar *p; ck_assert (! cc_oci_config_file_path (NULL)); p = cc_oci_config_file_path ("/tmp"); ck_assert (p); ck_assert (! g_strcmp0 (p, "/tmp/config.json")); g_free (p); } END_TEST
/*! * Determine the containers config file, its configuration * and state. * * \param[out] config_file Dynamically-allocated path to containers * config file. * \param[out] config \ref cc_oci_config. * \param[out] state \ref oci_state. * * \note Used by the "stop" command. * * \return \c true on success, else \c false. */ gboolean cc_oci_get_config_and_state (gchar **config_file, struct cc_oci_config *config, struct oci_state **state) { if ((!config_file) || (!config) || (!state)) { return false; } if (! cc_oci_runtime_path_get (config)) { return false; } if (! cc_oci_state_file_get (config)) { return false; } *state = cc_oci_state_file_read (config->state.state_file_path); if (! (*state)) { g_critical("failed to read state file for container %s", config->optarg_container_id); goto err; } /* Fill in further details to make the config valid */ config->bundle_path = g_strdup ((*state)->bundle_path); config->state.workload_pid = (*state)->pid; config->state.status = (*state)->status; g_strlcpy (config->state.comms_path, (*state)->comms_path, sizeof (config->state.comms_path)); g_strlcpy (config->state.procsock_path, (*state)->procsock_path, sizeof (config->state.procsock_path)); *config_file = cc_oci_config_file_path ((*state)->bundle_path); if (! (*config_file)) { goto err; } return true; err: cc_oci_state_free (*state); g_free_if_set (*config_file); return false; }