From: Christophe Genevey Metat Date: Fri, 27 May 2016 13:51:30 +0000 (+0000) Subject: begin to rewritten test case X-Git-Tag: initial-import-from-subversion-38251~839 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=e0c01618605c1ef2901b2002aed6801858603305;p=oweals%2Fgnunet.git begin to rewritten test case --- diff --git a/src/include/gnunet_my_lib.h b/src/include/gnunet_my_lib.h index dbd9f87f5..43c66e751 100644 --- a/src/include/gnunet_my_lib.h +++ b/src/include/gnunet_my_lib.h @@ -140,6 +140,12 @@ GNUNET_MY_exec_prepared (struct GNUNET_MYSQL_Context *mc, */ struct GNUNET_MY_ResultParam; +/** + * Information we pass to #GNUNET_MY_extract_result() to + * initialize the arguments of the prepared statement. + */ +struct GNUNET_MY_ResultSpec; + /** * Function called to convert input argument into SQL parameters. * diff --git a/src/my/test_my.c b/src/my/test_my.c index 29c60f68d..b20dbdc3a 100644 --- a/src/my/test_my.c +++ b/src/my/test_my.c @@ -136,7 +136,7 @@ run_queries (MYSQL * mysql) u32 = 32; u64 = 64; - struct GNUNET_CONFIGURATION_Handle * configuration_handle = NULL; +// struct GNUNET_CONFIGURATION_Handle * configuration_handle = NULL; // configuration_handle = GNUNET_CONFIGURATION_create(); /* char *query1 = "INSERT INTO test_my (" @@ -291,15 +291,78 @@ run_queries (MYSQL * mysql) } -/** OK **/ +/** REWRITTEN THIS FUNCTION **/ int main (int argc, const char * const argv[]) { - return GNUNET_OK; -// MYSQL mysql ; -// MYSQL_RES *result; + //CREATE A CONTEXTE + struct GNUNET_DATASTORE_PluginEnvironment *env; + struct GNUNET_MYSQL_Context *context; + + GNUNET_log_setup ( "test-my", + "WARNING", + NULL); + + context = GNUNET_MYSQL_context_create (NULL /* TO FIXE ***/, + "datastore-mysql"); + + struct GNUNET_MYSQL_StatementHandle *statements_handle; + + statements_handle = GNUNET_MYSQL_statement_prepare (context, + "CREATE TABLE test_my(" + "pub INT" + ", sig INT" + ", abs_time BIGINT" + ", forever BIGINT" + ", hash INT" + ", vsize VARCHAR" + ", u16 SMALLINT" + ", u32 INT" + ", u64 BIGINT" + ")"); + + //USE GNUNET_MY_exec_prepared + GNUNET_MY_exec_prepared(context, + statements_handle, + NULL); + + if (GNUNET_OK != GNUNET_MYSQL_context_destroy (context)) + { + //ERROR + } + + return GNUNET_OK; + +/* NEW VERSION TO FIXE if (GNUNET_OK != + mysql_prepare (&mysql)) + { + GNUNET_break (0) ; + mysql_close (&mysql); + return 1; + } + + int ret; + ret = run_queries (&mysql); + + + if (mysql_query (&mysql, + "DROP TABLE test_my;")) + { + fprintf (stderr, "Failed to drop table : %s\n", + mysql_error (&mysql)); + mysql_close (&mysql); + return 1; + } + +*/ +/* OLD VERSION (use SQL basic function) + + ret = run_queries (); + + MYSQL mysql ; + MYSQL_RES *result; -/* int ret; + int ret; char *hote = ""; char *pseudo = ""; @@ -375,6 +438,4 @@ main (int argc, const char * const argv[]) return ret; */ -// mysql_close (&mysql); -// return GNUNET_OK; }