From: Christian Grothoff Date: Sat, 27 Oct 2012 21:00:50 +0000 (+0000) Subject: -test case cleanup X-Git-Tag: initial-import-from-subversion-38251~11164 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=74e3276f887c7852a1359d39c9c7c57b856ee23e;p=oweals%2Fgnunet.git -test case cleanup --- diff --git a/src/gns/test_gns_cname_lookup.c b/src/gns/test_gns_cname_lookup.c index 36cdcde05..5a864b556 100644 --- a/src/gns/test_gns_cname_lookup.c +++ b/src/gns/test_gns_cname_lookup.c @@ -1,6 +1,6 @@ /* This file is part of GNUnet. - (C) 2009 Christian Grothoff (and other contributing authors) + (C) 2012 Christian Grothoff (and other contributing authors) GNUnet is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published @@ -20,7 +20,7 @@ /** * @file gns/test_gns_cname_lookup.c * @brief base testcase for testing a local GNS record lookup - * + * @author Martin Schanzenbach */ #include "platform.h" #include "gnunet_testing_lib-new.h" @@ -31,15 +31,12 @@ #include "gnunet_dnsparser_lib.h" #include "gnunet_gns_service.h" -/* DEFINES */ -#define VERBOSE GNUNET_YES -/* Timeout for entire testcase */ +/** + * Timeout for entire testcase + */ #define TIMEOUT GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 20) -/* If number of peers not in config file, use this number */ -#define DEFAULT_NUM_PEERS 2 - /* test records to resolve */ #define TEST_DOMAIN_PLUS "www.gads" #define TEST_DOMAIN_ZKEY "www2.gads" @@ -58,10 +55,9 @@ #define KEYFILE_BOB "zonefiles/188JSUMKEF25GVU8TTV0PBNNN8JVCPUEDFV1UHJJU884JD25V0T0.zkey" -/* Globals */ /* Task handle to use to schedule test failure */ -GNUNET_SCHEDULER_TaskIdentifier die_task; +static GNUNET_SCHEDULER_TaskIdentifier die_task; /* Global return value (0 for success, anything else for failure) */ static int ok; @@ -70,7 +66,8 @@ static struct GNUNET_NAMESTORE_Handle *namestore_handle; static struct GNUNET_GNS_Handle *gns_handle; -const struct GNUNET_CONFIGURATION_Handle *cfg; +static const struct GNUNET_CONFIGURATION_Handle *cfg; + /** * Check if the get_handle is being used, if so stop the request. Either @@ -83,10 +80,9 @@ end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) die_task = GNUNET_SCHEDULER_NO_TASK; if (NULL != gns_handle) { - GNUNET_GNS_disconnect(gns_handle); + GNUNET_GNS_disconnect (gns_handle); gns_handle = NULL; } - if (NULL != namestore_handle) { GNUNET_NAMESTORE_disconnect (namestore_handle); @@ -97,6 +93,7 @@ end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) ok = 1; } + static void end_badly_now () { @@ -104,26 +101,30 @@ end_badly_now () die_task = GNUNET_SCHEDULER_add_now (&end_badly, NULL); } -static void shutdown_task (void *cls, - const struct GNUNET_SCHEDULER_TaskContext *tc) + +static void +shutdown_task (void *cls, + const struct GNUNET_SCHEDULER_TaskContext *tc) { - GNUNET_GNS_disconnect(gns_handle); + GNUNET_GNS_disconnect (gns_handle); + gns_handle = NULL; GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Shutting down peer!\n"); GNUNET_SCHEDULER_shutdown (); } + static void -on_lookup_result_cname (void *cls, uint32_t rd_count, - const struct GNUNET_NAMESTORE_RecordData *rd) +on_lookup_result_cname (void *cls, + uint32_t rd_count, + const struct GNUNET_NAMESTORE_RecordData *rd) { - int i; + uint32_t i; if (GNUNET_SCHEDULER_NO_TASK != die_task) { GNUNET_SCHEDULER_cancel (die_task); die_task = GNUNET_SCHEDULER_NO_TASK; } - GNUNET_NAMESTORE_disconnect (namestore_handle); namestore_handle = NULL; if (rd_count == 0) @@ -158,12 +159,14 @@ on_lookup_result_cname (void *cls, uint32_t rd_count, GNUNET_SCHEDULER_add_now (&shutdown_task, NULL); } + static void -on_lookup_result_dns (void *cls, uint32_t rd_count, - const struct GNUNET_NAMESTORE_RecordData *rd) +on_lookup_result_dns (void *cls, + uint32_t rd_count, + const struct GNUNET_NAMESTORE_RecordData *rd) { struct in_addr a; - int i; + uint32_t i; char* addr; if (rd_count == 0) @@ -197,19 +200,19 @@ on_lookup_result_dns (void *cls, uint32_t rd_count, } } } - GNUNET_GNS_lookup (gns_handle, TEST_DOMAIN_PLUS, GNUNET_GNS_RECORD_CNAME, GNUNET_YES, NULL, &on_lookup_result_cname, TEST_DOMAIN_PLUS); } + static void on_lookup_result_zkey (void *cls, uint32_t rd_count, - const struct GNUNET_NAMESTORE_RecordData *rd) + const struct GNUNET_NAMESTORE_RecordData *rd) { struct in_addr a; - int i; + uint32_t i; char* addr; if (rd_count == 0) @@ -221,41 +224,46 @@ on_lookup_result_zkey (void *cls, uint32_t rd_count, else { ok = 1; - GNUNET_log (GNUNET_ERROR_TYPE_INFO, "name: %s\n", (char*)cls); + GNUNET_log (GNUNET_ERROR_TYPE_INFO, + "name: %s\n", (char*)cls); for (i=0; i