Skip to content

Commit

Permalink
Test cleanup:
Browse files Browse the repository at this point in the history
- removed unused test for old sqlite3 module
- to avoid warnings and make code more readable mysql_stmt_prepare and
  mysql_real_query now use the SL (string and length) macro.
  • Loading branch information
9EOR9 committed Jan 14, 2018
1 parent 64cf572 commit 2e42f7a
Show file tree
Hide file tree
Showing 20 changed files with 378 additions and 566 deletions.
5 changes: 4 additions & 1 deletion plugins/io/remote_io.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,10 @@ MARIADB_REMOTEIO_PLUGIN _mysql_client_plugin_declaration_ =
mysql_end_client_plugin;

/* {{{ ma_rio_init - Plugin initialization */
int ma_rio_init(char *unused1, size_t unused2, int unused3, va_list unused4)
int ma_rio_init(char *unused1 __attribute__((unused)),
size_t unused2 __attribute__((unused)),
int unused3 __attribute__((unused)),
va_list unused4 __attribute__((unused)))
{
curl_global_init(CURL_GLOBAL_ALL);
if (!multi_handle)
Expand Down
2 changes: 1 addition & 1 deletion unittest/libmariadb/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ INCLUDE_DIRECTORIES(${CC_SOURCE_DIR}/include
${CC_SOURCE_DIR}/unittest/libmariadb)
ADD_DEFINITIONS(-DLIBMARIADB)

SET(API_TESTS "bulk1" "performance" "basic-t" "fetch" "charset" "logs" "cursor" "errors" "view" "ps" "ps_bugs" "sp" "result" "connection" "misc" "ps_new" "sqlite3" "thread" "features-10_2" "bulk1")
SET(API_TESTS "bulk1" "performance" "basic-t" "fetch" "charset" "logs" "cursor" "errors" "view" "ps" "ps_bugs" "sp" "result" "connection" "misc" "ps_new" "thread" "features-10_2" "bulk1")
IF(WITH_DYNCOL)
SET(API_TESTS ${API_TESTS} "dyncol")
ENDIF()
Expand Down
2 changes: 0 additions & 2 deletions unittest/libmariadb/async.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@
#include <stdio.h>
#include <mysql.h>

#define SL(s) (s), sizeof(s)

my_bool skip_async= 0;

static int test_async(MYSQL *mysql)
Expand Down
2 changes: 1 addition & 1 deletion unittest/libmariadb/basic-t.c
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ static int test_bad_union(MYSQL *mysql)

stmt= mysql_stmt_init(mysql);
FAIL_IF(!stmt, mysql_error(mysql));
rc= mysql_stmt_prepare(stmt, query, (unsigned long)strlen(query));
rc= mysql_stmt_prepare(stmt, SL(query));
FAIL_UNLESS(rc && mysql_errno(mysql) == 1222, "Error expected");

mysql_stmt_close(stmt);
Expand Down
28 changes: 14 additions & 14 deletions unittest/libmariadb/bulk1.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ static int bulk1(MYSQL *mysql)
rc= mysql_query(mysql, "CREATE TABLE bulk1 (a int , b VARCHAR(255))");
check_mysql_rc(rc, mysql);

rc= mysql_stmt_prepare(stmt, stmt_str, (unsigned long)strlen(stmt_str));
rc= mysql_stmt_prepare(stmt, SL(stmt_str));
check_stmt_rc(rc, stmt);

/* allocate memory */
Expand Down Expand Up @@ -155,7 +155,7 @@ static int bulk2(MYSQL *mysql)
rc= mysql_query(mysql, "CREATE TABLE bulk2 (a int default 4, b int default 2)");
check_mysql_rc(rc, mysql);

rc= mysql_stmt_prepare(stmt, "INSERT INTO bulk2 VALUES (?,1)", -1);
rc= mysql_stmt_prepare(stmt, SL("INSERT INTO bulk2 VALUES (?,1)"));
check_stmt_rc(rc, stmt);

memset(bind, 0, 2 * sizeof(MYSQL_BIND));
Expand Down Expand Up @@ -211,7 +211,7 @@ static int bulk3(MYSQL *mysql)
rc= mysql_query(mysql, "CREATE TABLE bulk3 (name varchar(20), row int)");
check_mysql_rc(rc,mysql);

rc= mysql_stmt_prepare(stmt, "INSERT INTO bulk3 VALUES (?,?)", -1);
rc= mysql_stmt_prepare(stmt, SL("INSERT INTO bulk3 VALUES (?,?)"));
check_stmt_rc(rc, stmt);

memset(bind, 0, sizeof(MYSQL_BIND)*2);
Expand Down Expand Up @@ -265,7 +265,7 @@ static int bulk4(MYSQL *mysql)
rc= mysql_query(mysql, "CREATE TABLE bulk4 (name varchar(20), row int not null default 3)");
check_mysql_rc(rc,mysql);

rc= mysql_stmt_prepare(stmt, "INSERT INTO bulk4 VALUES (?,?)", -1);
rc= mysql_stmt_prepare(stmt, SL("INSERT INTO bulk4 VALUES (?,?)"));
check_stmt_rc(rc, stmt);

memset(bind, 0, sizeof(MYSQL_BIND)*2);
Expand Down Expand Up @@ -379,7 +379,7 @@ static int bulk5(MYSQL *mysql)

memset(bind, 0, sizeof(MYSQL_BIND) * 3);

rc= mysql_stmt_prepare(stmt, "UPDATE bulk5 SET a=? WHERE a=?", -1);
rc= mysql_stmt_prepare(stmt, SL("UPDATE bulk5 SET a=? WHERE a=?"));
check_stmt_rc(rc, stmt);

bind[0].buffer_type= MYSQL_TYPE_LONG;
Expand Down Expand Up @@ -443,7 +443,7 @@ static int bulk6(MYSQL *mysql)
memset(bind, 0, sizeof(MYSQL_BIND) * 3);

/* 1st case: UPDATE */
rc= mysql_stmt_prepare(stmt, "UPDATE bulk6 SET a=?, b=? WHERE a=?", -1);
rc= mysql_stmt_prepare(stmt, SL("UPDATE bulk6 SET a=?, b=? WHERE a=?"));
check_stmt_rc(rc, stmt);

bind[0].buffer_type= MYSQL_TYPE_LONG;
Expand Down Expand Up @@ -479,7 +479,7 @@ static int bulk6(MYSQL *mysql)
check_mysql_rc(rc, mysql);

stmt= mysql_stmt_init(mysql);
rc= mysql_stmt_prepare(stmt, "INSERT INTO bulk6 VALUES (?,?)", -1);
rc= mysql_stmt_prepare(stmt, SL("INSERT INTO bulk6 VALUES (?,?)"));
check_stmt_rc(rc, stmt);

rc= mysql_stmt_attr_set(stmt, STMT_ATTR_ARRAY_SIZE, &array_size);
Expand Down Expand Up @@ -549,7 +549,7 @@ static int test_conc243(MYSQL *mysql)
check_mysql_rc(rc, mysql);

stmt= mysql_stmt_init(mysql);
rc= mysql_stmt_prepare(stmt, "INSERT INTO bulk_example2 VALUES (?,?,?)", -1);
rc= mysql_stmt_prepare(stmt, SL("INSERT INTO bulk_example2 VALUES (?,?,?)"));
check_stmt_rc(rc, stmt);

memset(bind, 0, sizeof(MYSQL_BIND) * 3);
Expand Down Expand Up @@ -611,7 +611,7 @@ static int bulk7(MYSQL *mysql)
rc= mysql_query(mysql, "INSERT INTO t1 VALUES (1)");
check_mysql_rc(rc, mysql);

rc= mysql_stmt_prepare(stmt, "UPDATE t1 SET a=a+1", -1);
rc= mysql_stmt_prepare(stmt, SL("UPDATE t1 SET a=a+1"));
check_stmt_rc(rc, stmt);

rc= mysql_stmt_attr_set(stmt, STMT_ATTR_ARRAY_SIZE, &array_size);
Expand Down Expand Up @@ -645,7 +645,7 @@ static int test_char_conv1(MYSQL *mysql)
rc= mysql_query(mysql, "CREATE TABLE char_conv (a varchar(20)) CHARSET=latin1");
check_mysql_rc(rc, mysql);

rc= mysql_stmt_prepare(stmt, "INSERT INTO char_conv VALUES (?)", -1);
rc= mysql_stmt_prepare(stmt, SL("INSERT INTO char_conv VALUES (?)"));
check_stmt_rc(rc, stmt);

memset(&bind_in, 0, sizeof(MYSQL_BIND));
Expand All @@ -663,7 +663,7 @@ static int test_char_conv1(MYSQL *mysql)

stmt= mysql_stmt_init(mysql);

rc= mysql_stmt_prepare(stmt, "SELECT a from char_conv", -1);
rc= mysql_stmt_prepare(stmt, SL("SELECT a from char_conv"));
check_stmt_rc(rc, stmt);

memset(&bind_out, 0, sizeof(MYSQL_BIND));
Expand Down Expand Up @@ -718,7 +718,7 @@ static int test_char_conv2(MYSQL *mysql)
rc= mysql_query(mysql, "CREATE TABLE char_conv (a varchar(20)) CHARSET=latin1");
check_mysql_rc(rc, mysql);

rc= mysql_stmt_prepare(stmt, "INSERT INTO char_conv VALUES (?)", -1);
rc= mysql_stmt_prepare(stmt, SL("INSERT INTO char_conv VALUES (?)"));
check_stmt_rc(rc, stmt);

rc= mysql_stmt_attr_set(stmt, STMT_ATTR_ARRAY_SIZE, &array_size);
Expand All @@ -739,7 +739,7 @@ static int test_char_conv2(MYSQL *mysql)

stmt= mysql_stmt_init(mysql);

rc= mysql_stmt_prepare(stmt, "SELECT a from char_conv", -1);
rc= mysql_stmt_prepare(stmt, SL("SELECT a from char_conv"));
check_stmt_rc(rc, stmt);

memset(&bind_out, 0, sizeof(MYSQL_BIND));
Expand Down Expand Up @@ -810,7 +810,7 @@ static int bulk_skip_row(MYSQL *mysql)
check_mysql_rc(rc, mysql);

stmt= mysql_stmt_init(mysql);
rc= mysql_stmt_prepare(stmt, "INSERT INTO bulk_example2 VALUES (?,?,?)", -1);
rc= mysql_stmt_prepare(stmt, SL("INSERT INTO bulk_example2 VALUES (?,?,?)"));
check_stmt_rc(rc, stmt);

memset(bind, 0, sizeof(MYSQL_BIND) * 3);
Expand Down
36 changes: 18 additions & 18 deletions unittest/libmariadb/charset.c
Original file line number Diff line number Diff line change
Expand Up @@ -169,20 +169,20 @@ static int test_conversion(MYSQL *mysql)
ulong length;

stmt_text= "DROP TABLE IF EXISTS t1";
rc= mysql_real_query(mysql, stmt_text, (unsigned long)strlen(stmt_text));
rc= mysql_real_query(mysql, SL(stmt_text));
check_mysql_rc(rc, mysql);
stmt_text= "CREATE TABLE t1 (a TEXT) DEFAULT CHARSET latin1";
rc= mysql_real_query(mysql, stmt_text,(unsigned long) strlen(stmt_text));
rc= mysql_real_query(mysql, SL(stmt_text));
check_mysql_rc(rc, mysql);
stmt_text= "SET character_set_connection=utf8, character_set_client=utf8, "
" character_set_results=latin1";
rc= mysql_real_query(mysql, stmt_text, (unsigned long)strlen(stmt_text));
rc= mysql_real_query(mysql, SL(stmt_text));
check_mysql_rc(rc, mysql);

stmt= mysql_stmt_init(mysql);
FAIL_IF(!stmt, mysql_error(mysql));
stmt_text= "INSERT INTO t1 (a) VALUES (?)";
rc= mysql_stmt_prepare(stmt, stmt_text, (unsigned long)strlen(stmt_text));
rc= mysql_stmt_prepare(stmt, SL(stmt_text));
check_stmt_rc(rc, stmt);

memset(my_bind, '\0', sizeof(my_bind));
Expand All @@ -200,7 +200,7 @@ static int test_conversion(MYSQL *mysql)
check_stmt_rc(rc, stmt);

stmt_text= "SELECT a FROM t1";
rc= mysql_stmt_prepare(stmt, stmt_text, (unsigned long)strlen(stmt_text));
rc= mysql_stmt_prepare(stmt, SL(stmt_text));
check_stmt_rc(rc, stmt);
rc= mysql_stmt_execute(stmt);
check_stmt_rc(rc, stmt);
Expand All @@ -217,10 +217,10 @@ static int test_conversion(MYSQL *mysql)

mysql_stmt_close(stmt);
stmt_text= "DROP TABLE t1";
rc= mysql_real_query(mysql, stmt_text, (unsigned long)strlen(stmt_text));
rc= mysql_real_query(mysql, SL(stmt_text));
check_mysql_rc(rc, mysql);
stmt_text= "SET NAMES DEFAULT";
rc= mysql_real_query(mysql, stmt_text, (unsigned long)strlen(stmt_text));
rc= mysql_real_query(mysql, SL(stmt_text));
check_mysql_rc(rc, mysql);

return OK;
Expand Down Expand Up @@ -299,7 +299,7 @@ static int test_ps_i18n(MYSQL *mysql)
ulong buf1_len, buf2_len;

stmt_text= "DROP TABLE IF EXISTS t1";
rc= mysql_real_query(mysql, stmt_text, (unsigned long) strlen(stmt_text));
rc= mysql_real_query(mysql, SL(stmt_text));
check_mysql_rc(rc, mysql);

/*
Expand All @@ -309,14 +309,14 @@ static int test_ps_i18n(MYSQL *mysql)
*/

stmt_text= "CREATE TABLE t1 (c1 VARBINARY(255), c2 VARBINARY(255))";
rc= mysql_real_query(mysql, stmt_text, (unsigned long)strlen(stmt_text));
rc= mysql_real_query(mysql, SL(stmt_text));
check_mysql_rc(rc, mysql);

stmt_text= "SET CHARACTER_SET_CLIENT=koi8r, "
"CHARACTER_SET_CONNECTION=cp1251, "
"CHARACTER_SET_RESULTS=koi8r";

rc= mysql_real_query(mysql, stmt_text, (unsigned long)strlen(stmt_text));
rc= mysql_real_query(mysql, SL(stmt_text));
check_mysql_rc(rc, mysql);

memset(bind_array, '\0', sizeof(bind_array));
Expand All @@ -333,7 +333,7 @@ static int test_ps_i18n(MYSQL *mysql)

stmt_text= "INSERT INTO t1 (c1, c2) VALUES (?, ?)";

rc= mysql_stmt_prepare(stmt, stmt_text, (unsigned long)strlen(stmt_text));
rc= mysql_stmt_prepare(stmt, SL(stmt_text));
check_stmt_rc(rc, stmt);
mysql_stmt_bind_param(stmt, bind_array);
check_stmt_rc(rc, stmt);
Expand All @@ -345,7 +345,7 @@ static int test_ps_i18n(MYSQL *mysql)
stmt_text= "SELECT c1, c2 FROM t1";

/* c1 and c2 are binary so no conversion will be done on select */
rc= mysql_stmt_prepare(stmt, stmt_text,(unsigned long) strlen(stmt_text));
rc= mysql_stmt_prepare(stmt, SL(stmt_text));
check_stmt_rc(rc, stmt);
rc= mysql_stmt_execute(stmt);
check_stmt_rc(rc, stmt);
Expand All @@ -370,7 +370,7 @@ static int test_ps_i18n(MYSQL *mysql)
FAIL_UNLESS(rc == MYSQL_NO_DATA, "rc != MYSQL_NO_DATA");

stmt_text= "DROP TABLE IF EXISTS t1";
rc= mysql_real_query(mysql, stmt_text,(unsigned long) strlen(stmt_text));
rc= mysql_real_query(mysql, SL(stmt_text));
check_mysql_rc(rc, mysql);

/*
Expand All @@ -383,12 +383,12 @@ static int test_ps_i18n(MYSQL *mysql)
stmt_text= "CREATE TABLE t1 (c1 VARCHAR(255) CHARACTER SET cp1251, "
"c2 VARCHAR(255) CHARACTER SET cp1251)";

rc= mysql_real_query(mysql, stmt_text, (unsigned long)strlen(stmt_text));
rc= mysql_real_query(mysql, SL(stmt_text));
check_mysql_rc(rc, mysql);

stmt_text= "INSERT INTO t1 (c1, c2) VALUES (?, ?)";

rc= mysql_stmt_prepare(stmt, stmt_text, (unsigned long)strlen(stmt_text));
rc= mysql_stmt_prepare(stmt, SL(stmt_text));
check_stmt_rc(rc, stmt);
/* this data must be converted */
bind_array[0].buffer_type= MYSQL_TYPE_STRING;
Expand Down Expand Up @@ -425,7 +425,7 @@ static int test_ps_i18n(MYSQL *mysql)
stmt_text= "SELECT c1, c2 FROM t1";

/* c1 and c2 are binary so no conversion will be done on select */
rc= mysql_stmt_prepare(stmt, stmt_text, (unsigned long)strlen(stmt_text));
rc= mysql_stmt_prepare(stmt, SL(stmt_text));
check_stmt_rc(rc, stmt);
rc= mysql_stmt_execute(stmt);
check_stmt_rc(rc, stmt);
Expand All @@ -450,10 +450,10 @@ static int test_ps_i18n(MYSQL *mysql)
mysql_stmt_close(stmt);

stmt_text= "DROP TABLE t1";
rc= mysql_real_query(mysql, stmt_text, (unsigned long)strlen(stmt_text));
rc= mysql_real_query(mysql, SL(stmt_text));
check_mysql_rc(rc, mysql);
stmt_text= "SET NAMES DEFAULT";
rc= mysql_real_query(mysql, stmt_text, (unsigned long)strlen(stmt_text));
rc= mysql_real_query(mysql, SL(stmt_text));
check_mysql_rc(rc, mysql);
return OK;
}
Expand Down
Loading

0 comments on commit 2e42f7a

Please sign in to comment.