2 Unix SMB/CIFS implementation.
3 Samba utility functions
4 Copyright (C) Jelmer Vernooij <jelmer@samba.org> 2008
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>.
20 #ifndef _TORTURE_UTIL_H_
21 #define _TORTURE_UTIL_H_
23 #include "lib/torture/torture.h"
27 struct cli_credentials
;
30 * Useful target macros for handling server bugs in torture tests.
32 #define TARGET_IS_WINXP(_tctx) (torture_setting_bool(_tctx, "winxp", false))
33 #define TARGET_IS_W2K3(_tctx) (torture_setting_bool(_tctx, "w2k3", false))
34 #define TARGET_IS_W2K8(_tctx) (torture_setting_bool(_tctx, "w2k8", false))
35 #define TARGET_IS_W2K12(_tctx) (torture_setting_bool(_tctx, "w2k12", false))
36 #define TARGET_IS_WIN7(_tctx) (torture_setting_bool(_tctx, "win7", false))
37 #define TARGET_IS_SAMBA3(_tctx) (torture_setting_bool(_tctx, "samba3", false))
38 #define TARGET_IS_SAMBA4(_tctx) (torture_setting_bool(_tctx, "samba4", false))
41 setup a directory ready for a test
43 _PUBLIC_
bool torture_setup_dir(struct smbcli_state
*cli
, const char *dname
);
44 NTSTATUS
create_directory_handle(struct smbcli_tree
*tree
, const char *dname
, int *fnum
);
47 sometimes we need a fairly complex file to work with, so we can test
48 all possible attributes.
50 _PUBLIC_
int create_complex_file(struct smbcli_state
*cli
, TALLOC_CTX
*mem_ctx
, const char *fname
);
51 int create_complex_dir(struct smbcli_state
*cli
, TALLOC_CTX
*mem_ctx
, const char *dname
);
54 check that a wire string matches the flags specified
55 not 100% accurate, but close enough for testing
57 bool wire_bad_flags(struct smb_wire_string
*str
, int flags
,
58 struct smbcli_transport
*transport
);
59 void dump_all_info(TALLOC_CTX
*mem_ctx
, union smb_fileinfo
*finfo
);
60 void torture_all_info(struct smbcli_tree
*tree
, const char *fname
);
61 bool torture_set_file_attribute(struct smbcli_tree
*tree
, const char *fname
, uint16_t attrib
);
62 NTSTATUS
torture_set_sparse(struct smbcli_tree
*tree
, int fnum
);
63 NTSTATUS
torture_check_ea(struct smbcli_state
*cli
,
64 const char *fname
, const char *eaname
, const char *value
);
65 _PUBLIC_
bool torture_open_connection_share(TALLOC_CTX
*mem_ctx
,
66 struct smbcli_state
**c
,
67 struct torture_context
*tctx
,
69 const char *sharename
,
70 struct tevent_context
*ev
);
71 _PUBLIC_
bool torture_get_conn_index(int conn_index
,
73 struct torture_context
*tctx
,
74 char **host
, char **share
);
75 _PUBLIC_
bool torture_open_connection_ev(struct smbcli_state
**c
,
77 struct torture_context
*tctx
,
78 struct tevent_context
*ev
);
79 _PUBLIC_
bool torture_open_connection(struct smbcli_state
**c
, struct torture_context
*tctx
, int conn_index
);
80 _PUBLIC_
bool torture_close_connection(struct smbcli_state
*c
);
81 _PUBLIC_
bool check_error(const char *location
, struct smbcli_state
*c
,
82 uint8_t eclass
, uint32_t ecode
, NTSTATUS nterr
);
83 double torture_create_procs(struct torture_context
*tctx
,
84 bool (*fn
)(struct torture_context
*, struct smbcli_state
*, int), bool *result
);
85 _PUBLIC_
struct torture_test
*torture_suite_add_smb_multi_test(
86 struct torture_suite
*suite
,
88 bool (*run
) (struct torture_context
*,
89 struct smbcli_state
*,
91 _PUBLIC_
struct torture_test
*torture_suite_add_2smb_test(
92 struct torture_suite
*suite
,
94 bool (*run
) (struct torture_context
*,
95 struct smbcli_state
*,
96 struct smbcli_state
*));
97 _PUBLIC_
struct torture_test
*torture_suite_add_1smb_test(
98 struct torture_suite
*suite
,
100 bool (*run
) (struct torture_context
*, struct smbcli_state
*));
101 NTSTATUS
torture_second_tcon(TALLOC_CTX
*mem_ctx
,
102 struct smbcli_session
*session
,
103 const char *sharename
,
104 struct smbcli_tree
**res
);
107 NTSTATUS
torture_check_privilege(struct smbcli_state
*cli
,
109 const char *privilege
);
112 * Use this to pass a 2nd user:
114 * --option='torture:user2name=user2'
115 * --option='torture:user2domain=domain2'
116 * --option='torture:user2password=password2'
118 struct cli_credentials
*torture_user2_credentials(struct torture_context
*tctx
,
119 TALLOC_CTX
*mem_ctx
);
121 #endif /* _TORTURE_UTIL_H_ */