diff options
author | Christian Grothoff <christian@grothoff.org> | 2016-07-03 15:01:34 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2016-07-03 15:01:34 +0000 |
commit | 278eb59cd0a1c1483de7270ae46e5b6b57604aa8 (patch) | |
tree | 9662d28625ce530df1455c89711b1ae52ed3168c | |
parent | 07a59d7b5b66e8b59029894b9ee42069abb7a187 (diff) | |
download | gnunet-278eb59cd0a1c1483de7270ae46e5b6b57604aa8.tar.gz gnunet-278eb59cd0a1c1483de7270ae46e5b6b57604aa8.zip |
report skip if DB does not allow table creation
-rw-r--r-- | src/my/test_my.c | 44 |
1 files changed, 23 insertions, 21 deletions
diff --git a/src/my/test_my.c b/src/my/test_my.c index 4bea101ca..d6e6141b7 100644 --- a/src/my/test_my.c +++ b/src/my/test_my.c | |||
@@ -225,7 +225,7 @@ run_queries (struct GNUNET_MYSQL_Context *context) | |||
225 | 225 | ||
226 | 226 | ||
227 | int | 227 | int |
228 | main (int argc, const char * const argv[]) | 228 | main (int argc, const char *const argv[]) |
229 | { | 229 | { |
230 | struct GNUNET_CONFIGURATION_Handle *config; | 230 | struct GNUNET_CONFIGURATION_Handle *config; |
231 | struct GNUNET_MYSQL_Context *context; | 231 | struct GNUNET_MYSQL_Context *context; |
@@ -236,14 +236,15 @@ main (int argc, const char * const argv[]) | |||
236 | NULL); | 236 | NULL); |
237 | 237 | ||
238 | config = GNUNET_CONFIGURATION_create (); | 238 | config = GNUNET_CONFIGURATION_create (); |
239 | if (GNUNET_OK != GNUNET_CONFIGURATION_parse (config, "test_my.conf")) | 239 | if (GNUNET_OK != |
240 | GNUNET_CONFIGURATION_parse (config, "test_my.conf")) | ||
240 | { | 241 | { |
241 | fprintf (stderr, "Failed to parse configuaration\n"); | 242 | fprintf (stderr, "Failed to parse configuaration\n"); |
242 | return 1; | 243 | return 1; |
243 | } | 244 | } |
244 | 245 | ||
245 | context = GNUNET_MYSQL_context_create (config, | 246 | context = GNUNET_MYSQL_context_create (config, |
246 | "datastore-mysql"); | 247 | "datastore-mysql"); |
247 | if (NULL == context) | 248 | if (NULL == context) |
248 | { | 249 | { |
249 | fprintf(stderr, "Failed to connect to database\n"); | 250 | fprintf(stderr, "Failed to connect to database\n"); |
@@ -251,29 +252,30 @@ main (int argc, const char * const argv[]) | |||
251 | } | 252 | } |
252 | 253 | ||
253 | (void) GNUNET_MYSQL_statement_run (context, | 254 | (void) GNUNET_MYSQL_statement_run (context, |
254 | "DROP TABLE test_my2;"); | 255 | "DROP TABLE test_my2;"); |
255 | 256 | ||
256 | if (GNUNET_OK != GNUNET_MYSQL_statement_run (context, | 257 | if (GNUNET_OK != |
257 | "CREATE TABLE IF NOT EXISTS test_my2(" | 258 | GNUNET_MYSQL_statement_run (context, |
258 | " pub BLOB NOT NULL" | 259 | "CREATE TABLE IF NOT EXISTS test_my2(" |
259 | ",sig BLOB NOT NULL" | 260 | " pub BLOB NOT NULL" |
260 | ",abs_time BIGINT NOT NULL" | 261 | ",sig BLOB NOT NULL" |
261 | ",forever BIGINT NOT NULL" | 262 | ",abs_time BIGINT NOT NULL" |
262 | ",abs_time_nbo BIGINT NOT NULL" | 263 | ",forever BIGINT NOT NULL" |
263 | ",hash BLOB NOT NULL CHECK(LENGTH(hash)=64)" | 264 | ",abs_time_nbo BIGINT NOT NULL" |
264 | ",vsize BLOB NOT NULL" | 265 | ",hash BLOB NOT NULL CHECK(LENGTH(hash)=64)" |
265 | ",str BLOB NOT NULL" | 266 | ",vsize BLOB NOT NULL" |
266 | ",u16 SMALLINT NOT NULL" | 267 | ",str BLOB NOT NULL" |
267 | ",u32 INT NOT NULL" | 268 | ",u16 SMALLINT NOT NULL" |
268 | ",u64 BIGINT NOT NULL" | 269 | ",u32 INT NOT NULL" |
269 | ")")) | 270 | ",u64 BIGINT NOT NULL" |
271 | ")")) | ||
270 | { | 272 | { |
271 | fprintf (stderr, | 273 | fprintf (stderr, |
272 | "Failed to create table \n"); | 274 | "Failed to create table. Database likely not setup correctly.\n"); |
273 | GNUNET_MYSQL_statements_invalidate (context); | 275 | GNUNET_MYSQL_statements_invalidate (context); |
274 | GNUNET_MYSQL_context_destroy (context); | 276 | GNUNET_MYSQL_context_destroy (context); |
275 | 277 | ||
276 | return 1; | 278 | return 77; |
277 | } | 279 | } |
278 | 280 | ||
279 | ret = run_queries (context); | 281 | ret = run_queries (context); |