~drizzle-trunk/libdrizzle/jenkins-Libdrizzle-29

« back to all changes in this revision

Viewing changes to tests/unit/binlog.c

  • Committer: Continuous Integration
  • Date: 2012-12-29 11:51:43 UTC
  • mfrom: (68.1.1 5.1-trunk)
  • Revision ID: ci@drizzle.org-20121229115143-b2w1xjx16neqxyu2
Merge lp:~brianaker/libdrizzle/yatl_lite_bugreport_fix Build: jenkins-Libdrizzle-17

Show diffs side-by-side

added added

removed removed

Lines of Context:
35
35
 *
36
36
 */
37
37
 
 
38
#include <yatl/lite.h>
 
39
 
38
40
#include <libdrizzle-5.1/libdrizzle.h>
39
41
#include "libdrizzle/structs.h"
40
42
#include <stdio.h>
42
44
#include <stdint.h>
43
45
#include <inttypes.h>
44
46
 
45
 
#ifndef EXIT_SKIP
46
 
# define EXIT_SKIP 77
47
 
#endif
48
 
 
49
47
int main(int argc, char *argv[])
50
48
{
51
49
  (void) argc;
52
50
  (void) argv;
53
 
  drizzle_st *con;
54
 
  drizzle_return_t ret;
55
51
  drizzle_result_st *result;
56
52
 
57
 
  con = drizzle_create_tcp("localhost", 3306, "root", "", "", 0);
58
 
  if (con == NULL)
59
 
  {
60
 
    printf("Drizzle connection object creation error\n");
61
 
    return EXIT_FAILURE;
62
 
  }
63
 
  ret = drizzle_connect(con);
 
53
  drizzle_st *con= drizzle_create_tcp("localhost", 3306, "root", "", "", 0);
 
54
  ASSERT_NOT_NULL_(con, "Drizzle connection object creation error");
 
55
 
 
56
  drizzle_return_t ret = drizzle_connect(con);
64
57
  if (ret != DRIZZLE_RETURN_OK)
65
58
  {
66
 
    printf("Drizzle connection failure\n");
67
59
    drizzle_quit(con);
68
 
    return EXIT_SKIP;
 
60
    SKIP_IF_(ret != DRIZZLE_RETURN_OK, "Drizzle connection failure");
69
61
  }
70
62
 
71
63
  result= drizzle_start_binlog(con, 0, "", 0, &ret);
72
 
  if (ret != DRIZZLE_RETURN_OK)
73
 
  {
74
 
    printf("Drizzle binlog start failure\n");
75
 
    return EXIT_FAILURE;
76
 
  }
 
64
  ASSERT_EQ_(DRIZZLE_RETURN_OK, ret, "Drizzle binlog start failure");
77
65
 
78
66
  while (ret == DRIZZLE_RETURN_OK)
79
67
  {
83
71
    {
84
72
      break;
85
73
    }
86
 
    else if (ret != DRIZZLE_RETURN_OK)
87
 
    {
88
 
      printf("Binlog error %s\n", drizzle_error(con));
89
 
      return EXIT_FAILURE;
90
 
    }
 
74
    ASSERT_EQ_(DRIZZLE_RETURN_OK, ret, "Binlog error %s\n", drizzle_error(con));
91
75
    timestamp= drizzle_binlog_event_timestamp(result);
92
76
    /* Test to see if timestamp is greater than 2012-01-01 00:00:00, corrupted
93
77
     * timestamps will have weird values that shoud fail this after several
94
78
     * events.  Also rotate event doesn't have a timestamp so need to add 0
95
79
     * to this test */
96
 
    if ((timestamp < 1325376000) && (timestamp != 0))
97
 
    {
98
 
      printf("Bad timestamp retrieved: %"PRIu32"\n", timestamp);
99
 
      return EXIT_FAILURE;
100
 
    }
 
80
    ASSERT_FALSE_(((timestamp < 1325376000) && (timestamp != 0)), "Bad timestamp retrieved: %" PRIu32, timestamp);
 
81
 
101
82
    /* An event higher than the max known is bad, either we don't know about
102
83
     * new events or type is corrupted */
103
 
    if (drizzle_binlog_event_type(result) >= DRIZZLE_EVENT_TYPE_END)
104
 
    {
105
 
      printf("Bad event type: %d\n", drizzle_binlog_event_type(result));
106
 
      return EXIT_FAILURE;
107
 
    }
 
84
    ASSERT_FALSE_((drizzle_binlog_event_type(result) >= DRIZZLE_EVENT_TYPE_END), "Bad event type: %d", drizzle_binlog_event_type(result));
108
85
  }
109
86
 
110
87
  drizzle_quit(con);
 
88
 
111
89
  return EXIT_SUCCESS;
112
90
}