summaryrefslogtreecommitdiff
path: root/dbug/tests.c
diff options
context:
space:
mode:
authorunknown <serg@janus.mylan>2008-02-01 16:21:44 +0100
committerunknown <serg@janus.mylan>2008-02-01 16:21:44 +0100
commitd79e70597acbf4fab0e848d8df42888404cb2c29 (patch)
treec72f9566f5025f5c069393faf8da971fcb331364 /dbug/tests.c
parent74efae60fcd186e15da1b123f7765c66f8598f4a (diff)
downloadmariadb-git-d79e70597acbf4fab0e848d8df42888404cb2c29.tar.gz
negative lists in dbug (-#-d,info => everything but "info").
unit tests for dbug dbug/Makefile.am: unit tests for dbug dbug/dbug.c: negative lists (-#-d,info => everything but "info") include/my_dbug.h: negative lists (-#-d,info => everything but "info") unittest/Makefile.am: unit tests for dbug dbug/tests-t.pl: unit tests for dbug dbug/tests.c: unit tests for dbug
Diffstat (limited to 'dbug/tests.c')
-rw-r--r--dbug/tests.c73
1 files changed, 73 insertions, 0 deletions
diff --git a/dbug/tests.c b/dbug/tests.c
new file mode 100644
index 00000000000..42482635eee
--- /dev/null
+++ b/dbug/tests.c
@@ -0,0 +1,73 @@
+/*
+ A program to test DBUG features. Used by tests-t.pl
+*/
+
+#ifdef DBUG_OFF /* We are testing dbug */
+#undef DBUG_OFF
+#endif
+
+#include <my_global.h> /* This includes dbug.h */
+#include <my_pthread.h>
+#include <string.h>
+
+const char *func3()
+{
+ DBUG_ENTER("func3");
+ DBUG_RETURN(DBUG_EVALUATE("ret3", "ok", "ko"));
+}
+
+void func2()
+{
+ const char *s;
+ DBUG_ENTER("func2");
+ s=func3();
+ DBUG_PRINT("info", ("s=%s", s));
+ DBUG_VOID_RETURN;
+}
+
+int func1()
+{
+ DBUG_ENTER("func1");
+ func2();
+ DBUG_RETURN(10);
+}
+
+int main (int argc, char *argv[])
+{
+ int i;
+#if defined(HAVE_PTHREAD_INIT) && defined(THREAD)
+ pthread_init(); /* Must be called before DBUG_ENTER */
+#endif
+#ifdef THREAD
+ my_thread_global_init();
+#endif
+ dup2(1, 2);
+ for (i = 1; i < argc; i++)
+ DBUG_PUSH (argv[i]);
+ {
+ DBUG_ENTER ("main");
+ DBUG_PROCESS ("dbug-tests");
+ func1();
+ func2();
+ DBUG_EXECUTE_IF("dump",
+ {
+ char s[1000];
+ DBUG_EXPLAIN(s, sizeof(s)-1);
+ DBUG_DUMP("dump", (uchar*)s, strlen(s));
+ });
+ DBUG_EXECUTE_IF("push", DBUG_PUSH("+t"); );
+ DBUG_EXECUTE("execute", fprintf(DBUG_FILE, "=> execute\n"); );
+ DBUG_EXECUTE_IF("set", DBUG_SET("+F"); );
+ fprintf(DBUG_FILE, "=> evaluate: %s\n",
+ DBUG_EVALUATE("evaluate", "ON", "OFF"));
+ fprintf(DBUG_FILE, "=> evaluate_if: %s\n",
+ DBUG_EVALUATE_IF("evaluate_if", "ON", "OFF"));
+ DBUG_EXECUTE_IF("pop", DBUG_POP(); );
+ {
+ char s[1000];
+ DBUG_EXPLAIN(s, sizeof(s)-1);
+ DBUG_PRINT("explain", ("dbug explained: %s", s));
+ }
+ DBUG_RETURN (0);
+ }
+}