gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r8449 - flightrecorder/src/libflightrecorder


From: gnunet
Subject: [GNUnet-SVN] r8449 - flightrecorder/src/libflightrecorder
Date: Sun, 3 May 2009 05:20:03 -0600

Author: durner
Date: 2009-05-03 05:20:03 -0600 (Sun, 03 May 2009)
New Revision: 8449

Added:
   flightrecorder/src/libflightrecorder/test_st.c
Modified:
   flightrecorder/src/libflightrecorder/Makefile.am
Log:
function call stack test

Modified: flightrecorder/src/libflightrecorder/Makefile.am
===================================================================
--- flightrecorder/src/libflightrecorder/Makefile.am    2009-05-03 11:19:06 UTC 
(rev 8448)
+++ flightrecorder/src/libflightrecorder/Makefile.am    2009-05-03 11:20:03 UTC 
(rev 8449)
@@ -1,7 +1,7 @@
 INCLUDES = -I$(top_srcdir)/src/include
 
 lib_LTLIBRARIES = libflightrecorder.la
-TESTS = test_init
+TESTS = test_init test_st
 check_PROGRAMS = $(TESTS)
 
 pkgdata_DATA = advice.acc advice.include
@@ -16,6 +16,9 @@
 test_init_SOURCES = test_init.c
 test_init_LDADD = $(top_builddir)/src/libflightrecorder/libflightrecorder.la
 
+test_st_SOURCES = test_st.c
+test_st_LDADD = $(top_builddir)/src/libflightrecorder/libflightrecorder.la
+
 libflightrecorder_la_LDFLAGS = \
  -export-dynamic -Wl,--no-undefined $(WINFLAGS) \
  -version-info 1:0:0

Added: flightrecorder/src/libflightrecorder/test_st.c
===================================================================
--- flightrecorder/src/libflightrecorder/test_st.c                              
(rev 0)
+++ flightrecorder/src/libflightrecorder/test_st.c      2009-05-03 11:20:03 UTC 
(rev 8449)
@@ -0,0 +1,96 @@
+/*
+   libflightrecorder - Client library for flightrecorder, a recorder for
+   runtime information gathered by AOP advices or other process internal
+   checks
+
+   Copyright (C) 2009 Nils Durner
+
+   This library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   This library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with this library; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  
USA
+*/
+
+/**
+ * @brief Initialization test
+ * @file src/libflightrecorder/test_st.c
+ * @author Nils Durner
+ */
+
+#include "flightrecorder.h"
+
+struct Ret
+{
+  int counter, error;
+};
+
+int check1(struct StackTraceEntry *entry, void *data)
+{
+  char *func;
+  int line;
+
+  switch(((struct Ret *) data)->counter)
+  {
+    case 0:
+      func = "testfunc2";
+      line = 20;
+      break;
+    case 1:
+      func = "testfunc1";
+      line = 10;
+      break;
+    default:
+      ((struct Ret *) data)->error = 1;
+      return 0;
+  }
+
+  if (strcmp(entry->function, func) != 0 || entry->line != line)
+  {
+    printf("Error in stack trace: got `%s:%u', expected: `%s:%u'\n",
+        entry->function, entry->line, func, line);
+    ((struct Ret *) data)->error = 1;
+    return 0;
+  }
+
+  ((struct Ret *) data)->counter++;
+  return 1;
+}
+
+int main()
+{
+  struct Ret ret;
+
+  if (!fr_init())
+    return 1;
+
+  if (!fr_st_enter("test.c", 10, "testfunc1"))
+    return 2;
+
+  if (!fr_st_enter("test.c", 20, "testfunc2"))
+    return 3;
+
+  if (!fr_st_enter("test.c", 30, "testfunc3"))
+    return 4;
+
+  if(!fr_st_leave("test.c", 35, "testfunc3"))
+    return 5;
+
+  ret.error = 0;
+  ret.counter = 0;
+  fr_st_iterate(fr_st_get_this(), check1, (void *) &ret);
+  if (ret.error)
+    return 6;
+
+  fr_uninit();
+
+  return 0;
+}





reply via email to

[Prev in Thread] Current Thread [Next in Thread]