Commit 41c58b13 authored by kent@mysql.com's avatar kent@mysql.com

Merge mysql.com:/home/bk/mysql-4.1

into mysql.com:/users/kboortz/daily/work/mysql-4.1-wax
parents c865cd29 fd3ec9ca
...@@ -30,7 +30,8 @@ ...@@ -30,7 +30,8 @@
#ifndef __WIN__ #ifndef __WIN__
#include <sys/wait.h> #include <sys/wait.h>
#include <unistd.h> #include <unistd.h>
#include <fnmatch.h> #include <signal.h>
#include <fnmatch.h> /* FIXME HAVE_FNMATCH_H or something */
#else #else
#include <direct.h> #include <direct.h>
#include <stdlib.h> #include <stdlib.h>
...@@ -100,7 +101,7 @@ void init_args(arg_list_t *al) ...@@ -100,7 +101,7 @@ void init_args(arg_list_t *al)
void add_arg(arg_list_t *al, const char *format, ...) void add_arg(arg_list_t *al, const char *format, ...)
{ {
va_list ap; va_list ap;
char temp[PATH_MAX]; char temp[FN_REFLEN];
ASSERT(al != NULL); ASSERT(al != NULL);
...@@ -230,10 +231,10 @@ int wait_for_server_start(char *bin_dir __attribute__((unused)), ...@@ -230,10 +231,10 @@ int wait_for_server_start(char *bin_dir __attribute__((unused)),
{ {
arg_list_t al; arg_list_t al;
int err= 0, i; int err= 0, i;
char trash[PATH_MAX]; char trash[FN_REFLEN];
/* mysqladmin file */ /* mysqladmin file */
snprintf(trash, PATH_MAX, "%s/trash.out",tmp_dir); snprintf(trash, FN_REFLEN, "%s/trash.out",tmp_dir);
/* args */ /* args */
init_args(&al); init_args(&al);
...@@ -490,9 +491,9 @@ int stop_server(char *bin_dir __attribute__((unused)), char *mysqladmin_file, ...@@ -490,9 +491,9 @@ int stop_server(char *bin_dir __attribute__((unused)), char *mysqladmin_file,
{ {
arg_list_t al; arg_list_t al;
int err= 0; int err= 0;
char trash[PATH_MAX]; char trash[FN_REFLEN];
snprintf(trash, PATH_MAX, "%s/trash.out",tmp_dir); snprintf(trash, FN_REFLEN, "%s/trash.out",tmp_dir);
/* args */ /* args */
init_args(&al); init_args(&al);
...@@ -548,7 +549,7 @@ int stop_server(char *bin_dir __attribute__((unused)), char *mysqladmin_file, ...@@ -548,7 +549,7 @@ int stop_server(char *bin_dir __attribute__((unused)), char *mysqladmin_file,
#ifndef __WIN__ #ifndef __WIN__
pid_t get_server_pid(char *pid_file) pid_t get_server_pid(char *pid_file)
{ {
char buf[PATH_MAX]; char buf[FN_REFLEN];
int fd, err; int fd, err;
char *p; char *p;
pid_t id= 0; pid_t id= 0;
...@@ -556,7 +557,7 @@ pid_t get_server_pid(char *pid_file) ...@@ -556,7 +557,7 @@ pid_t get_server_pid(char *pid_file)
/* discover id */ /* discover id */
fd= open(pid_file, O_RDONLY); fd= open(pid_file, O_RDONLY);
err= read(fd, buf, PATH_MAX); err= read(fd, buf, FN_REFLEN);
close(fd); close(fd);
...@@ -619,7 +620,7 @@ void del_tree(char *dir) ...@@ -619,7 +620,7 @@ void del_tree(char *dir)
#ifndef __WIN__ #ifndef __WIN__
DIR *parent= opendir(dir); DIR *parent= opendir(dir);
struct dirent *entry; struct dirent *entry;
char temp[PATH_MAX]; char temp[FN_REFLEN];
if (parent == NULL) if (parent == NULL)
{ {
...@@ -629,14 +630,27 @@ void del_tree(char *dir) ...@@ -629,14 +630,27 @@ void del_tree(char *dir)
while ((entry= readdir(parent)) != NULL) while ((entry= readdir(parent)) != NULL)
{ {
/* create long name */ /* create long name */
snprintf(temp, PATH_MAX, "%s/%s", dir, entry->d_name); snprintf(temp, FN_REFLEN, "%s/%s", dir, entry->d_name);
if (entry->d_name[0] == '.') if (entry->d_name[0] == '.')
{ {
/* Skip */ /* Skip */
} }
else else
{
/* FIXME missing test in acinclude.m4 */
#ifndef STRUCT_DIRENT_HAS_D_TYPE
struct stat st;
if (lstat(entry->d_name, &st) == -1)
{
/* FIXME error */
return;
}
if (S_ISDIR(st.st_mode))
#else
if (S_ISDIR(entry->d_type)) if (S_ISDIR(entry->d_type))
#endif
{ {
/* delete subdirectory */ /* delete subdirectory */
del_tree(temp); del_tree(temp);
...@@ -647,15 +661,16 @@ void del_tree(char *dir) ...@@ -647,15 +661,16 @@ void del_tree(char *dir)
remove(temp); remove(temp);
} }
} }
}
/* remove directory */ /* remove directory */
rmdir(dir); rmdir(dir);
#else #else
struct _finddata_t parent; struct _finddata_t parent;
intptr_t handle; intptr_t handle;
char temp[PATH_MAX]; char temp[FN_REFLEN];
char mask[PATH_MAX]; char mask[FN_REFLEN];
snprintf(mask,MAX_PATH,"%s/*.*",dir); snprintf(mask,FN_REFLEN,"%s/*.*",dir);
if ((handle=_findfirst(mask,&parent)) == -1L) if ((handle=_findfirst(mask,&parent)) == -1L)
{ {
...@@ -665,7 +680,7 @@ void del_tree(char *dir) ...@@ -665,7 +680,7 @@ void del_tree(char *dir)
do do
{ {
/* create long name */ /* create long name */
snprintf(temp, PATH_MAX, "%s/%s", dir, parent.name); snprintf(temp, FN_REFLEN, "%s/%s", dir, parent.name);
if (parent.name[0] == '.') if (parent.name[0] == '.')
{ {
/* Skip */ /* Skip */
...@@ -700,11 +715,11 @@ int removef(const char *format, ...) ...@@ -700,11 +715,11 @@ int removef(const char *format, ...)
{ {
#ifdef __NETWARE__ #ifdef __NETWARE__
va_list ap; va_list ap;
char path[PATH_MAX]; char path[FN_REFLEN];
va_start(ap, format); va_start(ap, format);
vsnprintf(path, PATH_MAX, format, ap); vsnprintf(path, FN_REFLEN, format, ap);
va_end(ap); va_end(ap);
return remove(path); return remove(path);
...@@ -712,15 +727,15 @@ int removef(const char *format, ...) ...@@ -712,15 +727,15 @@ int removef(const char *format, ...)
#eldef __WIN__ #eldef __WIN__
{ {
va_list ap; va_list ap;
char path[PATH_MAX]; char path[FN_REFLEN];
struct _finddata_t parent; struct _finddata_t parent;
intptr_t handle; intptr_t handle;
char temp[PATH_MAX]; char temp[FN_REFLEN];
char *p; char *p;
va_start(ap, format); va_start(ap, format);
vsnprintf(path, PATH_MAX, format, ap); vsnprintf(path, FN_REFLEN, format, ap);
va_end(ap); va_end(ap);
...@@ -739,7 +754,7 @@ int removef(const char *format, ...) ...@@ -739,7 +754,7 @@ int removef(const char *format, ...)
{ {
if (! (parent.attrib & _A_SUBDIR)) if (! (parent.attrib & _A_SUBDIR))
{ {
snprintf(temp, PATH_MAX, "%s/%s", path, parent.name); snprintf(temp, FN_REFLEN, "%s/%s", path, parent.name);
remove(temp); remove(temp);
} }
}while (_findnext(handle,&parent) == 0); }while (_findnext(handle,&parent) == 0);
...@@ -749,14 +764,14 @@ int removef(const char *format, ...) ...@@ -749,14 +764,14 @@ int removef(const char *format, ...)
#else #else
DIR *parent; DIR *parent;
struct dirent *entry; struct dirent *entry;
char temp[PATH_MAX]; char temp[FN_REFLEN];
va_list ap; va_list ap;
char path[PATH_MAX]; char path[FN_REFLEN];
char *p; char *p;
/* Get path with mask */ /* Get path with mask */
va_start(ap, format); va_start(ap, format);
vsnprintf(path, PATH_MAX, format, ap); vsnprintf(path, FN_REFLEN, format, ap);
va_end(ap); va_end(ap);
...@@ -775,10 +790,21 @@ int removef(const char *format, ...) ...@@ -775,10 +790,21 @@ int removef(const char *format, ...)
while ((entry= readdir(parent)) != NULL) while ((entry= readdir(parent)) != NULL)
{ {
/* entry is not directory and entry matches with mask */ /* entry is not directory and entry matches with mask */
#ifndef STRUCT_DIRENT_HAS_D_TYPE
struct stat st;
if (lstat(entry->d_name, &st) == -1)
{
return 1;
}
if (!S_ISDIR(st.st_mode) && !fnmatch(p, entry->d_name,0))
#else
if (!S_ISDIR(entry->d_type) && !fnmatch(p, entry->d_name,0)) if (!S_ISDIR(entry->d_type) && !fnmatch(p, entry->d_name,0))
#endif
{ {
/* create long name */ /* create long name */
snprintf(temp, PATH_MAX, "%s/%s", path, entry->d_name); snprintf(temp, FN_REFLEN, "%s/%s", path, entry->d_name);
/* Delete only files */ /* Delete only files */
remove(temp); remove(temp);
} }
...@@ -795,7 +821,7 @@ int removef(const char *format, ...) ...@@ -795,7 +821,7 @@ int removef(const char *format, ...)
void get_basedir(char *argv0, char *basedir) void get_basedir(char *argv0, char *basedir)
{ {
char temp[PATH_MAX]; char temp[FN_REFLEN];
char *p; char *p;
int position; int position;
......
...@@ -52,8 +52,6 @@ int my_vsnprintf_(char *to, size_t n, const char* value, ...); ...@@ -52,8 +52,6 @@ int my_vsnprintf_(char *to, size_t n, const char* value, ...);
#define TRY_MAX 5 #define TRY_MAX 5
#ifdef __WIN__ #ifdef __WIN__
#define PATH_MAX _MAX_PATH
#define NAME_MAX _MAX_FNAME
#define kill(A,B) TerminateProcess((HANDLE)A,0) #define kill(A,B) TerminateProcess((HANDLE)A,0)
#define NOT_NEED_PID 0 #define NOT_NEED_PID 0
#define MASTER_PID 1 #define MASTER_PID 1
......
...@@ -73,25 +73,25 @@ const char *TEST_IGNORE= "[ignore]"; ...@@ -73,25 +73,25 @@ const char *TEST_IGNORE= "[ignore]";
******************************************************************************/ ******************************************************************************/
#ifdef __NETWARE__ #ifdef __NETWARE__
static char base_dir[PATH_MAX]= "sys:/mysql"; static char base_dir[FN_REFLEN]= "sys:/mysql";
#else #else
static char base_dir[PATH_MAX]= ".."; static char base_dir[FN_REFLEN]= "..";
#endif #endif
static char db[PATH_MAX]= "test"; static char db[FN_LEN]= "test";
static char user[PATH_MAX]= "root"; static char user[FN_LEN]= "root";
static char password[PATH_MAX]= ""; static char password[FN_LEN]= "";
int master_port= 9306; int master_port= 9306;
int slave_port= 9307; int slave_port= 9307;
#if !defined(__NETWARE__) && !defined(__WIN__) #if !defined(__NETWARE__) && !defined(__WIN__)
static char master_socket[PATH_MAX]= "./var/tmp/master.sock"; static char master_socket[FN_REFLEN]= "./var/tmp/master.sock";
static char slave_socket[PATH_MAX]= "./var/tmp/slave.sock"; static char slave_socket[FN_REFLEN]= "./var/tmp/slave.sock";
#endif #endif
/* comma delimited list of tests to skip or empty string */ /* comma delimited list of tests to skip or empty string */
#ifndef __WIN__ #ifndef __WIN__
static char skip_test[PATH_MAX]= " lowercase_table3 , system_mysql_db_fix "; static char skip_test[FN_REFLEN]= " lowercase_table3 , system_mysql_db_fix ";
#else #else
/* /*
The most ignore testes contain the calls of system command The most ignore testes contain the calls of system command
...@@ -110,7 +110,7 @@ static char skip_test[PATH_MAX]= " lowercase_table3 , system_mysql_db_fix "; ...@@ -110,7 +110,7 @@ static char skip_test[PATH_MAX]= " lowercase_table3 , system_mysql_db_fix ";
mysqldump contains a command system mysqldump contains a command system
rpl000001 makes non-exit loop...temporary skiped rpl000001 makes non-exit loop...temporary skiped
*/ */
static char skip_test[PATH_MAX]= static char skip_test[FN_REFLEN]=
" lowercase_table3 ," " lowercase_table3 ,"
" system_mysql_db_fix ," " system_mysql_db_fix ,"
" sp ," " sp ,"
...@@ -123,44 +123,44 @@ static char skip_test[PATH_MAX]= ...@@ -123,44 +123,44 @@ static char skip_test[PATH_MAX]=
" mysqldump ," " mysqldump ,"
" rpl000001 "; " rpl000001 ";
#endif #endif
static char ignore_test[PATH_MAX]= ""; static char ignore_test[FN_REFLEN]= "";
static char bin_dir[PATH_MAX]; static char bin_dir[FN_REFLEN];
static char mysql_test_dir[PATH_MAX]; static char mysql_test_dir[FN_REFLEN];
static char test_dir[PATH_MAX]; static char test_dir[FN_REFLEN];
static char mysql_tmp_dir[PATH_MAX]; static char mysql_tmp_dir[FN_REFLEN];
static char result_dir[PATH_MAX]; static char result_dir[FN_REFLEN];
static char master_dir[PATH_MAX]; static char master_dir[FN_REFLEN];
static char slave_dir[PATH_MAX]; static char slave_dir[FN_REFLEN];
static char lang_dir[PATH_MAX]; static char lang_dir[FN_REFLEN];
static char char_dir[PATH_MAX]; static char char_dir[FN_REFLEN];
static char mysqladmin_file[PATH_MAX]; static char mysqladmin_file[FN_REFLEN];
static char mysqld_file[PATH_MAX]; static char mysqld_file[FN_REFLEN];
static char mysqltest_file[PATH_MAX]; static char mysqltest_file[FN_REFLEN];
#ifndef __WIN__ #ifndef __WIN__
static char master_pid[PATH_MAX]; static char master_pid[FN_REFLEN];
static char slave_pid[PATH_MAX]; static char slave_pid[FN_REFLEN];
static char sh_file[PATH_MAX]= "/bin/sh"; static char sh_file[FN_REFLEN]= "/bin/sh";
#else #else
static HANDLE master_pid; static HANDLE master_pid;
static HANDLE slave_pid; static HANDLE slave_pid;
#endif #endif
static char master_opt[PATH_MAX]= ""; static char master_opt[FN_REFLEN]= "";
static char slave_opt[PATH_MAX]= ""; static char slave_opt[FN_REFLEN]= "";
static char slave_master_info[PATH_MAX]= ""; static char slave_master_info[FN_REFLEN]= "";
static char master_init_script[PATH_MAX]= ""; static char master_init_script[FN_REFLEN]= "";
static char slave_init_script[PATH_MAX]= ""; static char slave_init_script[FN_REFLEN]= "";
/* OpenSSL */ /* OpenSSL */
static char ca_cert[PATH_MAX]; static char ca_cert[FN_REFLEN];
static char server_cert[PATH_MAX]; static char server_cert[FN_REFLEN];
static char server_key[PATH_MAX]; static char server_key[FN_REFLEN];
static char client_cert[PATH_MAX]; static char client_cert[FN_REFLEN];
static char client_key[PATH_MAX]; static char client_key[FN_REFLEN];
int total_skip= 0; int total_skip= 0;
int total_pass= 0; int total_pass= 0;
...@@ -254,18 +254,18 @@ void install_db(char *datadir) ...@@ -254,18 +254,18 @@ void install_db(char *datadir)
{ {
arg_list_t al; arg_list_t al;
int err; int err;
char input[PATH_MAX]; char input[FN_REFLEN];
char output[PATH_MAX]; char output[FN_REFLEN];
char error[PATH_MAX]; char error[FN_REFLEN];
/* input file */ /* input file */
#ifdef __NETWARE__ #ifdef __NETWARE__
snprintf(input, PATH_MAX, "%s/bin/init_db.sql", base_dir); snprintf(input, FN_REFLEN, "%s/bin/init_db.sql", base_dir);
#else #else
snprintf(input, PATH_MAX, "%s/mysql-test/init_db.sql", base_dir); snprintf(input, FN_REFLEN, "%s/mysql-test/init_db.sql", base_dir);
#endif #endif
snprintf(output, PATH_MAX, "%s/install.out", datadir); snprintf(output, FN_REFLEN, "%s/install.out", datadir);
snprintf(error, PATH_MAX, "%s/install.err", datadir); snprintf(error, FN_REFLEN, "%s/install.err", datadir);
/* args */ /* args */
init_args(&al); init_args(&al);
...@@ -302,10 +302,10 @@ void install_db(char *datadir) ...@@ -302,10 +302,10 @@ void install_db(char *datadir)
void mysql_install_db() void mysql_install_db()
{ {
char temp[PATH_MAX]; char temp[FN_REFLEN];
/* var directory */ /* var directory */
snprintf(temp, PATH_MAX, "%s/var", mysql_test_dir); snprintf(temp, FN_REFLEN, "%s/var", mysql_test_dir);
/* clean up old direcotry */ /* clean up old direcotry */
del_tree(temp); del_tree(temp);
...@@ -315,41 +315,41 @@ void mysql_install_db() ...@@ -315,41 +315,41 @@ void mysql_install_db()
mkdir(temp, S_IRWXU); mkdir(temp, S_IRWXU);
/* create subdirectories */ /* create subdirectories */
mlog("Creating test-suite folders...\n"); mlog("Creating test-suite folders...\n");
snprintf(temp, PATH_MAX, "%s/var/run", mysql_test_dir); snprintf(temp, FN_REFLEN, "%s/var/run", mysql_test_dir);
mkdir(temp, S_IRWXU); mkdir(temp, S_IRWXU);
snprintf(temp, PATH_MAX, "%s/var/tmp", mysql_test_dir); snprintf(temp, FN_REFLEN, "%s/var/tmp", mysql_test_dir);
mkdir(temp, S_IRWXU); mkdir(temp, S_IRWXU);
snprintf(temp, PATH_MAX, "%s/var/master-data", mysql_test_dir); snprintf(temp, FN_REFLEN, "%s/var/master-data", mysql_test_dir);
mkdir(temp, S_IRWXU); mkdir(temp, S_IRWXU);
snprintf(temp, PATH_MAX, "%s/var/master-data/mysql", mysql_test_dir); snprintf(temp, FN_REFLEN, "%s/var/master-data/mysql", mysql_test_dir);
mkdir(temp, S_IRWXU); mkdir(temp, S_IRWXU);
snprintf(temp, PATH_MAX, "%s/var/master-data/test", mysql_test_dir); snprintf(temp, FN_REFLEN, "%s/var/master-data/test", mysql_test_dir);
mkdir(temp, S_IRWXU); mkdir(temp, S_IRWXU);
snprintf(temp, PATH_MAX, "%s/var/slave-data", mysql_test_dir); snprintf(temp, FN_REFLEN, "%s/var/slave-data", mysql_test_dir);
mkdir(temp, S_IRWXU); mkdir(temp, S_IRWXU);
snprintf(temp, PATH_MAX, "%s/var/slave-data/mysql", mysql_test_dir); snprintf(temp, FN_REFLEN, "%s/var/slave-data/mysql", mysql_test_dir);
mkdir(temp, S_IRWXU); mkdir(temp, S_IRWXU);
snprintf(temp, PATH_MAX, "%s/var/slave-data/test", mysql_test_dir); snprintf(temp, FN_REFLEN, "%s/var/slave-data/test", mysql_test_dir);
mkdir(temp, S_IRWXU); mkdir(temp, S_IRWXU);
#else #else
mkdir(temp); mkdir(temp);
/* create subdirectories */ /* create subdirectories */
mlog("Creating test-suite folders...\n"); mlog("Creating test-suite folders...\n");
snprintf(temp, PATH_MAX, "%s/var/run", mysql_test_dir); snprintf(temp, FN_REFLEN, "%s/var/run", mysql_test_dir);
mkdir(temp); mkdir(temp);
snprintf(temp, PATH_MAX, "%s/var/tmp", mysql_test_dir); snprintf(temp, FN_REFLEN, "%s/var/tmp", mysql_test_dir);
mkdir(temp); mkdir(temp);
snprintf(temp, PATH_MAX, "%s/var/master-data", mysql_test_dir); snprintf(temp, FN_REFLEN, "%s/var/master-data", mysql_test_dir);
mkdir(temp); mkdir(temp);
snprintf(temp, PATH_MAX, "%s/var/master-data/mysql", mysql_test_dir); snprintf(temp, FN_REFLEN, "%s/var/master-data/mysql", mysql_test_dir);
mkdir(temp); mkdir(temp);
snprintf(temp, PATH_MAX, "%s/var/master-data/test", mysql_test_dir); snprintf(temp, FN_REFLEN, "%s/var/master-data/test", mysql_test_dir);
mkdir(temp); mkdir(temp);
snprintf(temp, PATH_MAX, "%s/var/slave-data", mysql_test_dir); snprintf(temp, FN_REFLEN, "%s/var/slave-data", mysql_test_dir);
mkdir(temp); mkdir(temp);
snprintf(temp, PATH_MAX, "%s/var/slave-data/mysql", mysql_test_dir); snprintf(temp, FN_REFLEN, "%s/var/slave-data/mysql", mysql_test_dir);
mkdir(temp); mkdir(temp);
snprintf(temp, PATH_MAX, "%s/var/slave-data/test", mysql_test_dir); snprintf(temp, FN_REFLEN, "%s/var/slave-data/test", mysql_test_dir);
mkdir(temp); mkdir(temp);
#endif #endif
...@@ -372,10 +372,10 @@ void start_master() ...@@ -372,10 +372,10 @@ void start_master()
{ {
arg_list_t al; arg_list_t al;
int err; int err;
char master_out[PATH_MAX]; char master_out[FN_REFLEN];
char master_err[PATH_MAX]; char master_err[FN_REFLEN];
/* char temp[PATH_MAX]; */ /* char temp[FN_REFLEN]; */
char temp2[PATH_MAX]; char temp2[FN_REFLEN];
/* 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);
...@@ -405,7 +405,7 @@ void start_master() ...@@ -405,7 +405,7 @@ void start_master()
FILE *fp; FILE *fp;
/* create an empty index file */ /* create an empty index file */
snprintf(temp, PATH_MAX, "%s/test/t1.MYI", master_dir); snprintf(temp, FN_REFLEN, "%s/test/t1.MYI", master_dir);
fp= fopen(temp, "wb+"); fp= fopen(temp, "wb+");
fputs("1", fp); fputs("1", fp);
...@@ -418,19 +418,19 @@ void start_master() ...@@ -418,19 +418,19 @@ void start_master()
} }
/* redirection files */ /* redirection files */
snprintf(master_out, PATH_MAX, "%s/var/run/master%u.out", snprintf(master_out, FN_REFLEN, "%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", snprintf(master_err, FN_REFLEN, "%s/var/run/master%u.err",
mysql_test_dir, restarts); mysql_test_dir, restarts);
#ifndef __WIN__ #ifndef __WIN__
snprintf(temp2,PATH_MAX,"%s/var",mysql_test_dir); snprintf(temp2,FN_REFLEN,"%s/var",mysql_test_dir);
mkdir(temp2,S_IRWXU); mkdir(temp2,S_IRWXU);
snprintf(temp2,PATH_MAX,"%s/var/log",mysql_test_dir); snprintf(temp2,FN_REFLEN,"%s/var/log",mysql_test_dir);
mkdir(temp2,S_IRWXU); mkdir(temp2,S_IRWXU);
#else #else
snprintf(temp2,PATH_MAX,"%s/var",mysql_test_dir); snprintf(temp2,FN_REFLEN,"%s/var",mysql_test_dir);
mkdir(temp2); mkdir(temp2);
snprintf(temp2,PATH_MAX,"%s/var/log",mysql_test_dir); snprintf(temp2,FN_REFLEN,"%s/var/log",mysql_test_dir);
mkdir(temp2); mkdir(temp2);
#endif #endif
/* args */ /* args */
...@@ -539,8 +539,8 @@ void start_slave() ...@@ -539,8 +539,8 @@ void start_slave()
{ {
arg_list_t al; arg_list_t al;
int err; int err;
char slave_out[PATH_MAX]; char slave_out[FN_REFLEN];
char slave_err[PATH_MAX]; char slave_err[FN_REFLEN];
/* skip? */ /* skip? */
if (skip_slave) return; if (skip_slave) return;
...@@ -568,7 +568,7 @@ void start_slave() ...@@ -568,7 +568,7 @@ void start_slave()
if (strinstr(slave_init_script, "rpl000016-slave.sh") != 0) if (strinstr(slave_init_script, "rpl000016-slave.sh") != 0)
{ {
/* create empty master.info file */ /* create empty master.info file */
snprintf(temp, PATH_MAX, "%s/master.info", slave_dir); snprintf(temp, FN_REFLEN, "%s/master.info", slave_dir);
close(open(temp, O_WRONLY | O_CREAT,S_IRWXU|S_IRWXG|S_IRWXO)); close(open(temp, O_WRONLY | O_CREAT,S_IRWXU|S_IRWXG|S_IRWXO));
} }
else if (strinstr(slave_init_script, "rpl000017-slave.sh") != 0) else if (strinstr(slave_init_script, "rpl000017-slave.sh") != 0)
...@@ -576,7 +576,7 @@ void start_slave() ...@@ -576,7 +576,7 @@ void start_slave()
FILE *fp; FILE *fp;
/* create a master.info file */ /* create a master.info file */
snprintf(temp, PATH_MAX, "%s/master.info", slave_dir); snprintf(temp, FN_REFLEN, "%s/master.info", slave_dir);
fp= fopen(temp, "wb+"); fp= fopen(temp, "wb+");
fputs("master-bin.000001\n", fp); fputs("master-bin.000001\n", fp);
...@@ -593,7 +593,7 @@ void start_slave() ...@@ -593,7 +593,7 @@ void start_slave()
else if (strinstr(slave_init_script, "rpl_rotate_logs-slave.sh") != 0) else if (strinstr(slave_init_script, "rpl_rotate_logs-slave.sh") != 0)
{ {
/* create empty master.info file */ /* create empty master.info file */
snprintf(temp, PATH_MAX, "%s/master.info", slave_dir); snprintf(temp, FN_REFLEN, "%s/master.info", slave_dir);
close(open(temp, O_WRONLY | O_CREAT,S_IRWXU|S_IRWXG|S_IRWXO)); close(open(temp, O_WRONLY | O_CREAT,S_IRWXU|S_IRWXG|S_IRWXO));
} }
#elif !defined(__WIN__) #elif !defined(__WIN__)
...@@ -602,9 +602,9 @@ void start_slave() ...@@ -602,9 +602,9 @@ void start_slave()
} }
/* redirection files */ /* redirection files */
snprintf(slave_out, PATH_MAX, "%s/var/run/slave%u.out", snprintf(slave_out, FN_REFLEN, "%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", snprintf(slave_err, FN_REFLEN, "%s/var/run/slave%u.err",
mysql_test_dir, restarts); mysql_test_dir, restarts);
/* args */ /* args */
...@@ -859,14 +859,14 @@ int read_option(char *opt_file, char *opt) ...@@ -859,14 +859,14 @@ int read_option(char *opt_file, char *opt)
{ {
int fd, err; int fd, err;
char *p; char *p;
char buf[PATH_MAX]; char buf[FN_REFLEN];
/* copy current option */ /* copy current option */
strncpy(buf, opt, PATH_MAX); strncpy(buf, opt, FN_REFLEN);
/* open options file */ /* open options file */
fd= open(opt_file, O_RDONLY); fd= open(opt_file, O_RDONLY);
err= read(fd, opt, PATH_MAX); err= read(fd, opt, FN_REFLEN);
close(fd); close(fd);
if (err > 0) if (err > 0)
...@@ -890,7 +890,7 @@ int read_option(char *opt_file, char *opt) ...@@ -890,7 +890,7 @@ int read_option(char *opt_file, char *opt)
/* check for $MYSQL_TEST_DIR */ /* check for $MYSQL_TEST_DIR */
if ((p= strstr(opt, "$MYSQL_TEST_DIR")) != NULL) if ((p= strstr(opt, "$MYSQL_TEST_DIR")) != NULL)
{ {
char temp[PATH_MAX]; char temp[FN_REFLEN];
*p= 0; *p= 0;
...@@ -925,7 +925,7 @@ int read_option(char *opt_file, char *opt) ...@@ -925,7 +925,7 @@ int read_option(char *opt_file, char *opt)
void run_test(char *test) void run_test(char *test)
{ {
char temp[PATH_MAX]; char temp[FN_REFLEN];
const char *rstr; const char *rstr;
int skip= FALSE, ignore=FALSE; int skip= FALSE, ignore=FALSE;
int restart= FALSE; int restart= FALSE;
...@@ -933,13 +933,13 @@ void run_test(char *test) ...@@ -933,13 +933,13 @@ void run_test(char *test)
struct stat info; struct stat info;
/* skip tests in the skip list */ /* skip tests in the skip list */
snprintf(temp, PATH_MAX, " %s ", test); snprintf(temp, FN_REFLEN, " %s ", test);
skip= (strinstr(skip_test, temp) != 0); skip= (strinstr(skip_test, temp) != 0);
if (skip == FALSE) if (skip == FALSE)
ignore= (strinstr(ignore_test, temp) != 0); ignore= (strinstr(ignore_test, temp) != 0);
snprintf(master_init_script, PATH_MAX, "%s/%s-master.sh", test_dir, test); snprintf(master_init_script, FN_REFLEN, "%s/%s-master.sh", test_dir, test);
snprintf(slave_init_script, PATH_MAX, "%s/%s-slave.sh", test_dir, test); snprintf(slave_init_script, FN_REFLEN, "%s/%s-slave.sh", test_dir, test);
#ifdef __WIN__ #ifdef __WIN__
if (! stat(master_init_script, &info)) if (! stat(master_init_script, &info))
skip= TRUE; skip= TRUE;
...@@ -957,14 +957,14 @@ void run_test(char *test) ...@@ -957,14 +957,14 @@ void run_test(char *test)
} }
else if (!skip) /* skip test? */ else if (!skip) /* skip test? */
{ {
char test_file[PATH_MAX]; char test_file[FN_REFLEN];
char master_opt_file[PATH_MAX]; char master_opt_file[FN_REFLEN];
char slave_opt_file[PATH_MAX]; char slave_opt_file[FN_REFLEN];
char slave_master_info_file[PATH_MAX]; char slave_master_info_file[FN_REFLEN];
char result_file[PATH_MAX]; char result_file[FN_REFLEN];
char reject_file[PATH_MAX]; char reject_file[FN_REFLEN];
char out_file[PATH_MAX]; char out_file[FN_REFLEN];
char err_file[PATH_MAX]; char err_file[FN_REFLEN];
int err; int err;
arg_list_t al; arg_list_t al;
#ifdef __WIN__ #ifdef __WIN__
...@@ -981,20 +981,20 @@ void run_test(char *test) ...@@ -981,20 +981,20 @@ 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); snprintf(master_opt_file, FN_REFLEN, "%s/%s-master.opt", test_dir, test);
snprintf(slave_opt_file, PATH_MAX, "%s/%s-slave.opt", test_dir, test); snprintf(slave_opt_file, FN_REFLEN, "%s/%s-slave.opt", test_dir, test);
snprintf(slave_master_info_file, PATH_MAX, "%s/%s.slave-mi", snprintf(slave_master_info_file, FN_REFLEN, "%s/%s.slave-mi",
test_dir, test); test_dir, test);
snprintf(reject_file, PATH_MAX, "%s/%s%s", snprintf(reject_file, FN_REFLEN, "%s/%s%s",
result_dir, test, REJECT_SUFFIX); result_dir, test, REJECT_SUFFIX);
snprintf(out_file, PATH_MAX, "%s/%s%s", result_dir, test, OUT_SUFFIX); snprintf(out_file, FN_REFLEN, "%s/%s%s", result_dir, test, OUT_SUFFIX);
snprintf(err_file, PATH_MAX, "%s/%s%s", result_dir, test, ERR_SUFFIX); snprintf(err_file, FN_REFLEN, "%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); snprintf(test_file, FN_REFLEN, "%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); snprintf(test_file, FN_REFLEN, "%s/%s%s", test_dir, test, TEST_SUFFIX);
if (access(test_file,0)) if (access(test_file,0))
{ {
printf("Invalid test name %s, %s file not found\n",test,test_file); printf("Invalid test name %s, %s file not found\n",test,test_file);
...@@ -1002,11 +1002,11 @@ void run_test(char *test) ...@@ -1002,11 +1002,11 @@ void run_test(char *test)
} }
} }
snprintf(result_file, PATH_MAX, "%s/%s%s", snprintf(result_file, FN_REFLEN, "%s/%s%s",
result_dir, test, NW_RESULT_SUFFIX); result_dir, test, NW_RESULT_SUFFIX);
if (stat(result_file, &info)) if (stat(result_file, &info))
{ {
snprintf(result_file, PATH_MAX, "%s/%s%s", snprintf(result_file, FN_REFLEN, "%s/%s%s",
result_dir, test, RESULT_SUFFIX); result_dir, test, RESULT_SUFFIX);
} }
...@@ -1248,8 +1248,8 @@ void die(const char *msg) ...@@ -1248,8 +1248,8 @@ void die(const char *msg)
void setup(char *file __attribute__((unused))) void setup(char *file __attribute__((unused)))
{ {
char temp[PATH_MAX]; char temp[FN_REFLEN];
char file_path[PATH_MAX*2]; char file_path[FN_REFLEN*2];
char *p; char *p;
int position; int position;
...@@ -1257,14 +1257,14 @@ void setup(char *file __attribute__((unused))) ...@@ -1257,14 +1257,14 @@ void setup(char *file __attribute__((unused)))
#ifdef __WIN__ #ifdef __WIN__
_putenv( "TZ=GMT-3" ); _putenv( "TZ=GMT-3" );
#else #else
setenv("TZ", "GMT-3", TRUE); putenv((char *)"TZ=GMT-3");
#endif #endif
/* find base dir */ /* find base dir */
#ifdef __NETWARE__ #ifdef __NETWARE__
strcpy(temp, strlwr(file)); strcpy(temp, strlwr(file));
while ((p= strchr(temp, '\\')) != NULL) *p= '/'; while ((p= strchr(temp, '\\')) != NULL) *p= '/';
#else #else
getcwd(temp, PATH_MAX); getcwd(temp, FN_REFLEN);
position= strlen(temp); position= strlen(temp);
temp[position]= '/'; temp[position]= '/';
temp[position+1]= 0; temp[position+1]= 0;
...@@ -1284,100 +1284,100 @@ void setup(char *file __attribute__((unused))) ...@@ -1284,100 +1284,100 @@ void setup(char *file __attribute__((unused)))
#ifdef __NETWARE__ #ifdef __NETWARE__
/* setup paths */ /* setup paths */
snprintf(bin_dir, PATH_MAX, "%s/bin", base_dir); snprintf(bin_dir, FN_REFLEN, "%s/bin", base_dir);
snprintf(mysql_test_dir, PATH_MAX, "%s/mysql-test", base_dir); snprintf(mysql_test_dir, FN_REFLEN, "%s/mysql-test", base_dir);
snprintf(test_dir, PATH_MAX, "%s/t", mysql_test_dir); snprintf(test_dir, FN_REFLEN, "%s/t", mysql_test_dir);
snprintf(mysql_tmp_dir, PATH_MAX, "%s/var/tmp", mysql_test_dir); snprintf(mysql_tmp_dir, FN_REFLEN, "%s/var/tmp", mysql_test_dir);
snprintf(result_dir, PATH_MAX, "%s/r", mysql_test_dir); snprintf(result_dir, FN_REFLEN, "%s/r", mysql_test_dir);
snprintf(master_dir, PATH_MAX, "%s/var/master-data", mysql_test_dir); snprintf(master_dir, FN_REFLEN, "%s/var/master-data", mysql_test_dir);
snprintf(slave_dir, PATH_MAX, "%s/var/slave-data", mysql_test_dir); snprintf(slave_dir, FN_REFLEN, "%s/var/slave-data", mysql_test_dir);
snprintf(lang_dir, PATH_MAX, "%s/share/english", base_dir); snprintf(lang_dir, FN_REFLEN, "%s/share/english", base_dir);
snprintf(char_dir, PATH_MAX, "%s/share/charsets", base_dir); snprintf(char_dir, FN_REFLEN, "%s/share/charsets", base_dir);
#ifdef HAVE_OPENSSL #ifdef HAVE_OPENSSL
use_openssl= TRUE; use_openssl= TRUE;
#endif /* HAVE_OPENSSL */ #endif /* HAVE_OPENSSL */
/* OpenSSL paths */ /* OpenSSL paths */
snprintf(ca_cert, PATH_MAX, "%s/SSL/cacert.pem", base_dir); snprintf(ca_cert, FN_REFLEN, "%s/SSL/cacert.pem", base_dir);
snprintf(server_cert, PATH_MAX, "%s/SSL/server-cert.pem", base_dir); snprintf(server_cert, FN_REFLEN, "%s/SSL/server-cert.pem", base_dir);
snprintf(server_key, PATH_MAX, "%s/SSL/server-key.pem", base_dir); snprintf(server_key, FN_REFLEN, "%s/SSL/server-key.pem", base_dir);
snprintf(client_cert, PATH_MAX, "%s/SSL/client-cert.pem", base_dir); snprintf(client_cert, FN_REFLEN, "%s/SSL/client-cert.pem", base_dir);
snprintf(client_key, PATH_MAX, "%s/SSL/client-key.pem", base_dir); snprintf(client_key, FN_REFLEN, "%s/SSL/client-key.pem", base_dir);
/* setup files */ /* setup files */
snprintf(mysqld_file, PATH_MAX, "%s/mysqld", bin_dir); snprintf(mysqld_file, FN_REFLEN, "%s/mysqld", bin_dir);
snprintf(mysqltest_file, PATH_MAX, "%s/mysqltest", bin_dir); snprintf(mysqltest_file, FN_REFLEN, "%s/mysqltest", bin_dir);
snprintf(mysqladmin_file, PATH_MAX, "%s/mysqladmin", bin_dir); snprintf(mysqladmin_file, FN_REFLEN, "%s/mysqladmin", bin_dir);
snprintf(master_pid, PATH_MAX, "%s/var/run/master.pid", mysql_test_dir); snprintf(master_pid, FN_REFLEN, "%s/var/run/master.pid", mysql_test_dir);
snprintf(slave_pid, PATH_MAX, "%s/var/run/slave.pid", mysql_test_dir); snprintf(slave_pid, FN_REFLEN, "%s/var/run/slave.pid", mysql_test_dir);
#elif __WIN__ #elif __WIN__
/* setup paths */ /* setup paths */
#ifdef _DEBUG #ifdef _DEBUG
snprintf(bin_dir, PATH_MAX, "%s/client_debug", base_dir); snprintf(bin_dir, FN_REFLEN, "%s/client_debug", base_dir);
#else #else
snprintf(bin_dir, PATH_MAX, "%s/client_release", base_dir); snprintf(bin_dir, FN_REFLEN, "%s/client_release", base_dir);
#endif #endif
snprintf(mysql_test_dir, PATH_MAX, "%s/mysql-test", base_dir); snprintf(mysql_test_dir, FN_REFLEN, "%s/mysql-test", base_dir);
snprintf(test_dir, PATH_MAX, "%s/t", mysql_test_dir); snprintf(test_dir, FN_REFLEN, "%s/t", mysql_test_dir);
snprintf(mysql_tmp_dir, PATH_MAX, "%s/var/tmp", mysql_test_dir); snprintf(mysql_tmp_dir, FN_REFLEN, "%s/var/tmp", mysql_test_dir);
snprintf(result_dir, PATH_MAX, "%s/r", mysql_test_dir); snprintf(result_dir, FN_REFLEN, "%s/r", mysql_test_dir);
snprintf(master_dir, PATH_MAX, "%s/var/master-data", mysql_test_dir); snprintf(master_dir, FN_REFLEN, "%s/var/master-data", mysql_test_dir);
snprintf(slave_dir, PATH_MAX, "%s/var/slave-data", mysql_test_dir); snprintf(slave_dir, FN_REFLEN, "%s/var/slave-data", mysql_test_dir);
snprintf(lang_dir, PATH_MAX, "%s/share/english", base_dir); snprintf(lang_dir, FN_REFLEN, "%s/share/english", base_dir);
snprintf(char_dir, PATH_MAX, "%s/share/charsets", base_dir); snprintf(char_dir, FN_REFLEN, "%s/share/charsets", base_dir);
#ifdef HAVE_OPENSSL #ifdef HAVE_OPENSSL
use_openssl= TRUE; use_openssl= TRUE;
#endif /* HAVE_OPENSSL */ #endif /* HAVE_OPENSSL */
/* OpenSSL paths */ /* OpenSSL paths */
snprintf(ca_cert, PATH_MAX, "%s/SSL/cacert.pem", base_dir); snprintf(ca_cert, FN_REFLEN, "%s/SSL/cacert.pem", base_dir);
snprintf(server_cert, PATH_MAX, "%s/SSL/server-cert.pem", base_dir); snprintf(server_cert, FN_REFLEN, "%s/SSL/server-cert.pem", base_dir);
snprintf(server_key, PATH_MAX, "%s/SSL/server-key.pem", base_dir); snprintf(server_key, FN_REFLEN, "%s/SSL/server-key.pem", base_dir);
snprintf(client_cert, PATH_MAX, "%s/SSL/client-cert.pem", base_dir); snprintf(client_cert, FN_REFLEN, "%s/SSL/client-cert.pem", base_dir);
snprintf(client_key, PATH_MAX, "%s/SSL/client-key.pem", base_dir); snprintf(client_key, FN_REFLEN, "%s/SSL/client-key.pem", base_dir);
/* setup files */ /* setup files */
snprintf(mysqld_file, PATH_MAX, "%s/mysqld.exe", bin_dir); snprintf(mysqld_file, FN_REFLEN, "%s/mysqld.exe", bin_dir);
snprintf(mysqltest_file, PATH_MAX, "%s/mysqltest.exe", bin_dir); snprintf(mysqltest_file, FN_REFLEN, "%s/mysqltest.exe", bin_dir);
snprintf(mysqladmin_file, PATH_MAX, "%s/mysqladmin.exe", bin_dir); snprintf(mysqladmin_file, FN_REFLEN, "%s/mysqladmin.exe", bin_dir);
#else #else
/* setup paths */ /* setup paths */
snprintf(bin_dir, PATH_MAX, "%s/client", base_dir); snprintf(bin_dir, FN_REFLEN, "%s/client", base_dir);
snprintf(mysql_test_dir, PATH_MAX, "%s/mysql-test", base_dir); snprintf(mysql_test_dir, FN_REFLEN, "%s/mysql-test", base_dir);
snprintf(test_dir, PATH_MAX, "%s/t", mysql_test_dir); snprintf(test_dir, FN_REFLEN, "%s/t", mysql_test_dir);
snprintf(mysql_tmp_dir, PATH_MAX, "%s/var/tmp", mysql_test_dir); snprintf(mysql_tmp_dir, FN_REFLEN, "%s/var/tmp", mysql_test_dir);
snprintf(result_dir, PATH_MAX, "%s/r", mysql_test_dir); snprintf(result_dir, FN_REFLEN, "%s/r", mysql_test_dir);
snprintf(master_dir, PATH_MAX, "%s/var/master-data", mysql_test_dir); snprintf(master_dir, FN_REFLEN, "%s/var/master-data", mysql_test_dir);
snprintf(slave_dir, PATH_MAX, "%s/var/slave-data", mysql_test_dir); snprintf(slave_dir, FN_REFLEN, "%s/var/slave-data", mysql_test_dir);
snprintf(lang_dir, PATH_MAX, "%s/sql/share/english", base_dir); snprintf(lang_dir, FN_REFLEN, "%s/sql/share/english", base_dir);
snprintf(char_dir, PATH_MAX, "%s/sql/share/charsets", base_dir); snprintf(char_dir, FN_REFLEN, "%s/sql/share/charsets", base_dir);
#ifdef HAVE_OPENSSL #ifdef HAVE_OPENSSL
use_openssl= TRUE; use_openssl= TRUE;
#endif /* HAVE_OPENSSL */ #endif /* HAVE_OPENSSL */
/* OpenSSL paths */ /* OpenSSL paths */
snprintf(ca_cert, PATH_MAX, "%s/SSL/cacert.pem", base_dir); snprintf(ca_cert, FN_REFLEN, "%s/SSL/cacert.pem", base_dir);
snprintf(server_cert, PATH_MAX, "%s/SSL/server-cert.pem", base_dir); snprintf(server_cert, FN_REFLEN, "%s/SSL/server-cert.pem", base_dir);
snprintf(server_key, PATH_MAX, "%s/SSL/server-key.pem", base_dir); snprintf(server_key, FN_REFLEN, "%s/SSL/server-key.pem", base_dir);
snprintf(client_cert, PATH_MAX, "%s/SSL/client-cert.pem", base_dir); snprintf(client_cert, FN_REFLEN, "%s/SSL/client-cert.pem", base_dir);
snprintf(client_key, PATH_MAX, "%s/SSL/client-key.pem", base_dir); snprintf(client_key, FN_REFLEN, "%s/SSL/client-key.pem", base_dir);
/* setup files */ /* setup files */
snprintf(mysqld_file, PATH_MAX, "%s/sql/mysqld", base_dir); snprintf(mysqld_file, FN_REFLEN, "%s/sql/mysqld", base_dir);
snprintf(mysqltest_file, PATH_MAX, "%s/mysqltest", bin_dir); snprintf(mysqltest_file, FN_REFLEN, "%s/mysqltest", bin_dir);
snprintf(mysqladmin_file, PATH_MAX, "%s/mysqladmin", bin_dir); snprintf(mysqladmin_file, FN_REFLEN, "%s/mysqladmin", bin_dir);
snprintf(master_pid, PATH_MAX, "%s/var/run/master.pid", mysql_test_dir); snprintf(master_pid, FN_REFLEN, "%s/var/run/master.pid", mysql_test_dir);
snprintf(slave_pid, PATH_MAX, "%s/var/run/slave.pid", mysql_test_dir); snprintf(slave_pid, FN_REFLEN, "%s/var/run/slave.pid", mysql_test_dir);
snprintf(master_socket,PATH_MAX, "%s/var/tmp/master.sock", mysql_test_dir); snprintf(master_socket,FN_REFLEN, "%s/var/tmp/master.sock", mysql_test_dir);
snprintf(slave_socket,PATH_MAX, "%s/var/tmp/slave.sock", mysql_test_dir); snprintf(slave_socket,FN_REFLEN, "%s/var/tmp/slave.sock", mysql_test_dir);
#endif #endif
/* create log file */ /* create log file */
snprintf(temp, PATH_MAX, "%s/mysql-test-run.log", mysql_test_dir); snprintf(temp, FN_REFLEN, "%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."); log_errno("Unable to create log file.");
...@@ -1386,46 +1386,47 @@ void setup(char *file __attribute__((unused))) ...@@ -1386,46 +1386,47 @@ void setup(char *file __attribute__((unused)))
/* 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, strlwr(skip_test));
snprintf(skip_test, PATH_MAX, " %s ", temp); snprintf(skip_test, FN_REFLEN, " %s ", temp);
/* environment */ /* environment */
#ifdef __NETWARE__ #ifdef __NETWARE__
setenv("MYSQL_TEST_DIR", mysql_test_dir, 1); setenv("MYSQL_TEST_DIR", mysql_test_dir, 1);
snprintf(file_path, PATH_MAX*2, snprintf(file_path, FN_REFLEN*2,
"%s/client/mysqldump --no-defaults -u root --port=%u", "%s/client/mysqldump --no-defaults -u root --port=%u",
bin_dir, master_port); bin_dir, master_port);
setenv("MYSQL_DUMP", file_path, 1); setenv("MYSQL_DUMP", file_path, 1);
snprintf(file_path, PATH_MAX*2, snprintf(file_path, FN_REFLEN*2,
"%s/client/mysqlbinlog --no-defaults --local-load=%s", "%s/client/mysqlbinlog --no-defaults --local-load=%s",
bin_dir, mysql_tmp_dir); bin_dir, mysql_tmp_dir);
setenv("MYSQL_BINLOG", file_path, 1); setenv("MYSQL_BINLOG", file_path, 1);
#elif __WIN__ #elif __WIN__
snprintf(file_path,MAX_PATH,"MYSQL_TEST_DIR=%s",mysql_test_dir); snprintf(file_path,FN_REFLEN,"MYSQL_TEST_DIR=%s",mysql_test_dir);
_putenv(file_path); _putenv(file_path);
snprintf(file_path, PATH_MAX*2, snprintf(file_path, FN_REFLEN*2,
"MYSQL_DUMP=%s/mysqldump.exe --no-defaults -u root --port=%u", "MYSQL_DUMP=%s/mysqldump.exe --no-defaults -u root --port=%u",
bin_dir, master_port); bin_dir, master_port);
_putenv(file_path); _putenv(file_path);
snprintf(file_path, PATH_MAX*2, snprintf(file_path, FN_REFLEN*2,
"MYSQL_BINLOG=%s/mysqlbinlog.exe --no-defaults --local-load=%s", "MYSQL_BINLOG=%s/mysqlbinlog.exe --no-defaults --local-load=%s",
bin_dir, mysql_tmp_dir); bin_dir, mysql_tmp_dir);
_putenv(file_path); _putenv(file_path);
#else #else
setenv("MYSQL_TEST_DIR", mysql_test_dir, 1); snprintf(file_path,FN_REFLEN,"MYSQL_TEST_DIR=%s",mysql_test_dir);
snprintf(file_path, PATH_MAX*2, putenv(file_path);
"%s/mysqldump --no-defaults -u root --port=%u --socket=%s", snprintf(file_path, FN_REFLEN*2,
"MYSQL_DUMP=%s/mysqldump --no-defaults -u root --port=%u --socket=%s",
bin_dir, master_port, master_socket); bin_dir, master_port, master_socket);
setenv("MYSQL_DUMP", file_path, 1); putenv(file_path);
snprintf(file_path, PATH_MAX*2, snprintf(file_path, FN_REFLEN*2,
"%s/mysqlbinlog --no-defaults --local-load=%s", "MYSQL_BINLOG=%s/mysqlbinlog --no-defaults --local-load=%s",
bin_dir, mysql_tmp_dir); bin_dir, mysql_tmp_dir);
setenv("MYSQL_BINLOG", file_path, 1); putenv(file_path);
#endif #endif
#ifndef __WIN__ #ifndef __WIN__
setenv("MASTER_MYPORT", "9306", 1); putenv((char *)"MASTER_MYPORT=9306");
setenv("SLAVE_MYPORT", "9307", 1); putenv((char *)"SLAVE_MYPORT=9307");
setenv("MYSQL_TCP_PORT", "3306", 1); putenv((char *)"MYSQL_TCP_PORT=3306");
#else #else
_putenv("MASTER_MYPORT=9306"); _putenv("MASTER_MYPORT=9306");
_putenv("SLAVE_MYPORT=9307"); _putenv("SLAVE_MYPORT=9307");
...@@ -1461,7 +1462,7 @@ int main(int argc, char **argv) ...@@ -1461,7 +1462,7 @@ int main(int argc, char **argv)
temp= strdup(strchr(argv[1],'=') + 1); temp= strdup(strchr(argv[1],'=') + 1);
for (token=str_tok(temp, ","); token != NULL; token=str_tok(NULL, ",")) for (token=str_tok(temp, ","); token != NULL; token=str_tok(NULL, ","))
{ {
if (strlen(ignore_test) + strlen(token) + 2 <= PATH_MAX-1) if (strlen(ignore_test) + strlen(token) + 2 <= FN_REFLEN-1)
sprintf(ignore_test+strlen(ignore_test), " %s ", token); sprintf(ignore_test+strlen(ignore_test), " %s ", token);
else else
{ {
...@@ -1507,38 +1508,35 @@ int main(int argc, char **argv) ...@@ -1507,38 +1508,35 @@ int main(int argc, char **argv)
{ {
/* run all tests */ /* run all tests */
#ifndef __WIN__ #ifndef __WIN__
struct dirent **namelist; struct dirent *entry;
int i,n; DIR *parent;
char test[NAME_MAX]; char test[FN_LEN];
char *p;
int position; int position;
n= scandir(test_dir, &namelist, 0, alphasort); /* FIXME are we sure the list is sorted if using readdir()? */
if (n < 0) if ((parent= opendir(test_dir)) == NULL) /* Not thread safe */
die("Unable to open tests directory."); die("Unable to open tests directory.");
else else
{ {
for (i= 0; i < n; i++) while ((entry= readdir(parent)) != NULL) /* Not thread safe */
{ {
strcpy(test, strlwr(namelist[i]->d_name)); strcpy(test, strlwr(entry->d_name));
/* find the test suffix */ /* find the test suffix */
if ((position= strinstr(test, TEST_SUFFIX)) != 0) if ((position= strinstr(test, TEST_SUFFIX)) != 0)
{ {
p= test + position - 1;
/* null terminate at the suffix */ /* null terminate at the suffix */
*p= 0; *(test + position - 1)= '\0';
/* run test */ /* run test */
run_test(test); run_test(test);
} }
free(namelist[n]);
} }
free(namelist); closedir(parent);
} }
#else #else
struct _finddata_t dir; struct _finddata_t dir;
intptr_t handle; intptr_t handle;
char test[NAME_MAX]; char test[FN_LEN];
char mask[PATH_MAX]; char mask[FN_REFLEN];
char *p; char *p;
int position; int position;
char **names= 0; char **names= 0;
...@@ -1549,7 +1547,7 @@ int main(int argc, char **argv) ...@@ -1549,7 +1547,7 @@ int main(int argc, char **argv)
/* single test */ /* single test */
single_test= FALSE; single_test= FALSE;
snprintf(mask,MAX_PATH,"%s/*.test",test_dir); snprintf(mask,FN_REFLEN,"%s/*.test",test_dir);
if ((handle=_findfirst(mask,&dir)) == -1L) if ((handle=_findfirst(mask,&dir)) == -1L)
{ {
...@@ -1574,7 +1572,7 @@ int main(int argc, char **argv) ...@@ -1574,7 +1572,7 @@ int main(int argc, char **argv)
*p= 0; *p= 0;
/* insert test */ /* insert test */
*names= malloc(PATH_MAX); *names= malloc(FN_REFLEN);
strcpy(*names,test); strcpy(*names,test);
names++; names++;
name_index++; name_index++;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment