/** * Test our plugin's configuration (NAT traversal, etc.). * * @param cfg configuration to test */ static void do_test_configuration (const struct GNUNET_CONFIGURATION_Handle *cfg) { char *plugins; char *tok; unsigned long long bnd_port; unsigned long long adv_port; struct TestContext *tc; if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string (cfg, "transport", "plugins", &plugins)) { FPRINTF (stderr, "%s", _ ("No transport plugins configured, peer will never communicate\n")); ret = 4; return; } for (tok = strtok (plugins, " "); tok != NULL; tok = strtok (NULL, " ")) { char section[12 + strlen (tok)]; GNUNET_snprintf (section, sizeof (section), "transport-%s", tok); if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_number (cfg, section, "PORT", &bnd_port)) { FPRINTF (stderr, _("No port configured for plugin `%s', cannot test it\n"), tok); continue; } if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_number (cfg, section, "ADVERTISED_PORT", &adv_port)) adv_port = bnd_port; if (NULL == resolver) resolver = GNUNET_OS_start_process (GNUNET_YES, GNUNET_OS_INHERIT_STD_OUT_AND_ERR, NULL, NULL, "gnunet-service-resolver", "gnunet-service-resolver", NULL); resolver_users++; GNUNET_RESOLVER_connect (cfg); tc = GNUNET_malloc (sizeof (struct TestContext)); tc->name = GNUNET_strdup (tok); tc->tst = GNUNET_NAT_test_start (cfg, (0 == strcasecmp (tok, "udp")) ? GNUNET_NO : GNUNET_YES, (uint16_t) bnd_port, (uint16_t) adv_port, &result_callback, tc); if (NULL == tc->tst) { display_test_result (tc, GNUNET_SYSERR); continue; } tc->tsk = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &fail_timeout, tc); } GNUNET_free (plugins); }
/** * Function called by NAT on success. * Clean up and update GUI (with success). * * @param cls test context * @param success currently always GNUNET_OK */ static void result_callback (void *cls, int success) { struct TestContext *tc = cls; display_test_result (tc, success); }
void run_subbench(void *h, void *h2) { void *tmpfun; void *vsfun = NULL; for (int i = 0; fun_subbench_table[i].fun_name; i++, current_subtest_id++) { RESET_DIFF; SET_CURRENT_PROTECTED(INVISIBLE); SET_BENCHITER(1); current_fun_name = fun_subbench_table[i].fun_name; tmpfun = dlsym(h, fun_subbench_table[i].fun_name); if (h2) vsfun = dlsym(h2, fun_subbench_table[i].fun_name); if (tmpfun) fun_subbench_table[i].fun_bench_ptr(tmpfun, vsfun); else ft_raise(TEST_MISSING); } current_fun_name = ""; display_test_result(TEST_FINISHED, ""); printf("\nSee %s for more informations !\n", LOG_FILE); dprintf(g_log_fd, "\n"); close(g_log_fd); exit(0); }
void run_subtests(void *h, int start) { void *tmpfun; static void *handle = NULL; if (!handle) handle = h; for (int i = start; fun_subtest_table[i].fun_name; i++, current_subtest_id++) { MALLOC_RESET; RESET_DIFF; SET_CURRENT_PROTECTED(INVISIBLE); current_part = fun_subtest_table[i].part; current_fun_name = fun_subtest_table[i].fun_name; tmpfun = dlsym(handle, fun_subtest_table[i].fun_name); if (tmpfun) fun_subtest_table[i].fun_test_ptr(tmpfun); else if (fun_subtest_table[i].visible) ft_raise(TEST_MISSING); } current_fun_name = ""; display_test_result(TEST_FINISHED, ""); printf("\nSee %s for more informations !\n", LOG_FILE); dprintf(g_log_fd, "\n"); close(g_log_fd); exit(0); }
/** * Function called if NAT failed to confirm success. * Clean up and update GUI (with failure). * * @param cls test context * @param tc scheduler callback */ static void fail_timeout (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) { struct TestContext *tstc = cls; tstc->tsk = GNUNET_SCHEDULER_NO_TASK; display_test_result (tstc, GNUNET_NO); }
void ft_raise(int s) { display_test_result(s, current_explication); }