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.

83 lines
1.6 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. my_thread_global_init();
  41. dup2(1, 2);
  42. for (i = 1; i < argc; i++)
  43. {
  44. if (strncmp(argv[i], "--push1=", 8) == 0)
  45. push1=argv[i]+8;
  46. else
  47. DBUG_PUSH (argv[i]);
  48. }
  49. {
  50. DBUG_ENTER ("main");
  51. DBUG_PROCESS ("dbug-tests");
  52. func1();
  53. DBUG_EXECUTE_IF("dump",
  54. {
  55. char s[1000];
  56. DBUG_EXPLAIN(s, sizeof(s)-1);
  57. DBUG_DUMP("dump", (uchar*)s, strlen(s));
  58. });
  59. DBUG_EXECUTE_IF("push", DBUG_PUSH("+t"); );
  60. DBUG_EXECUTE("execute", fprintf(DBUG_FILE, "=> execute\n"); );
  61. DBUG_EXECUTE_IF("set", DBUG_SET("+F"); );
  62. fprintf(DBUG_FILE, "=> evaluate: %s\n",
  63. DBUG_EVALUATE("evaluate", "ON", "OFF"));
  64. fprintf(DBUG_FILE, "=> evaluate_if: %s\n",
  65. DBUG_EVALUATE_IF("evaluate_if", "ON", "OFF"));
  66. DBUG_EXECUTE_IF("pop", DBUG_POP(); );
  67. {
  68. char s[1000] __attribute__((unused));
  69. DBUG_EXPLAIN(s, sizeof(s)-1);
  70. DBUG_PRINT("explain", ("dbug explained: %s", s));
  71. }
  72. func2();
  73. DBUG_RETURN (0);
  74. }
  75. }