static void testservice_id_task (void *cls, int result) { const struct GNUNET_CONFIGURATION_Handle *cfg = cls; if (result != GNUNET_YES) { fprintf (stderr, _("Identity service is not running\n")); GNUNET_SCHEDULER_shutdown (); ret = -1; return; } GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &do_shutdown, (void *) cfg); if (NULL == ego_name) { idh = GNUNET_IDENTITY_connect (cfg, &id_connect_cb, (void *) cfg); if (NULL == idh) fprintf (stderr, _("Cannot connect to identity service\n")); ret = -1; return; } el = GNUNET_IDENTITY_ego_lookup (cfg, ego_name, &identity_cb, (void *) cfg); }
/** * Main function that will be run by the scheduler. * * @param cls closure * @param args remaining command-line arguments * @param cfgfile name of the configuration file used (for saving, can be NULL!) * @param cfg configuration */ static void run (void *cls, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) { if ( (NULL == set_subsystem) ^ (NULL == set_ego) ) { fprintf (stderr, "Options -e and -s must always be specified together\n"); return; } sh = GNUNET_IDENTITY_connect (cfg, &print_ego, NULL); if (NULL != delete_ego) delete_op = GNUNET_IDENTITY_delete (sh, delete_ego, &delete_finished, &delete_op); if (NULL != create_ego) create_op = GNUNET_IDENTITY_create (sh, create_ego, &create_finished, &create_op); GNUNET_SCHEDULER_add_shutdown (&shutdown_task, NULL); test_finished (); }
static void run (void *cls, const struct GNUNET_CONFIGURATION_Handle *c, struct GNUNET_TESTING_Peer *peer) { cfg = c; GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_test, NULL); id = GNUNET_IDENTITY_connect (cfg, &identity_cb, NULL); op = GNUNET_IDENTITY_create (id, "phone-ego", &phone_ego_create_cont, NULL); ns = GNUNET_NAMESTORE_connect (cfg); }
/** * Main function of the test, run from scheduler. * * @param cls NULL * @param cfg configuration we use (also to connect to identity service) * @param peer handle to access more of the peer (not used) */ static void run (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg, struct GNUNET_TESTING_Peer *peer) { endbadly_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &endbadly, NULL); GNUNET_SCHEDULER_add_shutdown (&end_normally, NULL); h = GNUNET_IDENTITY_connect (cfg, ¬ification_cb, NULL); GNUNET_assert (NULL != h); op = GNUNET_IDENTITY_create (h, "test-id", &create_cb, NULL); }
/** * Main function that will be run * * @param cls closure * @param args remaining command-line arguments * @param cfgfile name of the configuration file used (for saving, can be NULL) * @param c configuration */ static void run (void *cls, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *c) { cfg = c; //Connect to identity and namestore services ns_handle = GNUNET_NAMESTORE_connect (cfg); if (NULL == ns_handle) { GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "error connecting to namestore"); } identity_handle = GNUNET_IDENTITY_connect (cfg, &list_ego, NULL); GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &do_shutdown, NULL); }
static void run (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg, struct GNUNET_TESTING_Peer *peer) { enum MHD_FLAG flags; char *bin; char *bin_identity; char *bin_gns; char *config; if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string (cfg, "arm", "CONFIG", &config)) { fprintf (stderr, "Failed to locate configuration file. Skipping test.\n"); GNUNET_SCHEDULER_shutdown (); return; } char *const identity_args[] = { "gnunet-identity", "-C", "master-zone", "-c", config, NULL }; char *const identity2_args[] = { "gnunet-identity", "-e", "master-zone", "-s", "gns-master", "-c", config, NULL }; char *const identity3_args[] = { "gnunet-identity", "-e", "master-zone", "-s", "gns-intercept", "-c", config, NULL }; char *const gns_args[] = { "gnunet-gns", "-u", "www.gns", "-c", config, NULL }; GNUNET_TESTING_peer_get_identity (peer, &id); GNUNET_SCHEDULER_add_delayed (TIMEOUT, &do_shutdown, NULL); bin = GNUNET_OS_installation_get_path (GNUNET_OS_IPK_BINDIR); GNUNET_asprintf (&bin_identity, "%s/%s", bin, "gnunet-identity"); if (0 != fork_and_exec (bin_identity, identity_args)) { fprintf (stderr, "Failed to run `gnunet-identity -C. Skipping test.\n"); GNUNET_SCHEDULER_shutdown (); GNUNET_free (bin_identity); GNUNET_free (config); GNUNET_free (bin); return; } if (0 != fork_and_exec (bin_identity, identity2_args)) { fprintf (stderr, "Failed to run `gnunet-identity -e. Skipping test.\n"); GNUNET_SCHEDULER_shutdown (); GNUNET_free (bin_identity); GNUNET_free (config); GNUNET_free (bin); return; } if (0 != fork_and_exec (bin_identity, identity3_args)) { fprintf (stderr, "Failed to run `gnunet-identity -e. Skipping test.\n"); GNUNET_SCHEDULER_shutdown (); GNUNET_free (bin_identity); GNUNET_free (config); GNUNET_free (bin); return; } GNUNET_free (bin_identity); /* do lookup just to launch GNS service */ GNUNET_asprintf (&bin_gns, "%s/%s", bin, "gnunet-gns"); if (0 != fork_and_exec (bin_gns, gns_args)) { fprintf (stderr, "Failed to run `gnunet-gns -u. Skipping test.\n"); GNUNET_SCHEDULER_shutdown (); GNUNET_free (bin_gns); GNUNET_free (config); GNUNET_free (bin); return; } GNUNET_free (bin_gns); GNUNET_free (config); GNUNET_free (bin); namestore = GNUNET_NAMESTORE_connect (cfg); GNUNET_assert (NULL != namestore); flags = MHD_USE_DEBUG; if (GNUNET_YES == use_v6) flags |= MHD_USE_DUAL_STACK; mhd = MHD_start_daemon (flags, PORT, NULL, NULL, &mhd_ahc, NULL, MHD_OPTION_END); GNUNET_assert (NULL != mhd); mhd_main (); identity = GNUNET_IDENTITY_connect (cfg, &identity_cb, NULL); }