aboutsummaryrefslogtreecommitdiff
path: root/src/gnsrecord
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2018-06-05 00:37:06 +0200
committerChristian Grothoff <christian@grothoff.org>2018-06-05 00:37:06 +0200
commit1f083a4593b1f07dcf24549853963dedde7f4d02 (patch)
treee57137969a8a0cfd5af064cd063177936c6b894a /src/gnsrecord
parent324f6168c2374d7bb71c3632fb6521860d8fdfa1 (diff)
downloadgnunet-1f083a4593b1f07dcf24549853963dedde7f4d02.tar.gz
gnunet-1f083a4593b1f07dcf24549853963dedde7f4d02.zip
use real GNS record types in tests to avoid failures in new extra serialization/deserialization checking
Diffstat (limited to 'src/gnsrecord')
-rw-r--r--src/gnsrecord/test_gnsrecord_crypto.c3
-rw-r--r--src/gnsrecord/test_gnsrecord_serialization.c106
2 files changed, 58 insertions, 51 deletions
diff --git a/src/gnsrecord/test_gnsrecord_crypto.c b/src/gnsrecord/test_gnsrecord_crypto.c
index 9ba303e66..9dd09c0bf 100644
--- a/src/gnsrecord/test_gnsrecord_crypto.c
+++ b/src/gnsrecord/test_gnsrecord_crypto.c
@@ -23,11 +23,12 @@
23 */ 23 */
24#include "platform.h" 24#include "platform.h"
25#include "gnunet_util_lib.h" 25#include "gnunet_util_lib.h"
26#include "gnunet_dnsparser_lib.h"
26#include "gnunet_gnsrecord_lib.h" 27#include "gnunet_gnsrecord_lib.h"
27 28
28#define RECORDS 5 29#define RECORDS 5
29 30
30#define TEST_RECORD_TYPE 1234 31#define TEST_RECORD_TYPE GNUNET_DNSPARSER_TYPE_TXT
31 32
32#define TEST_RECORD_DATALEN 123 33#define TEST_RECORD_DATALEN 123
33 34
diff --git a/src/gnsrecord/test_gnsrecord_serialization.c b/src/gnsrecord/test_gnsrecord_serialization.c
index 3edd2bc48..a43bf2efa 100644
--- a/src/gnsrecord/test_gnsrecord_serialization.c
+++ b/src/gnsrecord/test_gnsrecord_serialization.c
@@ -24,6 +24,7 @@
24#include "platform.h" 24#include "platform.h"
25#include "gnunet_util_lib.h" 25#include "gnunet_util_lib.h"
26#include "gnunet_gnsrecord_lib.h" 26#include "gnunet_gnsrecord_lib.h"
27#include "gnunet_dnsparser_lib.h"
27 28
28#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 100) 29#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 100)
29 30
@@ -31,7 +32,9 @@ static int res;
31 32
32 33
33static void 34static void
34run (void *cls, char *const *args, const char *cfgfile, 35run (void *cls,
36 char *const *args,
37 const char *cfgfile,
35 const struct GNUNET_CONFIGURATION_Handle *cfg) 38 const struct GNUNET_CONFIGURATION_Handle *cfg)
36{ 39{
37 size_t len; 40 size_t len;
@@ -46,7 +49,7 @@ run (void *cls, char *const *args, const char *cfgfile,
46 data_len = 0; 49 data_len = 0;
47 for (c = 0; c < rd_count; c++) 50 for (c = 0; c < rd_count; c++)
48 { 51 {
49 src[c].record_type = c+1; 52 src[c].record_type = GNUNET_DNSPARSER_TYPE_TXT;
50 src[c].data_size = data_len; 53 src[c].data_size = data_len;
51 src[c].data = GNUNET_malloc (data_len); 54 src[c].data = GNUNET_malloc (data_len);
52 55
@@ -69,58 +72,61 @@ run (void *cls, char *const *args, const char *cfgfile,
69 (unsigned int) len); 72 (unsigned int) len);
70 73
71 GNUNET_assert (rd_ser != NULL); 74 GNUNET_assert (rd_ser != NULL);
72
73 struct GNUNET_GNSRECORD_Data dst[rd_count];
74 GNUNET_assert (GNUNET_OK ==
75 GNUNET_GNSRECORD_records_deserialize (len,
76 rd_ser,
77 rd_count,
78 dst));
79
80 GNUNET_assert (dst != NULL);
81
82 for (c = 0; c < rd_count; c++)
83 { 75 {
84 if (src[c].data_size != dst[c].data_size) 76 struct GNUNET_GNSRECORD_Data dst[rd_count];
85 { 77 GNUNET_assert (GNUNET_OK ==
86 GNUNET_break (0); 78 GNUNET_GNSRECORD_records_deserialize (len,
87 res = 1; 79 rd_ser,
88 } 80 rd_count,
89 if (src[c].expiration_time != dst[c].expiration_time) 81 dst));
90 {
91 GNUNET_break (0);
92 res = 1;
93 }
94 if (src[c].flags != dst[c].flags)
95 {
96 GNUNET_break (0);
97 res = 1;
98 }
99 if (src[c].record_type != dst[c].record_type)
100 {
101 GNUNET_break (0);
102 res = 1;
103 }
104 82
105 size_t data_size = src[c].data_size; 83 GNUNET_assert (dst != NULL);
106 char data[data_size]; 84
107 memset (data, 'a', data_size); 85 for (c = 0; c < rd_count; c++)
108 if (0 != memcmp (data, dst[c].data, data_size))
109 {
110 GNUNET_break (0);
111 res = 1;
112 }
113 if (0 != memcmp (data, src[c].data, data_size))
114 {
115 GNUNET_break (0);
116 res = 1;
117 }
118 if (0 != memcmp (src[c].data, dst[c].data, src[c].data_size))
119 { 86 {
120 GNUNET_break (0); 87 if (src[c].data_size != dst[c].data_size)
121 res = 1; 88 {
89 GNUNET_break (0);
90 res = 1;
91 }
92 if (src[c].expiration_time != dst[c].expiration_time)
93 {
94 GNUNET_break (0);
95 res = 1;
96 }
97 if (src[c].flags != dst[c].flags)
98 {
99 GNUNET_break (0);
100 res = 1;
101 }
102 if (src[c].record_type != dst[c].record_type)
103 {
104 GNUNET_break (0);
105 res = 1;
106 }
107
108 {
109 size_t data_size = src[c].data_size;
110 char data[data_size];
111
112 memset (data, 'a', data_size);
113 if (0 != memcmp (data, dst[c].data, data_size))
114 {
115 GNUNET_break (0);
116 res = 1;
117 }
118 if (0 != memcmp (data, src[c].data, data_size))
119 {
120 GNUNET_break (0);
121 res = 1;
122 }
123 if (0 != memcmp (src[c].data, dst[c].data, src[c].data_size))
124 {
125 GNUNET_break (0);
126 res = 1;
127 }
128 }
122 } 129 }
123
124 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Element [%i]: EQUAL\n", c); 130 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Element [%i]: EQUAL\n", c);
125 } 131 }
126 132