aboutsummaryrefslogtreecommitdiffstats
path: root/src/libcharon/plugins/stroke/stroke_socket.c
diff options
context:
space:
mode:
authorMartin Willi <martin@revosec.ch>2013-11-06 10:16:56 +0100
committerMartin Willi <martin@revosec.ch>2013-11-06 10:31:07 +0100
commit27467a6881414f024ad53740df115dfd4695c8cb (patch)
treee76d29c2ae1793d24808544f02dfb1b9fec09e86 /src/libcharon/plugins/stroke/stroke_socket.c
parentc49c3f320860786dde1c625cd47d5c05d8b6d10d (diff)
parent334f44cd292889173ed4a07d5d843fbd278d9e83 (diff)
downloadstrongswan-27467a6881414f024ad53740df115dfd4695c8cb.tar.bz2
strongswan-27467a6881414f024ad53740df115dfd4695c8cb.tar.xz
Merge branch 'unit-tests'
Replace the "check" based libstrongswan unit test framework with our own, giving us more flexibility for our specific needs. The new framework is more portable and uses complete libstrongswan init/deinit cycles for each test to properly catch leaks. It fully supports multi-threaded tests, and brings many of them for all threading primitives, watcher and streams. The --enable-unit-tests option is not required anymore for libstrongswan tests, but still is for the still "check" based charon-tkm tests.
Diffstat (limited to 'src/libcharon/plugins/stroke/stroke_socket.c')
-rw-r--r--src/libcharon/plugins/stroke/stroke_socket.c23
1 files changed, 22 insertions, 1 deletions
diff --git a/src/libcharon/plugins/stroke/stroke_socket.c b/src/libcharon/plugins/stroke/stroke_socket.c
index 3adebb523..cf7ec369c 100644
--- a/src/libcharon/plugins/stroke/stroke_socket.c
+++ b/src/libcharon/plugins/stroke/stroke_socket.c
@@ -490,6 +490,25 @@ static void stroke_leases(private_stroke_socket_t *this,
}
/**
+ * Callback function for usage report
+ */
+static void report_usage(FILE *out, int count, size_t bytes,
+ backtrace_t *bt, bool detailed)
+{
+ fprintf(out, "%d bytes total, %d allocations, %d bytes average:\n",
+ bytes, count, bytes / count);
+ bt->log(bt, out, detailed);
+}
+
+/**
+ * Callback function for memusage summary
+ */
+static void sum_usage(FILE *out, int count, size_t bytes, int whitelisted)
+{
+ fprintf(out, "Total memory usage: %zu\n", bytes);
+}
+
+/**
* Show memory usage
*/
static void stroke_memusage(private_stroke_socket_t *this,
@@ -497,7 +516,9 @@ static void stroke_memusage(private_stroke_socket_t *this,
{
if (lib->leak_detective)
{
- lib->leak_detective->usage(lib->leak_detective, out);
+ lib->leak_detective->usage(lib->leak_detective,
+ (leak_detective_report_cb_t)report_usage,
+ (leak_detective_summary_cb_t)sum_usage, out);
}
}