} END_TEST START_TEST(test_cc_oci_node_dump) { GNode* node; cc_oci_node_dump(NULL); cc_oci_json_parse(&node, TEST_DATA_DIR "/node.json"); ck_assert(node); cc_oci_node_dump(node); g_free_node(node); } END_TEST
/*! * Handle commands to stop the Hypervisor cleanly. * * \param sub \ref subcommand. * \param config \ref cc_oci_config. * \param argc Argument count. * \param argv Argument vector. * * \return \c true on success, else \c false. */ gboolean handle_command_stop (const struct subcommand *sub, struct cc_oci_config *config, int argc, char *argv[]) { struct oci_state *state = NULL; gchar *config_file = NULL; gboolean ret; GNode* root = NULL; g_assert (sub); g_assert (config); if (handle_default_usage (argc, argv, sub->name, &ret, 1, NULL)) { return ret; } /* Used to allow us to find the state file */ config->optarg_container_id = argv[0]; /* FIXME: deal with containerd calling "delete" twice */ if (! cc_oci_state_file_exists (config)) { g_warning ("state file does not exist for container %s", config->optarg_container_id); /* don't make this fatal to keep containerd happy */ ret = true; goto out; } ret = cc_oci_get_config_and_state (&config_file, config, &state); if (! ret) { goto out; } /* convert json file to GNode */ if (! cc_oci_json_parse(&root, config_file)) { goto out; } #ifdef DEBUG /* show json file converted to GNode */ cc_oci_node_dump(root); #endif /*DEBUG*/ if (! cc_oci_process_config(root, config, stop_spec_handlers)) { g_critical ("failed to process config"); goto out; } g_free_node(root); ret = cc_oci_stop (config, state); if (! ret) { goto out; } ret = true; g_print ("stopped container %s\n", config->optarg_container_id); out: g_free_if_set (config_file); cc_oci_state_free (state); if (! ret) { g_critical ("failed to stop container %s\n", config->optarg_container_id); } return ret; }