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.

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