~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to client/drizzletest.cc

  • Committer: Olaf van der Spek
  • Date: 2011-06-14 21:43:30 UTC
  • mto: (2318.6.3 refactor7)
  • mto: This revision was merged to the branch mainline in revision 2338.
  • Revision ID: olafvdspek@gmail.com-20110614214330-zlexwqc59ei33ybz
Refactor

Show diffs side-by-side

added added

removed removed

Lines of Context:
660
660
    fprintf(stderr, "\n\n");
661
661
  }
662
662
  drizzle_result_free(&res);
663
 
 
664
 
  return;
665
663
}
666
664
 
667
665
 
905
903
      free(i.second);
906
904
  }
907
905
  var_hash.clear();
908
 
  BOOST_FOREACH(vector<st_command*>::reference i, q_lines)
 
906
  BOOST_FOREACH(st_command* i, q_lines)
909
907
    delete i;
910
908
  for (size_t i= 0; i < var_reg.size(); i++)
911
909
  {
919
917
 
920
918
static void cleanup_and_exit(int exit_code)
921
919
{
922
 
  free_used_memory();
923
 
  internal::my_end();
 
920
  if (0) // Olaf: Freeing resources is unnecessary when exiting
 
921
  {
 
922
    free_used_memory(); 
 
923
    internal::my_end();
 
924
  }
924
925
 
925
 
  if (!silent) {
926
 
    switch (exit_code) {
 
926
  if (!silent) 
 
927
  {
 
928
    switch (exit_code) 
 
929
    {
927
930
    case 1:
928
931
      printf("not ok\n");
929
932
      break;
935
938
      break;
936
939
    default:
937
940
      printf("unknown exit code: %d\n", exit_code);
938
 
      assert(0);
 
941
      assert(false);
939
942
    }
940
943
  }
941
944
  exit(exit_code);
1482
1485
  if (access(result_file_name.c_str(), F_OK) != 0)
1483
1486
    die("The specified result file does not exist: '%s'", result_file_name.c_str());
1484
1487
 
1485
 
  switch (string_cmp(ds, result_file_name.c_str())) {
 
1488
  switch (string_cmp(ds, result_file_name.c_str())) 
 
1489
  {
1486
1490
  case RESULT_OK:
1487
1491
    break; /* ok */
1488
1492
  case RESULT_LENGTH_MISMATCH:
1521
1525
  default: /* impossible */
1522
1526
    die("Unknown error code from dyn_string_cmp()");
1523
1527
  }
1524
 
 
1525
 
  return;
1526
1528
}
1527
1529
 
1528
1530
 
1543
1545
 
1544
1546
static void check_require(string* ds, const string &fname)
1545
1547
{
1546
 
 
1547
 
 
1548
1548
  if (string_cmp(ds, fname.c_str()))
1549
1549
  {
1550
1550
    char reason[FN_REFLEN];
1551
1551
    internal::fn_format(reason, fname.c_str(), "", "", MY_REPLACE_EXT | MY_REPLACE_DIR);
1552
1552
    abort_not_supported_test("Test requires: '%s'", reason);
1553
1553
  }
1554
 
  return;
1555
1554
}
1556
1555
 
1557
1556
 
1989
1988
 
1990
1989
  {
1991
1990
    /* Get the value */
1992
 
    drizzle_row_t row;
1993
1991
    long rows= 0;
1994
1992
    const char* value= "No such row";
1995
1993
 
1996
 
    while ((row= drizzle_row_next(&res)))
 
1994
    while (drizzle_row_t row= drizzle_row_next(&res))
1997
1995
    {
1998
1996
      if (++rows == row_no)
1999
1997
      {
2155
2153
    }
2156
2154
    open_file(ds_filename.c_str());
2157
2155
  }
2158
 
 
2159
 
  return;
2160
2156
}
2161
2157
 
2162
2158
 
2401
2397
 
2402
2398
static void do_remove_file(st_command* command)
2403
2399
{
2404
 
  int error;
2405
2400
  string ds_filename;
2406
2401
  const struct command_arg rm_args[] = {
2407
2402
    { "filename", ARG_STRING, true, &ds_filename, "File to delete" }
2412
2407
                     rm_args, sizeof(rm_args)/sizeof(struct command_arg),
2413
2408
                     ' ');
2414
2409
 
2415
 
  error= internal::my_delete(ds_filename.c_str(), MYF(0)) != 0;
 
2410
  int error= internal::my_delete(ds_filename.c_str(), MYF(0)) != 0;
2416
2411
  handle_command_error(command, error);
2417
2412
}
2418
2413
 
2431
2426
 
2432
2427
static void do_copy_file(st_command* command)
2433
2428
{
2434
 
  int error;
2435
2429
  string ds_from_file;
2436
2430
  string ds_to_file;
2437
2431
  const struct command_arg copy_file_args[] = {
2445
2439
                     sizeof(copy_file_args)/sizeof(struct command_arg),
2446
2440
                     ' ');
2447
2441
 
2448
 
  error= (internal::my_copy(ds_from_file.c_str(), ds_to_file.c_str(),
 
2442
  int error= (internal::my_copy(ds_from_file.c_str(), ds_to_file.c_str(),
2449
2443
                  MYF(MY_DONT_OVERWRITE_FILE)) != 0);
2450
2444
  handle_command_error(command, error);
2451
2445
}
2500
2494
 
2501
2495
static void do_file_exist(st_command* command)
2502
2496
{
2503
 
  int error;
2504
2497
  string ds_filename;
2505
2498
  const struct command_arg file_exist_args[] = {
2506
2499
    { "filename", ARG_STRING, true, &ds_filename, "File to check if it exist" }
2512
2505
                     sizeof(file_exist_args)/sizeof(struct command_arg),
2513
2506
                     ' ');
2514
2507
 
2515
 
  error= (access(ds_filename.c_str(), F_OK) != 0);
 
2508
  int error= access(ds_filename.c_str(), F_OK) != 0;
2516
2509
  handle_command_error(command, error);
2517
2510
}
2518
2511
 
2530
2523
static void do_mkdir(st_command* command)
2531
2524
{
2532
2525
  string ds_dirname;
2533
 
  int error;
2534
2526
  const struct command_arg mkdir_args[] = {
2535
2527
    {"dirname", ARG_STRING, true, &ds_dirname, "Directory to create"}
2536
2528
  };
2540
2532
                     mkdir_args, sizeof(mkdir_args)/sizeof(struct command_arg),
2541
2533
                     ' ');
2542
2534
 
2543
 
  error= mkdir(ds_dirname.c_str(), (0777 & internal::my_umask_dir)) != 0;
 
2535
  int error= mkdir(ds_dirname.c_str(), (0777 & internal::my_umask_dir)) != 0;
2544
2536
  handle_command_error(command, error);
2545
2537
}
2546
2538
 
2556
2548
 
2557
2549
static void do_rmdir(st_command* command)
2558
2550
{
2559
 
  int error;
2560
2551
  string ds_dirname;
2561
2552
  const struct command_arg rmdir_args[] = {
2562
2553
    {"dirname", ARG_STRING, true, &ds_dirname, "Directory to remove"}
2567
2558
                     rmdir_args, sizeof(rmdir_args)/sizeof(struct command_arg),
2568
2559
                     ' ');
2569
2560
 
2570
 
  error= rmdir(ds_dirname.c_str()) != 0;
 
2561
  int error= rmdir(ds_dirname.c_str()) != 0;
2571
2562
  handle_command_error(command, error);
2572
2563
}
2573
2564
 
2599
2590
static void read_until_delimiter(string *ds,
2600
2591
                                 string *ds_delimiter)
2601
2592
{
2602
 
  char c;
2603
 
 
2604
2593
  if (ds_delimiter->length() > MAX_DELIMITER_LENGTH)
2605
2594
    die("Max delimiter length(%d) exceeded", MAX_DELIMITER_LENGTH);
2606
2595
 
2607
2596
  /* Read from file until delimiter is found */
2608
2597
  while (1)
2609
2598
  {
2610
 
    c= my_getc(cur_file->file);
 
2599
    char c= my_getc(cur_file->file);
2611
2600
 
2612
2601
    if (c == '\n')
2613
2602
    {
2635
2624
 
2636
2625
    ds->push_back(c);
2637
2626
  }
2638
 
  return;
2639
2627
}
2640
2628
 
2641
2629
 
2667
2655
  }
2668
2656
 
2669
2657
  read_until_delimiter(&ds_content, &ds_delimiter);
2670
 
  str_to_file2(ds_filename.c_str(), ds_content.c_str(),
2671
 
               ds_content.length(), append);
2672
 
  return;
 
2658
  str_to_file2(ds_filename.c_str(), ds_content.c_str(), ds_content.length(), append);
2673
2659
}
2674
2660
 
2675
2661
 
2764
2750
                     ' ');
2765
2751
 
2766
2752
  cat_file(&ds_res, ds_filename.c_str());
2767
 
 
2768
 
  return;
2769
2753
}
2770
2754
 
2771
2755
 
2783
2767
 
2784
2768
static void do_diff_files(st_command* command)
2785
2769
{
2786
 
  int error= 0;
2787
2770
  string ds_filename;
2788
2771
  string ds_filename2;
2789
2772
  const struct command_arg diff_file_args[] = {
2798
2781
                     sizeof(diff_file_args)/sizeof(struct command_arg),
2799
2782
                     ' ');
2800
2783
 
2801
 
  if ((error= compare_files(ds_filename.c_str(), ds_filename2.c_str())))
 
2784
  int error= compare_files(ds_filename.c_str(), ds_filename2.c_str());
 
2785
  if (error)
2802
2786
  {
2803
2787
    /* Compare of the two files failed, append them to output
2804
2788
       so the failure can be analyzed
2812
2796
 
2813
2797
static st_connection * find_connection_by_name(const char *name)
2814
2798
{
2815
 
  st_connection *con;
2816
 
  for (con= g_connections; con < next_con; con++)
 
2799
  for (st_connection* con= g_connections; con < next_con; con++)
2817
2800
  {
2818
 
    if (!strcmp(con->name, name))
2819
 
    {
 
2801
    if (not strcmp(con->name, name))
2820
2802
      return con;
2821
 
    }
2822
2803
  }
2823
 
  return 0; /* Connection not found */
 
2804
  return NULL;
2824
2805
}
2825
2806
 
2826
2807
 
3036
3017
      break;
3037
3018
    usleep(SLAVE_POLL_INTERVAL);
3038
3019
  }
3039
 
  return;
3040
3020
}
3041
3021
 
3042
3022
static void do_sync_with_master2(long offset)