diff options
Diffstat (limited to 'src/gnsrecord/test_gnsrecord_serialization.c')
-rw-r--r-- | src/gnsrecord/test_gnsrecord_serialization.c | 124 |
1 files changed, 64 insertions, 60 deletions
diff --git a/src/gnsrecord/test_gnsrecord_serialization.c b/src/gnsrecord/test_gnsrecord_serialization.c index 3edd2bc488..03a4d8b03f 100644 --- a/src/gnsrecord/test_gnsrecord_serialization.c +++ b/src/gnsrecord/test_gnsrecord_serialization.c @@ -2,20 +2,18 @@ This file is part of GNUnet. Copyright (C) 2013 GNUnet e.V. - GNUnet is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published - by the Free Software Foundation; either version 3, or (at your - option) any later version. + GNUnet is free software: you can redistribute it and/or modify it + under the terms of the GNU Affero General Public License as published + by the Free Software Foundation, either version 3 of the License, + or (at your option) any later version. GNUnet is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with GNUnet; see the file COPYING. If not, write to the - Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. + Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. */ /** * @file gnsrecord/test_gnsrecord_serialization.c @@ -24,6 +22,7 @@ #include "platform.h" #include "gnunet_util_lib.h" #include "gnunet_gnsrecord_lib.h" +#include "gnunet_dnsparser_lib.h" #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 100) @@ -31,7 +30,9 @@ static int res; static void -run (void *cls, char *const *args, const char *cfgfile, +run (void *cls, + char *const *args, + const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) { size_t len; @@ -46,7 +47,7 @@ run (void *cls, char *const *args, const char *cfgfile, data_len = 0; for (c = 0; c < rd_count; c++) { - src[c].record_type = c+1; + src[c].record_type = GNUNET_DNSPARSER_TYPE_TXT; src[c].data_size = data_len; src[c].data = GNUNET_malloc (data_len); @@ -69,58 +70,61 @@ run (void *cls, char *const *args, const char *cfgfile, (unsigned int) len); GNUNET_assert (rd_ser != NULL); - - struct GNUNET_GNSRECORD_Data dst[rd_count]; - GNUNET_assert (GNUNET_OK == - GNUNET_GNSRECORD_records_deserialize (len, - rd_ser, - rd_count, - dst)); - - GNUNET_assert (dst != NULL); - - for (c = 0; c < rd_count; c++) { - if (src[c].data_size != dst[c].data_size) - { - GNUNET_break (0); - res = 1; - } - if (src[c].expiration_time != dst[c].expiration_time) - { - GNUNET_break (0); - res = 1; - } - if (src[c].flags != dst[c].flags) - { - GNUNET_break (0); - res = 1; - } - if (src[c].record_type != dst[c].record_type) - { - GNUNET_break (0); - res = 1; - } + struct GNUNET_GNSRECORD_Data dst[rd_count]; + GNUNET_assert (GNUNET_OK == + GNUNET_GNSRECORD_records_deserialize (len, + rd_ser, + rd_count, + dst)); - size_t data_size = src[c].data_size; - char data[data_size]; - memset (data, 'a', data_size); - if (0 != memcmp (data, dst[c].data, data_size)) - { - GNUNET_break (0); - res = 1; - } - if (0 != memcmp (data, src[c].data, data_size)) - { - GNUNET_break (0); - res = 1; - } - if (0 != memcmp (src[c].data, dst[c].data, src[c].data_size)) + GNUNET_assert (dst != NULL); + + for (c = 0; c < rd_count; c++) { - GNUNET_break (0); - res = 1; + if (src[c].data_size != dst[c].data_size) + { + GNUNET_break (0); + res = 1; + } + if (src[c].expiration_time != dst[c].expiration_time) + { + GNUNET_break (0); + res = 1; + } + if (src[c].flags != dst[c].flags) + { + GNUNET_break (0); + res = 1; + } + if (src[c].record_type != dst[c].record_type) + { + GNUNET_break (0); + res = 1; + } + + { + size_t data_size = src[c].data_size; + char data[data_size]; + + memset (data, 'a', data_size); + if (0 != memcmp (data, dst[c].data, data_size)) + { + GNUNET_break (0); + res = 1; + } + if (0 != memcmp (data, src[c].data, data_size)) + { + GNUNET_break (0); + res = 1; + } + if (0 != memcmp (src[c].data, dst[c].data, src[c].data_size)) + { + GNUNET_break (0); + res = 1; + } + } } - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Element [%i]: EQUAL\n", c); } |