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
Show 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
davida@isil.mysql.com
gluh@gluh.(none)
gluh@gluh.mysql.r18.ru
greg@gcw.ath.cx
greg@mysql.com
guilhem@mysql.com
gweir@work.mysql.com
...
...
netware/Makefile.am
View file @
6f604246
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
it under the terms of the GNU General Public License as published by
...
...
@@ -16,37 +17,45 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <stdio.h>
#include <errno.h>
#include <dirent.h>
#include <string.h>
#include <screen.h>
#include <proc.h>
#include <ctype.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <assert.h>
/*****************************************************************************
** Utility functions for support programs
*****************************************************************************/
/* 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 <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"
/******************************************************************************
macros
******************************************************************************/
/******************************************************************************
global variables
******************************************************************************/
/******************************************************************************
functions
******************************************************************************/
#define __STDC__ 1
#include "process.h"
/******************************************************************************
init_args()
...
...
@@ -56,13 +65,17 @@
******************************************************************************/
void
init_args
(
arg_list_t
*
al
)
{
#ifndef __WIN__
ASSERT
(
al
!=
NULL
);
al
->
argc
=
0
;
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
);
#else
win_args
[
0
]
=
'\0'
;
skip_first_param
=
TRUE
;
#endif
return
;
}
...
...
@@ -73,18 +86,19 @@ void init_args(arg_list_t *al)
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
;
char
temp
[
PATH_MAX
];
ASSERT
(
al
!=
NULL
);
/
/ increase size
if
(
al
->
argc
>=
al
->
size
)
/
* increase size */
if
(
al
->
argc
>=
(
int
)
al
->
size
)
{
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
);
}
...
...
@@ -94,7 +108,7 @@ void add_arg(arg_list_t *al, char *format, ...)
vsprintf
(
temp
,
format
,
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
);
strcpy
(
al
->
argv
[
al
->
argc
],
temp
);
...
...
@@ -104,7 +118,23 @@ void add_arg(arg_list_t *al, char *format, ...)
{
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
;
}
...
...
@@ -117,6 +147,7 @@ void add_arg(arg_list_t *al, char *format, ...)
******************************************************************************/
void
free_args
(
arg_list_t
*
al
)
{
#ifndef __WIN__
int
i
;
ASSERT
(
al
!=
NULL
);
...
...
@@ -124,14 +155,14 @@ void free_args(arg_list_t *al)
for
(
i
=
0
;
i
<
al
->
argc
;
i
++
)
{
ASSERT
(
al
->
argv
[
i
]
!=
NULL
);
free
(
al
->
argv
[
i
]
);
my_free
(
al
->
argv
[
i
],
MYF
(
MY_WME
)
);
al
->
argv
[
i
]
=
NULL
;
}
free
(
al
->
argv
);
my_free
((
char
*
)
al
->
argv
,
MYF
(
MY_WME
)
);
al
->
argc
=
0
;
al
->
argv
=
NULL
;
#endif
return
;
}
...
...
@@ -144,13 +175,31 @@ void free_args(arg_list_t *al)
******************************************************************************/
int
sleep_until_file_deleted
(
char
*
pid_file
)
{
struct
stat
buf
;
int
i
,
err
;
for
(
i
=
0
;
(
i
<
TRY_MAX
)
&&
(
err
=
!
stat
(
pid_file
,
&
buf
));
i
++
)
sleep
(
1
);
if
(
err
!=
0
)
err
=
errno
;
MY_STAT
stat_info
;
int
i
,
err
=
0
;
#ifndef __WIN__
for
(
i
=
0
;
i
<
TRY_MAX
;
i
++
)
{
if
(
my_stat
(
pid_file
,
&
stat_info
,
MYF
(
0
))
==
(
MY_STAT
*
)
NULL
)
{
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
;
}
...
...
@@ -163,12 +212,32 @@ int sleep_until_file_deleted(char *pid_file)
******************************************************************************/
int
sleep_until_file_exists
(
char
*
pid_file
)
{
struct
stat
buf
;
int
i
,
err
;
MY_STAT
stat_info
;
int
i
,
err
=
0
;
for
(
i
=
0
;
(
i
<
TRY_MAX
)
&&
(
err
=
stat
(
pid_file
,
&
buf
));
i
++
)
sleep
(
1
);
if
(
err
!=
0
)
err
=
errno
;
#ifndef __WIN__
for
(
i
=
0
;
i
<
TRY_MAX
;
i
++
)
{
if
(
my_stat
(
pid_file
,
&
stat_info
,
MYF
(
0
))
==
(
MY_STAT
*
)
NULL
)
{
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
;
}
...
...
@@ -183,15 +252,13 @@ int sleep_until_file_exists(char *pid_file)
int
wait_for_server_start
(
char
*
bin_dir
,
char
*
user
,
char
*
password
,
int
port
)
{
arg_list_t
al
;
int
err
,
i
;
char
mysqladmin_file
[
PATH_MAX
];
int
err
=
0
,
i
;
char
trash
[
PATH_MAX
];
// mysqladmin file
snprintf
(
mysqladmin_file
,
PATH_MAX
,
"%s/mysqladmin"
,
bin_dir
);
snprintf
(
trash
,
PATH_MAX
,
"/tmp/trash.out"
);
/* mysqladmin file */
my_snprintf
(
trash
,
PATH_MAX
,
"/tmp/trash.out"
);
/
/ args
/
* args */
init_args
(
&
al
);
add_arg
(
&
al
,
"%s"
,
mysqladmin_file
);
add_arg
(
&
al
,
"--no-defaults"
);
...
...
@@ -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
,
"ping"
);
//
NetWare does not support the connect timeout in the TCP/IP stack
// -- we will try the ping multiple times
/*
NetWare does not support the connect timeout in the TCP/IP stack
-- we will try the ping multiple times */
for
(
i
=
0
;
(
i
<
TRY_MAX
)
&&
(
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
);
return
err
;
...
...
@@ -221,9 +288,12 @@ int wait_for_server_start(char *bin_dir, char *user, char *password, int port)
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
,
char
*
output
,
char
*
error
)
{
...
...
@@ -232,7 +302,7 @@ int spawn(char *path, arg_list_t *al, int join, char *input,
wiring_t
wiring
=
{
FD_UNUSED
,
FD_UNUSED
,
FD_UNUSED
};
unsigned
long
flags
=
PROC_CURRENT_SPACE
|
PROC_INHERIT_CWD
;
/
/ open wiring
/
* open wiring */
if
(
input
)
wiring
.
infd
=
open
(
input
,
O_RDONLY
);
...
...
@@ -242,10 +312,10 @@ int spawn(char *path, arg_list_t *al, int join, char *input,
if
(
error
)
wiring
.
errfd
=
open
(
error
,
O_WRONLY
|
O_CREAT
|
O_TRUNC
);
/
/ procve requires a NULL
/
* procve requires a NULL */
add_arg
(
al
,
NULL
);
/
/ go
/
* go */
pid
=
procve
(
path
,
flags
,
NULL
,
&
wiring
,
NULL
,
NULL
,
0
,
NULL
,
(
const
char
**
)
al
->
argv
);
...
...
@@ -258,7 +328,7 @@ int spawn(char *path, arg_list_t *al, int join, char *input,
waitpid
(
pid
,
&
result
,
0
);
}
/
/ close wiring
/
* close wiring */
if
(
wiring
.
infd
!=
-
1
)
close
(
wiring
.
infd
);
...
...
@@ -271,6 +341,164 @@ int spawn(char *path, arg_list_t *al, int join, char *input,
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()
...
...
@@ -282,15 +510,12 @@ int stop_server(char *bin_dir, char *user, char *password, int port,
char
*
pid_file
)
{
arg_list_t
al
;
int
err
,
i
,
argc
=
0
;
char
mysqladmin_file
[
PATH_MAX
];
int
err
;
char
trash
[
PATH_MAX
];
// mysqladmin file
snprintf
(
mysqladmin_file
,
PATH_MAX
,
"%s/mysqladmin"
,
bin_dir
);
snprintf
(
trash
,
PATH_MAX
,
"/tmp/trash.out"
);
my_snprintf
(
trash
,
PATH_MAX
,
"/tmp/trash.out"
);
/
/ args
/
* args */
init_args
(
&
al
);
add_arg
(
&
al
,
"%s"
,
mysqladmin_file
);
add_arg
(
&
al
,
"--no-defaults"
);
...
...
@@ -301,7 +526,7 @@ int stop_server(char *bin_dir, char *user, char *password, int port,
add_arg
(
&
al
,
"shutdown_timeout=20"
);
add_arg
(
&
al
,
"shutdown"
);
// spawn
/* spawn */
if
((
err
=
spawn
(
mysqladmin_file
,
&
al
,
TRUE
,
NULL
,
trash
,
NULL
))
==
0
)
{
...
...
@@ -311,16 +536,16 @@ int stop_server(char *bin_dir, char *user, char *password, int port,
{
pid_t
pid
=
get_server_pid
(
pid_file
);
/
/ shutdown failed - kill server
/
* shutdown failed - kill server */
kill_server
(
pid
);
sleep
(
TRY_MAX
);
/
/ remove pid file if possible
err
=
remove
(
pid_file
);
/
* remove pid file if possible */
err
=
my_delete
(
pid_file
,
MYF
(
MY_WME
)
);
}
/
/ free args
/
* free args */
free_args
(
&
al
);
return
err
;
...
...
@@ -336,33 +561,34 @@ int stop_server(char *bin_dir, char *user, char *password, int port,
pid_t
get_server_pid
(
char
*
pid_file
)
{
char
buf
[
PATH_MAX
];
int
fd
,
err
;
int
err
;
File
fd
;
char
*
p
;
pid_t
id
;
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
)
{
// terminate string
/* terminate string */
if
((
p
=
strchr
(
buf
,
'\n'
))
!=
NULL
)
{
*
p
=
NULL
;
*
p
=
'\0'
;
// check for a '\r'
/* check for a '\r' */
if
((
p
=
strchr
(
buf
,
'\r'
))
!=
NULL
)
{
*
p
=
NULL
;
*
p
=
'\0'
;
}
}
else
{
buf
[
err
]
=
NULL
;
buf
[
err
]
=
'\0'
;
}
id
=
strtol
(
buf
,
NULL
,
0
);
...
...
@@ -370,7 +596,6 @@ pid_t get_server_pid(char *pid_file)
return
id
;
}
/******************************************************************************
kill_server()
...
...
@@ -382,8 +607,16 @@ void kill_server(pid_t pid)
{
if
(
pid
>
0
)
{
// destroy vm
#if !defined(__NETWARE__)
/* Send SIGTERM to pid */
kill
(
pid
,
SIGTERM
);
#else
/* __NETWARE__ */
/* destroy vm */
NXVmDestroy
(
pid
);
#endif
}
}
...
...
@@ -396,37 +629,40 @@ void kill_server(pid_t pid)
******************************************************************************/
void
del_tree
(
char
*
dir
)
{
DIR
*
parent
=
opendir
(
dir
)
;
DIR
*
entry
;
MY_DIR
*
current
;
uint
i
;
char
temp
[
PATH_MAX
];
if
(
parent
==
NULL
)
{
current
=
my_dir
(
dir
,
MYF
(
MY_WME
|
MY_WANT_STAT
));
/* 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_typ
e
))
else
if
(
MY_S_ISDIR
(
current
->
dir_entry
[
i
].
mystat
.
st_mod
e
))
{
// delete subdirectory
/* delete subdirectory */
del_tree
(
temp
);
}
else
{
// remove file
remove
(
temp
);
/* remove file */
my_delete
(
temp
,
MYF
(
MY_WME
)
);
}
}
// remove directory
my_dirend
(
current
);
/* remove directory */
rmdir
(
dir
);
}
...
...
@@ -435,18 +671,53 @@ void del_tree(char *dir)
removef()
******************************************************************************/
int
removef
(
char
*
format
,
...)
int
removef
(
c
onst
c
har
*
format
,
...)
{
va_list
ap
;
char
path
[
PATH_MAX
];
va_start
(
ap
,
format
);
vsnprintf
(
path
,
PATH_MAX
,
format
,
ap
);
my_
vsnprintf
(
path
,
PATH_MAX
,
format
,
ap
);
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
;
return
remove
(
path
);
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
}
/******************************************************************************
...
...
@@ -462,12 +733,15 @@ void get_basedir(char *argv0, char *basedir)
ASSERT
(
argv0
!=
NULL
);
ASSERT
(
basedir
!=
NULL
);
strcpy
(
temp
,
strlwr
(
argv0
));
strcpy
(
temp
,
argv0
);
#ifndef __WIN__
casedn_str
(
temp
);
#endif
while
((
p
=
strchr
(
temp
,
'\\'
))
!=
NULL
)
*
p
=
'/'
;
if
((
p
=
strindex
(
temp
,
"/bin/"
))
!=
NULL
)
if
((
p
=
strstr
(
temp
,
"/bin/"
))
!=
NullS
)
{
*
p
=
NULL
;
*
p
=
'\0'
;
strcpy
(
basedir
,
temp
);
}
}
...
...
netware/my_manage.h
View file @
6f604246
...
...
@@ -26,17 +26,41 @@
******************************************************************************/
#include <stdlib.h>
#ifndef __WIN__
#include <unistd.h>
#endif
/******************************************************************************
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 TRY_MAX 5
#ifdef __NETWARE__
#define strstr(A,B) strindex(A,B)
#endif
/******************************************************************************
structures
...
...
@@ -53,6 +77,8 @@ typedef struct
}
arg_list_t
;
typedef
int
pid_t
;
/******************************************************************************
global variables
...
...
@@ -66,7 +92,7 @@ typedef struct
******************************************************************************/
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
*
);
int
sleep_until_file_exists
(
char
*
);
...
...
@@ -80,8 +106,12 @@ pid_t get_server_pid(char *);
void
kill_server
(
pid_t
pid
);
void
del_tree
(
char
*
);
int
removef
(
char
*
,
...);
int
removef
(
c
onst
c
har
*
,
...);
void
get_basedir
(
char
*
,
char
*
);
char
mysqladmin_file
[
PATH_MAX
];
#endif
/* _MY_MANAGE */
netware/mysql_test_run.c
View file @
6f604246
...
...
@@ -16,21 +16,29 @@
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 <
errno
.h>
#include <dirent.h>
#i
nclude <string.h>
#include <
stdarg
.h>
#i
fdef __NETWARE__
#include <screen.h>
#include <nks/vm.h>
#include <ctype.h>
#include <sys/stat.h>
#include <unistd.h>
#include <fcntl.h>
#endif
#include "my_config.h"
#include "my_manage.h"
#ifdef __WIN__
#include <Shlwapi.h>
#endif
/******************************************************************************
macros
...
...
@@ -59,7 +67,7 @@
******************************************************************************/
char
base_dir
[
PATH_MAX
]
=
"
sys:
/mysql"
;
char
base_dir
[
PATH_MAX
]
=
"/mysql"
;
char
db
[
PATH_MAX
]
=
"test"
;
char
user
[
PATH_MAX
]
=
"root"
;
char
password
[
PATH_MAX
]
=
""
;
...
...
@@ -67,7 +75,7 @@ char password[PATH_MAX] = "";
int
master_port
=
9306
;
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
bin_dir
[
PATH_MAX
];
...
...
@@ -80,7 +88,6 @@ char slave_dir[PATH_MAX];
char
lang_dir
[
PATH_MAX
];
char
char_dir
[
PATH_MAX
];
char
mysqladmin_file
[
PATH_MAX
];
char
mysqld_file
[
PATH_MAX
];
char
mysqltest_file
[
PATH_MAX
];
char
master_pid
[
PATH_MAX
];
...
...
@@ -109,6 +116,19 @@ int single_test = TRUE;
int
restarts
=
0
;
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
},
};
/******************************************************************************
...
...
@@ -135,12 +155,12 @@ void mysql_restart();
int
read_option
(
char
*
,
char
*
);
void
run_test
(
char
*
);
void
setup
(
char
*
);
void
vlog
(
char
*
,
va_list
);
void
log
(
char
*
,
...);
void
log_info
(
char
*
,
...);
void
log_error
(
char
*
,
...);
void
log_errno
(
char
*
,
...);
void
die
(
char
*
);
void
vlog
(
c
onst
c
har
*
,
va_list
);
void
mtr_log
(
const
char
*
,
...);
void
mtr_log_info
(
const
char
*
,
...);
void
mtr_log_error
(
const
char
*
,
...);
void
mtr_log_errno
(
const
char
*
,
...);
void
die
(
c
onst
c
har
*
);
/******************************************************************************
...
...
@@ -153,21 +173,21 @@ void report_stats()
{
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
{
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
);
log
(
"
\n
The .out and .err files in %s may give you some
\n
"
,
result_dir
);
log
(
"hint of what when wrong.
\n
"
);
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
(
"
\n
The .out and .err files in %s may give you some
\n
"
,
result_dir
);
mtr_
log
(
"hint of what when wrong.
\n
"
);
mtr_
log
(
"
\n
If you want to report this error, please first read the documentation
\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
);
}
/******************************************************************************
...
...
@@ -180,15 +200,15 @@ void report_stats()
void
install_db
(
char
*
datadir
)
{
arg_list_t
al
;
int
err
,
i
;
int
err
;
char
input
[
PATH_MAX
];
char
output
[
PATH_MAX
];
char
error
[
PATH_MAX
];
// input file
snprintf
(
input
,
PATH_MAX
,
"%s/bin/init_db.sql"
,
base_dir
);
snprintf
(
output
,
PATH_MAX
,
"%s/install.out"
,
datadir
);
snprintf
(
error
,
PATH_MAX
,
"%s/install.err"
,
datadir
);
my_
snprintf
(
input
,
PATH_MAX
,
"%s/bin/init_db.sql"
,
base_dir
);
my_
snprintf
(
output
,
PATH_MAX
,
"%s/install.out"
,
datadir
);
my_
snprintf
(
error
,
PATH_MAX
,
"%s/install.err"
,
datadir
);
// args
init_args
(
&
al
);
...
...
@@ -201,6 +221,7 @@ void install_db(char *datadir)
add_arg
(
&
al
,
"--skip-bdb"
);
// spawn
if
((
err
=
spawn
(
mysqld_file
,
&
al
,
TRUE
,
input
,
output
,
error
))
!=
0
)
{
die
(
"Unable to create database."
);
...
...
@@ -221,34 +242,34 @@ void mysql_install_db()
{
char
temp
[
PATH_MAX
];
/
/ var directory
snprintf
(
temp
,
PATH_MAX
,
"%s/var"
,
mysql_test_dir
);
/
* var directory */
my_
snprintf
(
temp
,
PATH_MAX
,
"%s/var"
,
mysql_test_dir
);
/
/ clean up old direcotry
/
* clean up old directory */
del_tree
(
temp
);
/
/ create var directory
m
kdir
(
temp
,
S_IRWXU
);
/
/ create subdirectories
snprintf
(
temp
,
PATH_MAX
,
"%s/var/run"
,
mysql_test_dir
);
m
kdir
(
temp
,
S_IRWXU
);
snprintf
(
temp
,
PATH_MAX
,
"%s/var/tmp"
,
mysql_test_dir
);
m
kdir
(
temp
,
S_IRWXU
);
snprintf
(
temp
,
PATH_MAX
,
"%s/var/master-data"
,
mysql_test_dir
);
m
kdir
(
temp
,
S_IRWXU
);
snprintf
(
temp
,
PATH_MAX
,
"%s/var/master-data/mysql"
,
mysql_test_dir
);
m
kdir
(
temp
,
S_IRWXU
);
snprintf
(
temp
,
PATH_MAX
,
"%s/var/master-data/test"
,
mysql_test_dir
);
m
kdir
(
temp
,
S_IRWXU
);
snprintf
(
temp
,
PATH_MAX
,
"%s/var/slave-data"
,
mysql_test_dir
);
m
kdir
(
temp
,
S_IRWXU
);
snprintf
(
temp
,
PATH_MAX
,
"%s/var/slave-data/mysql"
,
mysql_test_dir
);
m
kdir
(
temp
,
S_IRWXU
);
snprintf
(
temp
,
PATH_MAX
,
"%s/var/slave-data/test"
,
mysql_test_dir
);
m
kdir
(
temp
,
S_IRWXU
);
/
/ install databases
/
* create var directory */
m
y_mkdir
(
temp
,
0700
,
MYF
(
MY_WME
)
);
/
* create subdirectories */
my_
snprintf
(
temp
,
PATH_MAX
,
"%s/var/run"
,
mysql_test_dir
);
m
y_mkdir
(
temp
,
0700
,
MYF
(
MY_WME
)
);
my_
snprintf
(
temp
,
PATH_MAX
,
"%s/var/tmp"
,
mysql_test_dir
);
m
y_mkdir
(
temp
,
0700
,
MYF
(
MY_WME
)
);
my_
snprintf
(
temp
,
PATH_MAX
,
"%s/var/master-data"
,
mysql_test_dir
);
m
y_mkdir
(
temp
,
0700
,
MYF
(
MY_WME
)
);
my_
snprintf
(
temp
,
PATH_MAX
,
"%s/var/master-data/mysql"
,
mysql_test_dir
);
m
y_mkdir
(
temp
,
0700
,
MYF
(
MY_WME
)
);
my_
snprintf
(
temp
,
PATH_MAX
,
"%s/var/master-data/test"
,
mysql_test_dir
);
m
y_mkdir
(
temp
,
0700
,
MYF
(
MY_WME
)
);
my_
snprintf
(
temp
,
PATH_MAX
,
"%s/var/slave-data"
,
mysql_test_dir
);
m
y_mkdir
(
temp
,
0700
,
MYF
(
MY_WME
)
);
my_
snprintf
(
temp
,
PATH_MAX
,
"%s/var/slave-data/mysql"
,
mysql_test_dir
);
m
y_mkdir
(
temp
,
0700
,
MYF
(
MY_WME
)
);
my_
snprintf
(
temp
,
PATH_MAX
,
"%s/var/slave-data/test"
,
mysql_test_dir
);
m
y_mkdir
(
temp
,
0700
,
MYF
(
MY_WME
)
);
/
* install databases */
install_db
(
master_dir
);
install_db
(
slave_dir
);
}
...
...
@@ -263,56 +284,35 @@ void mysql_install_db()
void
start_master
()
{
arg_list_t
al
;
int
err
,
i
;
int
err
;
char
master_out
[
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
);
/
/ remove stale binary logs
/
* remove stale binary logs */
removef
(
"%s/*-bin.*"
,
master_dir
);
/
/ remove stale binary logs
/
* remove stale binary logs */
removef
(
"%s/*.index"
,
master_dir
);
/
/ remove master.info file
/
* remove master.info file */
removef
(
"%s/master.info"
,
master_dir
);
/
/ remove relay files
/
* remove relay files */
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
);
// init script
if
(
master_init_script
[
0
]
!=
NULL
)
{
// 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"
,
/* redirection files */
my_snprintf
(
master_out
,
PATH_MAX
,
"%s/var/run/master%u.out"
,
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
);
/
/ args
/
* args */
init_args
(
&
al
);
add_arg
(
&
al
,
"%s"
,
mysqld_file
);
add_arg
(
&
al
,
"--no-defaults"
);
...
...
@@ -328,11 +328,11 @@ void start_master()
add_arg
(
&
al
,
"--tmpdir=%s"
,
mysql_tmp_dir
);
add_arg
(
&
al
,
"--language=%s"
,
lang_dir
);
/
/ $MASTER_40_ARGS
/
* $MASTER_40_ARGS */
add_arg
(
&
al
,
"--rpl-recovery-rank=1"
);
add_arg
(
&
al
,
"--init-rpl-role=master"
);
/
/ $SMALL_SERVER
/
* $SMALL_SERVER */
add_arg
(
&
al
,
"-O"
);
add_arg
(
&
al
,
"key_buffer_size=1M"
);
add_arg
(
&
al
,
"-O"
);
...
...
@@ -340,8 +340,8 @@ void start_master()
add_arg
(
&
al
,
"-O"
);
add_arg
(
&
al
,
"max_heap_table_size=1M"
);
/
/ $EXTRA_MASTER_OPT
if
(
master_opt
[
0
]
!=
NULL
)
/
* $EXTRA_MASTER_OPT */
if
(
master_opt
[
0
]
!=
'\0'
)
{
char
*
p
;
...
...
@@ -355,10 +355,15 @@ void start_master()
}
}
// remove the pid file if it exists
remove
(
master_pid
);
/* remove the pid file if it exists */
#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
)
{
sleep_until_file_exists
(
master_pid
);
...
...
@@ -369,15 +374,15 @@ void start_master()
}
else
{
log_error
(
"The master server went down early."
);
mtr_
log_error
(
"The master server went down early."
);
}
}
else
{
log_error
(
"Unable to start master server."
);
mtr_
log_error
(
"Unable to start master server."
);
}
/
/ free_args
/
* free_args */
free_args
(
&
al
);
}
...
...
@@ -391,48 +396,48 @@ void start_master()
void
start_slave
()
{
arg_list_t
al
;
int
err
,
i
;
int
err
;
char
slave_out
[
PATH_MAX
];
char
slave_err
[
PATH_MAX
];
char
temp
[
PATH_MAX
];
/
/ skip?
/
* skip? */
if
(
skip_slave
)
return
;
/
/ remove stale binary logs
/
* remove stale binary logs */
removef
(
"%s/*-bin.*"
,
slave_dir
);
/
/ remove stale binary logs
/
* remove stale binary logs */
removef
(
"%s/*.index"
,
slave_dir
);
/
/ remove master.info file
/
* remove master.info file */
removef
(
"%s/master.info"
,
slave_dir
);
/
/ remove relay files
/
* remove relay files */
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
);
/
/ init script
if
(
slave_init_script
[
0
]
!=
NULL
)
/
* init script */
if
(
slave_init_script
[
0
]
!=
'\0'
)
{
/
/ run_init_script(slave_init_script);
/
* run_init_script(slave_init_script); */
/
/ TODO: use the scripts
if
(
str
index
(
slave_init_script
,
"rpl000016-slave.sh"
)
!=
NULL
)
/
* TODO: use the scripts */
if
(
str
str
(
slave_init_script
,
"rpl000016-slave.sh"
)
!=
NULL
)
{
/
/ create empty master.info file
snprintf
(
temp
,
PATH_MAX
,
"%s/master.info"
,
slave_dir
);
close
(
open
(
temp
,
O_WRONLY
|
O_CREAT
));
/
* create empty master.info file */
my_
snprintf
(
temp
,
PATH_MAX
,
"%s/master.info"
,
slave_dir
);
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
;
/
/ create a master.info file
snprintf
(
temp
,
PATH_MAX
,
"%s/master.info"
,
slave_dir
);
fp
=
fopen
(
temp
,
"wb+"
);
/
* create a master.info file */
my_
snprintf
(
temp
,
PATH_MAX
,
"%s/master.info"
,
slave_dir
);
fp
=
my_fopen
(
temp
,
(
int
)(
O_WRONLY
|
O_BINARY
|
O_CREAT
),
MYF
(
MY_WME
)
);
fputs
(
"master-bin.001
\n
"
,
fp
);
fputs
(
"4
\n
"
,
fp
);
...
...
@@ -443,20 +448,20 @@ void start_slave()
fputs
(
"1
\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
snprintf
(
temp
,
PATH_MAX
,
"%s/master.info"
,
slave_dir
);
close
(
open
(
temp
,
O_WRONLY
|
O_CREAT
));
/
* create empty master.info file */
my_
snprintf
(
temp
,
PATH_MAX
,
"%s/master.info"
,
slave_dir
);
my_close
(
my_open
(
temp
,
O_WRONLY
|
O_CREAT
,
MYF
(
0
)),
MYF
(
0
));
}
}
/
/ redirection files
snprintf
(
slave_out
,
PATH_MAX
,
"%s/var/run/slave%u.out"
,
/
* redirection files */
my_
snprintf
(
slave_out
,
PATH_MAX
,
"%s/var/run/slave%u.out"
,
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
);
// args
...
...
@@ -489,8 +494,8 @@ void start_slave()
add_arg
(
&
al
,
"-O"
);
add_arg
(
&
al
,
"slave_net_timeout=10"
);
/
/ slave master info
if
(
slave_master_info
[
0
]
!=
NULL
)
/
* slave master info */
if
(
slave_master_info
[
0
]
!=
'\0'
)
{
char
*
p
;
...
...
@@ -514,7 +519,7 @@ void start_slave()
add_arg
(
&
al
,
"--rpl-recovery-rank=2"
);
}
/
/ small server
/
* small server */
add_arg
(
&
al
,
"-O"
);
add_arg
(
&
al
,
"key_buffer_size=1M"
);
add_arg
(
&
al
,
"-O"
);
...
...
@@ -522,8 +527,8 @@ void start_slave()
add_arg
(
&
al
,
"-O"
);
add_arg
(
&
al
,
"max_heap_table_size=1M"
);
/
/ opt args
if
(
slave_opt
[
0
]
!=
NULL
)
/
* opt args */
if
(
slave_opt
[
0
]
!=
'\0'
)
{
char
*
p
;
...
...
@@ -537,8 +542,13 @@ void start_slave()
}
}
// remove the pid file if it exists
remove
(
slave_pid
);
/* remove the pid file if it exists */
#ifndef __WIN__
my_delete
(
slave_pid
,
MYF
(
MY_WME
));
#else
pid_mode
=
SLAVE_PID
;
run_server
=
TRUE
;
#endif
// spawn
if
((
err
=
spawn
(
mysqld_file
,
&
al
,
FALSE
,
NULL
,
slave_out
,
slave_err
))
==
0
)
...
...
@@ -551,12 +561,12 @@ void start_slave()
}
else
{
log_error
(
"The slave server went down early."
);
mtr_
log_error
(
"The slave server went down early."
);
}
}
else
{
log_error
(
"Unable to start slave server."
);
mtr_
log_error
(
"Unable to start slave server."
);
}
// free args
...
...
@@ -576,8 +586,10 @@ void mysql_start()
start_slave
();
#ifdef __NETWARE__
// activate the test screen
ActivateScreen
(
getscreenhandle
());
#endif
}
/******************************************************************************
...
...
@@ -591,17 +603,20 @@ void stop_slave()
{
int
err
;
/
/ running?
/
* running? */
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
)
{
slave_running
=
FALSE
;
}
else
{
log_error
(
"Unable to stop slave server."
);
mtr_
log_error
(
"Unable to stop slave server."
);
}
}
...
...
@@ -616,16 +631,18 @@ void stop_master()
{
int
err
;
/
/ running?
/
* running? */
if
(
!
master_running
)
return
;
#ifdef __WIN__
pid_mode
=
MASTER_PID
;
#endif
if
((
err
=
stop_server
(
bin_dir
,
user
,
password
,
master_port
,
master_pid
))
==
0
)
{
master_running
=
FALSE
;
}
else
{
log_error
(
"Unable to stop master server."
);
mtr_
log_error
(
"Unable to stop master server."
);
}
}
...
...
@@ -642,8 +659,10 @@ void mysql_stop()
stop_slave
();
#ifdef __NETWARE__
// activate the test screen
ActivateScreen
(
getscreenhandle
());
#endif
}
/******************************************************************************
...
...
@@ -655,7 +674,7 @@ void mysql_stop()
******************************************************************************/
void
mysql_restart
()
{
log_info
(
"Restarting the MySQL server(s): %u"
,
++
restarts
);
mtr_
log_info
(
"Restarting the MySQL server(s): %u"
,
++
restarts
);
mysql_stop
();
...
...
@@ -671,45 +690,50 @@ void mysql_restart()
******************************************************************************/
int
read_option
(
char
*
opt_file
,
char
*
opt
)
{
int
fd
,
err
;
int
result
;
File
fd
;
int
err
;
char
*
p
;
char
buf
[
PATH_MAX
];
/
/ copy current option
/
* copy current option */
strncpy
(
buf
,
opt
,
PATH_MAX
);
// open options file
fd
=
open
(
opt_file
,
O_RDONLY
);
#ifdef __WIN__
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
)
{
/
/ terminate string
/
* terminate string */
if
((
p
=
strchr
(
opt
,
'\n'
))
!=
NULL
)
{
*
p
=
NULL
;
*
p
=
'\0'
;
/
/ check for a '\r'
/
* check for a '\r' */
if
((
p
=
strchr
(
opt
,
'\r'
))
!=
NULL
)
{
*
p
=
NULL
;
*
p
=
'\0'
;
}
}
else
{
opt
[
err
]
=
NULL
;
opt
[
err
]
=
'\0'
;
}
/
/ check for $MYSQL_TEST_DIR
if
((
p
=
strstr
(
opt
,
"$MYSQL_TEST_DIR"
))
!=
N
ULL
)
/
* check for $MYSQL_TEST_DIR */
if
((
p
=
strstr
(
opt
,
"$MYSQL_TEST_DIR"
))
!=
N
ullS
)
{
char
temp
[
PATH_MAX
];
*
p
=
NULL
;
*
p
=
'\0'
;
strcpy
(
temp
,
p
+
strlen
(
"$MYSQL_TEST_DIR"
));
...
...
@@ -720,11 +744,14 @@ int read_option(char *opt_file, char *opt)
}
else
{
// clear option
*
opt
=
NULL
;
/* clear option */
*
opt
=
'\0'
;
}
#ifdef __WIN__
}
#endif
/
/ compare current option with previous
/
* compare current option with previous */
return
strcmp
(
opt
,
buf
);
}
...
...
@@ -739,21 +766,20 @@ void run_test(char *test)
{
char
temp
[
PATH_MAX
];
char
*
rstr
;
double
elapsed
=
0
;
int
skip
=
FALSE
;
int
restart
=
FALSE
;
int
flag
=
FALSE
;
struct
stat
info
;
/
/ single test?
/
* single test? */
if
(
!
single_test
)
{
// skip tests in the skip list
snprintf
(
temp
,
PATH_MAX
,
" %s "
,
test
);
skip
=
(
strindex
(
skip_test
,
temp
)
!=
NULL
);
my_
snprintf
(
temp
,
PATH_MAX
,
" %s "
,
test
);
skip
=
strinstr
(
skip_test
,
temp
);
}
/
/ skip test?
/
* skip test? */
if
(
!
skip
)
{
char
test_file
[
PATH_MAX
];
...
...
@@ -766,7 +792,6 @@ void run_test(char *test)
char
err_file
[
PATH_MAX
];
int
err
;
arg_list_t
al
;
NXTime_t
start
,
stop
;
// skip slave?
flag
=
skip_slave
;
...
...
@@ -774,36 +799,36 @@ void run_test(char *test)
if
(
flag
!=
skip_slave
)
restart
=
TRUE
;
// create files
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
);
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
);
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
(
master_opt_file
,
PATH_MAX
,
"%s/%s-master.opt"
,
test_dir
,
test
);
my_
snprintf
(
slave_opt_file
,
PATH_MAX
,
"%s/%s-slave.opt"
,
test_dir
,
test
);
my_
snprintf
(
slave_master_info_file
,
PATH_MAX
,
"%s/%s.slave-mi"
,
test_dir
,
test
);
my_
snprintf
(
reject_file
,
PATH_MAX
,
"%s/%s%s"
,
result_dir
,
test
,
REJECT_SUFFIX
);
my_
snprintf
(
out_file
,
PATH_MAX
,
"%s/%s%s"
,
result_dir
,
test
,
OUT_SUFFIX
);
my_
snprintf
(
err_file
,
PATH_MAX
,
"%s/%s%s"
,
result_dir
,
test
,
ERR_SUFFIX
);
// 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
))
{
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
))
{
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
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
))
master_init_script
[
0
]
=
NULL
;
master_init_script
[
0
]
=
'\0'
;
else
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
))
slave_init_script
[
0
]
=
NULL
;
slave_init_script
[
0
]
=
'\0'
;
else
restart
=
TRUE
;
...
...
@@ -825,7 +850,7 @@ void run_test(char *test)
sleep
(
1
);
// show test
log
(
"%-46s "
,
test
);
mtr_
log
(
"%-46s "
,
test
);
// args
init_args
(
&
al
);
...
...
@@ -842,26 +867,16 @@ void run_test(char *test)
add_arg
(
&
al
,
"-R"
);
add_arg
(
&
al
,
"%s"
,
result_file
);
// start timer
NXGetTime
(
NX_SINCE_BOOT
,
NX_USECONDS
,
&
start
);
// spawn
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
(
&
al
);
if
(
err
==
0
)
{
// pass
rstr
=
TEST_PASS
;
rstr
=
(
char
*
)
TEST_PASS
;
++
total_pass
;
// increment total
...
...
@@ -870,13 +885,13 @@ void run_test(char *test)
else
if
(
err
==
2
)
{
// skip
rstr
=
TEST_SKIP
;
rstr
=
(
char
*
)
TEST_SKIP
;
++
total_skip
;
}
else
if
(
err
==
1
)
{
// fail
rstr
=
TEST_FAIL
;
rstr
=
(
char
*
)
TEST_FAIL
;
++
total_fail
;
// increment total
...
...
@@ -884,21 +899,21 @@ void run_test(char *test)
}
else
{
rstr
=
TEST_BAD
;
rstr
=
(
char
*
)
TEST_BAD
;
}
}
else
// early skips
{
// show test
log
(
"%-46s "
,
test
);
mtr_
log
(
"%-46s "
,
test
);
// skip
rstr
=
TEST_SKIP
;
rstr
=
(
char
*
)
TEST_SKIP
;
++
total_skip
;
}
// result
log
(
"%10.06f %-14s
\n
"
,
elapsed
,
rstr
);
mtr_log
(
" %-14s
\n
"
,
rstr
);
}
/******************************************************************************
...
...
@@ -908,7 +923,7 @@ void run_test(char *test)
Log the message.
******************************************************************************/
void
vlog
(
char
*
format
,
va_list
ap
)
void
vlog
(
c
onst
c
har
*
format
,
va_list
ap
)
{
vfprintf
(
stdout
,
format
,
ap
);
fflush
(
stdout
);
...
...
@@ -922,12 +937,12 @@ void vlog(char *format, va_list ap)
/******************************************************************************
log()
mtr_
log()
Log the message.
******************************************************************************/
void
log
(
char
*
format
,
...)
void
mtr_log
(
const
char
*
format
,
...)
{
va_list
ap
;
...
...
@@ -940,60 +955,60 @@ void log(char *format, ...)
/******************************************************************************
log_info()
mtr_
log_info()
Log the given information.
******************************************************************************/
void
log_info
(
char
*
format
,
...)
void
mtr_log_info
(
const
char
*
format
,
...)
{
va_list
ap
;
va_start
(
ap
,
format
);
log
(
"-- INFO : "
);
mtr_
log
(
"-- INFO : "
);
vlog
(
format
,
ap
);
log
(
"
\n
"
);
mtr_
log
(
"
\n
"
);
va_end
(
ap
);
}
/******************************************************************************
log_error()
mtr_
log_error()
Log the given error.
******************************************************************************/
void
log_error
(
char
*
format
,
...)
void
mtr_log_error
(
const
char
*
format
,
...)
{
va_list
ap
;
va_start
(
ap
,
format
);
log
(
"-- ERROR: "
);
mtr_
log
(
"-- ERROR: "
);
vlog
(
format
,
ap
);
log
(
"
\n
"
);
mtr_
log
(
"
\n
"
);
va_end
(
ap
);
}
/******************************************************************************
log_errno()
mtr_
log_errno()
Log the given error and errno.
******************************************************************************/
void
log_errno
(
char
*
format
,
...)
void
mtr_log_errno
(
const
char
*
format
,
...)
{
va_list
ap
;
va_start
(
ap
,
format
);
log
(
"-- ERROR: (%003u) "
,
errno
);
mtr_
log
(
"-- ERROR: (%003u) "
,
errno
);
vlog
(
format
,
ap
);
log
(
"
\n
"
);
mtr_
log
(
"
\n
"
);
va_end
(
ap
);
}
...
...
@@ -1005,11 +1020,13 @@ void log_errno(char *format, ...)
Exit the application.
******************************************************************************/
void
die
(
char
*
msg
)
void
die
(
c
onst
c
har
*
msg
)
{
log_error
(
msg
);
mtr_
log_error
(
msg
);
#ifdef __NETWARE__
pressanykey
();
#endif
exit
(
-
1
);
}
...
...
@@ -1027,50 +1044,83 @@ void setup(char *file)
char
*
p
;
// set the timezone for the timestamp test
#ifdef __WIN__
_putenv
(
"TZ=GMT-3"
);
#else
setenv
(
"TZ"
,
"GMT-3"
,
TRUE
);
#endif
// find base dir
strcpy
(
temp
,
strlwr
(
file
));
strcpy
(
temp
,
file
);
#ifndef __WIN__
casedn_str
(
temp
);
#endif
while
((
p
=
strchr
(
temp
,
'\\'
))
!=
NULL
)
*
p
=
'/'
;
if
((
p
=
str
index
(
temp
,
"/mysql-test/"
))
!=
NULL
)
if
((
p
=
str
str
(
temp
,
"/mysql-test/"
))
)
{
*
p
=
NULL
;
strcpy
(
base_dir
,
temp
);
*
p
=
'\0'
;
strcpy
(
base_dir
,
(
const
char
*
)
temp
);
}
// setup paths
snprintf
(
bin_dir
,
PATH_MAX
,
"%s/bin"
,
base_dir
);
snprintf
(
mysql_test_dir
,
PATH_MAX
,
"%s/mysql-test"
,
base_dir
);
snprintf
(
test_dir
,
PATH_MAX
,
"%s/t"
,
mysql_test_dir
);
snprintf
(
mysql_tmp_dir
,
PATH_MAX
,
"%s/var/tmp"
,
mysql_test_dir
);
snprintf
(
result_dir
,
PATH_MAX
,
"%s/r"
,
mysql_test_dir
);
snprintf
(
master_dir
,
PATH_MAX
,
"%s/var/master-data"
,
mysql_test_dir
);
snprintf
(
slave_dir
,
PATH_MAX
,
"%s/var/slave-data"
,
mysql_test_dir
);
snprintf
(
lang_dir
,
PATH_MAX
,
"%s/share/english"
,
base_dir
);
snprintf
(
char_dir
,
PATH_MAX
,
"%s/share/charsets"
,
base_dir
);
#ifdef __WIN__
my_snprintf
(
bin_dir
,
PATH_MAX
,
"%s/%s"
,
base_dir
,
opt_exedir
);
#else
my_snprintf
(
bin_dir
,
PATH_MAX
,
"%s/bin"
,
base_dir
);
#endif
my_snprintf
(
mysql_test_dir
,
PATH_MAX
,
"%s/mysql-test"
,
base_dir
);
my_snprintf
(
test_dir
,
PATH_MAX
,
"%s/t"
,
mysql_test_dir
);
my_snprintf
(
mysql_tmp_dir
,
PATH_MAX
,
"%s/var/tmp"
,
mysql_test_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
snprintf
(
mysqld_file
,
PATH_MAX
,
"%s/mysqld"
,
bin_dir
);
snprintf
(
mysqltest_file
,
PATH_MAX
,
"%s/mysqltest"
,
bin_dir
);
snprintf
(
mysqladmin_file
,
PATH_MAX
,
"%s/mysqladmin"
,
bin_dir
);
snprintf
(
master_pid
,
PATH_MAX
,
"%s/var/run/master.pid"
,
mysql_test_dir
);
snprintf
(
slave_pid
,
PATH_MAX
,
"%s/var/run/slave.pid"
,
mysql_test_dir
);
#ifdef __WIN__
my_snprintf
(
mysqld_file
,
PATH_MAX
,
"%s/%s.exe"
,
bin_dir
,
mysqld
);
my_snprintf
(
mysqltest_file
,
PATH_MAX
,
"%s/mysqltest.exe"
,
bin_dir
);
my_snprintf
(
mysqladmin_file
,
PATH_MAX
,
"%s/mysqladmin.exe"
,
bin_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
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
)
{
log_errno
(
"Unable to create log file."
);
mtr_
log_errno
(
"Unable to create log file."
);
}
// prepare skip test list
while
((
p
=
strchr
(
skip_test
,
','
))
!=
NULL
)
*
p
=
' '
;
strcpy
(
temp
,
strlwr
(
skip_test
));
snprintf
(
skip_test
,
PATH_MAX
,
" %s "
,
temp
);
strcpy
(
temp
,
skip_test
);
#ifndef __WIN__
casedn_str
(
temp
);
#endif
my_snprintf
(
skip_test
,
PATH_MAX
,
" %s "
,
temp
);
// enviornment
#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)
******************************************************************************/
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
#ifdef __WIN__
setup
(
current_dir
);
#else
setup
(
argv
[
0
]);
#endif
// 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
mysql_install_db
();
log
(
"Starting Tests...
\n
"
);
mtr_
log
(
"Starting Tests...
\n
"
);
log
(
"
\n
"
);
log
(
HEADER
);
log
(
DASH
);
mtr_
log
(
"
\n
"
);
mtr_
log
(
HEADER
);
mtr_
log
(
DASH
);
#ifdef __WIN__
if
(
argc
>
0
)
#else
if
(
argc
>
1
)
#endif
{
int
i
;
// single test
single_test
=
TRUE
;
#ifdef __WIN__
for
(
i
=
0
;
i
<
argc
;
i
++
)
#else
for
(
i
=
1
;
i
<
argc
;
i
++
)
#endif
{
// run given test
run_test
(
argv
[
i
]);
...
...
@@ -1113,8 +1191,7 @@ int main(int argc, char **argv)
else
{
// run all tests
DIR
*
dir
=
opendir
(
test_dir
);
DIR
*
entry
;
MY_DIR
*
dir
=
my_dir
(
test_dir
,
MYF
(
MY_WME
|
MY_WANT_STAT
));
char
test
[
NAME_MAX
];
char
*
p
;
...
...
@@ -1126,14 +1203,16 @@ int main(int argc, char **argv)
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
if
((
p
=
str
index
(
test
,
TEST_SUFFIX
))
!=
NULL
)
if
((
p
=
str
str
(
test
,
TEST_SUFFIX
))
)
{
// null terminate at the suffix
*
p
=
'\0'
;
...
...
@@ -1144,13 +1223,13 @@ int main(int argc, char **argv)
}
}
closedir
(
dir
);
my_dirend
(
dir
);
}
log
(
DASH
);
log
(
"
\n
"
);
mtr_
log
(
DASH
);
mtr_
log
(
"
\n
"
);
log
(
"Ending Tests...
\n
"
);
mtr_
log
(
"Ending Tests...
\n
"
);
// stop server
mysql_stop
();
...
...
@@ -1161,8 +1240,10 @@ int main(int argc, char **argv)
// close log
if
(
log_fd
)
fclose
(
log_fd
);
#ifdef __NETWARE__
// keep results up
pressanykey
();
#endif
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