summaryrefslogtreecommitdiff
path: root/unittest
diff options
context:
space:
mode:
Diffstat (limited to 'unittest')
-rw-r--r--unittest/embedded/CMakeLists.txt20
-rw-r--r--unittest/embedded/test-connect.cc78
-rw-r--r--unittest/mysys/base64-t.c4
-rw-r--r--unittest/mysys/dynstring-t.c2
-rw-r--r--unittest/mysys/lf-t.c5
-rw-r--r--unittest/mysys/my_atomic-t.c6
-rw-r--r--unittest/mysys/thr_template.c2
-rw-r--r--unittest/mysys/waiting_threads-t.c5
-rw-r--r--unittest/sql/mf_iocache-t.cc29
9 files changed, 120 insertions, 31 deletions
diff --git a/unittest/embedded/CMakeLists.txt b/unittest/embedded/CMakeLists.txt
new file mode 100644
index 00000000000..cf48550c377
--- /dev/null
+++ b/unittest/embedded/CMakeLists.txt
@@ -0,0 +1,20 @@
+
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include
+ ${CMAKE_SOURCE_DIR}/libmysqld/include
+ ${PCRE_INCLUDES}
+ ${CMAKE_SOURCE_DIR}/sql
+ ${MY_READLINE_INCLUDE_DIR}
+ )
+
+
+ADD_DEFINITIONS(-DEMBEDDED_LIBRARY -UMYSQL_CLIENT)
+
+
+MYSQL_ADD_EXECUTABLE(test-connect-t test-connect.cc
+ COMPONENT Test)
+TARGET_LINK_LIBRARIES(test-connect-t mysqlserver )
+MY_ADD_TEST(test-connect)
+
+IF(UNIX)
+SET_TARGET_PROPERTIES(test-connect-t PROPERTIES ENABLE_EXPORTS TRUE)
+ENDIF()
diff --git a/unittest/embedded/test-connect.cc b/unittest/embedded/test-connect.cc
new file mode 100644
index 00000000000..cd122286130
--- /dev/null
+++ b/unittest/embedded/test-connect.cc
@@ -0,0 +1,78 @@
+#include <mysql.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+int get_evar(char **hostname, char **port, char** username, char ** password)
+{
+
+ if (!((*hostname)= getenv("MYSQL_TEST_HOST")))
+ (*hostname)= (char *)"127.0.0.1";
+
+ if (!((*port)= getenv("MASTER_MYPORT")))
+ {
+ if (!((*port)= getenv("MYSQL_TEST_PORT")))
+ return 1;
+ }
+
+ if (!((*username)= getenv("MYSQL_TEST_USER")))
+ (*username)= (char *)"root";
+
+ if (!((*password)= getenv("MYSQL_TEST_PASSWD")))
+ (*password)= (char *)"";
+
+ return 0;
+}
+
+int main(int argc, char *argv[])
+{
+ MYSQL *mysql;
+ char *host;
+ char *user;
+ char *passwd;
+ char *porta;
+ unsigned int port;
+
+ if (get_evar(&host, &porta, &user, &passwd))
+ {
+ printf("set environment variable MASTER_MYPORT\n");
+ return 1;
+ }
+
+ port = atoi(porta);
+
+ mysql_thread_init();
+
+ if (mysql_server_init(-1, NULL, NULL) != 0) {
+ printf("mysql_library_init failed");
+ return 1;
+ }
+
+
+ mysql = mysql_init(NULL);
+
+ if (!mysql) {
+ printf("mysql_init failed");
+ return 1;
+ }
+
+ if (mysql_options(mysql, MYSQL_OPT_USE_REMOTE_CONNECTION, NULL) != 0) {
+ printf("mysql_options MYSQL_OPT_USE_REMOTE_CONNECTION failed: %s\n", mysql_error(mysql));
+ return 1;
+ }
+
+ if (mysql_options(mysql, MYSQL_SET_CHARSET_NAME, "utf8mb4") != 0) {
+ printf("mysql_options MYSQL_SET_CHARSET_NAME utf8mb4 failed: %s\n", mysql_error(mysql));
+ return 1;
+ }
+
+ if (!mysql_real_connect(mysql, host, user, passwd, NULL, port, NULL, CLIENT_FOUND_ROWS | CLIENT_MULTI_RESULTS | CLIENT_REMEMBER_OPTIONS)) {
+ printf("mysql_real_connect failed: %s\n", mysql_error(mysql));
+ return 1;
+ }
+ mysql_close(mysql);
+ mysql_thread_end();
+ mysql_library_end();
+
+ return 0;
+
+}
diff --git a/unittest/mysys/base64-t.c b/unittest/mysys/base64-t.c
index abbc028917d..a61deefa669 100644
--- a/unittest/mysys/base64-t.c
+++ b/unittest/mysys/base64-t.c
@@ -48,7 +48,7 @@ main(int argc __attribute__((unused)),char *argv[])
}
/* Encode */
- needed_length= my_base64_needed_encoded_length(src_len);
+ needed_length= my_base64_needed_encoded_length((int)src_len);
str= (char *) malloc(needed_length);
for (k= 0; k < needed_length; k++)
str[k]= 0xff; /* Fill memory to check correct NUL termination */
@@ -58,7 +58,7 @@ main(int argc __attribute__((unused)),char *argv[])
"my_base64_needed_encoded_length: size %d", i);
/* Decode */
- dst= (char *) malloc(my_base64_needed_decoded_length(strlen(str)));
+ dst= (char *) malloc(my_base64_needed_decoded_length((int)strlen(str)));
dst_len= my_base64_decode(str, strlen(str), dst, NULL, 0);
ok(dst_len == src_len, "Comparing lengths");
diff --git a/unittest/mysys/dynstring-t.c b/unittest/mysys/dynstring-t.c
index fed8488da2c..5343f854acd 100644
--- a/unittest/mysys/dynstring-t.c
+++ b/unittest/mysys/dynstring-t.c
@@ -13,7 +13,7 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
-//#include <my_global.h>
+#include <my_global.h>
#include <m_string.h>
#include <my_sys.h>
#include <tap.h>
diff --git a/unittest/mysys/lf-t.c b/unittest/mysys/lf-t.c
index 80f58856940..7070da648a8 100644
--- a/unittest/mysys/lf-t.c
+++ b/unittest/mysys/lf-t.c
@@ -177,15 +177,12 @@ pthread_handler_t test_lf_hash(void *arg)
void do_tests()
{
- plan(7);
+ plan(6);
lf_alloc_init(&lf_allocator, sizeof(TLA), offsetof(TLA, not_used));
lf_hash_init(&lf_hash, sizeof(int), LF_HASH_UNIQUE, 0, sizeof(int), 0,
&my_charset_bin);
- bad= my_atomic_initialize();
- ok(!bad, "my_atomic_initialize() returned %d", bad);
-
with_my_thread_init= 1;
test_concurrently("lf_pinbox (with my_thread_init)", test_lf_pinbox, N= THREADS, CYCLES);
test_concurrently("lf_alloc (with my_thread_init)", test_lf_alloc, N= THREADS, CYCLES);
diff --git a/unittest/mysys/my_atomic-t.c b/unittest/mysys/my_atomic-t.c
index 3198da6836d..7a7fbaeecd1 100644
--- a/unittest/mysys/my_atomic-t.c
+++ b/unittest/mysys/my_atomic-t.c
@@ -102,11 +102,7 @@ pthread_handler_t test_atomic_cas(void *arg)
void do_tests()
{
- plan(6);
-
- bad= my_atomic_initialize();
- ok(!bad, "my_atomic_initialize() returned %d", bad);
-
+ plan(5);
b32= c32= 0;
test_concurrently("my_atomic_add32", test_atomic_add, THREADS, CYCLES);
diff --git a/unittest/mysys/thr_template.c b/unittest/mysys/thr_template.c
index 38b8d2903a5..3606a253ae4 100644
--- a/unittest/mysys/thr_template.c
+++ b/unittest/mysys/thr_template.c
@@ -63,7 +63,7 @@ int main(int argc __attribute__((unused)), char **argv)
#define CYCLES 3000
#define THREADS 30
- diag("N CPUs: %d, atomic ops: %s", my_getncpus(), MY_ATOMIC_MODE);
+ diag("N CPUs: %d", my_getncpus());
do_tests();
diff --git a/unittest/mysys/waiting_threads-t.c b/unittest/mysys/waiting_threads-t.c
index ac481e0fe99..a2cb7a51c85 100644
--- a/unittest/mysys/waiting_threads-t.c
+++ b/unittest/mysys/waiting_threads-t.c
@@ -184,14 +184,11 @@ void do_tests()
skip(1, "Big test skipped");
return;
}
- plan(14);
+ plan(13);
compile_time_assert(THREADS >= 4);
DBUG_PRINT("wt", ("================= initialization ==================="));
- bad= my_atomic_initialize();
- ok(!bad, "my_atomic_initialize() returned %d", bad);
-
pthread_cond_init(&thread_sync, 0);
pthread_mutex_init(&lock, 0);
wt_init();
diff --git a/unittest/sql/mf_iocache-t.cc b/unittest/sql/mf_iocache-t.cc
index 287f1cb837a..40fd9509a88 100644
--- a/unittest/sql/mf_iocache-t.cc
+++ b/unittest/sql/mf_iocache-t.cc
@@ -13,6 +13,7 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA */
+#include <my_global.h>
#include <my_sys.h>
#include <my_crypt.h>
#include <tap.h>
@@ -143,7 +144,7 @@ void temp_io_cache()
res= reinit_io_cache(&info, READ_CACHE, 0, 0, 0);
ok(res == 0, "reinit READ_CACHE" INFO_TAIL);
- res= my_pread(info.file, buf, 50, 50, MYF(MY_NABP));
+ res= (int)my_pread(info.file, buf, 50, 50, MYF(MY_NABP));
ok(res == 0 && data_bad(buf, 50) == encrypt_tmp_files,
"file must be %sreadable", encrypt_tmp_files ?"un":"");
@@ -181,7 +182,7 @@ void mdev9044()
res= reinit_io_cache(&info, READ_CACHE, 0, 0, 0);
ok(res == 0, "reinit READ_CACHE" INFO_TAIL);
- res= my_b_fill(&info);
+ res= (int)my_b_fill(&info);
ok(res == 0, "fill" INFO_TAIL);
res= reinit_io_cache(&info, READ_CACHE, 0, 0, 0);
@@ -218,14 +219,14 @@ void mdev10259()
res= reinit_io_cache(&info, READ_CACHE, 0, 0, 0);
ok(res == 0, "reinit READ_CACHE" INFO_TAIL);
- res= my_b_fill(&info);
- ok(res == 200, "fill" INFO_TAIL);
+ size_t s= my_b_fill(&info);
+ ok(s == 200, "fill" INFO_TAIL);
- res= my_b_fill(&info);
- ok(res == 0, "fill" INFO_TAIL);
+ s= my_b_fill(&info);
+ ok(s == 0, "fill" INFO_TAIL);
- res= my_b_fill(&info);
- ok(res == 0, "fill" INFO_TAIL);
+ s= my_b_fill(&info);
+ ok(s == 0, "fill" INFO_TAIL);
res= reinit_io_cache(&info, WRITE_CACHE, saved_pos, 0, 0);
ok(res == 0, "reinit WRITE_CACHE" INFO_TAIL);
@@ -235,14 +236,14 @@ void mdev10259()
ok(200 == my_b_bytes_in_cache(&info),"my_b_bytes_in_cache == 200");
- res= my_b_fill(&info);
- ok(res == 0, "fill" INFO_TAIL);
+ s= my_b_fill(&info);
+ ok(s == 0, "fill" INFO_TAIL);
- res= my_b_fill(&info);
- ok(res == 0, "fill" INFO_TAIL);
+ s= my_b_fill(&info);
+ ok(s == 0, "fill" INFO_TAIL);
- res= my_b_fill(&info);
- ok(res == 0, "fill" INFO_TAIL);
+ s= my_b_fill(&info);
+ ok(s == 0, "fill" INFO_TAIL);
res= reinit_io_cache(&info, WRITE_CACHE, saved_pos, 0, 0);
ok(res == 0, "reinit WRITE_CACHE" INFO_TAIL);