[PATCH] torture3: Add a little gencache_parse load test

Christof Schmitt cs at samba.org
Thu May 22 17:27:13 MDT 2014


>From faa49e4ba0e95b60cca2fd3a26523e0ab44ac8aa Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Mon, 10 Mar 2014 15:43:19 +0100
Subject: [PATCH] torture3: Add a little gencache_parse load test

Signed-off-by: Volker Lendecke <vl at samba.org>
Reviewed-by: Christof Schmitt <cs at samba.org>
---
 source3/torture/torture.c |   24 ++++++++++++++++++++++++
 1 files changed, 24 insertions(+), 0 deletions(-)

diff --git a/source3/torture/torture.c b/source3/torture/torture.c
index 95d8b33..cea9089 100644
--- a/source3/torture/torture.c
+++ b/source3/torture/torture.c
@@ -8119,12 +8119,26 @@ static bool run_local_base64(int dummy)
 	return ret;
 }
 
+static void parse_fn(time_t timeout, DATA_BLOB blob, void *private_data)
+{
+	return;
+}
+
 static bool run_local_gencache(int dummy)
 {
 	char *val;
 	time_t tm;
 	DATA_BLOB blob;
 	char v;
+	struct memcache *mem;
+	int i;
+
+	mem = memcache_init(NULL, 0);
+	if (mem == NULL) {
+		d_printf("%s: memcache_init failed\n", __location__);
+		return false;
+	}
+	memcache_set_global(mem);
 
 	if (!gencache_set("foo", "bar", time(NULL) + 1000)) {
 		d_printf("%s: gencache_set() failed\n", __location__);
@@ -8136,6 +8150,16 @@ static bool run_local_gencache(int dummy)
 		return False;
 	}
 
+	for (i=0; i<1000000; i++) {
+		gencache_parse("foo", parse_fn, NULL);
+	}
+
+	if (!gencache_get("foo", talloc_tos(), &val, &tm)) {
+		d_printf("%s: gencache_get() failed\n", __location__);
+		return False;
+	}
+	TALLOC_FREE(val);
+
 	if (!gencache_get("foo", talloc_tos(), &val, &tm)) {
 		d_printf("%s: gencache_get() failed\n", __location__);
 		return False;
-- 
1.7.1



More information about the samba-technical mailing list