~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to client/drizzletest.cc

merge with latest from the trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
64
64
 
65
65
enum {
66
66
  OPT_PS_PROTOCOL, OPT_SP_PROTOCOL, OPT_CURSOR_PROTOCOL, OPT_VIEW_PROTOCOL,
67
 
  OPT_MAX_CONNECT_RETRIES, OPT_MARK_PROGRESS, OPT_LOG_DIR, OPT_TAIL_LINES
 
67
  OPT_MAX_CONNECT_RETRIES, OPT_MARK_PROGRESS, OPT_LOG_DIR, OPT_TAIL_LINES,
 
68
  OPT_TESTDIR
68
69
};
69
70
 
70
71
static int record= 0, opt_sleep= -1;
72
73
const char *opt_user= 0, *opt_host= 0, *unix_sock= 0, *opt_basedir= "./";
73
74
const char *opt_logdir= "";
74
75
const char *opt_include= 0, *opt_charsets_dir;
 
76
const char *opt_testdir= 0;
75
77
static int opt_port= 0;
76
78
static int opt_max_connect_retries;
77
79
static bool opt_compress= 0, silent= 0, verbose= 0;
1282
1284
  File fd2;
1283
1285
  uint len, len2;
1284
1286
  char buff[512], buff2[512];
 
1287
  const char *fname= filename2;
 
1288
  string tmpfile;
1285
1289
 
1286
 
  if ((fd2= my_open(filename2, O_RDONLY, MYF(0))) < 0)
 
1290
  if ((fd2= my_open(fname, O_RDONLY, MYF(0))) < 0)
1287
1291
  {
1288
1292
    my_close(fd, MYF(0));
1289
 
    die("Failed to open second file: '%s'", filename2);
 
1293
    if (opt_testdir != NULL)
 
1294
    {
 
1295
      tmpfile= opt_testdir;
 
1296
      if (tmpfile[tmpfile.length()] != '/')
 
1297
        tmpfile.append("/");
 
1298
      tmpfile.append(filename2);
 
1299
      fname= tmpfile.c_str();
 
1300
    }
 
1301
    if ((fd2= my_open(fname, O_RDONLY, MYF(0))) < 0)
 
1302
    {
 
1303
      my_close(fd, MYF(0));
 
1304
    
 
1305
      die("Failed to open second file: '%s'", fname);
 
1306
    }
1290
1307
  }
1291
1308
  while((len= my_read(fd, (unsigned char*)&buff,
1292
1309
                      sizeof(buff), MYF(0))) > 0)
2088
2105
    ; /* Do nothing */
2089
2106
  else
2090
2107
  {
 
2108
    if (opt_testdir != NULL)
 
2109
    {
 
2110
      string testdir(opt_testdir);
 
2111
      if (testdir[testdir.length()] != '/')
 
2112
        testdir.append("/");
 
2113
      testdir.append(ds_filename);
 
2114
      ds_filename.swap(testdir);
 
2115
    }
2091
2116
    open_file(ds_filename.c_str());
2092
2117
  }
2093
2118
 
2468
2493
 
2469
2494
static void do_mkdir(struct st_command *command)
2470
2495
{
 
2496
  string ds_dirname;
2471
2497
  int error;
2472
 
  string ds_dirname;
2473
2498
  const struct command_arg mkdir_args[] = {
2474
2499
    {"dirname", ARG_STRING, true, &ds_dirname, "Directory to create"}
2475
2500
  };
2479
2504
                     mkdir_args, sizeof(mkdir_args)/sizeof(struct command_arg),
2480
2505
                     ' ');
2481
2506
 
2482
 
  error= my_mkdir(ds_dirname.c_str(), 0777, MYF(0)) != 0;
 
2507
  error= mkdir(ds_dirname.c_str(), (0777 & my_umask_dir)) != 0;
2483
2508
  handle_command_error(command, error);
2484
2509
  return;
2485
2510
}
2990
3015
    drizzle_free_result(res);
2991
3016
    if (done)
2992
3017
      break;
2993
 
    my_sleep(SLAVE_POLL_INTERVAL);
 
3018
    usleep(SLAVE_POLL_INTERVAL);
2994
3019
  }
2995
3020
  return;
2996
3021
}
3193
3218
    sleep_val= opt_sleep;
3194
3219
 
3195
3220
  if (sleep_val)
3196
 
    my_sleep((uint32_t) (sleep_val * 1000000L));
 
3221
    usleep((uint32_t) (sleep_val * 1000000L));
3197
3222
  command->last_argument= sleep_end;
3198
3223
  return 0;
3199
3224
}
3584
3609
      verbose_msg("Connect attempt %d/%d failed: %d: %s", failed_attempts,
3585
3610
                  opt_max_connect_retries, drizzle_errno(drizzle),
3586
3611
                  drizzle_error(drizzle));
3587
 
      my_sleep(connection_retry_sleep);
 
3612
      usleep(connection_retry_sleep);
3588
3613
    }
3589
3614
    else
3590
3615
    {
4443
4468
   GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
4444
4469
  {"include", 'i', "Include SQL before each test case.", (char**) &opt_include,
4445
4470
   (char**) &opt_include, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
 
4471
  {"testdir", OPT_TESTDIR, "Path to use to search for test files",
 
4472
   (char**) &opt_testdir,
 
4473
   (char**) &opt_testdir, 0,GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
4446
4474
  {"logdir", OPT_LOG_DIR, "Directory for log files", (char**) &opt_logdir,
4447
4475
   (char**) &opt_logdir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
4448
4476
  {"mark-progress", OPT_MARK_PROGRESS,