summaryrefslogtreecommitdiff
path: root/source4/torture/local
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2004-10-17 10:04:49 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 12:59:57 -0500
commit6591a226144d371a6b68fc5e7201a90a77dc9153 (patch)
tree072ee4cbf33f0469f23e424517d17b79c750852d /source4/torture/local
parent844de2b65c931120a2408365c00fa80cb65959fc (diff)
downloadsamba-6591a226144d371a6b68fc5e7201a90a77dc9153.tar.gz
samba-6591a226144d371a6b68fc5e7201a90a77dc9153.tar.bz2
samba-6591a226144d371a6b68fc5e7201a90a77dc9153.zip
r3016: - converted the events code to talloc
- added the new messaging system, based on unix domain sockets. It gets over 10k messages/second on my laptop without any socket cacheing, which is better than I expected. - added a LOCAL-MESSAGING torture test (This used to be commit 3af06478da7ab34a272226d8d9ac87e0a4940cfb)
Diffstat (limited to 'source4/torture/local')
-rw-r--r--source4/torture/local/messaging.c92
1 files changed, 92 insertions, 0 deletions
diff --git a/source4/torture/local/messaging.c b/source4/torture/local/messaging.c
new file mode 100644
index 0000000000..7302e3c119
--- /dev/null
+++ b/source4/torture/local/messaging.c
@@ -0,0 +1,92 @@
+/*
+ Unix SMB/CIFS implementation.
+
+ local test for messaging code
+
+ Copyright (C) Andrew Tridgell 2004
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program 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 General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#include "includes.h"
+
+static void pong_message(void *msg_ctx, void *private,
+ uint32_t msg_type, servid_t src, DATA_BLOB *data)
+{
+ int *count = private;
+ (*count)++;
+}
+
+/*
+ test ping speed
+*/
+static BOOL test_ping_speed(TALLOC_CTX *mem_ctx)
+{
+ struct event_context *ev = event_context_init(mem_ctx);
+ void *msg_ctx1, *msg_ctx2;
+ int ping_count = 0;
+ int pong_count = 0;
+ BOOL ret = True;
+
+ msg_ctx1 = messaging_init(mem_ctx, 1, ev);
+ msg_ctx2 = messaging_init(mem_ctx, 2, ev);
+
+ messaging_register(msg_ctx2, &pong_count, MSG_PONG, pong_message);
+
+ start_timer();
+
+ printf("Sending pings for 10 seconds\n");
+ while (end_timer() < 10.0) {
+ DATA_BLOB data;
+ data.data = "testing";
+ data.length = strlen(data.data);
+
+ messaging_send(msg_ctx2, 1, MSG_PING, &data);
+ messaging_send(msg_ctx2, 1, MSG_PING, NULL);
+ ping_count += 2;
+ event_loop_once(ev);
+ event_loop_once(ev);
+ }
+
+ printf("waiting for %d remaining replies\n", ping_count - pong_count);
+ while (end_timer() < 30 && pong_count < ping_count) {
+ event_loop_once(ev);
+ }
+
+ if (ping_count != pong_count) {
+ printf("ping test failed! received %d, sent %d\n", pong_count, ping_count);
+ ret = False;
+ }
+
+ printf("ping rate of %.0f messages/sec\n", (ping_count+pong_count)/end_timer());
+
+ talloc_free(msg_ctx1);
+ talloc_free(msg_ctx2);
+
+ event_context_destroy(ev);
+ return ret;
+}
+
+BOOL torture_local_messaging(int dummy)
+{
+ TALLOC_CTX *mem_ctx = talloc_init("torture_local_messaging");
+ BOOL ret = True;
+
+ ret &= test_ping_speed(mem_ctx);
+
+ talloc_free(mem_ctx);
+
+ return True;
+}