summaryrefslogtreecommitdiff
path: root/client/mysqltest.c
diff options
context:
space:
mode:
Diffstat (limited to 'client/mysqltest.c')
-rw-r--r--client/mysqltest.c59
1 files changed, 40 insertions, 19 deletions
diff --git a/client/mysqltest.c b/client/mysqltest.c
index 4288b5d7871..1361dc843ed 100644
--- a/client/mysqltest.c
+++ b/client/mysqltest.c
@@ -45,7 +45,7 @@
#define MTEST_VERSION "1.10"
-#include <global.h>
+#include <my_global.h>
#include <my_sys.h>
#include <m_string.h>
#include <mysql.h>
@@ -257,7 +257,6 @@ static int mysql_rpl_parse_enabled(MYSQL* mysql __attribute__((unused))) { retur
static int mysql_rpl_probe(MYSQL *mysql __attribute__((unused))) { return 1; }
#endif
-
static void do_eval(DYNAMIC_STRING* query_eval, const char* query)
{
const char* p;
@@ -1112,6 +1111,25 @@ char* safe_get_param(char* str, char** arg, const char* msg)
DBUG_RETURN(str);
}
+int safe_connect(MYSQL* con, const char* host, const char* user,
+ const char* pass,
+ const char* db, int port, const char* sock)
+{
+ int con_error = 1;
+ int i;
+ for (i = 0; i < MAX_CON_TRIES; ++i)
+ {
+ if(mysql_real_connect(con, host,user, pass,
+ db, port, sock, 0))
+ {
+ con_error = 0;
+ break;
+ }
+ sleep(CON_RETRY_SLEEP);
+ }
+ return con_error;
+}
+
int do_connect(struct st_query* q)
{
@@ -1120,7 +1138,7 @@ int do_connect(struct st_query* q)
char* p=q->first_argument;
char buff[FN_REFLEN];
int con_port;
- int i, con_error;
+ int con_error;
DBUG_ENTER("do_connect");
DBUG_PRINT("enter",("connect: %s",p));
@@ -1153,20 +1171,9 @@ int do_connect(struct st_query* q)
con_sock=fn_format(buff, con_sock, TMPDIR, "",0);
if (!con_db[0])
con_db=db;
- con_error = 1;
- for (i = 0; i < MAX_CON_TRIES; ++i)
- {
- if(mysql_real_connect(&next_con->mysql, con_host,
+ if((con_error = safe_connect(&next_con->mysql, con_host,
con_user, con_pass,
- con_db, con_port, con_sock, 0))
- {
- con_error = 0;
- break;
- }
- sleep(CON_RETRY_SLEEP);
- }
-
- if(con_error)
+ con_db, con_port, con_sock)))
die("Could not open connection '%s': %s", con_name,
mysql_error(&next_con->mysql));
@@ -1928,12 +1935,26 @@ static void init_var_hash()
var_from_env("BIG_TEST", opt_big_test ? "1" : "0");
}
+static const char *embedded_server_args[] = {
+ "", /* XXX: argv[0] is program name - we should fix the API */
+ "--datadir=.",
+ "--language=/usr/local/mysql/share/mysql/english",
+ "--skip-innodb",
+ NullS
+};
+static const char *embedded_server_groups[] = {
+ "mysql-test-server",
+ NullS
+};
+
int main(int argc, char** argv)
{
int error = 0;
struct st_query* q;
my_bool require_file=0, q_send_flag=0;
char save_file[FN_REFLEN];
+ mysql_server_init(sizeof(embedded_server_args) / sizeof(char *) - 1,
+ embedded_server_args, embedded_server_groups);
MY_INIT(argv[0]);
save_file[0]=0;
@@ -1970,9 +1991,8 @@ int main(int argc, char** argv)
if (!cur_con->name)
die("Out of memory");
- if (!mysql_real_connect(&cur_con->mysql, host,
- user, pass, db, port, unix_sock,
- 0))
+ if (safe_connect(&cur_con->mysql, host,
+ user, pass, db, port, unix_sock))
die("Failed in mysql_real_connect(): %s", mysql_error(&cur_con->mysql));
while (!read_query(&q))
@@ -2098,6 +2118,7 @@ int main(int argc, char** argv)
printf("ok\n");
}
+ mysql_server_end();
free_used_memory();
exit(error ? 1 : 0);
return error ? 1 : 0; /* Keep compiler happy */