~jlukas79/+junk/mysql-server

« back to all changes in this revision

Viewing changes to dbug/tests.c

manual merge 6.0-main --> 6.0-bka-review

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
#if defined(HAVE_PTHREAD_INIT) && defined(THREAD)
 
48
  pthread_init();                       /* Must be called before DBUG_ENTER */
 
49
#endif
 
50
#ifdef THREAD
 
51
  my_thread_global_init();
 
52
#endif
 
53
  dup2(1, 2);
 
54
  for (i = 1; i < argc; i++)
 
55
  {
 
56
    if (strncmp(argv[i], "--push1=", 8) == 0)
 
57
      push1=argv[i]+8;
 
58
    else
 
59
      DBUG_PUSH (argv[i]);
 
60
  }
 
61
  {
 
62
    DBUG_ENTER ("main");
 
63
    DBUG_PROCESS ("dbug-tests");
 
64
    func1();
 
65
    DBUG_EXECUTE_IF("dump",
 
66
    {
 
67
      char s[1000];
 
68
      DBUG_EXPLAIN(s, sizeof(s)-1);
 
69
      DBUG_DUMP("dump", (uchar*)s, strlen(s));
 
70
    });
 
71
    DBUG_EXECUTE_IF("push",  DBUG_PUSH("+t"); );
 
72
    DBUG_EXECUTE("execute", fprintf(DBUG_FILE, "=> execute\n"); );
 
73
    DBUG_EXECUTE_IF("set",  DBUG_SET("+F"); );
 
74
    fprintf(DBUG_FILE, "=> evaluate: %s\n",
 
75
            DBUG_EVALUATE("evaluate", "ON", "OFF"));
 
76
    fprintf(DBUG_FILE, "=> evaluate_if: %s\n",
 
77
            DBUG_EVALUATE_IF("evaluate_if", "ON", "OFF"));
 
78
    DBUG_EXECUTE_IF("pop",  DBUG_POP(); );
 
79
    {
 
80
      char s[1000] __attribute__((unused));
 
81
      DBUG_EXPLAIN(s, sizeof(s)-1);
 
82
      DBUG_PRINT("explain", ("dbug explained: %s", s));
 
83
    }
 
84
    func2();
 
85
    DBUG_RETURN (0);
 
86
  }
 
87
}