summaryrefslogtreecommitdiff
path: root/source4/torture/torture_util.c
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2006-03-17 17:59:58 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:57:37 -0500
commitd09b70c98b8222eb293bc9d8713ec071188ed01d (patch)
treee24c521a4adaff0bdbe3938ff80dfc4e8a21c428 /source4/torture/torture_util.c
parent8437d5b8913d949b844448d84a003896f9694b94 (diff)
downloadsamba-d09b70c98b8222eb293bc9d8713ec071188ed01d.tar.gz
samba-d09b70c98b8222eb293bc9d8713ec071188ed01d.tar.bz2
samba-d09b70c98b8222eb293bc9d8713ec071188ed01d.zip
r14527: Fix build problems.
(This used to be commit 863ca4014d9b821706ee90f58ab5d5cf3899a4c7)
Diffstat (limited to 'source4/torture/torture_util.c')
-rw-r--r--source4/torture/torture_util.c95
1 files changed, 75 insertions, 20 deletions
diff --git a/source4/torture/torture_util.c b/source4/torture/torture_util.c
index ba96731b20..69c462bc6d 100644
--- a/source4/torture/torture_util.c
+++ b/source4/torture/torture_util.c
@@ -354,26 +354,6 @@ void torture_all_info(struct smbcli_tree *tree, const char *fname)
/*
- split a UNC name into server and share names
-*/
-BOOL split_unc_name(const char *unc, char **server, char **share)
-{
- char *p = strdup(unc);
- if (!p) return False;
- all_string_sub(p, "\\", "/", 0);
- if (strncmp(p, "//", 2) != 0) return False;
-
- (*server) = p+2;
- p = strchr(*server, '/');
- if (!p) return False;
-
- *p = 0;
- (*share) = p+1;
-
- return True;
-}
-
-/*
set a attribute on a file
*/
BOOL torture_set_file_attribute(struct smbcli_tree *tree, const char *fname, uint16_t attrib)
@@ -483,3 +463,78 @@ NTSTATUS torture_check_ea(struct smbcli_state *cli,
return NT_STATUS_EA_CORRUPT_ERROR;
}
+BOOL torture_open_connection_share(TALLOC_CTX *mem_ctx,
+ struct smbcli_state **c,
+ const char *hostname,
+ const char *sharename,
+ struct event_context *ev)
+{
+ NTSTATUS status;
+
+ status = smbcli_full_connection(mem_ctx, c, hostname,
+ sharename, NULL,
+ cmdline_credentials, ev);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("Failed to open connection - %s\n", nt_errstr(status));
+ return False;
+ }
+
+ (*c)->transport->options.use_oplocks = use_oplocks;
+ (*c)->transport->options.use_level2_oplocks = use_level_II_oplocks;
+
+ return True;
+}
+
+_PUBLIC_ BOOL torture_open_connection(struct smbcli_state **c)
+{
+ const char *host = lp_parm_string(-1, "torture", "host");
+ const char *share = lp_parm_string(-1, "torture", "share");
+
+ return torture_open_connection_share(NULL, c, host, share, NULL);
+}
+
+
+
+_PUBLIC_ BOOL torture_close_connection(struct smbcli_state *c)
+{
+ BOOL ret = True;
+ if (!c) return True;
+ if (NT_STATUS_IS_ERR(smbcli_tdis(c))) {
+ printf("tdis failed (%s)\n", smbcli_errstr(c->tree));
+ ret = False;
+ }
+ talloc_free(c);
+ return ret;
+}
+
+
+/* check if the server produced the expected error code */
+_PUBLIC_ BOOL check_error(const char *location, struct smbcli_state *c,
+ uint8_t eclass, uint32_t ecode, NTSTATUS nterr)
+{
+ NTSTATUS status;
+
+ status = smbcli_nt_error(c->tree);
+ if (NT_STATUS_IS_DOS(status)) {
+ int class, num;
+ class = NT_STATUS_DOS_CLASS(status);
+ num = NT_STATUS_DOS_CODE(status);
+ if (eclass != class || ecode != num) {
+ printf("unexpected error code %s\n", nt_errstr(status));
+ printf(" expected %s or %s (at %s)\n",
+ nt_errstr(NT_STATUS_DOS(eclass, ecode)),
+ nt_errstr(nterr), location);
+ return False;
+ }
+ } else {
+ if (!NT_STATUS_EQUAL(nterr, status)) {
+ printf("unexpected error code %s\n", nt_errstr(status));
+ printf(" expected %s (at %s)\n", nt_errstr(nterr), location);
+ return False;
+ }
+ }
+
+ return True;
+}
+
+