MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
tests.c
1 /*
2  A program to test DBUG features. Used by tests-t.pl
3 */
4 
5 char *push1=0;
6 
7 #include <my_global.h> /* This includes dbug.h */
8 #include <my_pthread.h>
9 #include <string.h>
10 
11 const char *func3()
12 {
13  DBUG_ENTER("func3");
14  DBUG_RETURN(DBUG_EVALUATE("ret3", "ok", "ko"));
15 }
16 
17 void func2()
18 {
19  const char *s;
20  DBUG_ENTER("func2");
21  s=func3();
22  DBUG_PRINT("info", ("s=%s", s));
23  DBUG_VOID_RETURN;
24 }
25 
26 int func1()
27 {
28  DBUG_ENTER("func1");
29  func2();
30  if (push1)
31  {
32  DBUG_PUSH(push1);
33  fprintf(DBUG_FILE, "=> push1\n");
34  }
35  DBUG_RETURN(10);
36 }
37 
38 int main (int argc, char *argv[])
39 {
40  int i;
41 #ifdef DBUG_OFF
42  return 1;
43 #endif
44  if (argc == 1)
45  return 0;
46 
47  my_thread_global_init();
48 
49  dup2(1, 2);
50  for (i = 1; i < argc; i++)
51  {
52  if (strncmp(argv[i], "--push1=", 8) == 0)
53  push1=argv[i]+8;
54  else
55  DBUG_PUSH (argv[i]);
56  }
57  {
58  DBUG_ENTER ("main");
59  DBUG_PROCESS ("dbug-tests");
60  func1();
61  DBUG_EXECUTE_IF("dump",
62  {
63  char s[1000];
64  DBUG_EXPLAIN(s, sizeof(s)-1);
65  DBUG_DUMP("dump", (uchar*)s, strlen(s));
66  });
67  DBUG_EXECUTE_IF("push", DBUG_PUSH("+t"); );
68  DBUG_EXECUTE("execute", fprintf(DBUG_FILE, "=> execute\n"); );
69  DBUG_EXECUTE_IF("set", DBUG_SET("+F"); );
70  fprintf(DBUG_FILE, "=> evaluate: %s\n",
71  DBUG_EVALUATE("evaluate", "ON", "OFF"));
72  fprintf(DBUG_FILE, "=> evaluate_if: %s\n",
73  DBUG_EVALUATE_IF("evaluate_if", "ON", "OFF"));
74  DBUG_EXECUTE_IF("pop", DBUG_POP(); );
75  {
76  char s[1000] __attribute__((unused));
77  DBUG_EXPLAIN(s, sizeof(s)-1);
78  DBUG_PRINT("explain", ("dbug explained: %s", s));
79  }
80  func2();
81  DBUG_RETURN (0);
82  }
83 }