diff options
author | Jelmer Vernooij <jelmer@samba.org> | 2006-06-12 19:31:35 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 14:09:02 -0500 |
commit | c714fdaa222b9d79328f651b79d76c3141c993d5 (patch) | |
tree | 224b0f75c72986388560ff1b8ae080cbf46c5c41 /source4/torture/local/binding_string.c | |
parent | 5afa7ef9265ee7ef8569210673d688919b12371d (diff) | |
download | samba-c714fdaa222b9d79328f651b79d76c3141c993d5.tar.gz samba-c714fdaa222b9d79328f651b79d76c3141c993d5.tar.bz2 samba-c714fdaa222b9d79328f651b79d76c3141c993d5.zip |
r16162: Convert to UI API
(This used to be commit 78db534f65245c6f093ca8b2bf24dfba9a125ea0)
Diffstat (limited to 'source4/torture/local/binding_string.c')
-rw-r--r-- | source4/torture/local/binding_string.c | 59 |
1 files changed, 28 insertions, 31 deletions
diff --git a/source4/torture/local/binding_string.c b/source4/torture/local/binding_string.c index 3384a9b9d6..4405bf0256 100644 --- a/source4/torture/local/binding_string.c +++ b/source4/torture/local/binding_string.c @@ -24,46 +24,41 @@ #include "librpc/gen_ndr/epmapper.h" #include "librpc/rpc/dcerpc.h" #include "torture/torture.h" +#include "torture/ui.h" -static BOOL test_BindingString(TALLOC_CTX *mem_ctx, const char *binding) +static BOOL test_BindingString(struct torture_context *torture, const char *binding) { struct dcerpc_binding *b, *b2; const char *s, *s2; struct epm_tower tower; NTSTATUS status; + struct torture_test *test = torture_test(torture, binding, binding); /* Parse */ - status = dcerpc_parse_binding(mem_ctx, binding, &b); - if (NT_STATUS_IS_ERR(status)) { - DEBUG(0, ("Error parsing binding string '%s': %s\n", binding, nt_errstr(status))); - return False; - } + torture_assert_ntstatus_ok(test, + dcerpc_parse_binding(test, binding, &b), + "Error parsing binding string"); - s = dcerpc_binding_string(mem_ctx, b); + s = dcerpc_binding_string(test, b); if (!s) { - DEBUG(0, ("Error converting binding back to string for '%s'\n", binding)); + torture_fail(test, "Error converting binding back to string"); + talloc_free(test); return False; } - if (strcasecmp(binding, s) != 0) { - DEBUG(0, ("Mismatch while comparing original and regenerated binding strings: '%s' <> '%s'\n", binding, s)); - return False; - } + torture_assert_casestr_equal(test, binding, s, + "Mismatch while comparing original and regenerated binding strings"); /* Generate protocol towers */ - status = dcerpc_binding_build_tower(mem_ctx, b, &tower); - if (NT_STATUS_IS_ERR(status)) { - DEBUG(0, ("Error generating protocol tower from '%s': %s\n", binding, nt_errstr(status))); - return False; - } + torture_assert_ntstatus_ok(test, + dcerpc_binding_build_tower(test, b, &tower), + "Error generating protocol tower"); /* Convert back to binding and then back to string and compare */ - status = dcerpc_binding_from_tower(mem_ctx, &tower, &b2); - if (NT_STATUS_IS_ERR(status)) { - DEBUG(0, ("Error generating binding from tower for original binding '%s': %s\n", binding, nt_errstr(status))); - return False; - } + torture_assert_ntstatus_ok(test, + dcerpc_binding_from_tower(test, &tower, &b2), + "Error generating binding from tower for original binding"); /* Compare to a stripped down version of the binding string because * the protocol tower doesn't contain the extra option data */ @@ -71,24 +66,29 @@ static BOOL test_BindingString(TALLOC_CTX *mem_ctx, const char *binding) b->flags = 0; - s = dcerpc_binding_string(mem_ctx, b); + s = dcerpc_binding_string(test, b); if (!s) { - DEBUG(0, ("Error converting binding back to string for (stripped down) '%s'\n", binding)); + torture_fail(test, "Error converting binding back to string for (stripped down)"); + talloc_free(test); return False; } - s2 = dcerpc_binding_string(mem_ctx, b2); + s2 = dcerpc_binding_string(test, b2); if (!s) { - DEBUG(0, ("Error converting binding back to string for '%s'\n", binding)); + torture_fail(test, "Error converting binding back to string"); + talloc_free(test); return False; } if (is_ipaddress(b->host) && strcasecmp(s, s2) != 0) { - DEBUG(0, ("Mismatch while comparing original and from protocol tower generated binding strings: '%s' <> '%s'\n", s, s2)); + torture_fail(test, "Mismatch while comparing original and from protocol tower generated binding strings: '%s' <> '%s'\n", s, s2); + talloc_free(test); return False; } + torture_ok(test); + talloc_free(test); return True; } @@ -120,14 +120,11 @@ static const char *test_strings[] = { BOOL torture_local_binding_string(struct torture_context *torture) { BOOL ret = True; - TALLOC_CTX *mem_ctx = talloc_init("test_BindingString"); int i; for (i = 0; i < ARRAY_SIZE(test_strings); i++) { - ret &= test_BindingString(mem_ctx, test_strings[i]); + ret &= test_BindingString(torture, test_strings[i]); } - talloc_free(mem_ctx); - return ret; } |