const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg)
{
struct GNUNET_TESTING_Host *hosts;
+ struct GNUNET_TESTING_Host *hostpos;
struct GNUNET_TESTING_Host *temphost;
char *hostfile;
struct stat frstat;
&num_peers))
num_peers = DEFAULT_NUM_PEERS;
+ GNUNET_assert(num_peers > 0 && num_peers < (unsigned long long)-1);
if (GNUNET_OK !=
GNUNET_CONFIGURATION_get_value_string (cfg, "testing", "hostfile",
&hostfile))
hostfile = NULL;
hosts = NULL;
+ data = NULL;
if (hostfile != NULL)
{
if (GNUNET_OK != GNUNET_DISK_file_test (hostfile))
NULL,
NULL,
hosts);
+ hostpos = hosts;
+ while (hostpos != NULL)
+ {
+ temphost = hostpos->next;
+ GNUNET_free(hostpos);
+ hostpos = temphost;
+ }
+ GNUNET_free_non_null(data);
GNUNET_assert (pg != NULL);
}
"Called finish testing, stopping daemons.\n");
#endif
- int count;
- count = 0;
pos = test_messages;
while (pos != NULL)
{
GNUNET_SCHEDULER_cancel (sched, die_task);
GNUNET_asprintf(&dotOutFileNameFinished, "%s.dot", "final_topology");
dotOutFileFinished = fopen (dotOutFileNameFinished, "w");
+ GNUNET_free(dotOutFileNameFinished);
if (dotOutFileFinished != NULL)
{
fprintf(dotOutFileFinished, "strict graph G {\n");
GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, SECONDS_PER_PEER_START * num_peers),
&end_badly, "didn't generate all hostkeys within a reasonable amount of time!!!");
+ GNUNET_assert(num_peers > 0 && num_peers < (unsigned int)-1);
pg = GNUNET_TESTING_daemons_start (sched, cfg,
peers_left, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, SECONDS_PER_PEER_START * num_peers), &hostkey_callback, NULL, &peers_started_callback, NULL,
&topology_callback, NULL, NULL);
char *our_binary_name;
binary_start_pos = rindex(argv[0], '/');
+ GNUNET_assert(binary_start_pos != NULL);
topology_string = strstr (binary_start_pos,
"_topology");
GNUNET_assert (topology_string != NULL);
main_cfg = cfg;
+ GNUNET_assert(num_peers > 0 && num_peers < (unsigned int)-1);
peers_left = num_peers;
/* For this specific test we only really want a CLIQUE topology as the
main_cfg = cfg;
peers_left = num_peers;
+ GNUNET_assert(num_peers > 0 && num_peers < (unsigned int)-1);
/* For this specific test we only really want a CLIQUE topology as the
* overlay allowed topology, and a RING topology as the underlying connection
send_hello(void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
{
struct ConnectContext *ctx = cls;
-
+ struct GNUNET_MessageHeader *hello;
ctx->hello_send_task = GNUNET_SCHEDULER_NO_TASK;
if (tc->reason == GNUNET_SCHEDULER_REASON_SHUTDOWN)
return;
- if (ctx->d1->hello != NULL)
+ if ((ctx->d1->hello != NULL) && (NULL != GNUNET_HELLO_get_header(ctx->d1->hello)))
{
- GNUNET_TRANSPORT_offer_hello (ctx->d2th, GNUNET_HELLO_get_header(ctx->d1->hello));
+ hello = GNUNET_HELLO_get_header(ctx->d1->hello);
+ GNUNET_assert(hello != NULL);
+ GNUNET_TRANSPORT_offer_hello (ctx->d2th, hello);
ctx->timeout_hello = GNUNET_TIME_relative_add(ctx->timeout_hello,
GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS,
500));
unsigned int distance;
double probability, random, percentage;
unsigned int smallWorldConnections;
+ unsigned int small_world_it;
char *p_string;
int connect_attempts;
square = floor (sqrt (pg->total));
"TESTING");
GNUNET_free (p_string);
}
+ if (percentage < 0.0)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ _("Invalid value `%s' for option `%s' in section `%s': got %f, needed value greater than 0\n"),
+ "PERCENTAGE", "TESTING", percentage);
+ percentage = 0.5;
+ }
probability = 0.5; /* FIXME: default percentage? */
if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string(pg->cfg,
"TESTING",
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _("Total connections added thus far: %u!\n"), connect_attempts);
#endif
smallWorldConnections = 0;
- for (i = 0; i < (int) (natLog * percentage); i++)
+ small_world_it = (unsigned int)(natLog * percentage);
+ GNUNET_assert(small_world_it > 0 && small_world_it < (unsigned int)-1);
+ for (i = 0; i < small_world_it; i++)
{
for (j = 0; j < pg->total; j++)
{
int unblacklisted_connections;
GNUNET_assert (pg->notify_connection != NULL);
- ret = GNUNET_OK;
switch (topology)
{
}
}
+ GNUNET_assert(running >= voff);
for (i = 0; i < voff; i++)
{
#if DEBUG_CHURN
GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Stopping peer %d!\n", running_permute[i]);
#endif
+ GNUNET_assert(running_arr != NULL);
GNUNET_TESTING_daemon_stop (pg->peers[running_arr[running_permute[i]]].daemon,
timeout,
&churn_stop_callback, churn_ctx,
GNUNET_NO, GNUNET_YES);
}
+ GNUNET_assert(stopped >= von);
for (i = 0; i < von; i++)
{
#if DEBUG_CHURN
GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Starting up peer %d!\n", stopped_permute[i]);
#endif
+ GNUNET_assert(stopped_arr != NULL);
GNUNET_TESTING_daemon_start_stopped(pg->peers[stopped_arr[stopped_permute[i]]].daemon,
timeout, &churn_start_callback, churn_ctx);
}
schedule_shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc)
{
struct PeerShutdownContext *peer_shutdown_ctx = cls;
- struct ShutdownContext *shutdown_ctx = peer_shutdown_ctx->shutdown_ctx;
+ struct ShutdownContext *shutdown_ctx;
GNUNET_assert(peer_shutdown_ctx != NULL);
+ shutdown_ctx = peer_shutdown_ctx->shutdown_ctx;
GNUNET_assert(shutdown_ctx != NULL);
if (shutdown_ctx->outstanding > MAX_CONCURRENT_SHUTDOWN)