2 Unix SMB/CIFS implementation.
4 Copyright (C) Jelmer Vernooij 2006
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/>.
21 #include "libcli/smb2/smb2.h"
23 #include "torture/smbtorture.h"
24 #include "torture/smb2/proto.h"
25 #include "../lib/util/dlinklist.h"
27 static bool wrap_simple_1smb2_test(struct torture_context
*torture_ctx
,
28 struct torture_tcase
*tcase
,
29 struct torture_test
*test
)
31 bool (*fn
) (struct torture_context
*, struct smb2_tree
*);
33 struct smb2_tree
*tree1
;
34 TALLOC_CTX
*mem_ctx
= talloc_new(torture_ctx
);
36 if (!torture_smb2_connection(torture_ctx
, &tree1
)) {
37 torture_fail(torture_ctx
,
38 "Establishing SMB2 connection failed\n");
44 * The test might close the connection. If we steal the tree context
45 * before that and free the parent instead of tree directly, we avoid
46 * a double free error.
48 talloc_steal(mem_ctx
, tree1
);
52 ret
= fn(torture_ctx
, tree1
);
59 struct torture_test
*torture_suite_add_1smb2_test(struct torture_suite
*suite
,
61 bool (*run
)(struct torture_context
*,
64 struct torture_test
*test
;
65 struct torture_tcase
*tcase
;
67 tcase
= torture_suite_add_tcase(suite
, name
);
69 test
= talloc(tcase
, struct torture_test
);
71 test
->name
= talloc_strdup(test
, name
);
72 test
->description
= NULL
;
73 test
->run
= wrap_simple_1smb2_test
;
75 test
->dangerous
= false;
77 DLIST_ADD_END(tcase
->tests
, test
);
83 static bool wrap_simple_2smb2_test(struct torture_context
*torture_ctx
,
84 struct torture_tcase
*tcase
,
85 struct torture_test
*test
)
87 bool (*fn
) (struct torture_context
*, struct smb2_tree
*, struct smb2_tree
*);
90 struct smb2_tree
*tree1
;
91 struct smb2_tree
*tree2
;
92 TALLOC_CTX
*mem_ctx
= talloc_new(torture_ctx
);
94 if (!torture_smb2_connection(torture_ctx
, &tree1
)) {
95 torture_fail(torture_ctx
,
96 "Establishing SMB2 connection failed\n");
100 talloc_steal(mem_ctx
, tree1
);
102 if (!torture_smb2_connection(torture_ctx
, &tree2
)) {
103 torture_fail(torture_ctx
,
104 "Establishing SMB2 connection failed\n");
108 talloc_steal(mem_ctx
, tree2
);
112 ret
= fn(torture_ctx
, tree1
, tree2
);
115 /* the test may already have closed some of the connections */
116 talloc_free(mem_ctx
);
122 struct torture_test
*torture_suite_add_2smb2_test(struct torture_suite
*suite
,
124 bool (*run
)(struct torture_context
*,
128 struct torture_test
*test
;
129 struct torture_tcase
*tcase
;
131 tcase
= torture_suite_add_tcase(suite
, name
);
133 test
= talloc(tcase
, struct torture_test
);
135 test
->name
= talloc_strdup(test
, name
);
136 test
->description
= NULL
;
137 test
->run
= wrap_simple_2smb2_test
;
139 test
->dangerous
= false;
141 DLIST_ADD_END(tcase
->tests
, test
);
146 NTSTATUS
torture_smb2_init(TALLOC_CTX
*ctx
)
148 struct torture_suite
*suite
= torture_suite_create(ctx
, "smb2");
149 torture_suite_add_simple_test(suite
, "connect", torture_smb2_connect
);
150 torture_suite_add_suite(suite
, torture_smb2_scan_init(suite
));
151 torture_suite_add_suite(suite
, torture_smb2_getinfo_init(suite
));
152 torture_suite_add_simple_test(suite
, "setinfo", torture_smb2_setinfo
);
153 torture_suite_add_suite(suite
, torture_smb2_lock_init(suite
));
154 torture_suite_add_suite(suite
, torture_smb2_read_init(suite
));
155 torture_suite_add_suite(suite
, torture_smb2_aio_delay_init(suite
));
156 torture_suite_add_suite(suite
, torture_smb2_bench_init(suite
));
157 torture_suite_add_suite(suite
, torture_smb2_create_init(suite
));
158 torture_suite_add_suite(suite
, torture_smb2_twrp_init(suite
));
159 torture_suite_add_suite(suite
, torture_smb2_fileid_init(suite
));
160 torture_suite_add_suite(suite
, torture_smb2_acls_init(suite
));
161 torture_suite_add_suite(suite
, torture_smb2_acls_non_canonical_init(suite
));
162 torture_suite_add_suite(suite
, torture_smb2_notify_init(suite
));
163 torture_suite_add_suite(suite
, torture_smb2_notify_inotify_init(suite
));
164 torture_suite_add_suite(suite
,
165 torture_smb2_notify_disabled_init(suite
));
166 torture_suite_add_suite(suite
, torture_smb2_durable_open_init(suite
));
167 torture_suite_add_suite(suite
,
168 torture_smb2_durable_open_disconnect_init(suite
));
169 torture_suite_add_suite(suite
,
170 torture_smb2_durable_v2_open_init(suite
));
171 torture_suite_add_suite(suite
,
172 torture_smb2_durable_v2_delay_init(suite
));
173 torture_suite_add_suite(suite
,
174 torture_smb2_durable_v2_regressions_init(suite
));
175 torture_suite_add_suite(suite
, torture_smb2_dir_init(suite
));
176 torture_suite_add_suite(suite
, torture_smb2_lease_init(suite
));
177 torture_suite_add_suite(suite
, torture_smb2_dirlease_init(suite
));
178 torture_suite_add_suite(suite
, torture_smb2_compound_init(suite
));
179 torture_suite_add_suite(suite
, torture_smb2_compound_find_init(suite
));
180 torture_suite_add_suite(suite
, torture_smb2_compound_async_init(suite
));
181 torture_suite_add_suite(suite
, torture_smb2_oplocks_init(suite
));
182 torture_suite_add_suite(suite
, torture_smb2_kernel_oplocks_init(suite
));
183 torture_suite_add_suite(suite
, torture_smb2_streams_init(suite
));
184 torture_suite_add_1smb2_test(suite
, "stream-inherit-perms",
185 test_stream_inherit_perms
);
186 torture_suite_add_suite(suite
, torture_smb2_ioctl_init(suite
));
187 torture_suite_add_simple_test(suite
, "set-sparse-ioctl",
188 test_ioctl_set_sparse
);
189 torture_suite_add_simple_test(suite
, "zero-data-ioctl",
190 test_ioctl_zero_data
);
191 torture_suite_add_simple_test(suite
, "ioctl-on-stream",
192 test_ioctl_alternate_data_stream
);
193 torture_suite_add_suite(suite
, torture_smb2_rename_init(suite
));
194 torture_suite_add_suite(suite
, torture_smb2_sharemode_init(suite
));
195 torture_suite_add_1smb2_test(suite
, "hold-oplock", test_smb2_hold_oplock
);
196 torture_suite_add_suite(suite
, torture_smb2_session_init(suite
));
197 torture_suite_add_suite(suite
, torture_smb2_session_req_sign_init(suite
));
198 torture_suite_add_suite(suite
, torture_smb2_replay_init(suite
));
199 torture_suite_add_simple_test(suite
, "dosmode", torture_smb2_dosmode
);
200 torture_suite_add_simple_test(suite
, "async_dosmode", torture_smb2_async_dosmode
);
201 torture_suite_add_simple_test(suite
, "maxfid", torture_smb2_maxfid
);
202 torture_suite_add_simple_test(suite
, "hold-sharemode",
203 torture_smb2_hold_sharemode
);
204 torture_suite_add_simple_test(suite
, "check-sharemode",
205 torture_smb2_check_sharemode
);
206 torture_suite_add_suite(suite
, torture_smb2_crediting_init(suite
));
208 torture_suite_add_suite(suite
, torture_smb2_doc_init(suite
));
209 torture_suite_add_suite(suite
, torture_smb2_multichannel_init(suite
));
210 torture_suite_add_suite(suite
, torture_smb2_samba3misc_init(suite
));
211 torture_suite_add_suite(suite
, torture_smb2_timestamps_init(suite
));
212 torture_suite_add_suite(suite
, torture_smb2_timestamp_resolution_init(suite
));
213 torture_suite_add_1smb2_test(suite
, "openattr", torture_smb2_openattrtest
);
214 torture_suite_add_1smb2_test(suite
, "winattr", torture_smb2_winattrtest
);
215 torture_suite_add_1smb2_test(suite
, "winattr2", torture_smb2_winattr2
);
216 torture_suite_add_1smb2_test(suite
, "sdread", torture_smb2_sdreadtest
);
217 torture_suite_add_suite(suite
, torture_smb2_readwrite_init(suite
));
218 torture_suite_add_suite(suite
, torture_smb2_max_allowed(suite
));
219 torture_suite_add_1smb2_test(suite
, "tcon", run_tcon_test
);
220 torture_suite_add_1smb2_test(suite
, "mkdir", torture_smb2_mkdir
);
221 torture_suite_add_suite(suite
, torture_smb2_name_mangling_init(suite
));
223 torture_suite_add_suite(suite
, torture_smb2_charset(suite
));
224 torture_suite_add_1smb2_test(suite
, "secleak", torture_smb2_sec_leak
);
225 torture_suite_add_1smb2_test(suite
, "session-id", run_sessidtest
);
226 torture_suite_add_suite(suite
, torture_smb2_deny_init(suite
));
227 torture_suite_add_suite(suite
, torture_smb2_ea(suite
));
228 torture_suite_add_suite(suite
, torture_smb2_create_no_streams_init(suite
));
230 suite
->description
= talloc_strdup(suite
, "SMB2-specific tests");
232 torture_register_suite(ctx
, suite
);