Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mariadb
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
mariadb
Commits
6f604246
Commit
6f604246
authored
Jul 23, 2003
by
greg@gcw.ath.cx
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mysql_test_run.c and associated files, with my initial changes and WAX's changes for Windows
parent
19efafcc
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
939 additions
and
553 deletions
+939
-553
BitKeeper/etc/logging_ok
BitKeeper/etc/logging_ok
+1
-0
netware/Makefile.am
netware/Makefile.am
+28
-28
netware/my_manage.c
netware/my_manage.c
+521
-247
netware/my_manage.h
netware/my_manage.h
+32
-2
netware/mysql_test_run.c
netware/mysql_test_run.c
+357
-276
No files found.
BitKeeper/etc/logging_ok
View file @
6f604246
...
@@ -22,6 +22,7 @@ carsten@tsort.bitbybit.dk
...
@@ -22,6 +22,7 @@ carsten@tsort.bitbybit.dk
davida@isil.mysql.com
davida@isil.mysql.com
gluh@gluh.(none)
gluh@gluh.(none)
gluh@gluh.mysql.r18.ru
gluh@gluh.mysql.r18.ru
greg@gcw.ath.cx
greg@mysql.com
greg@mysql.com
guilhem@mysql.com
guilhem@mysql.com
gweir@work.mysql.com
gweir@work.mysql.com
...
...
netware/Makefile.am
View file @
6f604246
# Copyright (c) 2002 Novell, Inc. All Rights Reserved.
# Copyright (c) 2002 Novell, Inc. All Rights Reserved.
#
#
# This program is free software; you can redistribute it and/or modify
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# it under the terms of the GNU General Public License as published by
...
@@ -11,37 +11,37 @@
...
@@ -11,37 +11,37 @@
# GNU General Public License for more details.
# GNU General Public License for more details.
#
#
# You should have received a copy of the GNU General Public License
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
INCLUDES
=
-I
$(srcdir)
/../include
-I
../include
-I
..
INCLUDES
=
-I
$(srcdir)
/../include
-I
../include
-I
..
bin_PROGRAMS
=
mysqld_safe mysql_install_db mysql_test_run libmysql
bin_PROGRAMS
=
mysqld_safe mysql_install_db mysql_test_run libmysql
mysqld_safe_SOURCES
=
mysqld_safe.c my_manage.c
mysqld_safe_SOURCES
=
mysqld_safe.c my_manage.c
mysql_install_db_SOURCES
=
mysql_install_db.c my_manage.c
mysql_install_db_SOURCES
=
mysql_install_db.c my_manage.c
mysql_test_run_SOURCES
=
mysql_test_run.c my_manage.c
mysql_test_run_SOURCES
=
mysql_test_run.c my_manage.c
libmysql_SOURCES
=
libmysqlmain.c
libmysql_SOURCES
=
libmysqlmain.c
libmysql_LDADD
=
../libmysql/.libs/libmysqlclient.a
libmysql_LDADD
=
../libmysql/.libs/libmysqlclient.a
netware_build_files
=
client/mysql.def client/mysqladmin.def
\
netware_build_files
=
client/mysql.def client/mysqladmin.def
\
client/mysqlbinlog.def client/mysqlcheck.def
\
client/mysqlbinlog.def client/mysqlcheck.def
\
client/mysqldump.def client/mysqlimport.def
\
client/mysqldump.def client/mysqlimport.def
\
client/mysqlshow.def client/mysqltest.def
\
client/mysqlshow.def client/mysqltest.def
\
extra/mysql_install.def extra/my_print_defaults.def
\
extra/mysql_install.def extra/my_print_defaults.def
\
extra/perror.def extra/replace.def
\
extra/perror.def extra/replace.def
\
extra/resolveip.def extra/comp_err.def
\
extra/resolveip.def extra/comp_err.def
\
isam/isamchk.def
\
isam/isamchk.def
\
isam/isamlog.def isam/pack_isam.def
\
isam/isamlog.def isam/pack_isam.def
\
libmysqld/libmysqld.def myisam/myisamchk.def
\
libmysqld/libmysqld.def myisam/myisamchk.def
\
myisam/myisamlog.def myisam/myisampack.def
\
myisam/myisamlog.def myisam/myisampack.def
\
sql/mysqld.def
sql/mysqld.def
link_sources
:
link_sources
:
set
-x
;
\
set
-x;
\
for
f
in
$(netware_build_files)
;
do
\
for
f
in
$(netware_build_files);
do
\
rm
-f
$(srcdir)
/../
$$
f
;
\
rm
-f
$(srcdir)/../$$f;
\
org
=
`
echo
$$
f |
sed
-e
's/.*\/\(.*\)/\1/g'
`
;
\
org
=
`
echo
$$
f |
sed
-e
's/.*\/\(.*\)/\1/g'
`
;
\
@LN_CP_F@
$(srcdir)
/
$$
org
$(srcdir)
/../
$$
f
;
\
@LN_CP_F@
$(srcdir)
/
$$
org
$(srcdir)
/../
$$
f
;
\
done
;
done
;
# Don't update the files from bitkeeper
# Don't update the files from bitkeeper
%
::
SCCS/s.%
%
::
SCCS/s.%
netware/my_manage.c
View file @
6f604246
/*
/*
Copyright (c) 2003 Novell, Inc. All Rights Reserved.
Copyright (c) 2003 MySQL AB
Copyright (c) 2003 Novell, Inc.
This program is free software; you can redistribute it and/or modify
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
(at your option) any later version.
This program is distributed in the hope that it will be useful,
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
*/
#include <stdio.h>
/*****************************************************************************
#include <errno.h>
** Utility functions for support programs
#include <dirent.h>
*****************************************************************************/
#include <string.h>
#include <screen.h>
/* MySQL library headers */
#include <proc.h>
#include <my_global.h>
#include <ctype.h>
#include <my_sys.h>
#include <sys/stat.h>
#include <my_dir.h>
#include <fcntl.h>
#include <m_string.h>
#include <assert.h>
/* These 'should' be POSIX or ANSI */
#include <assert.h>
/* ASSERT */
#include <stdarg.h>
/* vsprintf, va_* */
#include <sys/types.h>
/* pid_t */
#ifndef __WIN__
#include <unistd.h>
/* fork, rmdir, execve */
#endif
#include <stdio.h>
/* freopen */
#include <stdlib.h>
/* FILE */
#ifndef __WIN__
#include <dirent.h>
/* opendir, readdir */
#endif
#if !defined(__NETWARE__) && !defined(__WIN__)
#include <sys/wait.h>
#endif
#if !defined(__NETWARE__)
#include <signal.h>
#endif
/* For ASSERT -- Not totally sure about this one: */
#if !defined(ASSERT)
#define ASSERT(A) assert(A)
#endif
#include "my_manage.h"
#include "my_manage.h"
#define __STDC__ 1
/******************************************************************************
#include "process.h"
macros
******************************************************************************/
/******************************************************************************
global variables
******************************************************************************/
/******************************************************************************
/******************************************************************************
functions
init_args()
******************************************************************************/
/******************************************************************************
init_args()
Init an argument list.
Init an argument list.
******************************************************************************/
******************************************************************************/
void
init_args
(
arg_list_t
*
al
)
void
init_args
(
arg_list_t
*
al
)
{
{
#ifndef __WIN__
ASSERT
(
al
!=
NULL
);
ASSERT
(
al
!=
NULL
);
al
->
argc
=
0
;
al
->
argc
=
0
;
al
->
size
=
ARG_BUF
;
al
->
size
=
ARG_BUF
;
al
->
argv
=
malloc
(
al
->
size
*
sizeof
(
char
*
));
al
->
argv
=
(
char
**
)
my_malloc
(
al
->
size
*
sizeof
(
char
*
),
MYF
(
MY_WME
));
ASSERT
(
al
->
argv
!=
NULL
);
ASSERT
(
al
->
argv
!=
NULL
);
#else
win_args
[
0
]
=
'\0'
;
skip_first_param
=
TRUE
;
#endif
return
;
return
;
}
}
/******************************************************************************
/******************************************************************************
add_arg()
add_arg()
Add an argument to a list.
Add an argument to a list.
******************************************************************************/
******************************************************************************/
void
add_arg
(
arg_list_t
*
al
,
char
*
format
,
...)
void
add_arg
(
arg_list_t
*
al
,
c
onst
c
har
*
format
,
...)
{
{
#ifndef __WIN__
va_list
ap
;
va_list
ap
;
char
temp
[
PATH_MAX
];
char
temp
[
PATH_MAX
];
ASSERT
(
al
!=
NULL
);
ASSERT
(
al
!=
NULL
);
/
/ increase size
/
* increase size */
if
(
al
->
argc
>=
al
->
size
)
if
(
al
->
argc
>=
(
int
)
al
->
size
)
{
{
al
->
size
+=
ARG_BUF
;
al
->
size
+=
ARG_BUF
;
al
->
argv
=
realloc
(
al
->
argv
,
al
->
size
*
sizeof
(
char
*
));
al
->
argv
=
(
char
**
)
my_realloc
((
char
*
)
al
->
argv
,
al
->
size
*
sizeof
(
char
*
),
MYF
(
MY_WME
));
ASSERT
(
al
->
argv
!=
NULL
);
ASSERT
(
al
->
argv
!=
NULL
);
}
}
...
@@ -94,7 +108,7 @@ void add_arg(arg_list_t *al, char *format, ...)
...
@@ -94,7 +108,7 @@ void add_arg(arg_list_t *al, char *format, ...)
vsprintf
(
temp
,
format
,
ap
);
vsprintf
(
temp
,
format
,
ap
);
va_end
(
ap
);
va_end
(
ap
);
al
->
argv
[
al
->
argc
]
=
m
alloc
(
strlen
(
temp
)
+
1
);
al
->
argv
[
al
->
argc
]
=
m
y_malloc
(
strlen
(
temp
)
+
1
,
MYF
(
MY_WME
)
);
ASSERT
(
al
->
argv
[
al
->
argc
]
!=
NULL
);
ASSERT
(
al
->
argv
[
al
->
argc
]
!=
NULL
);
strcpy
(
al
->
argv
[
al
->
argc
],
temp
);
strcpy
(
al
->
argv
[
al
->
argc
],
temp
);
...
@@ -104,19 +118,36 @@ void add_arg(arg_list_t *al, char *format, ...)
...
@@ -104,19 +118,36 @@ void add_arg(arg_list_t *al, char *format, ...)
{
{
al
->
argv
[
al
->
argc
]
=
NULL
;
al
->
argv
[
al
->
argc
]
=
NULL
;
}
}
#else
va_list
ap
;
char
param
[
PATH_MAX
];
if
(
!
skip_first_param
)
{
va_start
(
ap
,
format
);
vsprintf
(
&
param
,
format
,
ap
);
va_end
(
ap
);
strcat
(
win_args
,
" "
);
strcat
(
win_args
,
param
);
}
else
{
skip_first_param
=
FALSE
;
}
#endif
return
;
return
;
}
}
/******************************************************************************
/******************************************************************************
free_args()
free_args()
Free an argument list.
Free an argument list.
******************************************************************************/
******************************************************************************/
void
free_args
(
arg_list_t
*
al
)
void
free_args
(
arg_list_t
*
al
)
{
{
#ifndef __WIN__
int
i
;
int
i
;
ASSERT
(
al
!=
NULL
);
ASSERT
(
al
!=
NULL
);
...
@@ -124,74 +155,110 @@ void free_args(arg_list_t *al)
...
@@ -124,74 +155,110 @@ void free_args(arg_list_t *al)
for
(
i
=
0
;
i
<
al
->
argc
;
i
++
)
for
(
i
=
0
;
i
<
al
->
argc
;
i
++
)
{
{
ASSERT
(
al
->
argv
[
i
]
!=
NULL
);
ASSERT
(
al
->
argv
[
i
]
!=
NULL
);
free
(
al
->
argv
[
i
]
);
my_free
(
al
->
argv
[
i
],
MYF
(
MY_WME
)
);
al
->
argv
[
i
]
=
NULL
;
al
->
argv
[
i
]
=
NULL
;
}
}
free
(
al
->
argv
);
my_free
((
char
*
)
al
->
argv
,
MYF
(
MY_WME
)
);
al
->
argc
=
0
;
al
->
argc
=
0
;
al
->
argv
=
NULL
;
al
->
argv
=
NULL
;
#endif
return
;
return
;
}
}
/******************************************************************************
/******************************************************************************
sleep_until_file_deleted()
sleep_until_file_deleted()
Sleep until the given file is no longer found.
Sleep until the given file is no longer found.
******************************************************************************/
******************************************************************************/
int
sleep_until_file_deleted
(
char
*
pid_file
)
int
sleep_until_file_deleted
(
char
*
pid_file
)
{
{
struct
stat
buf
;
MY_STAT
stat_info
;
int
i
,
err
;
int
i
,
err
=
0
;
#ifndef __WIN__
for
(
i
=
0
;
(
i
<
TRY_MAX
)
&&
(
err
=
!
stat
(
pid_file
,
&
buf
));
i
++
)
sleep
(
1
);
for
(
i
=
0
;
i
<
TRY_MAX
;
i
++
)
{
if
(
err
!=
0
)
err
=
errno
;
if
(
my_stat
(
pid_file
,
&
stat_info
,
MYF
(
0
))
==
(
MY_STAT
*
)
NULL
)
{
return
err
;
err
=
errno
;
break
;
}
my_sleep
(
1
);
}
#else
switch
(
pid_mode
)
{
case
MASTER_PID
:
err
=
(
WaitForSingleObject
(
master_server
,
TRY_MAX
*
1000
)
==
WAIT_TIMEOUT
);
pid_mode
=
0
;
break
;
case
SLAVE_PID
:
err
=
(
WaitForSingleObject
(
slave_server
,
TRY_MAX
*
1000
)
==
WAIT_TIMEOUT
);
pid_mode
=
0
;
break
;
};
#endif
return
err
;
}
}
/******************************************************************************
/******************************************************************************
sleep_until_file_exists()
sleep_until_file_exists()
Sleep until the given file exists.
Sleep until the given file exists.
******************************************************************************/
******************************************************************************/
int
sleep_until_file_exists
(
char
*
pid_file
)
int
sleep_until_file_exists
(
char
*
pid_file
)
{
{
struct
stat
buf
;
MY_STAT
stat_info
;
int
i
,
err
;
int
i
,
err
=
0
;
for
(
i
=
0
;
(
i
<
TRY_MAX
)
&&
(
err
=
stat
(
pid_file
,
&
buf
));
i
++
)
sleep
(
1
);
#ifndef __WIN__
for
(
i
=
0
;
i
<
TRY_MAX
;
i
++
)
if
(
err
!=
0
)
err
=
errno
;
{
if
(
my_stat
(
pid_file
,
&
stat_info
,
MYF
(
0
))
==
(
MY_STAT
*
)
NULL
)
return
err
;
{
err
=
errno
;
break
;
}
my_sleep
(
1
);
}
#else
switch
(
pid_mode
)
{
case
MASTER_PID
:
WaitForSingleObject
(
master_server
,
TRY_MAX
*
1000
);
pid_mode
=
0
;
break
;
case
SLAVE_PID
:
WaitForSingleObject
(
slave_server
,
TRY_MAX
*
1000
);
pid_mode
=
0
;
break
;
};
#endif
return
err
;
}
}
/******************************************************************************
/******************************************************************************
wait_for_server_start()
wait_for_server_start()
Wait for the server on the given port to start.
Wait for the server on the given port to start.
******************************************************************************/
******************************************************************************/
int
wait_for_server_start
(
char
*
bin_dir
,
char
*
user
,
char
*
password
,
int
port
)
int
wait_for_server_start
(
char
*
bin_dir
,
char
*
user
,
char
*
password
,
int
port
)
{
{
arg_list_t
al
;
arg_list_t
al
;
int
err
,
i
;
int
err
=
0
,
i
;
char
mysqladmin_file
[
PATH_MAX
];
char
trash
[
PATH_MAX
];
char
trash
[
PATH_MAX
];
// mysqladmin file
/* mysqladmin file */
snprintf
(
mysqladmin_file
,
PATH_MAX
,
"%s/mysqladmin"
,
bin_dir
);
my_snprintf
(
trash
,
PATH_MAX
,
"/tmp/trash.out"
);
snprintf
(
trash
,
PATH_MAX
,
"/tmp/trash.out"
);
/* args */
// args
init_args
(
&
al
);
init_args
(
&
al
);
add_arg
(
&
al
,
"%s"
,
mysqladmin_file
);
add_arg
(
&
al
,
"%s"
,
mysqladmin_file
);
add_arg
(
&
al
,
"--no-defaults"
);
add_arg
(
&
al
,
"--no-defaults"
);
...
@@ -205,13 +272,13 @@ int wait_for_server_start(char *bin_dir, char *user, char *password, int port)
...
@@ -205,13 +272,13 @@ int wait_for_server_start(char *bin_dir, char *user, char *password, int port)
add_arg
(
&
al
,
"--host=localhost"
);
add_arg
(
&
al
,
"--host=localhost"
);
add_arg
(
&
al
,
"ping"
);
add_arg
(
&
al
,
"ping"
);
//
NetWare does not support the connect timeout in the TCP/IP stack
/*
NetWare does not support the connect timeout in the TCP/IP stack
// -- we will try the ping multiple times
-- we will try the ping multiple times */
for
(
i
=
0
;
(
i
<
TRY_MAX
)
for
(
i
=
0
;
(
i
<
TRY_MAX
)
&&
(
err
=
spawn
(
mysqladmin_file
,
&
al
,
TRUE
,
NULL
,
&&
(
err
=
spawn
(
mysqladmin_file
,
&
al
,
TRUE
,
NULL
,
trash
,
NULL
));
i
++
)
sleep
(
1
);
trash
,
NULL
,
NOT_NEED_PID
));
i
++
)
sleep
(
1
);
/
/ free args
/
* free args */
free_args
(
&
al
);
free_args
(
&
al
);
return
err
;
return
err
;
...
@@ -219,20 +286,23 @@ int wait_for_server_start(char *bin_dir, char *user, char *password, int port)
...
@@ -219,20 +286,23 @@ int wait_for_server_start(char *bin_dir, char *user, char *password, int port)
/******************************************************************************
/******************************************************************************
spawn()
spawn()
Spawn
the given path with the given arguments.
Spawn the executable at
the given path with the given arguments.
******************************************************************************/
******************************************************************************/
#ifdef __NETWARE__
int
spawn
(
char
*
path
,
arg_list_t
*
al
,
int
join
,
char
*
input
,
int
spawn
(
char
*
path
,
arg_list_t
*
al
,
int
join
,
char
*
input
,
char
*
output
,
char
*
error
)
char
*
output
,
char
*
error
)
{
{
pid_t
pid
;
pid_t
pid
;
int
result
=
0
;
int
result
=
0
;
wiring_t
wiring
=
{
FD_UNUSED
,
FD_UNUSED
,
FD_UNUSED
};
wiring_t
wiring
=
{
FD_UNUSED
,
FD_UNUSED
,
FD_UNUSED
};
unsigned
long
flags
=
PROC_CURRENT_SPACE
|
PROC_INHERIT_CWD
;
unsigned
long
flags
=
PROC_CURRENT_SPACE
|
PROC_INHERIT_CWD
;
/
/ open wiring
/
* open wiring */
if
(
input
)
if
(
input
)
wiring
.
infd
=
open
(
input
,
O_RDONLY
);
wiring
.
infd
=
open
(
input
,
O_RDONLY
);
...
@@ -242,14 +312,14 @@ int spawn(char *path, arg_list_t *al, int join, char *input,
...
@@ -242,14 +312,14 @@ int spawn(char *path, arg_list_t *al, int join, char *input,
if
(
error
)
if
(
error
)
wiring
.
errfd
=
open
(
error
,
O_WRONLY
|
O_CREAT
|
O_TRUNC
);
wiring
.
errfd
=
open
(
error
,
O_WRONLY
|
O_CREAT
|
O_TRUNC
);
/
/ procve requires a NULL
/
* procve requires a NULL */
add_arg
(
al
,
NULL
);
add_arg
(
al
,
NULL
);
/
/ go
/
* go */
pid
=
procve
(
path
,
flags
,
NULL
,
&
wiring
,
NULL
,
NULL
,
0
,
pid
=
procve
(
path
,
flags
,
NULL
,
&
wiring
,
NULL
,
NULL
,
0
,
NULL
,
(
const
char
**
)
al
->
argv
);
NULL
,
(
const
char
**
)
al
->
argv
);
if
(
pid
==
-
1
)
if
(
pid
==
-
1
)
{
{
result
=
-
1
;
result
=
-
1
;
}
}
...
@@ -257,8 +327,8 @@ int spawn(char *path, arg_list_t *al, int join, char *input,
...
@@ -257,8 +327,8 @@ int spawn(char *path, arg_list_t *al, int join, char *input,
{
{
waitpid
(
pid
,
&
result
,
0
);
waitpid
(
pid
,
&
result
,
0
);
}
}
/
/ close wiring
/
* close wiring */
if
(
wiring
.
infd
!=
-
1
)
if
(
wiring
.
infd
!=
-
1
)
close
(
wiring
.
infd
);
close
(
wiring
.
infd
);
...
@@ -268,207 +338,411 @@ int spawn(char *path, arg_list_t *al, int join, char *input,
...
@@ -268,207 +338,411 @@ int spawn(char *path, arg_list_t *al, int join, char *input,
if
(
wiring
.
errfd
!=
-
1
)
if
(
wiring
.
errfd
!=
-
1
)
close
(
wiring
.
errfd
);
close
(
wiring
.
errfd
);
return
result
;
return
result
;
}
#else
/* NOT __NETWARE__ */
#ifdef __WIN__
int
my_vsnprintf_
(
char
*
to
,
size_t
n
,
const
char
*
value
,
...)
{
char
*
start
=
to
,
*
end
=
to
+
n
-
1
;
uint
length
,
num_state
,
pre_zero
;
reg2
char
*
par
;
// = value;
va_list
args
;
va_start
(
args
,
value
);
par
=
va_arg
(
args
,
char
*
);
while
(
par
!=
NULL
)
{
uint
plen
,
left_len
=
(
uint
)(
end
-
to
)
+
1
;
if
(
!
par
)
par
=
(
char
*
)
"(null)"
;
plen
=
(
uint
)
strlen
(
par
);
if
(
left_len
<=
plen
)
plen
=
left_len
-
1
;
to
=
strnmov
(
to
+
strlen
(
to
),
par
,
plen
);
par
=
va_arg
(
args
,
char
*
);
}
va_end
(
args
);
DBUG_ASSERT
(
to
<=
end
);
*
to
=
'\0'
;
return
(
uint
)
(
to
-
start
);
}
int
spawn
(
char
*
path
,
arg_list_t
*
al
,
int
join
,
char
*
input
,
char
*
output
,
char
*
error
)
{
char
*
cl
;
char
*
arg
;
intptr_t
result
;
int
j
;
int
err
;
STARTUPINFO
startup_info
;
PROCESS_INFORMATION
process_information
;
ULONG
dosretval
;
int
retval
;
DWORD
exit_code
;
SECURITY_ATTRIBUTES
process_attributes
,
thread_attributes
;
char
command_line
[
1024
]
=
""
;
memset
(
&
startup_info
,
0
,
sizeof
(
STARTUPINFO
));
startup_info
.
cb
=
sizeof
(
STARTUPINFO
);
if
(
input
)
freopen
(
input
,
"rb"
,
stdin
);
if
(
output
)
freopen
(
output
,
"wb"
,
stdout
);
if
(
error
)
freopen
(
error
,
"wb"
,
stderr
);
result
=
CreateProcess
(
path
,
&
win_args
,
NULL
,
NULL
,
TRUE
,
0
,
NULL
,
NULL
,
&
startup_info
,
&
process_information
);
if
(
process_information
.
hProcess
)
{
if
(
join
)
{
if
(
WaitForSingleObject
(
process_information
.
hProcess
,
mysqld_timeout
)
==
WAIT_TIMEOUT
)
{
exit_code
=
-
1
;
}
else
{
GetExitCodeProcess
(
process_information
.
hProcess
,
&
exit_code
);
}
CloseHandle
(
process_information
.
hProcess
);
}
else
{
exit_code
=
0
;
}
if
(
run_server
)
{
switch
(
pid_mode
)
{
case
MASTER_PID
:
master_server
=
process_information
.
hProcess
;
break
;
case
SLAVE_PID
:
slave_server
=
process_information
.
hProcess
;
break
;
};
pid_mode
=
0
;
run_server
=
FALSE
;
};
}
else
{
exit_code
=
-
1
;
}
if
(
input
)
freopen
(
"CONIN$"
,
"rb"
,
stdin
);
if
(
output
)
freopen
(
"CONOUT$"
,
"wb"
,
stdout
);
if
(
error
)
freopen
(
"CONOUT$"
,
"wb"
,
stderr
);
return
exit_code
;
}
}
#else
/* NOT __NETWARE__, NOT __WIN__ */
/* This assumes full POSIX.1 compliance */
int
spawn
(
char
*
path
,
arg_list_t
*
al
,
int
join
,
char
*
input
,
char
*
output
,
char
*
error
)
{
int
result
=
0
;
pid_t
pid
;
if
((
pid
=
fork
()))
{
/* Remains in parent process */
if
(
join
&&
(
pid
!=
-
1
))
waitpid
(
pid
,
&
result
,
0
);
}
else
{
/* Child process */
/* Reassign streams */
if
(
input
)
freopen
(
input
,
"r"
,
stdin
);
if
(
output
)
freopen
(
output
,
"w"
,
stdout
);
if
(
error
)
freopen
(
error
,
"w"
,
stderr
);
/* Spawn the process */
execve
(
path
,
al
->
argv
,
environ
);
}
return
result
;
}
#endif
/* __WIN__ */
#endif
/* __NETWARE__ */
/******************************************************************************
/******************************************************************************
stop_server()
stop_server()
Stop the server with the given port and pid file.
Stop the server with the given port and pid file.
******************************************************************************/
******************************************************************************/
int
stop_server
(
char
*
bin_dir
,
char
*
user
,
char
*
password
,
int
port
,
int
stop_server
(
char
*
bin_dir
,
char
*
user
,
char
*
password
,
int
port
,
char
*
pid_file
)
char
*
pid_file
)
{
{
arg_list_t
al
;
arg_list_t
al
;
int
err
,
i
,
argc
=
0
;
int
err
;
char
mysqladmin_file
[
PATH_MAX
];
char
trash
[
PATH_MAX
];
char
trash
[
PATH_MAX
];
// mysqladmin file
my_snprintf
(
trash
,
PATH_MAX
,
"/tmp/trash.out"
);
snprintf
(
mysqladmin_file
,
PATH_MAX
,
"%s/mysqladmin"
,
bin_dir
);
snprintf
(
trash
,
PATH_MAX
,
"/tmp/trash.out"
);
/* args */
// args
init_args
(
&
al
);
init_args
(
&
al
);
add_arg
(
&
al
,
"%s"
,
mysqladmin_file
);
add_arg
(
&
al
,
"%s"
,
mysqladmin_file
);
add_arg
(
&
al
,
"--no-defaults"
);
add_arg
(
&
al
,
"--no-defaults"
);
add_arg
(
&
al
,
"--port=%u"
,
port
);
add_arg
(
&
al
,
"--port=%u"
,
port
);
add_arg
(
&
al
,
"--user=%s"
,
user
);
add_arg
(
&
al
,
"--user=%s"
,
user
);
add_arg
(
&
al
,
"--password=%s"
,
password
);
add_arg
(
&
al
,
"--password=%s"
,
password
);
add_arg
(
&
al
,
"-O"
);
add_arg
(
&
al
,
"-O"
);
add_arg
(
&
al
,
"shutdown_timeout=20"
);
add_arg
(
&
al
,
"shutdown_timeout=20"
);
add_arg
(
&
al
,
"shutdown"
);
add_arg
(
&
al
,
"shutdown"
);
// spawn
/* spawn */
if
((
err
=
spawn
(
mysqladmin_file
,
&
al
,
TRUE
,
NULL
,
if
((
err
=
spawn
(
mysqladmin_file
,
&
al
,
TRUE
,
NULL
,
trash
,
NULL
))
==
0
)
trash
,
NULL
))
==
0
)
{
{
sleep_until_file_deleted
(
pid_file
);
sleep_until_file_deleted
(
pid_file
);
}
}
else
else
{
{
pid_t
pid
=
get_server_pid
(
pid_file
);
pid_t
pid
=
get_server_pid
(
pid_file
);
// shutdown failed - kill server
kill_server
(
pid
);
sleep
(
TRY_MAX
);
// remove pid file if possible
/* shutdown failed - kill server */
err
=
remove
(
pid_file
);
kill_server
(
pid
);
sleep
(
TRY_MAX
);
/* remove pid file if possible */
err
=
my_delete
(
pid_file
,
MYF
(
MY_WME
));
}
}
/
/ free args
/
* free args */
free_args
(
&
al
);
free_args
(
&
al
);
return
err
;
return
err
;
}
}
/******************************************************************************
/******************************************************************************
get_server_pid()
get_server_pid()
Get the VM id with the given pid file.
Get the VM id with the given pid file.
******************************************************************************/
******************************************************************************/
pid_t
get_server_pid
(
char
*
pid_file
)
pid_t
get_server_pid
(
char
*
pid_file
)
{
{
char
buf
[
PATH_MAX
];
char
buf
[
PATH_MAX
];
int
fd
,
err
;
int
err
;
char
*
p
;
File
fd
;
pid_t
id
;
char
*
p
;
pid_t
id
=
0
;
// discover id
fd
=
open
(
pid_file
,
O_RDONLY
);
/* discover id */
fd
=
my_open
(
pid_file
,
O_RDONLY
,
MYF
(
MY_WME
));
err
=
read
(
fd
,
buf
,
PATH_MAX
);
err
=
my_read
(
fd
,
buf
,
PATH_MAX
,
MYF
(
MY_WME
));
close
(
fd
);
my_close
(
fd
,
MYF
(
MY_WME
));
if
(
err
>
0
)
{
if
(
err
>
0
)
// terminate string
{
if
((
p
=
strchr
(
buf
,
'\n'
))
!=
NULL
)
/* terminate string */
{
if
((
p
=
strchr
(
buf
,
'\n'
))
!=
NULL
)
*
p
=
NULL
;
{
*
p
=
'\0'
;
// check for a '\r'
if
((
p
=
strchr
(
buf
,
'\r'
))
!=
NULL
)
/* check for a '\r' */
{
if
((
p
=
strchr
(
buf
,
'\r'
))
!=
NULL
)
*
p
=
NULL
;
{
}
*
p
=
'\0'
;
}
}
else
}
{
else
buf
[
err
]
=
NULL
;
{
}
buf
[
err
]
=
'\0'
;
}
id
=
strtol
(
buf
,
NULL
,
0
);
}
id
=
strtol
(
buf
,
NULL
,
0
);
}
return
id
;
return
id
;
}
}
/******************************************************************************
/******************************************************************************
kill_server()
kill_server()
Force a kill of the server with the given pid.
Force a kill of the server with the given pid.
******************************************************************************/
******************************************************************************/
void
kill_server
(
pid_t
pid
)
void
kill_server
(
pid_t
pid
)
{
{
if
(
pid
>
0
)
if
(
pid
>
0
)
{
{
// destroy vm
#if !defined(__NETWARE__)
/* Send SIGTERM to pid */
kill
(
pid
,
SIGTERM
);
#else
/* __NETWARE__ */
/* destroy vm */
NXVmDestroy
(
pid
);
NXVmDestroy
(
pid
);
#endif
}
}
}
}
/******************************************************************************
/******************************************************************************
del_tree()
del_tree()
Delete the directory and subdirectories.
Delete the directory and subdirectories.
******************************************************************************/
******************************************************************************/
void
del_tree
(
char
*
dir
)
void
del_tree
(
char
*
dir
)
{
{
DIR
*
parent
=
opendir
(
dir
);
MY_DIR
*
current
;
DIR
*
entry
;
uint
i
;
char
temp
[
PATH_MAX
];
char
temp
[
PATH_MAX
];
if
(
parent
==
NULL
)
current
=
my_dir
(
dir
,
MYF
(
MY_WME
|
MY_WANT_STAT
));
{
return
;
/* current is NULL if dir does not exist */
}
if
(
current
==
NULL
)
return
;
while
((
entry
=
readdir
(
parent
))
!=
NULL
)
{
for
(
i
=
0
;
i
<
current
->
number_off_files
;
i
++
)
// create long name
{
snprintf
(
temp
,
PATH_MAX
,
"%s/%s"
,
dir
,
entry
->
d_name
);
/* create long name */
my_snprintf
(
temp
,
PATH_MAX
,
"%s/%s"
,
dir
,
current
->
dir_entry
[
i
].
name
);
if
(
entry
->
d_name
[
0
]
==
'.'
)
{
if
(
current
->
dir_entry
[
i
].
name
[
0
]
==
'.'
)
// Skip
{
}
/* Skip */
else
if
(
S_ISDIR
(
entry
->
d_type
))
}
{
else
if
(
MY_S_ISDIR
(
current
->
dir_entry
[
i
].
mystat
.
st_mode
))
// delete subdirectory
{
del_tree
(
temp
);
/* delete subdirectory */
}
del_tree
(
temp
);
else
}
{
else
// remove file
{
remove
(
temp
);
/* remove file */
}
my_delete
(
temp
,
MYF
(
MY_WME
));
}
}
}
// remove directory
rmdir
(
dir
);
my_dirend
(
current
);
/* remove directory */
rmdir
(
dir
);
}
}
/******************************************************************************
/******************************************************************************
removef()
removef()
******************************************************************************/
******************************************************************************/
int
removef
(
char
*
format
,
...)
int
removef
(
c
onst
c
har
*
format
,
...)
{
{
va_list
ap
;
va_list
ap
;
char
path
[
PATH_MAX
];
char
path
[
PATH_MAX
];
va_start
(
ap
,
format
);
vsnprintf
(
path
,
PATH_MAX
,
format
,
ap
);
va_start
(
ap
,
format
);
va_end
(
ap
);
my_vsnprintf
(
path
,
PATH_MAX
,
format
,
ap
);
return
remove
(
path
);
va_end
(
ap
);
#ifdef __WIN__
{
MY_DIR
*
current
;
uint
i
;
struct
_finddata_t
find
;
char
temp
[
PATH_MAX
];
#ifdef _WIN64
__int64
handle
;
#else
long
handle
;
#endif
char
*
p
;
p
=
strrchr
(
path
,
'\\'
);
if
(
p
==
NULL
)
{
p
=
strrchr
(
path
,
'/'
);
if
(
p
==
NULL
)
p
=
&
path
;
else
p
++
;
}
else
p
++
;
if
((
handle
=
_findfirst
(
path
,
&
find
))
==
-
1L
)
return
0
;
do
{
strcpy
(
p
,
find
.
name
);
my_delete
(
path
,
MYF
(
MY_WME
));
}
while
(
!
_findnext
(
handle
,
&
find
));
_findclose
(
handle
);
}
#else
return
my_delete
(
path
,
MYF
(
MY_WME
));
#endif
}
}
/******************************************************************************
/******************************************************************************
get_basedir()
get_basedir()
******************************************************************************/
******************************************************************************/
void
get_basedir
(
char
*
argv0
,
char
*
basedir
)
void
get_basedir
(
char
*
argv0
,
char
*
basedir
)
{
{
char
temp
[
PATH_MAX
];
char
temp
[
PATH_MAX
];
char
*
p
;
char
*
p
;
ASSERT
(
argv0
!=
NULL
);
ASSERT
(
argv0
!=
NULL
);
ASSERT
(
basedir
!=
NULL
);
ASSERT
(
basedir
!=
NULL
);
strcpy
(
temp
,
strlwr
(
argv0
));
strcpy
(
temp
,
argv0
);
while
((
p
=
strchr
(
temp
,
'\\'
))
!=
NULL
)
*
p
=
'/'
;
#ifndef __WIN__
casedn_str
(
temp
);
if
((
p
=
strindex
(
temp
,
"/bin/"
))
!=
NULL
)
#endif
{
while
((
p
=
strchr
(
temp
,
'\\'
))
!=
NULL
)
*
p
=
'/'
;
*
p
=
NULL
;
strcpy
(
basedir
,
temp
);
if
((
p
=
strstr
(
temp
,
"/bin/"
))
!=
NullS
)
}
{
*
p
=
'\0'
;
strcpy
(
basedir
,
temp
);
}
}
}
netware/my_manage.h
View file @
6f604246
...
@@ -26,17 +26,41 @@
...
@@ -26,17 +26,41 @@
******************************************************************************/
******************************************************************************/
#include <stdlib.h>
#include <stdlib.h>
#ifndef __WIN__
#include <unistd.h>
#include <unistd.h>
#endif
/******************************************************************************
/******************************************************************************
macros
macros
******************************************************************************/
******************************************************************************/
#ifdef __WIN__
#define PATH_MAX _MAX_PATH
#define NAME_MAX _MAX_FNAME
#define kill(A,B) TerminateProcess((HANDLE)A,0)
#define NOT_NEED_PID 0
#define MASTER_PID 1
#define SLAVE_PID 2
#define mysqld_timeout 60000
intptr_t
master_server
;
intptr_t
slave_server
;
int
pid_mode
;
bool
run_server
;
char
win_args
[
1024
];
bool
skip_first_param
;
#endif
#define ARG_BUF 10
#define ARG_BUF 10
#define TRY_MAX 5
#define TRY_MAX 5
#ifdef __NETWARE__
#define strstr(A,B) strindex(A,B)
#endif
/******************************************************************************
/******************************************************************************
structures
structures
...
@@ -53,6 +77,8 @@ typedef struct
...
@@ -53,6 +77,8 @@ typedef struct
}
arg_list_t
;
}
arg_list_t
;
typedef
int
pid_t
;
/******************************************************************************
/******************************************************************************
global variables
global variables
...
@@ -66,7 +92,7 @@ typedef struct
...
@@ -66,7 +92,7 @@ typedef struct
******************************************************************************/
******************************************************************************/
void
init_args
(
arg_list_t
*
);
void
init_args
(
arg_list_t
*
);
void
add_arg
(
arg_list_t
*
,
char
*
,
...);
void
add_arg
(
arg_list_t
*
,
c
onst
c
har
*
,
...);
void
free_args
(
arg_list_t
*
);
void
free_args
(
arg_list_t
*
);
int
sleep_until_file_exists
(
char
*
);
int
sleep_until_file_exists
(
char
*
);
...
@@ -80,8 +106,12 @@ pid_t get_server_pid(char *);
...
@@ -80,8 +106,12 @@ pid_t get_server_pid(char *);
void
kill_server
(
pid_t
pid
);
void
kill_server
(
pid_t
pid
);
void
del_tree
(
char
*
);
void
del_tree
(
char
*
);
int
removef
(
char
*
,
...);
int
removef
(
c
onst
c
har
*
,
...);
void
get_basedir
(
char
*
,
char
*
);
void
get_basedir
(
char
*
,
char
*
);
char
mysqladmin_file
[
PATH_MAX
];
#endif
/* _MY_MANAGE */
#endif
/* _MY_MANAGE */
netware/mysql_test_run.c
View file @
6f604246
...
@@ -16,21 +16,29 @@
...
@@ -16,21 +16,29 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
*/
#include <stdlib.h>
/* MySQL library headers */
#include <my_global.h>
#include <my_sys.h>
#include <my_dir.h>
#include <m_string.h>
/* These 'should' be POSIX or ANSI */
#include <stdio.h>
#include <stdio.h>
#include <
errno
.h>
#include <
stdarg
.h>
#include <dirent.h>
#i
nclude <string.h>
#i
fdef __NETWARE__
#include <screen.h>
#include <screen.h>
#include <nks/vm.h>
#endif
#include <ctype.h>
#include <sys/stat.h>
#include <unistd.h>
#include <fcntl.h>
#include "my_config.h"
#include "my_config.h"
#include "my_manage.h"
#include "my_manage.h"
#ifdef __WIN__
#include <Shlwapi.h>
#endif
/******************************************************************************
/******************************************************************************
macros
macros
...
@@ -42,16 +50,16 @@
...
@@ -42,16 +50,16 @@
#define NW_TEST_SUFFIX ".nw-test"
#define NW_TEST_SUFFIX ".nw-test"
#define NW_RESULT_SUFFIX ".nw-result"
#define NW_RESULT_SUFFIX ".nw-result"
#define TEST_SUFFIX
".test"
#define TEST_SUFFIX
".test"
#define RESULT_SUFFIX
".result"
#define RESULT_SUFFIX
".result"
#define REJECT_SUFFIX
".reject"
#define REJECT_SUFFIX
".reject"
#define OUT_SUFFIX
".out"
#define OUT_SUFFIX
".out"
#define ERR_SUFFIX
".err"
#define ERR_SUFFIX
".err"
#define TEST_PASS
"[ pass ]"
#define TEST_PASS
"[ pass ]"
#define TEST_SKIP
"[ skip ]"
#define TEST_SKIP
"[ skip ]"
#define TEST_FAIL
"[ fail ]"
#define TEST_FAIL
"[ fail ]"
#define TEST_BAD
"[ bad ]"
#define TEST_BAD
"[ bad ]"
/******************************************************************************
/******************************************************************************
...
@@ -59,7 +67,7 @@
...
@@ -59,7 +67,7 @@
******************************************************************************/
******************************************************************************/
char
base_dir
[
PATH_MAX
]
=
"
sys:
/mysql"
;
char
base_dir
[
PATH_MAX
]
=
"/mysql"
;
char
db
[
PATH_MAX
]
=
"test"
;
char
db
[
PATH_MAX
]
=
"test"
;
char
user
[
PATH_MAX
]
=
"root"
;
char
user
[
PATH_MAX
]
=
"root"
;
char
password
[
PATH_MAX
]
=
""
;
char
password
[
PATH_MAX
]
=
""
;
...
@@ -67,7 +75,7 @@ char password[PATH_MAX] = "";
...
@@ -67,7 +75,7 @@ char password[PATH_MAX] = "";
int
master_port
=
9306
;
int
master_port
=
9306
;
int
slave_port
=
9307
;
int
slave_port
=
9307
;
/
/ comma delimited list of tests to skip or empty string
/
* comma delimited list of tests to skip or empty string */
char
skip_test
[
PATH_MAX
]
=
""
;
char
skip_test
[
PATH_MAX
]
=
""
;
char
bin_dir
[
PATH_MAX
];
char
bin_dir
[
PATH_MAX
];
...
@@ -80,7 +88,6 @@ char slave_dir[PATH_MAX];
...
@@ -80,7 +88,6 @@ char slave_dir[PATH_MAX];
char
lang_dir
[
PATH_MAX
];
char
lang_dir
[
PATH_MAX
];
char
char_dir
[
PATH_MAX
];
char
char_dir
[
PATH_MAX
];
char
mysqladmin_file
[
PATH_MAX
];
char
mysqld_file
[
PATH_MAX
];
char
mysqld_file
[
PATH_MAX
];
char
mysqltest_file
[
PATH_MAX
];
char
mysqltest_file
[
PATH_MAX
];
char
master_pid
[
PATH_MAX
];
char
master_pid
[
PATH_MAX
];
...
@@ -109,17 +116,30 @@ int single_test = TRUE;
...
@@ -109,17 +116,30 @@ int single_test = TRUE;
int
restarts
=
0
;
int
restarts
=
0
;
FILE
*
log_fd
=
NULL
;
FILE
*
log_fd
=
NULL
;
// WAX
#include <my_getopt.h>
const
char
*
mysqld
=
"mysqld"
,
*
opt_exedir
=
"client_debug"
;
static
struct
my_option
my_long_options
[]
=
{
{
"mysqld"
,
'M'
,
"Type of mysqld (without extention of file)- mysqld, mysql-nt, mysql-nt-max, mysqld-max."
,
(
gptr
*
)
&
mysqld
,
(
gptr
*
)
&
mysqld
,
0
,
GET_STR
,
REQUIRED_ARG
,
0
,
0
,
0
,
0
,
0
,
0
},
{
"exefiledir"
,
'e'
,
"Directory of .exe files (client_debug or client_release)."
,
(
gptr
*
)
&
opt_exedir
,
(
gptr
*
)
&
opt_exedir
,
0
,
GET_STR
,
REQUIRED_ARG
,
0
,
0
,
0
,
0
,
0
,
0
},
};
/******************************************************************************
/******************************************************************************
functions
functions
******************************************************************************/
******************************************************************************/
/******************************************************************************
/******************************************************************************
prototypes
prototypes
******************************************************************************/
******************************************************************************/
void
report_stats
();
void
report_stats
();
...
@@ -135,17 +155,17 @@ void mysql_restart();
...
@@ -135,17 +155,17 @@ void mysql_restart();
int
read_option
(
char
*
,
char
*
);
int
read_option
(
char
*
,
char
*
);
void
run_test
(
char
*
);
void
run_test
(
char
*
);
void
setup
(
char
*
);
void
setup
(
char
*
);
void
vlog
(
char
*
,
va_list
);
void
vlog
(
c
onst
c
har
*
,
va_list
);
void
log
(
char
*
,
...);
void
mtr_log
(
const
char
*
,
...);
void
log_info
(
char
*
,
...);
void
mtr_log_info
(
const
char
*
,
...);
void
log_error
(
char
*
,
...);
void
mtr_log_error
(
const
char
*
,
...);
void
log_errno
(
char
*
,
...);
void
mtr_log_errno
(
const
char
*
,
...);
void
die
(
char
*
);
void
die
(
c
onst
c
har
*
);
/******************************************************************************
/******************************************************************************
report_stats()
report_stats()
Report the gathered statistics.
Report the gathered statistics.
******************************************************************************/
******************************************************************************/
...
@@ -153,42 +173,42 @@ void report_stats()
...
@@ -153,42 +173,42 @@ void report_stats()
{
{
if
(
total_fail
==
0
)
if
(
total_fail
==
0
)
{
{
log
(
"
\n
All %d test(s) were successful.
\n
"
,
total_test
);
mtr_
log
(
"
\n
All %d test(s) were successful.
\n
"
,
total_test
);
}
}
else
else
{
{
double
percent
=
((
double
)
total_pass
/
total_test
)
*
100
;
double
percent
=
((
double
)
total_pass
/
total_test
)
*
100
;
log
(
"
\n
Failed %u/%u test(s), %.02f%% successful.
\n
"
,
mtr_
log
(
"
\n
Failed %u/%u test(s), %.02f%% successful.
\n
"
,
total_fail
,
total_test
,
percent
);
total_fail
,
total_test
,
percent
);
log
(
"
\n
The .out and .err files in %s may give you some
\n
"
,
result_dir
);
mtr_
log
(
"
\n
The .out and .err files in %s may give you some
\n
"
,
result_dir
);
log
(
"hint of what when wrong.
\n
"
);
mtr_
log
(
"hint of what when wrong.
\n
"
);
log
(
"
\n
If you want to report this error, please first read the documentation
\n
"
);
mtr_
log
(
"
\n
If you want to report this error, please first read the documentation
\n
"
);
log
(
"at: http://www.mysql.com/doc/M/y/MySQL_test_suite.html
\n
"
);
mtr_
log
(
"at: http://www.mysql.com/doc/M/y/MySQL_test_suite.html
\n
"
);
}
}
log
(
"
\n
%.02f total minutes elapsed in the test cases
\n\n
"
,
total_time
/
60
);
mtr_
log
(
"
\n
%.02f total minutes elapsed in the test cases
\n\n
"
,
total_time
/
60
);
}
}
/******************************************************************************
/******************************************************************************
install_db()
install_db()
Install the a database.
Install the a database.
******************************************************************************/
******************************************************************************/
void
install_db
(
char
*
datadir
)
void
install_db
(
char
*
datadir
)
{
{
arg_list_t
al
;
arg_list_t
al
;
int
err
,
i
;
int
err
;
char
input
[
PATH_MAX
];
char
input
[
PATH_MAX
];
char
output
[
PATH_MAX
];
char
output
[
PATH_MAX
];
char
error
[
PATH_MAX
];
char
error
[
PATH_MAX
];
// input file
// input file
snprintf
(
input
,
PATH_MAX
,
"%s/bin/init_db.sql"
,
base_dir
);
my_
snprintf
(
input
,
PATH_MAX
,
"%s/bin/init_db.sql"
,
base_dir
);
snprintf
(
output
,
PATH_MAX
,
"%s/install.out"
,
datadir
);
my_
snprintf
(
output
,
PATH_MAX
,
"%s/install.out"
,
datadir
);
snprintf
(
error
,
PATH_MAX
,
"%s/install.err"
,
datadir
);
my_
snprintf
(
error
,
PATH_MAX
,
"%s/install.err"
,
datadir
);
// args
// args
init_args
(
&
al
);
init_args
(
&
al
);
...
@@ -201,6 +221,7 @@ void install_db(char *datadir)
...
@@ -201,6 +221,7 @@ void install_db(char *datadir)
add_arg
(
&
al
,
"--skip-bdb"
);
add_arg
(
&
al
,
"--skip-bdb"
);
// spawn
// spawn
if
((
err
=
spawn
(
mysqld_file
,
&
al
,
TRUE
,
input
,
output
,
error
))
!=
0
)
if
((
err
=
spawn
(
mysqld_file
,
&
al
,
TRUE
,
input
,
output
,
error
))
!=
0
)
{
{
die
(
"Unable to create database."
);
die
(
"Unable to create database."
);
...
@@ -221,34 +242,34 @@ void mysql_install_db()
...
@@ -221,34 +242,34 @@ void mysql_install_db()
{
{
char
temp
[
PATH_MAX
];
char
temp
[
PATH_MAX
];
/
/ var directory
/
* var directory */
snprintf
(
temp
,
PATH_MAX
,
"%s/var"
,
mysql_test_dir
);
my_
snprintf
(
temp
,
PATH_MAX
,
"%s/var"
,
mysql_test_dir
);
/
/ clean up old direcotry
/
* clean up old directory */
del_tree
(
temp
);
del_tree
(
temp
);
/
/ create var directory
/
* create var directory */
m
kdir
(
temp
,
S_IRWXU
);
m
y_mkdir
(
temp
,
0700
,
MYF
(
MY_WME
)
);
/
/ create subdirectories
/
* create subdirectories */
snprintf
(
temp
,
PATH_MAX
,
"%s/var/run"
,
mysql_test_dir
);
my_
snprintf
(
temp
,
PATH_MAX
,
"%s/var/run"
,
mysql_test_dir
);
m
kdir
(
temp
,
S_IRWXU
);
m
y_mkdir
(
temp
,
0700
,
MYF
(
MY_WME
)
);
snprintf
(
temp
,
PATH_MAX
,
"%s/var/tmp"
,
mysql_test_dir
);
my_
snprintf
(
temp
,
PATH_MAX
,
"%s/var/tmp"
,
mysql_test_dir
);
m
kdir
(
temp
,
S_IRWXU
);
m
y_mkdir
(
temp
,
0700
,
MYF
(
MY_WME
)
);
snprintf
(
temp
,
PATH_MAX
,
"%s/var/master-data"
,
mysql_test_dir
);
my_
snprintf
(
temp
,
PATH_MAX
,
"%s/var/master-data"
,
mysql_test_dir
);
m
kdir
(
temp
,
S_IRWXU
);
m
y_mkdir
(
temp
,
0700
,
MYF
(
MY_WME
)
);
snprintf
(
temp
,
PATH_MAX
,
"%s/var/master-data/mysql"
,
mysql_test_dir
);
my_
snprintf
(
temp
,
PATH_MAX
,
"%s/var/master-data/mysql"
,
mysql_test_dir
);
m
kdir
(
temp
,
S_IRWXU
);
m
y_mkdir
(
temp
,
0700
,
MYF
(
MY_WME
)
);
snprintf
(
temp
,
PATH_MAX
,
"%s/var/master-data/test"
,
mysql_test_dir
);
my_
snprintf
(
temp
,
PATH_MAX
,
"%s/var/master-data/test"
,
mysql_test_dir
);
m
kdir
(
temp
,
S_IRWXU
);
m
y_mkdir
(
temp
,
0700
,
MYF
(
MY_WME
)
);
snprintf
(
temp
,
PATH_MAX
,
"%s/var/slave-data"
,
mysql_test_dir
);
my_
snprintf
(
temp
,
PATH_MAX
,
"%s/var/slave-data"
,
mysql_test_dir
);
m
kdir
(
temp
,
S_IRWXU
);
m
y_mkdir
(
temp
,
0700
,
MYF
(
MY_WME
)
);
snprintf
(
temp
,
PATH_MAX
,
"%s/var/slave-data/mysql"
,
mysql_test_dir
);
my_
snprintf
(
temp
,
PATH_MAX
,
"%s/var/slave-data/mysql"
,
mysql_test_dir
);
m
kdir
(
temp
,
S_IRWXU
);
m
y_mkdir
(
temp
,
0700
,
MYF
(
MY_WME
)
);
snprintf
(
temp
,
PATH_MAX
,
"%s/var/slave-data/test"
,
mysql_test_dir
);
my_
snprintf
(
temp
,
PATH_MAX
,
"%s/var/slave-data/test"
,
mysql_test_dir
);
m
kdir
(
temp
,
S_IRWXU
);
m
y_mkdir
(
temp
,
0700
,
MYF
(
MY_WME
)
);
/
/ install databases
/
* install databases */
install_db
(
master_dir
);
install_db
(
master_dir
);
install_db
(
slave_dir
);
install_db
(
slave_dir
);
}
}
...
@@ -263,56 +284,35 @@ void mysql_install_db()
...
@@ -263,56 +284,35 @@ void mysql_install_db()
void
start_master
()
void
start_master
()
{
{
arg_list_t
al
;
arg_list_t
al
;
int
err
,
i
;
int
err
;
char
master_out
[
PATH_MAX
];
char
master_out
[
PATH_MAX
];
char
master_err
[
PATH_MAX
];
char
master_err
[
PATH_MAX
];
char
temp
[
PATH_MAX
];
/
/ remove old berkeley db log files that can confuse the server
/
* remove old berkeley db log files that can confuse the server */
removef
(
"%s/log.*"
,
master_dir
);
removef
(
"%s/log.*"
,
master_dir
);
/
/ remove stale binary logs
/
* remove stale binary logs */
removef
(
"%s/*-bin.*"
,
master_dir
);
removef
(
"%s/*-bin.*"
,
master_dir
);
/
/ remove stale binary logs
/
* remove stale binary logs */
removef
(
"%s/*.index"
,
master_dir
);
removef
(
"%s/*.index"
,
master_dir
);
/
/ remove master.info file
/
* remove master.info file */
removef
(
"%s/master.info"
,
master_dir
);
removef
(
"%s/master.info"
,
master_dir
);
/
/ remove relay files
/
* remove relay files */
removef
(
"%s/var/log/*relay*"
,
mysql_test_dir
);
removef
(
"%s/var/log/*relay*"
,
mysql_test_dir
);
/
/ remove relay-log.info file
/
* remove relay-log.info file */
removef
(
"%s/relay-log.info"
,
master_dir
);
removef
(
"%s/relay-log.info"
,
master_dir
);
// init script
/* redirection files */
if
(
master_init_script
[
0
]
!=
NULL
)
my_snprintf
(
master_out
,
PATH_MAX
,
"%s/var/run/master%u.out"
,
{
// run_init_script(master_init_script);
// TODO: use the scripts
if
(
strindex
(
master_init_script
,
"repair_part2-master.sh"
)
!=
NULL
)
{
FILE
*
fp
;
// create an empty index file
snprintf
(
temp
,
PATH_MAX
,
"%s/test/t1.MYI"
,
master_dir
);
fp
=
fopen
(
temp
,
"wb+"
);
fputs
(
"1"
,
fp
);
fclose
(
fp
);
}
}
// redirection files
snprintf
(
master_out
,
PATH_MAX
,
"%s/var/run/master%u.out"
,
mysql_test_dir
,
restarts
);
mysql_test_dir
,
restarts
);
snprintf
(
master_err
,
PATH_MAX
,
"%s/var/run/master%u.err"
,
my_
snprintf
(
master_err
,
PATH_MAX
,
"%s/var/run/master%u.err"
,
mysql_test_dir
,
restarts
);
mysql_test_dir
,
restarts
);
/
/ args
/
* args */
init_args
(
&
al
);
init_args
(
&
al
);
add_arg
(
&
al
,
"%s"
,
mysqld_file
);
add_arg
(
&
al
,
"%s"
,
mysqld_file
);
add_arg
(
&
al
,
"--no-defaults"
);
add_arg
(
&
al
,
"--no-defaults"
);
...
@@ -328,11 +328,11 @@ void start_master()
...
@@ -328,11 +328,11 @@ void start_master()
add_arg
(
&
al
,
"--tmpdir=%s"
,
mysql_tmp_dir
);
add_arg
(
&
al
,
"--tmpdir=%s"
,
mysql_tmp_dir
);
add_arg
(
&
al
,
"--language=%s"
,
lang_dir
);
add_arg
(
&
al
,
"--language=%s"
,
lang_dir
);
/
/ $MASTER_40_ARGS
/
* $MASTER_40_ARGS */
add_arg
(
&
al
,
"--rpl-recovery-rank=1"
);
add_arg
(
&
al
,
"--rpl-recovery-rank=1"
);
add_arg
(
&
al
,
"--init-rpl-role=master"
);
add_arg
(
&
al
,
"--init-rpl-role=master"
);
/
/ $SMALL_SERVER
/
* $SMALL_SERVER */
add_arg
(
&
al
,
"-O"
);
add_arg
(
&
al
,
"-O"
);
add_arg
(
&
al
,
"key_buffer_size=1M"
);
add_arg
(
&
al
,
"key_buffer_size=1M"
);
add_arg
(
&
al
,
"-O"
);
add_arg
(
&
al
,
"-O"
);
...
@@ -340,8 +340,8 @@ void start_master()
...
@@ -340,8 +340,8 @@ void start_master()
add_arg
(
&
al
,
"-O"
);
add_arg
(
&
al
,
"-O"
);
add_arg
(
&
al
,
"max_heap_table_size=1M"
);
add_arg
(
&
al
,
"max_heap_table_size=1M"
);
/
/ $EXTRA_MASTER_OPT
/
* $EXTRA_MASTER_OPT */
if
(
master_opt
[
0
]
!=
NULL
)
if
(
master_opt
[
0
]
!=
'\0'
)
{
{
char
*
p
;
char
*
p
;
...
@@ -350,34 +350,39 @@ void start_master()
...
@@ -350,34 +350,39 @@ void start_master()
while
(
p
)
while
(
p
)
{
{
add_arg
(
&
al
,
"%s"
,
p
);
add_arg
(
&
al
,
"%s"
,
p
);
p
=
(
char
*
)
strtok
(
NULL
,
"
\t
"
);
p
=
(
char
*
)
strtok
(
NULL
,
"
\t
"
);
}
}
}
}
// remove the pid file if it exists
/* remove the pid file if it exists */
remove
(
master_pid
);
#ifndef __WIN__
my_delete
(
master_pid
,
MYF
(
MY_WME
));
#else
pid_mode
=
MASTER_PID
;
run_server
=
TRUE
;
#endif
/
/ spawn
/
* spawn */
if
((
err
=
spawn
(
mysqld_file
,
&
al
,
FALSE
,
NULL
,
master_out
,
master_err
))
==
0
)
if
((
err
=
spawn
(
mysqld_file
,
&
al
,
FALSE
,
NULL
,
master_out
,
master_err
))
==
0
)
{
{
sleep_until_file_exists
(
master_pid
);
sleep_until_file_exists
(
master_pid
);
if
((
err
=
wait_for_server_start
(
bin_dir
,
user
,
password
,
master_port
))
==
0
)
if
((
err
=
wait_for_server_start
(
bin_dir
,
user
,
password
,
master_port
))
==
0
)
{
{
master_running
=
TRUE
;
master_running
=
TRUE
;
}
}
else
else
{
{
log_error
(
"The master server went down early."
);
mtr_
log_error
(
"The master server went down early."
);
}
}
}
}
else
else
{
{
log_error
(
"Unable to start master server."
);
mtr_
log_error
(
"Unable to start master server."
);
}
}
/
/ free_args
/
* free_args */
free_args
(
&
al
);
free_args
(
&
al
);
}
}
...
@@ -391,48 +396,48 @@ void start_master()
...
@@ -391,48 +396,48 @@ void start_master()
void
start_slave
()
void
start_slave
()
{
{
arg_list_t
al
;
arg_list_t
al
;
int
err
,
i
;
int
err
;
char
slave_out
[
PATH_MAX
];
char
slave_out
[
PATH_MAX
];
char
slave_err
[
PATH_MAX
];
char
slave_err
[
PATH_MAX
];
char
temp
[
PATH_MAX
];
char
temp
[
PATH_MAX
];
/
/ skip?
/
* skip? */
if
(
skip_slave
)
return
;
if
(
skip_slave
)
return
;
/
/ remove stale binary logs
/
* remove stale binary logs */
removef
(
"%s/*-bin.*"
,
slave_dir
);
removef
(
"%s/*-bin.*"
,
slave_dir
);
/
/ remove stale binary logs
/
* remove stale binary logs */
removef
(
"%s/*.index"
,
slave_dir
);
removef
(
"%s/*.index"
,
slave_dir
);
/
/ remove master.info file
/
* remove master.info file */
removef
(
"%s/master.info"
,
slave_dir
);
removef
(
"%s/master.info"
,
slave_dir
);
/
/ remove relay files
/
* remove relay files */
removef
(
"%s/var/log/*relay*"
,
mysql_test_dir
);
removef
(
"%s/var/log/*relay*"
,
mysql_test_dir
);
/
/ remove relay-log.info file
/
* remove relay-log.info file */
removef
(
"%s/relay-log.info"
,
slave_dir
);
removef
(
"%s/relay-log.info"
,
slave_dir
);
/
/ init script
/
* init script */
if
(
slave_init_script
[
0
]
!=
NULL
)
if
(
slave_init_script
[
0
]
!=
'\0'
)
{
{
/
/ run_init_script(slave_init_script);
/
* run_init_script(slave_init_script); */
/
/ TODO: use the scripts
/
* TODO: use the scripts */
if
(
str
index
(
slave_init_script
,
"rpl000016-slave.sh"
)
!=
NULL
)
if
(
str
str
(
slave_init_script
,
"rpl000016-slave.sh"
)
!=
NULL
)
{
{
/
/ create empty master.info file
/
* create empty master.info file */
snprintf
(
temp
,
PATH_MAX
,
"%s/master.info"
,
slave_dir
);
my_
snprintf
(
temp
,
PATH_MAX
,
"%s/master.info"
,
slave_dir
);
close
(
open
(
temp
,
O_WRONLY
|
O_CREAT
));
my_close
(
my_open
(
temp
,
O_WRONLY
|
O_CREAT
,
MYF
(
0
)),
MYF
(
0
));
}
}
else
if
(
str
index
(
slave_init_script
,
"rpl000017-slave.sh"
)
!=
NULL
)
else
if
(
str
str
(
slave_init_script
,
"rpl000017-slave.sh"
)
!=
NullS
)
{
{
FILE
*
fp
;
FILE
*
fp
;
/
/ create a master.info file
/
* create a master.info file */
snprintf
(
temp
,
PATH_MAX
,
"%s/master.info"
,
slave_dir
);
my_
snprintf
(
temp
,
PATH_MAX
,
"%s/master.info"
,
slave_dir
);
fp
=
fopen
(
temp
,
"wb+"
);
fp
=
my_fopen
(
temp
,
(
int
)(
O_WRONLY
|
O_BINARY
|
O_CREAT
),
MYF
(
MY_WME
)
);
fputs
(
"master-bin.001
\n
"
,
fp
);
fputs
(
"master-bin.001
\n
"
,
fp
);
fputs
(
"4
\n
"
,
fp
);
fputs
(
"4
\n
"
,
fp
);
...
@@ -443,20 +448,20 @@ void start_slave()
...
@@ -443,20 +448,20 @@ void start_slave()
fputs
(
"1
\n
"
,
fp
);
fputs
(
"1
\n
"
,
fp
);
fputs
(
"0
\n
"
,
fp
);
fputs
(
"0
\n
"
,
fp
);
fclose
(
fp
);
my_fclose
(
fp
,
MYF
(
MY_WME
)
);
}
}
else
if
(
str
index
(
slave_init_script
,
"rpl_rotate_logs-slave.sh"
)
!=
NULL
)
else
if
(
str
str
(
slave_init_script
,
"rpl_rotate_logs-slave.sh"
)
!=
NullS
)
{
{
/
/ create empty master.info file
/
* create empty master.info file */
snprintf
(
temp
,
PATH_MAX
,
"%s/master.info"
,
slave_dir
);
my_
snprintf
(
temp
,
PATH_MAX
,
"%s/master.info"
,
slave_dir
);
close
(
open
(
temp
,
O_WRONLY
|
O_CREAT
));
my_close
(
my_open
(
temp
,
O_WRONLY
|
O_CREAT
,
MYF
(
0
)),
MYF
(
0
));
}
}
}
}
/
/ redirection files
/
* redirection files */
snprintf
(
slave_out
,
PATH_MAX
,
"%s/var/run/slave%u.out"
,
my_
snprintf
(
slave_out
,
PATH_MAX
,
"%s/var/run/slave%u.out"
,
mysql_test_dir
,
restarts
);
mysql_test_dir
,
restarts
);
snprintf
(
slave_err
,
PATH_MAX
,
"%s/var/run/slave%u.err"
,
my_
snprintf
(
slave_err
,
PATH_MAX
,
"%s/var/run/slave%u.err"
,
mysql_test_dir
,
restarts
);
mysql_test_dir
,
restarts
);
// args
// args
...
@@ -482,15 +487,15 @@ void start_slave()
...
@@ -482,15 +487,15 @@ void start_slave()
add_arg
(
&
al
,
"--slave-load-tmpdir=../../var/tmp"
);
add_arg
(
&
al
,
"--slave-load-tmpdir=../../var/tmp"
);
add_arg
(
&
al
,
"--report-user=%s"
,
user
);
add_arg
(
&
al
,
"--report-user=%s"
,
user
);
add_arg
(
&
al
,
"--report-host=127.0.0.1"
);
add_arg
(
&
al
,
"--report-host=127.0.0.1"
);
add_arg
(
&
al
,
"--report-port=%u"
,
slave_port
);
add_arg
(
&
al
,
"--report-port=%u"
,
slave_port
);
add_arg
(
&
al
,
"--master-retry-count=10"
);
add_arg
(
&
al
,
"--master-retry-count=10"
);
add_arg
(
&
al
,
"-O"
);
add_arg
(
&
al
,
"-O"
);
add_arg
(
&
al
,
"slave_net_timeout=10"
);
add_arg
(
&
al
,
"slave_net_timeout=10"
);
/
/ slave master info
/
* slave master info */
if
(
slave_master_info
[
0
]
!=
NULL
)
if
(
slave_master_info
[
0
]
!=
'\0'
)
{
{
char
*
p
;
char
*
p
;
...
@@ -514,7 +519,7 @@ void start_slave()
...
@@ -514,7 +519,7 @@ void start_slave()
add_arg
(
&
al
,
"--rpl-recovery-rank=2"
);
add_arg
(
&
al
,
"--rpl-recovery-rank=2"
);
}
}
/
/ small server
/
* small server */
add_arg
(
&
al
,
"-O"
);
add_arg
(
&
al
,
"-O"
);
add_arg
(
&
al
,
"key_buffer_size=1M"
);
add_arg
(
&
al
,
"key_buffer_size=1M"
);
add_arg
(
&
al
,
"-O"
);
add_arg
(
&
al
,
"-O"
);
...
@@ -522,8 +527,8 @@ void start_slave()
...
@@ -522,8 +527,8 @@ void start_slave()
add_arg
(
&
al
,
"-O"
);
add_arg
(
&
al
,
"-O"
);
add_arg
(
&
al
,
"max_heap_table_size=1M"
);
add_arg
(
&
al
,
"max_heap_table_size=1M"
);
/
/ opt args
/
* opt args */
if
(
slave_opt
[
0
]
!=
NULL
)
if
(
slave_opt
[
0
]
!=
'\0'
)
{
{
char
*
p
;
char
*
p
;
...
@@ -536,9 +541,14 @@ void start_slave()
...
@@ -536,9 +541,14 @@ void start_slave()
p
=
(
char
*
)
strtok
(
NULL
,
"
\t
"
);
p
=
(
char
*
)
strtok
(
NULL
,
"
\t
"
);
}
}
}
}
// remove the pid file if it exists
/* remove the pid file if it exists */
remove
(
slave_pid
);
#ifndef __WIN__
my_delete
(
slave_pid
,
MYF
(
MY_WME
));
#else
pid_mode
=
SLAVE_PID
;
run_server
=
TRUE
;
#endif
// spawn
// spawn
if
((
err
=
spawn
(
mysqld_file
,
&
al
,
FALSE
,
NULL
,
slave_out
,
slave_err
))
==
0
)
if
((
err
=
spawn
(
mysqld_file
,
&
al
,
FALSE
,
NULL
,
slave_out
,
slave_err
))
==
0
)
...
@@ -551,12 +561,12 @@ void start_slave()
...
@@ -551,12 +561,12 @@ void start_slave()
}
}
else
else
{
{
log_error
(
"The slave server went down early."
);
mtr_
log_error
(
"The slave server went down early."
);
}
}
}
}
else
else
{
{
log_error
(
"Unable to start slave server."
);
mtr_
log_error
(
"Unable to start slave server."
);
}
}
// free args
// free args
...
@@ -576,8 +586,10 @@ void mysql_start()
...
@@ -576,8 +586,10 @@ void mysql_start()
start_slave
();
start_slave
();
#ifdef __NETWARE__
// activate the test screen
// activate the test screen
ActivateScreen
(
getscreenhandle
());
ActivateScreen
(
getscreenhandle
());
#endif
}
}
/******************************************************************************
/******************************************************************************
...
@@ -591,17 +603,20 @@ void stop_slave()
...
@@ -591,17 +603,20 @@ void stop_slave()
{
{
int
err
;
int
err
;
/
/ running?
/
* running? */
if
(
!
slave_running
)
return
;
if
(
!
slave_running
)
return
;
#ifdef __WIN__
pid_mode
=
SLAVE_PID
;
#endif
/
/ stop
/
* stop */
if
((
err
=
stop_server
(
bin_dir
,
user
,
password
,
slave_port
,
slave_pid
))
==
0
)
if
((
err
=
stop_server
(
bin_dir
,
user
,
password
,
slave_port
,
slave_pid
))
==
0
)
{
{
slave_running
=
FALSE
;
slave_running
=
FALSE
;
}
}
else
else
{
{
log_error
(
"Unable to stop slave server."
);
mtr_
log_error
(
"Unable to stop slave server."
);
}
}
}
}
...
@@ -616,16 +631,18 @@ void stop_master()
...
@@ -616,16 +631,18 @@ void stop_master()
{
{
int
err
;
int
err
;
/
/ running?
/
* running? */
if
(
!
master_running
)
return
;
if
(
!
master_running
)
return
;
#ifdef __WIN__
pid_mode
=
MASTER_PID
;
#endif
if
((
err
=
stop_server
(
bin_dir
,
user
,
password
,
master_port
,
master_pid
))
==
0
)
if
((
err
=
stop_server
(
bin_dir
,
user
,
password
,
master_port
,
master_pid
))
==
0
)
{
{
master_running
=
FALSE
;
master_running
=
FALSE
;
}
}
else
else
{
{
log_error
(
"Unable to stop master server."
);
mtr_
log_error
(
"Unable to stop master server."
);
}
}
}
}
...
@@ -642,8 +659,10 @@ void mysql_stop()
...
@@ -642,8 +659,10 @@ void mysql_stop()
stop_slave
();
stop_slave
();
#ifdef __NETWARE__
// activate the test screen
// activate the test screen
ActivateScreen
(
getscreenhandle
());
ActivateScreen
(
getscreenhandle
());
#endif
}
}
/******************************************************************************
/******************************************************************************
...
@@ -655,7 +674,7 @@ void mysql_stop()
...
@@ -655,7 +674,7 @@ void mysql_stop()
******************************************************************************/
******************************************************************************/
void
mysql_restart
()
void
mysql_restart
()
{
{
log_info
(
"Restarting the MySQL server(s): %u"
,
++
restarts
);
mtr_
log_info
(
"Restarting the MySQL server(s): %u"
,
++
restarts
);
mysql_stop
();
mysql_stop
();
...
@@ -671,45 +690,50 @@ void mysql_restart()
...
@@ -671,45 +690,50 @@ void mysql_restart()
******************************************************************************/
******************************************************************************/
int
read_option
(
char
*
opt_file
,
char
*
opt
)
int
read_option
(
char
*
opt_file
,
char
*
opt
)
{
{
int
fd
,
err
;
File
fd
;
int
result
;
int
err
;
char
*
p
;
char
*
p
;
char
buf
[
PATH_MAX
];
char
buf
[
PATH_MAX
];
/
/ copy current option
/
* copy current option */
strncpy
(
buf
,
opt
,
PATH_MAX
);
strncpy
(
buf
,
opt
,
PATH_MAX
);
// open options file
#ifdef __WIN__
fd
=
open
(
opt_file
,
O_RDONLY
);
if
(
PathFileExistsA
(
opt_file
))
{
#endif
/* open options file */
fd
=
my_open
(
opt_file
,
O_RDONLY
,
MYF
(
MY_WME
));
err
=
read
(
fd
,
opt
,
PATH_MAX
);
err
=
my_read
(
fd
,
opt
,
PATH_MAX
,
MYF
(
MY_WME
)
);
close
(
fd
);
my_close
(
fd
,
MYF
(
MY_WME
)
);
if
(
err
>
0
)
if
(
err
>
0
)
{
{
/
/ terminate string
/
* terminate string */
if
((
p
=
strchr
(
opt
,
'\n'
))
!=
NULL
)
if
((
p
=
strchr
(
opt
,
'\n'
))
!=
NULL
)
{
{
*
p
=
NULL
;
*
p
=
'\0'
;
/
/ check for a '\r'
/
* check for a '\r' */
if
((
p
=
strchr
(
opt
,
'\r'
))
!=
NULL
)
if
((
p
=
strchr
(
opt
,
'\r'
))
!=
NULL
)
{
{
*
p
=
NULL
;
*
p
=
'\0'
;
}
}
}
}
else
else
{
{
opt
[
err
]
=
NULL
;
opt
[
err
]
=
'\0'
;
}
}
/
/ check for $MYSQL_TEST_DIR
/
* check for $MYSQL_TEST_DIR */
if
((
p
=
strstr
(
opt
,
"$MYSQL_TEST_DIR"
))
!=
N
ULL
)
if
((
p
=
strstr
(
opt
,
"$MYSQL_TEST_DIR"
))
!=
N
ullS
)
{
{
char
temp
[
PATH_MAX
];
char
temp
[
PATH_MAX
];
*
p
=
NULL
;
*
p
=
'\0'
;
strcpy
(
temp
,
p
+
strlen
(
"$MYSQL_TEST_DIR"
));
strcpy
(
temp
,
p
+
strlen
(
"$MYSQL_TEST_DIR"
));
...
@@ -720,11 +744,14 @@ int read_option(char *opt_file, char *opt)
...
@@ -720,11 +744,14 @@ int read_option(char *opt_file, char *opt)
}
}
else
else
{
{
/
/ clear option
/
* clear option */
*
opt
=
NULL
;
*
opt
=
'\0'
;
}
}
#ifdef __WIN__
}
#endif
/
/ compare current option with previous
/
* compare current option with previous */
return
strcmp
(
opt
,
buf
);
return
strcmp
(
opt
,
buf
);
}
}
...
@@ -739,21 +766,20 @@ void run_test(char *test)
...
@@ -739,21 +766,20 @@ void run_test(char *test)
{
{
char
temp
[
PATH_MAX
];
char
temp
[
PATH_MAX
];
char
*
rstr
;
char
*
rstr
;
double
elapsed
=
0
;
int
skip
=
FALSE
;
int
skip
=
FALSE
;
int
restart
=
FALSE
;
int
restart
=
FALSE
;
int
flag
=
FALSE
;
int
flag
=
FALSE
;
struct
stat
info
;
struct
stat
info
;
/
/ single test?
/
* single test? */
if
(
!
single_test
)
if
(
!
single_test
)
{
{
// skip tests in the skip list
// skip tests in the skip list
snprintf
(
temp
,
PATH_MAX
,
" %s "
,
test
);
my_
snprintf
(
temp
,
PATH_MAX
,
" %s "
,
test
);
skip
=
(
strindex
(
skip_test
,
temp
)
!=
NULL
);
skip
=
strinstr
(
skip_test
,
temp
);
}
}
/
/ skip test?
/
* skip test? */
if
(
!
skip
)
if
(
!
skip
)
{
{
char
test_file
[
PATH_MAX
];
char
test_file
[
PATH_MAX
];
...
@@ -766,7 +792,6 @@ void run_test(char *test)
...
@@ -766,7 +792,6 @@ void run_test(char *test)
char
err_file
[
PATH_MAX
];
char
err_file
[
PATH_MAX
];
int
err
;
int
err
;
arg_list_t
al
;
arg_list_t
al
;
NXTime_t
start
,
stop
;
// skip slave?
// skip slave?
flag
=
skip_slave
;
flag
=
skip_slave
;
...
@@ -774,36 +799,36 @@ void run_test(char *test)
...
@@ -774,36 +799,36 @@ void run_test(char *test)
if
(
flag
!=
skip_slave
)
restart
=
TRUE
;
if
(
flag
!=
skip_slave
)
restart
=
TRUE
;
// create files
// create files
snprintf
(
master_opt_file
,
PATH_MAX
,
"%s/%s-master.opt"
,
test_dir
,
test
);
my_
snprintf
(
master_opt_file
,
PATH_MAX
,
"%s/%s-master.opt"
,
test_dir
,
test
);
snprintf
(
slave_opt_file
,
PATH_MAX
,
"%s/%s-slave.opt"
,
test_dir
,
test
);
my_
snprintf
(
slave_opt_file
,
PATH_MAX
,
"%s/%s-slave.opt"
,
test_dir
,
test
);
snprintf
(
slave_master_info_file
,
PATH_MAX
,
"%s/%s.slave-mi"
,
test_dir
,
test
);
my_
snprintf
(
slave_master_info_file
,
PATH_MAX
,
"%s/%s.slave-mi"
,
test_dir
,
test
);
snprintf
(
reject_file
,
PATH_MAX
,
"%s/%s%s"
,
result_dir
,
test
,
REJECT_SUFFIX
);
my_
snprintf
(
reject_file
,
PATH_MAX
,
"%s/%s%s"
,
result_dir
,
test
,
REJECT_SUFFIX
);
snprintf
(
out_file
,
PATH_MAX
,
"%s/%s%s"
,
result_dir
,
test
,
OUT_SUFFIX
);
my_
snprintf
(
out_file
,
PATH_MAX
,
"%s/%s%s"
,
result_dir
,
test
,
OUT_SUFFIX
);
snprintf
(
err_file
,
PATH_MAX
,
"%s/%s%s"
,
result_dir
,
test
,
ERR_SUFFIX
);
my_
snprintf
(
err_file
,
PATH_MAX
,
"%s/%s%s"
,
result_dir
,
test
,
ERR_SUFFIX
);
// netware specific files
// netware specific files
snprintf
(
test_file
,
PATH_MAX
,
"%s/%s%s"
,
test_dir
,
test
,
NW_TEST_SUFFIX
);
my_
snprintf
(
test_file
,
PATH_MAX
,
"%s/%s%s"
,
test_dir
,
test
,
NW_TEST_SUFFIX
);
if
(
stat
(
test_file
,
&
info
))
if
(
stat
(
test_file
,
&
info
))
{
{
snprintf
(
test_file
,
PATH_MAX
,
"%s/%s%s"
,
test_dir
,
test
,
TEST_SUFFIX
);
my_
snprintf
(
test_file
,
PATH_MAX
,
"%s/%s%s"
,
test_dir
,
test
,
TEST_SUFFIX
);
}
}
snprintf
(
result_file
,
PATH_MAX
,
"%s/%s%s"
,
result_dir
,
test
,
NW_RESULT_SUFFIX
);
my_
snprintf
(
result_file
,
PATH_MAX
,
"%s/%s%s"
,
result_dir
,
test
,
NW_RESULT_SUFFIX
);
if
(
stat
(
result_file
,
&
info
))
if
(
stat
(
result_file
,
&
info
))
{
{
snprintf
(
result_file
,
PATH_MAX
,
"%s/%s%s"
,
result_dir
,
test
,
RESULT_SUFFIX
);
my_
snprintf
(
result_file
,
PATH_MAX
,
"%s/%s%s"
,
result_dir
,
test
,
RESULT_SUFFIX
);
}
}
// init scripts
// init scripts
snprintf
(
master_init_script
,
PATH_MAX
,
"%s/%s-master.sh"
,
test_dir
,
test
);
my_
snprintf
(
master_init_script
,
PATH_MAX
,
"%s/%s-master.sh"
,
test_dir
,
test
);
if
(
stat
(
master_init_script
,
&
info
))
if
(
stat
(
master_init_script
,
&
info
))
master_init_script
[
0
]
=
NULL
;
master_init_script
[
0
]
=
'\0'
;
else
else
restart
=
TRUE
;
restart
=
TRUE
;
snprintf
(
slave_init_script
,
PATH_MAX
,
"%s/%s-slave.sh"
,
test_dir
,
test
);
my_
snprintf
(
slave_init_script
,
PATH_MAX
,
"%s/%s-slave.sh"
,
test_dir
,
test
);
if
(
stat
(
slave_init_script
,
&
info
))
if
(
stat
(
slave_init_script
,
&
info
))
slave_init_script
[
0
]
=
NULL
;
slave_init_script
[
0
]
=
'\0'
;
else
else
restart
=
TRUE
;
restart
=
TRUE
;
...
@@ -825,7 +850,7 @@ void run_test(char *test)
...
@@ -825,7 +850,7 @@ void run_test(char *test)
sleep
(
1
);
sleep
(
1
);
// show test
// show test
log
(
"%-46s "
,
test
);
mtr_
log
(
"%-46s "
,
test
);
// args
// args
init_args
(
&
al
);
init_args
(
&
al
);
...
@@ -842,26 +867,16 @@ void run_test(char *test)
...
@@ -842,26 +867,16 @@ void run_test(char *test)
add_arg
(
&
al
,
"-R"
);
add_arg
(
&
al
,
"-R"
);
add_arg
(
&
al
,
"%s"
,
result_file
);
add_arg
(
&
al
,
"%s"
,
result_file
);
// start timer
NXGetTime
(
NX_SINCE_BOOT
,
NX_USECONDS
,
&
start
);
// spawn
// spawn
err
=
spawn
(
mysqltest_file
,
&
al
,
TRUE
,
test_file
,
out_file
,
err_file
);
err
=
spawn
(
mysqltest_file
,
&
al
,
TRUE
,
test_file
,
out_file
,
err_file
);
// stop timer
NXGetTime
(
NX_SINCE_BOOT
,
NX_USECONDS
,
&
stop
);
// calculate
elapsed
=
((
double
)(
stop
-
start
))
/
NX_USECONDS
;
total_time
+=
elapsed
;
// free args
// free args
free_args
(
&
al
);
free_args
(
&
al
);
if
(
err
==
0
)
if
(
err
==
0
)
{
{
// pass
// pass
rstr
=
TEST_PASS
;
rstr
=
(
char
*
)
TEST_PASS
;
++
total_pass
;
++
total_pass
;
// increment total
// increment total
...
@@ -870,13 +885,13 @@ void run_test(char *test)
...
@@ -870,13 +885,13 @@ void run_test(char *test)
else
if
(
err
==
2
)
else
if
(
err
==
2
)
{
{
// skip
// skip
rstr
=
TEST_SKIP
;
rstr
=
(
char
*
)
TEST_SKIP
;
++
total_skip
;
++
total_skip
;
}
}
else
if
(
err
==
1
)
else
if
(
err
==
1
)
{
{
// fail
// fail
rstr
=
TEST_FAIL
;
rstr
=
(
char
*
)
TEST_FAIL
;
++
total_fail
;
++
total_fail
;
// increment total
// increment total
...
@@ -884,21 +899,21 @@ void run_test(char *test)
...
@@ -884,21 +899,21 @@ void run_test(char *test)
}
}
else
else
{
{
rstr
=
TEST_BAD
;
rstr
=
(
char
*
)
TEST_BAD
;
}
}
}
}
else
// early skips
else
// early skips
{
{
// show test
// show test
log
(
"%-46s "
,
test
);
mtr_
log
(
"%-46s "
,
test
);
// skip
// skip
rstr
=
TEST_SKIP
;
rstr
=
(
char
*
)
TEST_SKIP
;
++
total_skip
;
++
total_skip
;
}
}
// result
// result
log
(
"%10.06f %-14s
\n
"
,
elapsed
,
rstr
);
mtr_log
(
" %-14s
\n
"
,
rstr
);
}
}
/******************************************************************************
/******************************************************************************
...
@@ -908,7 +923,7 @@ void run_test(char *test)
...
@@ -908,7 +923,7 @@ void run_test(char *test)
Log the message.
Log the message.
******************************************************************************/
******************************************************************************/
void
vlog
(
char
*
format
,
va_list
ap
)
void
vlog
(
c
onst
c
har
*
format
,
va_list
ap
)
{
{
vfprintf
(
stdout
,
format
,
ap
);
vfprintf
(
stdout
,
format
,
ap
);
fflush
(
stdout
);
fflush
(
stdout
);
...
@@ -922,12 +937,12 @@ void vlog(char *format, va_list ap)
...
@@ -922,12 +937,12 @@ void vlog(char *format, va_list ap)
/******************************************************************************
/******************************************************************************
log()
mtr_
log()
Log the message.
Log the message.
******************************************************************************/
******************************************************************************/
void
log
(
char
*
format
,
...)
void
mtr_log
(
const
char
*
format
,
...)
{
{
va_list
ap
;
va_list
ap
;
...
@@ -940,60 +955,60 @@ void log(char *format, ...)
...
@@ -940,60 +955,60 @@ void log(char *format, ...)
/******************************************************************************
/******************************************************************************
log_info()
mtr_
log_info()
Log the given information.
Log the given information.
******************************************************************************/
******************************************************************************/
void
log_info
(
char
*
format
,
...)
void
mtr_log_info
(
const
char
*
format
,
...)
{
{
va_list
ap
;
va_list
ap
;
va_start
(
ap
,
format
);
va_start
(
ap
,
format
);
log
(
"-- INFO : "
);
mtr_
log
(
"-- INFO : "
);
vlog
(
format
,
ap
);
vlog
(
format
,
ap
);
log
(
"
\n
"
);
mtr_
log
(
"
\n
"
);
va_end
(
ap
);
va_end
(
ap
);
}
}
/******************************************************************************
/******************************************************************************
log_error()
mtr_
log_error()
Log the given error.
Log the given error.
******************************************************************************/
******************************************************************************/
void
log_error
(
char
*
format
,
...)
void
mtr_log_error
(
const
char
*
format
,
...)
{
{
va_list
ap
;
va_list
ap
;
va_start
(
ap
,
format
);
va_start
(
ap
,
format
);
log
(
"-- ERROR: "
);
mtr_
log
(
"-- ERROR: "
);
vlog
(
format
,
ap
);
vlog
(
format
,
ap
);
log
(
"
\n
"
);
mtr_
log
(
"
\n
"
);
va_end
(
ap
);
va_end
(
ap
);
}
}
/******************************************************************************
/******************************************************************************
log_errno()
mtr_
log_errno()
Log the given error and errno.
Log the given error and errno.
******************************************************************************/
******************************************************************************/
void
log_errno
(
char
*
format
,
...)
void
mtr_log_errno
(
const
char
*
format
,
...)
{
{
va_list
ap
;
va_list
ap
;
va_start
(
ap
,
format
);
va_start
(
ap
,
format
);
log
(
"-- ERROR: (%003u) "
,
errno
);
mtr_
log
(
"-- ERROR: (%003u) "
,
errno
);
vlog
(
format
,
ap
);
vlog
(
format
,
ap
);
log
(
"
\n
"
);
mtr_
log
(
"
\n
"
);
va_end
(
ap
);
va_end
(
ap
);
}
}
...
@@ -1005,11 +1020,13 @@ void log_errno(char *format, ...)
...
@@ -1005,11 +1020,13 @@ void log_errno(char *format, ...)
Exit the application.
Exit the application.
******************************************************************************/
******************************************************************************/
void
die
(
char
*
msg
)
void
die
(
c
onst
c
har
*
msg
)
{
{
log_error
(
msg
);
mtr_
log_error
(
msg
);
#ifdef __NETWARE__
pressanykey
();
pressanykey
();
#endif
exit
(
-
1
);
exit
(
-
1
);
}
}
...
@@ -1027,50 +1044,83 @@ void setup(char *file)
...
@@ -1027,50 +1044,83 @@ void setup(char *file)
char
*
p
;
char
*
p
;
// set the timezone for the timestamp test
// set the timezone for the timestamp test
#ifdef __WIN__
_putenv
(
"TZ=GMT-3"
);
#else
setenv
(
"TZ"
,
"GMT-3"
,
TRUE
);
setenv
(
"TZ"
,
"GMT-3"
,
TRUE
);
#endif
// find base dir
// find base dir
strcpy
(
temp
,
strlwr
(
file
));
strcpy
(
temp
,
file
);
#ifndef __WIN__
casedn_str
(
temp
);
#endif
while
((
p
=
strchr
(
temp
,
'\\'
))
!=
NULL
)
*
p
=
'/'
;
while
((
p
=
strchr
(
temp
,
'\\'
))
!=
NULL
)
*
p
=
'/'
;
if
((
p
=
str
index
(
temp
,
"/mysql-test/"
))
!=
NULL
)
if
((
p
=
str
str
(
temp
,
"/mysql-test/"
))
)
{
{
*
p
=
NULL
;
*
p
=
'\0'
;
strcpy
(
base_dir
,
temp
);
strcpy
(
base_dir
,
(
const
char
*
)
temp
);
}
}
// setup paths
// setup paths
snprintf
(
bin_dir
,
PATH_MAX
,
"%s/bin"
,
base_dir
);
#ifdef __WIN__
snprintf
(
mysql_test_dir
,
PATH_MAX
,
"%s/mysql-test"
,
base_dir
);
my_snprintf
(
bin_dir
,
PATH_MAX
,
"%s/%s"
,
base_dir
,
opt_exedir
);
snprintf
(
test_dir
,
PATH_MAX
,
"%s/t"
,
mysql_test_dir
);
#else
snprintf
(
mysql_tmp_dir
,
PATH_MAX
,
"%s/var/tmp"
,
mysql_test_dir
);
my_snprintf
(
bin_dir
,
PATH_MAX
,
"%s/bin"
,
base_dir
);
snprintf
(
result_dir
,
PATH_MAX
,
"%s/r"
,
mysql_test_dir
);
#endif
snprintf
(
master_dir
,
PATH_MAX
,
"%s/var/master-data"
,
mysql_test_dir
);
my_snprintf
(
mysql_test_dir
,
PATH_MAX
,
"%s/mysql-test"
,
base_dir
);
snprintf
(
slave_dir
,
PATH_MAX
,
"%s/var/slave-data"
,
mysql_test_dir
);
my_snprintf
(
test_dir
,
PATH_MAX
,
"%s/t"
,
mysql_test_dir
);
snprintf
(
lang_dir
,
PATH_MAX
,
"%s/share/english"
,
base_dir
);
my_snprintf
(
mysql_tmp_dir
,
PATH_MAX
,
"%s/var/tmp"
,
mysql_test_dir
);
snprintf
(
char_dir
,
PATH_MAX
,
"%s/share/charsets"
,
base_dir
);
my_snprintf
(
result_dir
,
PATH_MAX
,
"%s/r"
,
mysql_test_dir
);
my_snprintf
(
master_dir
,
PATH_MAX
,
"%s/var/master-data"
,
mysql_test_dir
);
my_snprintf
(
slave_dir
,
PATH_MAX
,
"%s/var/slave-data"
,
mysql_test_dir
);
my_snprintf
(
lang_dir
,
PATH_MAX
,
"%s/share/english"
,
base_dir
);
my_snprintf
(
char_dir
,
PATH_MAX
,
"%s/share/charsets"
,
base_dir
);
// setup files
// setup files
snprintf
(
mysqld_file
,
PATH_MAX
,
"%s/mysqld"
,
bin_dir
);
#ifdef __WIN__
snprintf
(
mysqltest_file
,
PATH_MAX
,
"%s/mysqltest"
,
bin_dir
);
my_snprintf
(
mysqld_file
,
PATH_MAX
,
"%s/%s.exe"
,
bin_dir
,
mysqld
);
snprintf
(
mysqladmin_file
,
PATH_MAX
,
"%s/mysqladmin"
,
bin_dir
);
my_snprintf
(
mysqltest_file
,
PATH_MAX
,
"%s/mysqltest.exe"
,
bin_dir
);
snprintf
(
master_pid
,
PATH_MAX
,
"%s/var/run/master.pid"
,
mysql_test_dir
);
my_snprintf
(
mysqladmin_file
,
PATH_MAX
,
"%s/mysqladmin.exe"
,
bin_dir
);
snprintf
(
slave_pid
,
PATH_MAX
,
"%s/var/run/slave.pid"
,
mysql_test_dir
);
pid_mode
=
NOT_NEED_PID
;
#else
my_snprintf
(
mysqld_file
,
PATH_MAX
,
"%s/mysqld"
,
bin_dir
);
my_snprintf
(
mysqltest_file
,
PATH_MAX
,
"%s/mysqltest"
,
bin_dir
);
my_snprintf
(
mysqladmin_file
,
PATH_MAX
,
"%s/mysqladmin"
,
bin_dir
);
#endif
my_snprintf
(
master_pid
,
PATH_MAX
,
"%s/var/run/master.pid"
,
mysql_test_dir
);
my_snprintf
(
slave_pid
,
PATH_MAX
,
"%s/var/run/slave.pid"
,
mysql_test_dir
);
// create log file
// create log file
snprintf
(
temp
,
PATH_MAX
,
"%s/mysql-test-run.log"
,
mysql_test_dir
);
my_
snprintf
(
temp
,
PATH_MAX
,
"%s/mysql-test-run.log"
,
mysql_test_dir
);
if
((
log_fd
=
fopen
(
temp
,
"w+"
))
==
NULL
)
if
((
log_fd
=
fopen
(
temp
,
"w+"
))
==
NULL
)
{
{
log_errno
(
"Unable to create log file."
);
mtr_
log_errno
(
"Unable to create log file."
);
}
}
// prepare skip test list
// prepare skip test list
while
((
p
=
strchr
(
skip_test
,
','
))
!=
NULL
)
*
p
=
' '
;
while
((
p
=
strchr
(
skip_test
,
','
))
!=
NULL
)
*
p
=
' '
;
strcpy
(
temp
,
strlwr
(
skip_test
));
strcpy
(
temp
,
skip_test
);
snprintf
(
skip_test
,
PATH_MAX
,
" %s "
,
temp
);
#ifndef __WIN__
casedn_str
(
temp
);
#endif
my_snprintf
(
skip_test
,
PATH_MAX
,
" %s "
,
temp
);
// enviornment
// enviornment
setenv
(
"MYSQL_TEST_DIR"
,
mysql_test_dir
,
1
);
#ifdef __WIN__
my_snprintf
(
temp
,
PATH_MAX
,
"MYSQL_TEST_DIR=%s"
,
mysql_test_dir
);
_putenv
(
temp
);
#else
setenv
(
"MYSQL_TEST_DIR"
,
mysql_test_dir
,
1
);
#endif
}
static
my_bool
get_one_option
(
int
optid
,
const
struct
my_option
*
opt
__attribute__
((
unused
)),
char
*
argument
)
{
return
(
0
);
}
}
/******************************************************************************
/******************************************************************************
...
@@ -1080,31 +1130,59 @@ void setup(char *file)
...
@@ -1080,31 +1130,59 @@ void setup(char *file)
******************************************************************************/
******************************************************************************/
int
main
(
int
argc
,
char
**
argv
)
int
main
(
int
argc
,
char
**
argv
)
{
{
int
i
;
uint
ui
;
#ifdef __WIN__
int
ho_error
;
DWORD
len
=
PATH_MAX
;
char
current_dir
[
PATH_MAX
]
=
"."
;
if
((
ho_error
=
handle_options
(
&
argc
,
&
argv
,
my_long_options
,
get_one_option
)))
exit
(
1
);
if
(
len
=
GetCurrentDirectory
(
&
len
,
current_dir
))
{
current_dir
[
len
]
=
'\\'
;
current_dir
[
len
+
1
]
=
'\0'
;
};
MY_INIT
(
current_dir
);
#endif
// setup
// setup
#ifdef __WIN__
setup
(
current_dir
);
#else
setup
(
argv
[
0
]);
setup
(
argv
[
0
]);
#endif
// header
// header
log
(
"MySQL Server %s, for %s (%s)
\n\n
"
,
VERSION
,
SYSTEM_TYPE
,
MACHINE_TYPE
);
mtr_
log
(
"MySQL Server %s, for %s (%s)
\n\n
"
,
VERSION
,
SYSTEM_TYPE
,
MACHINE_TYPE
);
log
(
"Initializing Tests...
\n
"
);
mtr_
log
(
"Initializing Tests...
\n
"
);
// install test databases
// install test databases
mysql_install_db
();
mysql_install_db
();
log
(
"Starting Tests...
\n
"
);
mtr_
log
(
"Starting Tests...
\n
"
);
log
(
"
\n
"
);
mtr_
log
(
"
\n
"
);
log
(
HEADER
);
mtr_
log
(
HEADER
);
log
(
DASH
);
mtr_
log
(
DASH
);
#ifdef __WIN__
if
(
argc
>
0
)
#else
if
(
argc
>
1
)
if
(
argc
>
1
)
#endif
{
{
int
i
;
// single test
// single test
single_test
=
TRUE
;
single_test
=
TRUE
;
#ifdef __WIN__
for
(
i
=
0
;
i
<
argc
;
i
++
)
#else
for
(
i
=
1
;
i
<
argc
;
i
++
)
for
(
i
=
1
;
i
<
argc
;
i
++
)
#endif
{
{
// run given test
// run given test
run_test
(
argv
[
i
]);
run_test
(
argv
[
i
]);
...
@@ -1113,8 +1191,7 @@ int main(int argc, char **argv)
...
@@ -1113,8 +1191,7 @@ int main(int argc, char **argv)
else
else
{
{
// run all tests
// run all tests
DIR
*
dir
=
opendir
(
test_dir
);
MY_DIR
*
dir
=
my_dir
(
test_dir
,
MYF
(
MY_WME
|
MY_WANT_STAT
));
DIR
*
entry
;
char
test
[
NAME_MAX
];
char
test
[
NAME_MAX
];
char
*
p
;
char
*
p
;
...
@@ -1126,14 +1203,16 @@ int main(int argc, char **argv)
...
@@ -1126,14 +1203,16 @@ int main(int argc, char **argv)
die
(
"Unable to open tests directory."
);
die
(
"Unable to open tests directory."
);
}
}
while
((
entry
=
readdir
(
dir
))
!=
NULL
)
for
(
ui
=
0
;
ui
<
dir
->
number_off_files
;
ui
++
)
{
{
if
(
!
S_ISDIR
(
entry
->
d_typ
e
))
if
(
!
MY_S_ISDIR
(
dir
->
dir_entry
[
ui
].
mystat
.
st_mod
e
))
{
{
strcpy
(
test
,
strlwr
(
entry
->
d_name
));
strcpy
(
test
,
dir
->
dir_entry
[
ui
].
name
);
#ifndef __WIN__
casedn_str
(
test
);
#endif
// find the test suffix
// find the test suffix
if
((
p
=
str
index
(
test
,
TEST_SUFFIX
))
!=
NULL
)
if
((
p
=
str
str
(
test
,
TEST_SUFFIX
))
)
{
{
// null terminate at the suffix
// null terminate at the suffix
*
p
=
'\0'
;
*
p
=
'\0'
;
...
@@ -1143,14 +1222,14 @@ int main(int argc, char **argv)
...
@@ -1143,14 +1222,14 @@ int main(int argc, char **argv)
}
}
}
}
}
}
closedir
(
dir
);
my_dirend
(
dir
);
}
}
log
(
DASH
);
mtr_
log
(
DASH
);
log
(
"
\n
"
);
mtr_
log
(
"
\n
"
);
log
(
"Ending Tests...
\n
"
);
mtr_
log
(
"Ending Tests...
\n
"
);
// stop server
// stop server
mysql_stop
();
mysql_stop
();
...
@@ -1161,8 +1240,10 @@ int main(int argc, char **argv)
...
@@ -1161,8 +1240,10 @@ int main(int argc, char **argv)
// close log
// close log
if
(
log_fd
)
fclose
(
log_fd
);
if
(
log_fd
)
fclose
(
log_fd
);
#ifdef __NETWARE__
// keep results up
// keep results up
pressanykey
();
pressanykey
();
#endif
return
0
;
return
0
;
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment