summaryrefslogtreecommitdiff
path: root/source3/torture
diff options
context:
space:
mode:
authorVolker Lendecke <vlendec@samba.org>2007-10-07 13:36:56 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 12:31:13 -0500
commit3a14416dde836e3f6be57bcdfd63250f9df7f615 (patch)
tree4a853ed2413758986262b468b9da20b99de2d923 /source3/torture
parentf708132de775403f582bd3cf216f7ed76e26932e (diff)
downloadsamba-3a14416dde836e3f6be57bcdfd63250f9df7f615.tar.gz
samba-3a14416dde836e3f6be57bcdfd63250f9df7f615.tar.bz2
samba-3a14416dde836e3f6be57bcdfd63250f9df7f615.zip
r25563: Show which local-substitute subtest fails
(This used to be commit 2b3392df1024539d326fb0f560ab2b0a29124a06)
Diffstat (limited to 'source3/torture')
-rw-r--r--source3/torture/torture.c60
1 files changed, 32 insertions, 28 deletions
diff --git a/source3/torture/torture.c b/source3/torture/torture.c
index 6d0fc546ab..991dadf9e3 100644
--- a/source3/torture/torture.c
+++ b/source3/torture/torture.c
@@ -4780,40 +4780,44 @@ static BOOL run_error_map_extract(int dummy) {
return True;
}
+static bool subst_test(const char *str, const char *user, const char *domain,
+ uid_t uid, gid_t gid, const char *expected)
+{
+ char *subst;
+ bool result = true;
+
+ subst = talloc_sub_specified(talloc_tos(), str, user, domain, uid, gid);
+
+ if (strcmp(subst, expected) != 0) {
+ printf("sub_specified(%s, %s, %s, %d, %d) returned [%s], expected "
+ "[%s]\n", str, user, domain, (int)uid, (int)gid, subst,
+ expected);
+ result = false;
+ }
+
+ TALLOC_FREE(subst);
+ return result;
+}
+
static BOOL run_local_substitute(int dummy)
{
- TALLOC_CTX *mem_ctx;
- int diff = 0;
-
- if ((mem_ctx = talloc_init("run_local_subst")) == NULL) {
- printf("talloc_init failed\n");
- return False;
- }
-
- diff |= strcmp(talloc_sub_specified(mem_ctx, "%U", "bla", "", -1, -1),
- "bla");
- diff |= strcmp(talloc_sub_specified(mem_ctx, "%u%U", "bla", "", -1, -1),
- "blabla");
- diff |= strcmp(talloc_sub_specified(mem_ctx, "%g", "", "", -1, -1),
- "NO_GROUP");
- diff |= strcmp(talloc_sub_specified(mem_ctx, "%G", "", "", -1, -1),
- "NO_GROUP");
- diff |= strcmp(talloc_sub_specified(mem_ctx, "%g", "", "", -1, 0),
- gidtoname(0));
- diff |= strcmp(talloc_sub_specified(mem_ctx, "%G", "", "", -1, 0),
- gidtoname(0));
- diff |= strcmp(talloc_sub_specified(mem_ctx, "%D%u", "u", "dom", -1, 0),
- "domu");
- diff |= strcmp(talloc_sub_specified(mem_ctx, "%i %I", "", "", -1, -1),
- "0.0.0.0 0.0.0.0");
+ bool ok = true;
+
+ ok &= subst_test("%U", "bla", "", -1, -1, "bla");
+ ok &= subst_test("%u%U", "bla", "", -1, -1, "blabla");
+ ok &= subst_test("%g", "", "", -1, -1, "NO_GROUP");
+ ok &= subst_test("%G", "", "", -1, -1, "NO_GROUP");
+ ok &= subst_test("%g", "", "", -1, 0, gidtoname(0));
+ ok &= subst_test("%G", "", "", -1, 0, gidtoname(0));
+ ok &= subst_test("%D%u", "u", "dom", -1, 0, "domu");
+ ok &= subst_test("%i %I", "", "", -1, -1, "0.0.0.0 0.0.0.0");
/* Different captialization rules in sub_basic... */
- diff |= strcmp(talloc_sub_basic(mem_ctx, "BLA", "dom", "%U%D"),
- "blaDOM");
+ ok &= (strcmp(talloc_sub_basic(talloc_tos(), "BLA", "dom", "%U%D"),
+ "blaDOM") == 0);
- TALLOC_FREE(mem_ctx);
- return (diff == 0);
+ return ok;
}
static BOOL run_local_gencache(int dummy)