You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

87 lines
1.8 KiB

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