aboutsummaryrefslogtreecommitdiff
path: root/src/my
diff options
context:
space:
mode:
authorChristophe Genevey Metat <genevey.christophe@gmail.com>2016-06-13 11:24:06 +0000
committerChristophe Genevey Metat <genevey.christophe@gmail.com>2016-06-13 11:24:06 +0000
commite290fbfbeae0a3bccf2c2dc68f5d37bc1f3c4f81 (patch)
tree028a079fd3665654ce95dc60d3c75f126b15d0be /src/my
parentfcbbb6b6eb594be079894681d23e318918f6bf26 (diff)
downloadgnunet-e290fbfbeae0a3bccf2c2dc68f5d37bc1f3c4f81.tar.gz
gnunet-e290fbfbeae0a3bccf2c2dc68f5d37bc1f3c4f81.zip
lcov test function
Diffstat (limited to 'src/my')
-rw-r--r--src/my/my_result_helper.c31
-rw-r--r--src/my/test_my.c21
2 files changed, 46 insertions, 6 deletions
diff --git a/src/my/my_result_helper.c b/src/my/my_result_helper.c
index 963e3f618..c0a1dff4d 100644
--- a/src/my/my_result_helper.c
+++ b/src/my/my_result_helper.c
@@ -501,10 +501,11 @@ pre_extract_string (void * cls,
501 unsigned int column, 501 unsigned int column,
502 MYSQL_BIND *results) 502 MYSQL_BIND *results)
503{ 503{
504 results[0].buffer = (char *)rs->dst; 504 results[0].buffer = NULL;
505 results[0].buffer_length = rs->dst_size; 505 results[0].buffer_length = 0;
506 results[0].length = &rs->mysql_bind_output_length; 506 results[0].length = &rs->mysql_bind_output_length;
507 507 results[0].buffer_type = MYSQL_TYPE_BLOB;
508
508 return GNUNET_OK; 509 return GNUNET_OK;
509} 510}
510 511
@@ -528,8 +529,30 @@ post_extract_string (void * cls,
528 unsigned int column, 529 unsigned int column,
529 MYSQL_BIND *results) 530 MYSQL_BIND *results)
530{ 531{
531 if (rs->dst_size != rs->mysql_bind_output_length) 532 size_t size;
533
534 size = (size_t) rs->mysql_bind_output_length;
535 char buf[size];
536
537 if (rs->mysql_bind_output_length != size)
538 return GNUNET_SYSERR;
539
540 results[0].buffer = buf;
541 results[0].buffer_length = size;
542 results[0].buffer_type = MYSQL_TYPE_BLOB;
543
544 if (0 !=
545 mysql_stmt_fetch_column (stmt,
546 results,
547 column,
548 0))
549 {
550 GNUNET_free (buf);
532 return GNUNET_SYSERR; 551 return GNUNET_SYSERR;
552 }
553
554 rs->dst = buf;
555
533 return GNUNET_OK; 556 return GNUNET_OK;
534} 557}
535 558
diff --git a/src/my/test_my.c b/src/my/test_my.c
index 5f778ad46..3e051e467 100644
--- a/src/my/test_my.c
+++ b/src/my/test_my.c
@@ -46,12 +46,16 @@ run_queries (struct GNUNET_MYSQL_Context *context)
46 struct GNUNET_TIME_Absolute abs_time2; 46 struct GNUNET_TIME_Absolute abs_time2;
47 struct GNUNET_TIME_Absolute forever = GNUNET_TIME_UNIT_FOREVER_ABS; 47 struct GNUNET_TIME_Absolute forever = GNUNET_TIME_UNIT_FOREVER_ABS;
48 struct GNUNET_TIME_Absolute forever2; 48 struct GNUNET_TIME_Absolute forever2;
49 const struct GNUNET_TIME_AbsoluteNBO abs_time_nbo = GNUNET_TIME_absolute_hton (abs_time);
49 struct GNUNET_HashCode hc; 50 struct GNUNET_HashCode hc;
50 struct GNUNET_HashCode hc2; 51 struct GNUNET_HashCode hc2;
51 const char msg[] = "hello"; 52 const char msg[] = "hello";
52 void *msg2 = NULL;; 53 void *msg2 = NULL;
53 size_t msg2_len; 54 size_t msg2_len;
54 55
56 const char msg3[] = "world";
57 char *msg4 = "";
58
55 uint16_t u16; 59 uint16_t u16;
56 uint16_t u162; 60 uint16_t u162;
57 uint32_t u32; 61 uint32_t u32;
@@ -85,13 +89,15 @@ run_queries (struct GNUNET_MYSQL_Context *context)
85 ",sig" 89 ",sig"
86 ",abs_time" 90 ",abs_time"
87 ",forever" 91 ",forever"
92 ",abs_time_nbo"
88 ",hash" 93 ",hash"
89 ",vsize" 94 ",vsize"
95 ",str"
90 ",u16" 96 ",u16"
91 ",u32" 97 ",u32"
92 ",u64" 98 ",u64"
93 ") VALUES " 99 ") VALUES "
94 "( ?, ?, ?, ?, ?, ?, ?, ?, ?)"); 100 "( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
95 101
96 if (NULL == statements_handle_insert) 102 if (NULL == statements_handle_insert)
97 { 103 {
@@ -104,8 +110,10 @@ run_queries (struct GNUNET_MYSQL_Context *context)
104 GNUNET_MY_query_param_rsa_signature (sig), 110 GNUNET_MY_query_param_rsa_signature (sig),
105 GNUNET_MY_query_param_absolute_time (&abs_time), 111 GNUNET_MY_query_param_absolute_time (&abs_time),
106 GNUNET_MY_query_param_absolute_time (&forever), 112 GNUNET_MY_query_param_absolute_time (&forever),
113 GNUNET_MY_query_param_absolute_time_nbo (&abs_time_nbo),
107 GNUNET_MY_query_param_auto_from_type (&hc), 114 GNUNET_MY_query_param_auto_from_type (&hc),
108 GNUNET_MY_query_param_fixed_size (msg, strlen (msg)), 115 GNUNET_MY_query_param_fixed_size (msg, strlen (msg)),
116 GNUNET_MY_query_param_string (msg3),
109 GNUNET_MY_query_param_uint16 (&u16), 117 GNUNET_MY_query_param_uint16 (&u16),
110 GNUNET_MY_query_param_uint32 (&u32), 118 GNUNET_MY_query_param_uint32 (&u32),
111 GNUNET_MY_query_param_uint64 (&u64), 119 GNUNET_MY_query_param_uint64 (&u64),
@@ -128,6 +136,7 @@ run_queries (struct GNUNET_MYSQL_Context *context)
128 ",forever" 136 ",forever"
129 ",hash" 137 ",hash"
130 ",vsize" 138 ",vsize"
139 ",str"
131 ",u16" 140 ",u16"
132 ",u32" 141 ",u32"
133 ",u64" 142 ",u64"
@@ -158,6 +167,7 @@ run_queries (struct GNUNET_MYSQL_Context *context)
158 GNUNET_MY_result_spec_absolute_time (&forever2), 167 GNUNET_MY_result_spec_absolute_time (&forever2),
159 GNUNET_MY_result_spec_auto_from_type (&hc2), 168 GNUNET_MY_result_spec_auto_from_type (&hc2),
160 GNUNET_MY_result_spec_variable_size (&msg2, &msg2_len), 169 GNUNET_MY_result_spec_variable_size (&msg2, &msg2_len),
170 GNUNET_MY_result_spec_string (&msg4),
161 GNUNET_MY_result_spec_uint16 (&u162), 171 GNUNET_MY_result_spec_uint16 (&u162),
162 GNUNET_MY_result_spec_uint32 (&u322), 172 GNUNET_MY_result_spec_uint32 (&u322),
163 GNUNET_MY_result_spec_uint64 (&u642), 173 GNUNET_MY_result_spec_uint64 (&u642),
@@ -190,6 +200,11 @@ run_queries (struct GNUNET_MYSQL_Context *context)
190 msg2, 200 msg2,
191 msg2_len)); 201 msg2_len));
192 202
203GNUNET_break (strlen (msg3) == strlen(msg4));
204GNUNET_break (0 ==
205 strcmp (msg3,
206 msg4));
207
193 GNUNET_break (16 == u162); 208 GNUNET_break (16 == u162);
194 GNUNET_break (32 == u322); 209 GNUNET_break (32 == u322);
195 GNUNET_break (64 == u642); 210 GNUNET_break (64 == u642);
@@ -242,8 +257,10 @@ main (int argc, const char * const argv[])
242 ",sig BLOB NOT NULL" 257 ",sig BLOB NOT NULL"
243 ",abs_time BIGINT NOT NULL" 258 ",abs_time BIGINT NOT NULL"
244 ",forever BIGINT NOT NULL" 259 ",forever BIGINT NOT NULL"
260 ",abs_time_nbo BIGINT NOT NULL"
245 ",hash BLOB NOT NULL CHECK(LENGTH(hash)=64)" 261 ",hash BLOB NOT NULL CHECK(LENGTH(hash)=64)"
246 ",vsize BLOB NOT NULL" 262 ",vsize BLOB NOT NULL"
263 ",str BLOB NOT NULL"
247 ",u16 SMALLINT NOT NULL" 264 ",u16 SMALLINT NOT NULL"
248 ",u32 INT NOT NULL" 265 ",u32 INT NOT NULL"
249 ",u64 BIGINT NOT NULL" 266 ",u64 BIGINT NOT NULL"