summaryrefslogtreecommitdiff
path: root/source3/torture/torture.c
diff options
context:
space:
mode:
authorVolker Lendecke <vlendec@samba.org>2006-09-09 21:05:51 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 11:51:19 -0500
commit96c72e2f8152f2b9e006a392e6e8d1006b9cdd2c (patch)
treebe3250f4adc897d2c8e29a5f4ffec5ef948462c6 /source3/torture/torture.c
parent415aa96f09fd708d134eb15a9e8f729ca3eb05c4 (diff)
downloadsamba-96c72e2f8152f2b9e006a392e6e8d1006b9cdd2c.tar.gz
samba-96c72e2f8152f2b9e006a392e6e8d1006b9cdd2c.tar.bz2
samba-96c72e2f8152f2b9e006a392e6e8d1006b9cdd2c.zip
r18310: Add a little test for some gencache routines
Remove unused gencache_set_only Use CONST_DISCARD instead of SMB_STRDUP Volker (This used to be commit 651e7e44e2e56eab81c5fe708f33e6d3918a39f9)
Diffstat (limited to 'source3/torture/torture.c')
-rw-r--r--source3/torture/torture.c60
1 files changed, 60 insertions, 0 deletions
diff --git a/source3/torture/torture.c b/source3/torture/torture.c
index 2b3d245d25..7944494612 100644
--- a/source3/torture/torture.c
+++ b/source3/torture/torture.c
@@ -4805,6 +4805,65 @@ static BOOL run_local_substitute(int dummy)
return (diff == 0);
}
+static BOOL run_local_gencache(int dummy)
+{
+ char *val;
+ time_t tm;
+
+ if (!gencache_init()) {
+ d_printf("%s: gencache_init() failed\n", __location__);
+ return False;
+ }
+
+ if (!gencache_set("foo", "bar", time(NULL) + 1000)) {
+ d_printf("%s: gencache_set() failed\n", __location__);
+ return False;
+ }
+
+ if (!gencache_get("foo", &val, &tm)) {
+ d_printf("%s: gencache_get() failed\n", __location__);
+ return False;
+ }
+
+ if (strcmp(val, "bar") != 0) {
+ d_printf("%s: gencache_get() returned %s, expected %s\n",
+ __location__, val, "bar");
+ SAFE_FREE(val);
+ return False;
+ }
+
+ SAFE_FREE(val);
+
+ if (!gencache_del("foo")) {
+ d_printf("%s: gencache_del() failed\n", __location__);
+ return False;
+ }
+ if (gencache_del("foo")) {
+ d_printf("%s: second gencache_del() succeeded\n",
+ __location__);
+ return False;
+ }
+
+ if (gencache_get("foo", &val, &tm)) {
+ d_printf("%s: gencache_get() on deleted entry "
+ "succeeded\n", __location__);
+ return False;
+ }
+
+ if (!gencache_shutdown()) {
+ d_printf("%s: gencache_shutdown() failed\n", __location__);
+ return False;
+ }
+
+ if (gencache_shutdown()) {
+ d_printf("%s: second gencache_shutdown() succeeded\n",
+ __location__);
+ return False;
+ }
+
+ return True;
+}
+
static double create_procs(BOOL (*fn)(int), BOOL *result)
{
int i, status;
@@ -4956,6 +5015,7 @@ static struct {
{"FDSESS", run_fdsesstest, 0},
{ "EATEST", run_eatest, 0},
{ "LOCAL-SUBSTITUTE", run_local_substitute, 0},
+ { "LOCAL-GENCACHE", run_local_gencache, 0},
{NULL, NULL, 0}};