74
74
using namespace std;
75
using namespace drizzled;
78
unsigned char *get_var_key(const unsigned char* var, size_t *len, bool);
79
bool get_one_option(int optid, const struct my_option *, char *argument);
78
unsigned char *get_var_key(const unsigned char* var, size_t *len, bool);
80
bool get_one_option(int optid, const struct my_option *, char *argument);
82
82
#define MAX_VAR_NAME_LENGTH 256
83
83
#define MAX_COLUMNS 256
1143
1143
char buff[512];
1145
if ((fd= my_open(filename, O_RDONLY, MYF(0))) < 0)
1145
if ((fd= internal::my_open(filename, O_RDONLY, MYF(0))) < 0)
1146
1146
die("Failed to open file '%s'", filename);
1147
while((len= my_read(fd, (unsigned char*)&buff,
1147
while((len= internal::my_read(fd, (unsigned char*)&buff,
1148
1148
sizeof(buff), MYF(0))) > 0)
1150
1150
char *p= buff, *start= buff;
1351
1351
const char *fname= filename2;
1352
1352
string tmpfile;
1354
if ((fd2= my_open(fname, O_RDONLY, MYF(0))) < 0)
1354
if ((fd2= internal::my_open(fname, O_RDONLY, MYF(0))) < 0)
1356
my_close(fd, MYF(0));
1356
internal::my_close(fd, MYF(0));
1357
1357
if (opt_testdir != NULL)
1359
1359
tmpfile= opt_testdir;
1362
1362
tmpfile.append(filename2);
1363
1363
fname= tmpfile.c_str();
1365
if ((fd2= my_open(fname, O_RDONLY, MYF(0))) < 0)
1365
if ((fd2= internal::my_open(fname, O_RDONLY, MYF(0))) < 0)
1367
my_close(fd, MYF(0));
1367
internal::my_close(fd, MYF(0));
1369
1369
die("Failed to open second file: '%s'", fname);
1372
while((len= my_read(fd, (unsigned char*)&buff,
1372
while((len= internal::my_read(fd, (unsigned char*)&buff,
1373
1373
sizeof(buff), MYF(0))) > 0)
1375
if ((len2= my_read(fd2, (unsigned char*)&buff2,
1375
if ((len2= internal::my_read(fd2, (unsigned char*)&buff2,
1376
1376
sizeof(buff2), MYF(0))) < len)
1378
1378
/* File 2 was smaller */
1395
if (!error && my_read(fd2, (unsigned char*)&buff2,
1395
if (!error && internal::my_read(fd2, (unsigned char*)&buff2,
1396
1396
sizeof(buff2), MYF(0)) > 0)
1398
1398
/* File 1 was smaller */
1399
1399
error= RESULT_LENGTH_MISMATCH;
1402
my_close(fd2, MYF(0));
1402
internal::my_close(fd2, MYF(0));
1426
if ((fd= my_open(filename1, O_RDONLY, MYF(0))) < 0)
1426
if ((fd= internal::my_open(filename1, O_RDONLY, MYF(0))) < 0)
1427
1427
die("Failed to open first file: '%s'", filename1);
1429
1429
error= compare_files2(fd, filename2);
1431
my_close(fd, MYF(0));
1431
internal::my_close(fd, MYF(0));
1453
1453
char temp_file_path[FN_REFLEN];
1455
if ((fd= create_temp_file(temp_file_path, NULL,
1455
if ((fd= internal::create_temp_file(temp_file_path, NULL,
1456
1456
"tmp", MYF(MY_WME))) < 0)
1457
1457
die("Failed to create temporary file for ds");
1459
1459
/* Write ds to temporary file and set file pos to beginning*/
1460
if (my_write(fd, (unsigned char *) ds->c_str(), ds->length(),
1460
if (internal::my_write(fd, (unsigned char *) ds->c_str(), ds->length(),
1461
1461
MYF(MY_FNABP | MY_WME)) ||
1462
1462
lseek(fd, 0, SEEK_SET) == MY_FILEPOS_ERROR)
1464
my_close(fd, MYF(0));
1464
internal::my_close(fd, MYF(0));
1465
1465
/* Remove the temporary file */
1466
my_delete(temp_file_path, MYF(0));
1466
internal::my_delete(temp_file_path, MYF(0));
1467
1467
die("Failed to write file '%s'", temp_file_path);
1470
1470
error= compare_files2(fd, fname);
1472
my_close(fd, MYF(0));
1472
internal::my_close(fd, MYF(0));
1473
1473
/* Remove the temporary file */
1474
my_delete(temp_file_path, MYF(0));
1474
internal::my_delete(temp_file_path, MYF(0));
1514
1514
char reject_file[FN_REFLEN];
1515
1515
size_t reject_length;
1516
dirname_part(reject_file, result_file_name, &reject_length);
1516
internal::dirname_part(reject_file, result_file_name, &reject_length);
1518
1518
if (access(reject_file, W_OK) == 0)
1520
1520
/* Result file directory is writable, save reject file there */
1521
fn_format(reject_file, result_file_name, NULL,
1521
internal::fn_format(reject_file, result_file_name, NULL,
1522
1522
".reject", MY_REPLACE_EXT);
1526
1526
/* Put reject file in opt_logdir */
1527
fn_format(reject_file, result_file_name, opt_logdir,
1527
internal::fn_format(reject_file, result_file_name, opt_logdir,
1528
1528
".reject", MY_REPLACE_DIR | MY_REPLACE_EXT);
1530
1530
str_to_file(reject_file, ds->c_str(), ds->length());
1565
1565
if (string_cmp(ds, fname.c_str()))
1567
1567
char reason[FN_REFLEN];
1568
fn_format(reason, fname.c_str(), "", "", MY_REPLACE_EXT | MY_REPLACE_DIR);
1568
internal::fn_format(reason, fname.c_str(), "", "", MY_REPLACE_EXT | MY_REPLACE_DIR);
1569
1569
abort_not_supported_test("Test requires: '%s'", reason);
2146
2146
char buff[FN_REFLEN];
2148
if (!test_if_hard_path(name))
2148
if (!internal::test_if_hard_path(name))
2150
2150
sprintf(buff,"%s%s",opt_basedir,name);
2153
fn_format(buff, name, "", "", MY_UNPACK_FILENAME);
2153
internal::fn_format(buff, name, "", "", MY_UNPACK_FILENAME);
2155
2155
if (cur_file == file_stack_end)
2156
2156
die("Source directives are nesting too deep");
2469
2469
rm_args, sizeof(rm_args)/sizeof(struct command_arg),
2472
error= my_delete(ds_filename.c_str(), MYF(0)) != 0;
2472
error= internal::my_delete(ds_filename.c_str(), MYF(0)) != 0;
2473
2473
handle_command_error(command, error);
2503
2503
sizeof(copy_file_args)/sizeof(struct command_arg),
2506
error= (my_copy(ds_from_file.c_str(), ds_to_file.c_str(),
2506
error= (internal::my_copy(ds_from_file.c_str(), ds_to_file.c_str(),
2507
2507
MYF(MY_DONT_OVERWRITE_FILE)) != 0);
2508
2508
handle_command_error(command, error);
2601
2601
mkdir_args, sizeof(mkdir_args)/sizeof(struct command_arg),
2604
error= mkdir(ds_dirname.c_str(), (0777 & my_umask_dir)) != 0;
2604
error= mkdir(ds_dirname.c_str(), (0777 & internal::my_umask_dir)) != 0;
2605
2605
handle_command_error(command, error);
2992
2992
read_until_delimiter(&ds_script, &ds_delimiter);
2994
2994
/* Create temporary file name */
2995
if ((fd= create_temp_file(temp_file_path, getenv("MYSQLTEST_VARDIR"),
2995
if ((fd= internal::create_temp_file(temp_file_path, getenv("MYSQLTEST_VARDIR"),
2996
2996
"tmp", MYF(MY_WME))) < 0)
2997
2997
die("Failed to create temporary file for perl command");
2998
my_close(fd, MYF(0));
2998
internal::my_close(fd, MYF(0));
3000
3000
str_to_file(temp_file_path, ds_script.c_str(), ds_script.length());
3015
3015
error= pclose(res_file);
3017
3017
/* Remove the temporary file */
3018
my_delete(temp_file_path, MYF(0));
3018
internal::my_delete(temp_file_path, MYF(0));
3020
3020
handle_command_error(command, WEXITSTATUS(error));
3316
3316
die("Missing argument to %.*s", command->first_word_len, command->query);
3317
3317
sleep_start= p;
3318
/* Check that arg starts with a digit, not handled by my_strtod */
3318
/* Check that arg starts with a digit, not handled by internal::my_strtod */
3319
3319
if (!my_isdigit(charset_info, *sleep_start))
3320
3320
die("Invalid argument to %.*s \"%s\"", command->first_word_len,
3321
3321
command->query,command->first_argument);
3884
3884
if (*ds_sock.c_str() != FN_LIBCHAR)
3886
3886
char buff[FN_REFLEN];
3887
fn_format(buff, ds_sock.c_str(), TMPDIR, "", 0);
3887
internal::fn_format(buff, ds_sock.c_str(), TMPDIR, "", 0);
3888
3888
ds_sock.clear();
3889
3889
ds_sock.append(buff);
4650
4650
static void print_version(void)
4652
printf("%s Ver %s Distrib %s, for %s-%s (%s)\n",my_progname,MTEST_VERSION,
4652
printf("%s Ver %s Distrib %s, for %s-%s (%s)\n",internal::my_progname,MTEST_VERSION,
4653
4653
drizzle_version(),HOST_VENDOR,HOST_OS,HOST_CPU);
4660
4660
printf("Drizzle version modified by Brian, Jay, Monty Taylor, PatG and Stewart\n");
4661
4661
printf("This software comes with ABSOLUTELY NO WARRANTY\n\n");
4662
4662
printf("Runs a test against the DRIZZLE server and compares output with a results file.\n\n");
4663
printf("Usage: %s [OPTIONS] [database] < test_file\n", my_progname);
4663
printf("Usage: %s [OPTIONS] [database] < test_file\n", internal::my_progname);
4664
4664
my_print_help(my_long_options);
4665
4665
printf(" --no-defaults Don't read default options from any options file.\n");
4666
4666
my_print_variables(my_long_options);
4680
4680
char buff[FN_REFLEN];
4681
if (!test_if_hard_path(argument))
4681
if (!internal::test_if_hard_path(argument))
4683
4683
sprintf(buff,"%s%s",opt_basedir,argument);
4684
4684
argument= buff;
4686
fn_format(buff, argument, "", "", MY_UNPACK_FILENAME);
4686
internal::fn_format(buff, argument, "", "", MY_UNPACK_FILENAME);
4687
4687
assert(cur_file == file_stack && cur_file->file == 0);
4688
4688
if (!(cur_file->file= fopen(buff, "r")))
4689
4689
die("Could not open '%s' for reading: errno = %d", buff, errno);
4697
4697
static char buff[FN_REFLEN];
4698
if (!test_if_hard_path(argument))
4698
if (!internal::test_if_hard_path(argument))
4700
4700
sprintf(buff,"%s%s",opt_basedir,argument);
4701
4701
argument= buff;
4703
fn_format(buff, argument, "", "", MY_UNPACK_FILENAME);
4703
internal::fn_format(buff, argument, "", "", MY_UNPACK_FILENAME);
4704
4704
timer_file= buff;
4705
4705
unlink(timer_file); /* Ignore error, may not exist */
4761
4761
static int parse_args(int argc, char **argv)
4763
load_defaults("drizzle",load_default_groups,&argc,&argv);
4763
internal::load_defaults("drizzle",load_default_groups,&argc,&argv);
4764
4764
default_argv= argv;
4766
4766
if ((handle_options(&argc, &argv, my_long_options, get_one_option)))
4796
4796
char buff[FN_REFLEN];
4797
4797
int flags= O_WRONLY | O_CREAT;
4798
if (!test_if_hard_path(fname))
4798
if (!internal::test_if_hard_path(fname))
4800
4800
sprintf(buff,"%s%s",opt_basedir,fname);
4803
fn_format(buff, fname, "", "", MY_UNPACK_FILENAME);
4803
internal::fn_format(buff, fname, "", "", MY_UNPACK_FILENAME);
4806
4806
flags|= O_TRUNC;
4807
if ((fd= my_open(buff, flags,
4807
if ((fd= internal::my_open(buff, flags,
4808
4808
MYF(MY_WME | MY_FFNF))) < 0)
4809
4809
die("Could not open '%s' for writing: errno = %d", buff, errno);
4810
4810
if (append && lseek(fd, 0, SEEK_END) == MY_FILEPOS_ERROR)
4811
4811
die("Could not find end of file '%s': errno = %d", buff, errno);
4812
if (my_write(fd, (unsigned char*)str, size, MYF(MY_WME|MY_FNABP)))
4812
if (internal::my_write(fd, (unsigned char*)str, size, MYF(MY_WME|MY_FNABP)))
4813
4813
die("write failed");
4814
my_close(fd, MYF(0));
4814
internal::my_close(fd, MYF(0));
4833
4833
void dump_result_to_log_file(const char *buf, int size)
4835
4835
char log_file[FN_REFLEN];
4836
str_to_file(fn_format(log_file, result_file_name, opt_logdir, ".log",
4836
str_to_file(internal::fn_format(log_file, result_file_name, opt_logdir, ".log",
4837
4837
*opt_logdir ? MY_REPLACE_DIR | MY_REPLACE_EXT :
4838
4838
MY_REPLACE_EXT),
4844
4844
void dump_progress(void)
4846
4846
char progress_file[FN_REFLEN];
4847
str_to_file(fn_format(progress_file, result_file_name,
4847
str_to_file(internal::fn_format(progress_file, result_file_name,
4848
4848
opt_logdir, ".progress",
4849
4849
*opt_logdir ? MY_REPLACE_DIR | MY_REPLACE_EXT :
4850
4850
MY_REPLACE_EXT),
4856
4856
char warn_file[FN_REFLEN];
4858
str_to_file(fn_format(warn_file, result_file_name, opt_logdir, ".warnings",
4858
str_to_file(internal::fn_format(warn_file, result_file_name, opt_logdir, ".warnings",
4859
4859
*opt_logdir ? MY_REPLACE_DIR | MY_REPLACE_EXT :
4860
4860
MY_REPLACE_EXT),
4861
4861
ds_warning_messages.c_str(), ds_warning_messages.length());
6040
6040
uint64_t timer_now(void)
6042
return my_micro_time() / 1000;
6042
#if defined(HAVE_GETHRTIME)
6043
return gethrtime()/1000/1000;
6048
The following loop is here because gettimeofday may fail on some systems
6050
while (gettimeofday(&t, NULL) != 0)
6052
newtime= (uint64_t)t.tv_sec * 1000000 + t.tv_usec;
6053
return newtime/1000;
6054
#endif /* defined(HAVE_GETHRTIME) */