2 Unix SMB/CIFS implementation.
3 RAW_SEARCH_* individual test suite
4 Copyright (C) Andrew Tridgell 2003
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 2 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, write to the Free Software
18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 #include "system/filesys.h"
23 #include "libcli/raw/libcliraw.h"
26 #define BASEDIR "\\testsearch"
29 callback function for single_search
31 static BOOL single_search_callback(void *private, union smb_search_data *file)
33 union smb_search_data *data = private;
41 do a single file (non-wildcard) search
43 static NTSTATUS single_search(struct smbcli_state *cli,
46 enum smb_search_level level,
47 union smb_search_data *data)
49 union smb_search_first io;
50 union smb_search_close c;
53 io.generic.level = level;
54 if (level == RAW_SEARCH_SEARCH ||
55 level == RAW_SEARCH_FFIRST ||
56 level == RAW_SEARCH_FUNIQUE) {
57 io.search_first.in.max_count = 1;
58 io.search_first.in.search_attrib = 0;
59 io.search_first.in.pattern = pattern;
61 io.t2ffirst.in.search_attrib = 0;
62 io.t2ffirst.in.max_count = 1;
63 io.t2ffirst.in.flags = FLAG_TRANS2_FIND_CLOSE;
64 io.t2ffirst.in.storage_type = 0;
65 io.t2ffirst.in.pattern = pattern;
68 status = smb_raw_search_first(cli->tree, mem_ctx,
69 &io, (void *)data, single_search_callback);
71 if (NT_STATUS_IS_OK(status) && level == RAW_SEARCH_FFIRST) {
72 c.fclose.level = RAW_FINDCLOSE_FCLOSE;
73 c.fclose.in.max_count = 1;
74 c.fclose.in.search_attrib = 0;
75 c.fclose.in.id = data->search.id;
76 status = smb_raw_search_close(cli->tree, &c);
85 enum smb_search_level level;
86 uint32_t capability_mask;
88 union smb_search_data data;
90 {"FFIRST", RAW_SEARCH_FFIRST, },
91 {"FUNIQUE", RAW_SEARCH_FUNIQUE, },
92 {"SEARCH", RAW_SEARCH_SEARCH, },
93 {"STANDARD", RAW_SEARCH_STANDARD, },
94 {"EA_SIZE", RAW_SEARCH_EA_SIZE, },
95 {"DIRECTORY_INFO", RAW_SEARCH_DIRECTORY_INFO, },
96 {"FULL_DIRECTORY_INFO", RAW_SEARCH_FULL_DIRECTORY_INFO, },
97 {"NAME_INFO", RAW_SEARCH_NAME_INFO, },
98 {"BOTH_DIRECTORY_INFO", RAW_SEARCH_BOTH_DIRECTORY_INFO, },
99 {"ID_FULL_DIRECTORY_INFO", RAW_SEARCH_ID_FULL_DIRECTORY_INFO, },
100 {"ID_BOTH_DIRECTORY_INFO", RAW_SEARCH_ID_BOTH_DIRECTORY_INFO, },
101 {"UNIX_INFO", RAW_SEARCH_UNIX_INFO, CAP_UNIX}
104 /* find a level in the table by name */
105 static union smb_search_data *find(const char *name)
108 for (i=0;i<ARRAY_SIZE(levels);i++) {
109 if (NT_STATUS_IS_OK(levels[i].status) &&
110 strcmp(levels[i].name, name) == 0) {
111 return &levels[i].data;
118 basic testing of all RAW_SEARCH_* calls using a single file
120 static BOOL test_one_file(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
124 const char *fname = "\\torture_search.txt";
125 const char *fname2 = "\\torture_search-NOTEXIST.txt";
128 union smb_fileinfo all_info, alt_info, name_info, internal_info;
129 union smb_search_data *s;
131 printf("Testing one file searches\n");
133 fnum = create_complex_file(cli, mem_ctx, fname);
135 printf("ERROR: open of %s failed (%s)\n", fname, smbcli_errstr(cli->tree));
140 /* call all the levels */
141 for (i=0;i<ARRAY_SIZE(levels);i++) {
142 NTSTATUS expected_status;
143 uint32_t cap = cli->transport->negotiate.capabilities;
145 printf("testing %s\n", levels[i].name);
147 levels[i].status = single_search(cli, mem_ctx, fname,
148 levels[i].level, &levels[i].data);
150 /* see if this server claims to support this level */
151 if ((cap & levels[i].capability_mask) != levels[i].capability_mask) {
152 printf("search level %s(%d) not supported by server\n",
153 levels[i].name, (int)levels[i].level);
157 if (!NT_STATUS_IS_OK(levels[i].status)) {
158 printf("search level %s(%d) failed - %s\n",
159 levels[i].name, (int)levels[i].level,
160 nt_errstr(levels[i].status));
165 status = single_search(cli, mem_ctx, fname2,
166 levels[i].level, &levels[i].data);
168 expected_status = NT_STATUS_NO_SUCH_FILE;
169 if (levels[i].level == RAW_SEARCH_SEARCH ||
170 levels[i].level == RAW_SEARCH_FFIRST ||
171 levels[i].level == RAW_SEARCH_FUNIQUE) {
172 expected_status = STATUS_NO_MORE_FILES;
174 if (!NT_STATUS_EQUAL(status, expected_status)) {
175 printf("search level %s(%d) should fail with %s - %s\n",
176 levels[i].name, (int)levels[i].level,
177 nt_errstr(expected_status),
183 /* get the all_info file into to check against */
184 all_info.generic.level = RAW_FILEINFO_ALL_INFO;
185 all_info.generic.in.fname = fname;
186 status = smb_raw_pathinfo(cli->tree, mem_ctx, &all_info);
187 if (!NT_STATUS_IS_OK(status)) {
188 printf("RAW_FILEINFO_ALL_INFO failed - %s\n", nt_errstr(status));
193 alt_info.generic.level = RAW_FILEINFO_ALT_NAME_INFO;
194 alt_info.generic.in.fname = fname;
195 status = smb_raw_pathinfo(cli->tree, mem_ctx, &alt_info);
196 if (!NT_STATUS_IS_OK(status)) {
197 printf("RAW_FILEINFO_ALT_NAME_INFO failed - %s\n", nt_errstr(status));
202 internal_info.generic.level = RAW_FILEINFO_INTERNAL_INFORMATION;
203 internal_info.generic.in.fname = fname;
204 status = smb_raw_pathinfo(cli->tree, mem_ctx, &internal_info);
205 if (!NT_STATUS_IS_OK(status)) {
206 printf("RAW_FILEINFO_INTERNAL_INFORMATION failed - %s\n", nt_errstr(status));
211 name_info.generic.level = RAW_FILEINFO_NAME_INFO;
212 name_info.generic.in.fname = fname;
213 status = smb_raw_pathinfo(cli->tree, mem_ctx, &name_info);
214 if (!NT_STATUS_IS_OK(status)) {
215 printf("RAW_FILEINFO_NAME_INFO failed - %s\n", nt_errstr(status));
220 #define CHECK_VAL(name, sname1, field1, v, sname2, field2) do { \
223 if ((s->sname1.field1) != (v.sname2.out.field2)) { \
224 printf("(%s) %s/%s [0x%x] != %s/%s [0x%x]\n", \
226 #sname1, #field1, (int)s->sname1.field1, \
227 #sname2, #field2, (int)v.sname2.out.field2); \
232 #define CHECK_TIME(name, sname1, field1, v, sname2, field2) do { \
235 if (s->sname1.field1 != (~1 & nt_time_to_unix(v.sname2.out.field2))) { \
236 printf("(%s) %s/%s [%s] != %s/%s [%s]\n", \
238 #sname1, #field1, timestring(mem_ctx, s->sname1.field1), \
239 #sname2, #field2, nt_time_string(mem_ctx, v.sname2.out.field2)); \
244 #define CHECK_NTTIME(name, sname1, field1, v, sname2, field2) do { \
247 if (s->sname1.field1 != v.sname2.out.field2) { \
248 printf("(%s) %s/%s [%s] != %s/%s [%s]\n", \
250 #sname1, #field1, nt_time_string(mem_ctx, s->sname1.field1), \
251 #sname2, #field2, nt_time_string(mem_ctx, v.sname2.out.field2)); \
256 #define CHECK_STR(name, sname1, field1, v, sname2, field2) do { \
259 if (!s->sname1.field1 || strcmp(s->sname1.field1, v.sname2.out.field2.s)) { \
260 printf("(%s) %s/%s [%s] != %s/%s [%s]\n", \
262 #sname1, #field1, s->sname1.field1, \
263 #sname2, #field2, v.sname2.out.field2.s); \
268 #define CHECK_WSTR(name, sname1, field1, v, sname2, field2, flags) do { \
271 if (!s->sname1.field1.s || \
272 strcmp(s->sname1.field1.s, v.sname2.out.field2.s) || \
273 wire_bad_flags(&s->sname1.field1, flags, cli)) { \
274 printf("(%s) %s/%s [%s] != %s/%s [%s]\n", \
276 #sname1, #field1, s->sname1.field1.s, \
277 #sname2, #field2, v.sname2.out.field2.s); \
282 #define CHECK_NAME(name, sname1, field1, fname, flags) do { \
285 if (!s->sname1.field1.s || \
286 strcmp(s->sname1.field1.s, fname) || \
287 wire_bad_flags(&s->sname1.field1, flags, cli)) { \
288 printf("(%s) %s/%s [%s] != %s\n", \
290 #sname1, #field1, s->sname1.field1.s, \
296 #define CHECK_UNIX_NAME(name, sname1, field1, fname, flags) do { \
299 if (!s->sname1.field1 || \
300 strcmp(s->sname1.field1, fname)) { \
301 printf("(%s) %s/%s [%s] != %s\n", \
303 #sname1, #field1, s->sname1.field1, \
309 /* check that all the results are as expected */
310 CHECK_VAL("SEARCH", search, attrib, all_info, all_info, attrib&0xFFF);
311 CHECK_VAL("STANDARD", standard, attrib, all_info, all_info, attrib&0xFFF);
312 CHECK_VAL("EA_SIZE", ea_size, attrib, all_info, all_info, attrib&0xFFF);
313 CHECK_VAL("DIRECTORY_INFO", directory_info, attrib, all_info, all_info, attrib);
314 CHECK_VAL("FULL_DIRECTORY_INFO", full_directory_info, attrib, all_info, all_info, attrib);
315 CHECK_VAL("BOTH_DIRECTORY_INFO", both_directory_info, attrib, all_info, all_info, attrib);
316 CHECK_VAL("ID_FULL_DIRECTORY_INFO", id_full_directory_info, attrib, all_info, all_info, attrib);
317 CHECK_VAL("ID_BOTH_DIRECTORY_INFO", id_both_directory_info, attrib, all_info, all_info, attrib);
319 CHECK_TIME("SEARCH", search, write_time, all_info, all_info, write_time);
320 CHECK_TIME("STANDARD", standard, write_time, all_info, all_info, write_time);
321 CHECK_TIME("EA_SIZE", ea_size, write_time, all_info, all_info, write_time);
322 CHECK_TIME("STANDARD", standard, create_time, all_info, all_info, create_time);
323 CHECK_TIME("EA_SIZE", ea_size, create_time, all_info, all_info, create_time);
324 CHECK_TIME("STANDARD", standard, access_time, all_info, all_info, access_time);
325 CHECK_TIME("EA_SIZE", ea_size, access_time, all_info, all_info, access_time);
327 CHECK_NTTIME("DIRECTORY_INFO", directory_info, write_time, all_info, all_info, write_time);
328 CHECK_NTTIME("FULL_DIRECTORY_INFO", full_directory_info, write_time, all_info, all_info, write_time);
329 CHECK_NTTIME("BOTH_DIRECTORY_INFO", both_directory_info, write_time, all_info, all_info, write_time);
330 CHECK_NTTIME("ID_FULL_DIRECTORY_INFO", id_full_directory_info, write_time, all_info, all_info, write_time);
331 CHECK_NTTIME("ID_BOTH_DIRECTORY_INFO", id_both_directory_info, write_time, all_info, all_info, write_time);
333 CHECK_NTTIME("DIRECTORY_INFO", directory_info, create_time, all_info, all_info, create_time);
334 CHECK_NTTIME("FULL_DIRECTORY_INFO", full_directory_info, create_time, all_info, all_info, create_time);
335 CHECK_NTTIME("BOTH_DIRECTORY_INFO", both_directory_info, create_time, all_info, all_info, create_time);
336 CHECK_NTTIME("ID_FULL_DIRECTORY_INFO", id_full_directory_info, create_time, all_info, all_info, create_time);
337 CHECK_NTTIME("ID_BOTH_DIRECTORY_INFO", id_both_directory_info, create_time, all_info, all_info, create_time);
339 CHECK_NTTIME("DIRECTORY_INFO", directory_info, access_time, all_info, all_info, access_time);
340 CHECK_NTTIME("FULL_DIRECTORY_INFO", full_directory_info, access_time, all_info, all_info, access_time);
341 CHECK_NTTIME("BOTH_DIRECTORY_INFO", both_directory_info, access_time, all_info, all_info, access_time);
342 CHECK_NTTIME("ID_FULL_DIRECTORY_INFO", id_full_directory_info, access_time, all_info, all_info, access_time);
343 CHECK_NTTIME("ID_BOTH_DIRECTORY_INFO", id_both_directory_info, access_time, all_info, all_info, access_time);
345 CHECK_NTTIME("DIRECTORY_INFO", directory_info, create_time, all_info, all_info, create_time);
346 CHECK_NTTIME("FULL_DIRECTORY_INFO", full_directory_info, create_time, all_info, all_info, create_time);
347 CHECK_NTTIME("BOTH_DIRECTORY_INFO", both_directory_info, create_time, all_info, all_info, create_time);
348 CHECK_NTTIME("ID_FULL_DIRECTORY_INFO", id_full_directory_info, create_time, all_info, all_info, create_time);
349 CHECK_NTTIME("ID_BOTH_DIRECTORY_INFO", id_both_directory_info, create_time, all_info, all_info, create_time);
351 CHECK_VAL("SEARCH", search, size, all_info, all_info, size);
352 CHECK_VAL("STANDARD", standard, size, all_info, all_info, size);
353 CHECK_VAL("EA_SIZE", ea_size, size, all_info, all_info, size);
354 CHECK_VAL("DIRECTORY_INFO", directory_info, size, all_info, all_info, size);
355 CHECK_VAL("FULL_DIRECTORY_INFO", full_directory_info, size, all_info, all_info, size);
356 CHECK_VAL("BOTH_DIRECTORY_INFO", both_directory_info, size, all_info, all_info, size);
357 CHECK_VAL("ID_FULL_DIRECTORY_INFO", id_full_directory_info, size, all_info, all_info, size);
358 CHECK_VAL("ID_BOTH_DIRECTORY_INFO", id_both_directory_info, size, all_info, all_info, size);
359 CHECK_VAL("UNIX_INFO", unix_info, size, all_info, all_info, size);
361 CHECK_VAL("STANDARD", standard, alloc_size, all_info, all_info, alloc_size);
362 CHECK_VAL("EA_SIZE", ea_size, alloc_size, all_info, all_info, alloc_size);
363 CHECK_VAL("DIRECTORY_INFO", directory_info, alloc_size, all_info, all_info, alloc_size);
364 CHECK_VAL("FULL_DIRECTORY_INFO", full_directory_info, alloc_size, all_info, all_info, alloc_size);
365 CHECK_VAL("BOTH_DIRECTORY_INFO", both_directory_info, alloc_size, all_info, all_info, alloc_size);
366 CHECK_VAL("ID_FULL_DIRECTORY_INFO", id_full_directory_info, alloc_size, all_info, all_info, alloc_size);
367 CHECK_VAL("ID_BOTH_DIRECTORY_INFO", id_both_directory_info, alloc_size, all_info, all_info, alloc_size);
368 CHECK_VAL("UNIX_INFO", unix_info, alloc_size, all_info, all_info, alloc_size);
370 CHECK_VAL("EA_SIZE", ea_size, ea_size, all_info, all_info, ea_size);
371 CHECK_VAL("FULL_DIRECTORY_INFO", full_directory_info, ea_size, all_info, all_info, ea_size);
372 CHECK_VAL("BOTH_DIRECTORY_INFO", both_directory_info, ea_size, all_info, all_info, ea_size);
373 CHECK_VAL("ID_FULL_DIRECTORY_INFO", id_full_directory_info, ea_size, all_info, all_info, ea_size);
374 CHECK_VAL("ID_BOTH_DIRECTORY_INFO", id_both_directory_info, ea_size, all_info, all_info, ea_size);
376 CHECK_STR("SEARCH", search, name, alt_info, alt_name_info, fname);
377 CHECK_WSTR("BOTH_DIRECTORY_INFO", both_directory_info, short_name, alt_info, alt_name_info, fname, STR_UNICODE);
379 CHECK_NAME("STANDARD", standard, name, fname+1, 0);
380 CHECK_NAME("EA_SIZE", ea_size, name, fname+1, 0);
381 CHECK_NAME("DIRECTORY_INFO", directory_info, name, fname+1, STR_TERMINATE_ASCII);
382 CHECK_NAME("FULL_DIRECTORY_INFO", full_directory_info, name, fname+1, STR_TERMINATE_ASCII);
383 CHECK_NAME("NAME_INFO", name_info, name, fname+1, STR_TERMINATE_ASCII);
384 CHECK_NAME("BOTH_DIRECTORY_INFO", both_directory_info, name, fname+1, STR_TERMINATE_ASCII);
385 CHECK_NAME("ID_FULL_DIRECTORY_INFO", id_full_directory_info, name, fname+1, STR_TERMINATE_ASCII);
386 CHECK_NAME("ID_BOTH_DIRECTORY_INFO", id_both_directory_info, name, fname+1, STR_TERMINATE_ASCII);
387 CHECK_UNIX_NAME("UNIX_INFO", unix_info, name, fname+1, STR_TERMINATE_ASCII);
389 CHECK_VAL("ID_FULL_DIRECTORY_INFO", id_full_directory_info, file_id, internal_info, internal_information, file_id);
390 CHECK_VAL("ID_BOTH_DIRECTORY_INFO", id_both_directory_info, file_id, internal_info, internal_information, file_id);
393 smb_raw_exit(cli->session);
394 smbcli_unlink(cli->tree, fname);
400 struct multiple_result {
403 union smb_search_data *list;
407 callback function for multiple_search
409 static BOOL multiple_search_callback(void *private, union smb_search_data *file)
411 struct multiple_result *data = private;
415 data->list = talloc_realloc(data->mem_ctx,
417 union smb_search_data,
420 data->list[data->count-1] = *file;
425 enum continue_type {CONT_FLAGS, CONT_NAME, CONT_RESUME_KEY};
428 do a single file (non-wildcard) search
430 static NTSTATUS multiple_search(struct smbcli_state *cli,
433 enum smb_search_level level,
434 enum continue_type cont_type,
437 union smb_search_first io;
438 union smb_search_next io2;
440 const int per_search = 300;
441 struct multiple_result *result = data;
443 io.generic.level = level;
444 if (level == RAW_SEARCH_SEARCH) {
445 io.search_first.in.max_count = per_search;
446 io.search_first.in.search_attrib = 0;
447 io.search_first.in.pattern = pattern;
449 io.t2ffirst.in.search_attrib = 0;
450 io.t2ffirst.in.max_count = per_search;
451 io.t2ffirst.in.flags = FLAG_TRANS2_FIND_CLOSE_IF_END;
452 io.t2ffirst.in.storage_type = 0;
453 io.t2ffirst.in.pattern = pattern;
454 if (cont_type == CONT_RESUME_KEY) {
455 io.t2ffirst.in.flags |= FLAG_TRANS2_FIND_REQUIRE_RESUME |
456 FLAG_TRANS2_FIND_BACKUP_INTENT;
460 status = smb_raw_search_first(cli->tree, mem_ctx,
461 &io, data, multiple_search_callback);
464 while (NT_STATUS_IS_OK(status)) {
465 io2.generic.level = level;
466 if (level == RAW_SEARCH_SEARCH) {
467 io2.search_next.in.max_count = per_search;
468 io2.search_next.in.search_attrib = 0;
469 io2.search_next.in.id = result->list[result->count-1].search.id;
471 io2.t2fnext.in.handle = io.t2ffirst.out.handle;
472 io2.t2fnext.in.max_count = per_search;
473 io2.t2fnext.in.resume_key = 0;
474 io2.t2fnext.in.flags = FLAG_TRANS2_FIND_CLOSE_IF_END;
475 io2.t2fnext.in.last_name = "";
477 case CONT_RESUME_KEY:
478 if (level == RAW_SEARCH_STANDARD) {
479 io2.t2fnext.in.resume_key =
480 result->list[result->count-1].standard.resume_key;
481 } else if (level == RAW_SEARCH_EA_SIZE) {
482 io2.t2fnext.in.resume_key =
483 result->list[result->count-1].ea_size.resume_key;
484 } else if (level == RAW_SEARCH_DIRECTORY_INFO) {
485 io2.t2fnext.in.resume_key =
486 result->list[result->count-1].directory_info.file_index;
488 io2.t2fnext.in.resume_key =
489 result->list[result->count-1].both_directory_info.file_index;
491 if (io2.t2fnext.in.resume_key == 0) {
492 printf("Server does not support resume by key\n");
493 return NT_STATUS_NOT_SUPPORTED;
495 io2.t2fnext.in.flags |= FLAG_TRANS2_FIND_REQUIRE_RESUME |
496 FLAG_TRANS2_FIND_BACKUP_INTENT;
499 if (level == RAW_SEARCH_STANDARD) {
500 io2.t2fnext.in.last_name =
501 result->list[result->count-1].standard.name.s;
502 } else if (level == RAW_SEARCH_EA_SIZE) {
503 io2.t2fnext.in.last_name =
504 result->list[result->count-1].ea_size.name.s;
505 } else if (level == RAW_SEARCH_DIRECTORY_INFO) {
506 io2.t2fnext.in.last_name =
507 result->list[result->count-1].directory_info.name.s;
509 io2.t2fnext.in.last_name =
510 result->list[result->count-1].both_directory_info.name.s;
514 io2.t2fnext.in.flags |= FLAG_TRANS2_FIND_CONTINUE;
519 status = smb_raw_search_next(cli->tree, mem_ctx,
520 &io2, data, multiple_search_callback);
521 if (!NT_STATUS_IS_OK(status)) {
524 if (level == RAW_SEARCH_SEARCH) {
525 if (io2.search_next.out.count == 0) {
528 } else if (io2.t2fnext.out.count == 0 ||
529 io2.t2fnext.out.end_of_search) {
537 #define CHECK_STATUS(status, correct) do { \
538 if (!NT_STATUS_EQUAL(status, correct)) { \
539 printf("(%s) Incorrect status %s - should be %s\n", \
540 __location__, nt_errstr(status), nt_errstr(correct)); \
545 #define CHECK_VALUE(v, correct) do { \
546 if ((v) != (correct)) { \
547 printf("(%s) Incorrect value %s=%d - should be %d\n", \
548 __location__, #v, v, correct); \
552 #define CHECK_STRING(v, correct) do { \
553 if (StrCaseCmp(v, correct) != 0) { \
554 printf("(%s) Incorrect value %s='%s' - should be '%s'\n", \
555 __location__, #v, v, correct); \
560 static int search_both_compare(union smb_search_data *d1, union smb_search_data *d2)
562 return strcmp_safe(d1->both_directory_info.name.s, d2->both_directory_info.name.s);
565 static int search_standard_compare(union smb_search_data *d1, union smb_search_data *d2)
567 return strcmp_safe(d1->standard.name.s, d2->standard.name.s);
570 static int search_ea_size_compare(union smb_search_data *d1, union smb_search_data *d2)
572 return strcmp_safe(d1->ea_size.name.s, d2->ea_size.name.s);
575 static int search_directory_info_compare(union smb_search_data *d1, union smb_search_data *d2)
577 return strcmp_safe(d1->directory_info.name.s, d2->directory_info.name.s);
580 static int search_old_compare(union smb_search_data *d1, union smb_search_data *d2)
582 return strcmp_safe(d1->search.name, d2->search.name);
587 basic testing of search calls using many files
589 static BOOL test_many_files(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
591 const int num_files = 700;
596 struct multiple_result result;
599 const char *cont_name;
600 enum smb_search_level level;
601 enum continue_type cont_type;
603 {"SEARCH", "ID", RAW_SEARCH_SEARCH, CONT_RESUME_KEY},
604 {"BOTH_DIRECTORY_INFO", "NAME", RAW_SEARCH_BOTH_DIRECTORY_INFO, CONT_NAME},
605 {"BOTH_DIRECTORY_INFO", "FLAGS", RAW_SEARCH_BOTH_DIRECTORY_INFO, CONT_FLAGS},
606 {"BOTH_DIRECTORY_INFO", "KEY", RAW_SEARCH_BOTH_DIRECTORY_INFO, CONT_RESUME_KEY},
607 {"STANDARD", "FLAGS", RAW_SEARCH_STANDARD, CONT_FLAGS},
608 {"STANDARD", "KEY", RAW_SEARCH_STANDARD, CONT_RESUME_KEY},
609 {"STANDARD", "NAME", RAW_SEARCH_STANDARD, CONT_NAME},
610 {"EA_SIZE", "FLAGS", RAW_SEARCH_EA_SIZE, CONT_FLAGS},
611 {"EA_SIZE", "KEY", RAW_SEARCH_EA_SIZE, CONT_RESUME_KEY},
612 {"EA_SIZE", "NAME", RAW_SEARCH_EA_SIZE, CONT_NAME},
613 {"DIRECTORY_INFO", "FLAGS", RAW_SEARCH_DIRECTORY_INFO, CONT_FLAGS},
614 {"DIRECTORY_INFO", "KEY", RAW_SEARCH_DIRECTORY_INFO, CONT_RESUME_KEY},
615 {"DIRECTORY_INFO", "NAME", RAW_SEARCH_DIRECTORY_INFO, CONT_NAME}
618 if (!torture_setup_dir(cli, BASEDIR)) {
622 printf("Creating %d files\n", num_files);
624 for (i=0;i<num_files;i++) {
625 asprintf(&fname, BASEDIR "\\t%03d-%d.txt", i, i);
626 fnum = smbcli_open(cli->tree, fname, O_CREAT|O_RDWR, DENY_NONE);
628 printf("Failed to create %s - %s\n", fname, smbcli_errstr(cli->tree));
633 smbcli_close(cli->tree, fnum);
637 for (t=0;t<ARRAY_SIZE(search_types);t++) {
639 result.mem_ctx = talloc_new(mem_ctx);
641 printf("Continue %s via %s\n", search_types[t].name, search_types[t].cont_name);
643 status = multiple_search(cli, mem_ctx, BASEDIR "\\*.*",
644 search_types[t].level,
645 search_types[t].cont_type,
648 if (!NT_STATUS_IS_OK(status)) {
649 printf("search failed - %s\n", nt_errstr(status));
653 CHECK_VALUE(result.count, num_files);
655 if (search_types[t].level == RAW_SEARCH_BOTH_DIRECTORY_INFO) {
656 qsort(result.list, result.count, sizeof(result.list[0]),
657 QSORT_CAST search_both_compare);
658 } else if (search_types[t].level == RAW_SEARCH_STANDARD) {
659 qsort(result.list, result.count, sizeof(result.list[0]),
660 QSORT_CAST search_standard_compare);
661 } else if (search_types[t].level == RAW_SEARCH_EA_SIZE) {
662 qsort(result.list, result.count, sizeof(result.list[0]),
663 QSORT_CAST search_ea_size_compare);
664 } else if (search_types[t].level == RAW_SEARCH_DIRECTORY_INFO) {
665 qsort(result.list, result.count, sizeof(result.list[0]),
666 QSORT_CAST search_directory_info_compare);
668 qsort(result.list, result.count, sizeof(result.list[0]),
669 QSORT_CAST search_old_compare);
672 for (i=0;i<result.count;i++) {
674 if (search_types[t].level == RAW_SEARCH_BOTH_DIRECTORY_INFO) {
675 s = result.list[i].both_directory_info.name.s;
676 } else if (search_types[t].level == RAW_SEARCH_STANDARD) {
677 s = result.list[i].standard.name.s;
678 } else if (search_types[t].level == RAW_SEARCH_EA_SIZE) {
679 s = result.list[i].ea_size.name.s;
680 } else if (search_types[t].level == RAW_SEARCH_DIRECTORY_INFO) {
681 s = result.list[i].directory_info.name.s;
683 s = result.list[i].search.name;
685 asprintf(&fname, "t%03d-%d.txt", i, i);
686 if (strcmp(fname, s)) {
687 printf("Incorrect name %s at entry %d\n", s, i);
693 talloc_free(result.mem_ctx);
697 smb_raw_exit(cli->session);
698 smbcli_deltree(cli->tree, BASEDIR);
704 check a individual file result
706 static BOOL check_result(struct multiple_result *result, const char *name, BOOL exist, uint32_t attrib)
709 for (i=0;i<result->count;i++) {
710 if (strcmp(name, result->list[i].both_directory_info.name.s) == 0) break;
712 if (i == result->count) {
714 printf("failed: '%s' should exist with attribute %s\n",
715 name, attrib_string(result->list, attrib));
722 printf("failed: '%s' should NOT exist (has attribute %s)\n",
723 name, attrib_string(result->list, result->list[i].both_directory_info.attrib));
727 if ((result->list[i].both_directory_info.attrib&0xFFF) != attrib) {
728 printf("failed: '%s' should have attribute 0x%x (has 0x%x)\n",
730 attrib, result->list[i].both_directory_info.attrib);
737 test what happens when the directory is modified during a search
739 static BOOL test_modify_search(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
741 const int num_files = 20;
746 struct multiple_result result;
747 union smb_search_first io;
748 union smb_search_next io2;
749 union smb_setfileinfo sfinfo;
751 if (!torture_setup_dir(cli, BASEDIR)) {
755 printf("Creating %d files\n", num_files);
757 for (i=num_files-1;i>=0;i--) {
758 asprintf(&fname, BASEDIR "\\t%03d-%d.txt", i, i);
759 fnum = smbcli_open(cli->tree, fname, O_CREAT|O_RDWR, DENY_NONE);
761 printf("Failed to create %s - %s\n", fname, smbcli_errstr(cli->tree));
766 smbcli_close(cli->tree, fnum);
769 printf("pulling the first file\n");
771 result.mem_ctx = talloc_new(mem_ctx);
773 io.generic.level = RAW_SEARCH_BOTH_DIRECTORY_INFO;
774 io.t2ffirst.in.search_attrib = 0;
775 io.t2ffirst.in.max_count = 0;
776 io.t2ffirst.in.flags = 0;
777 io.t2ffirst.in.storage_type = 0;
778 io.t2ffirst.in.pattern = BASEDIR "\\*.*";
780 status = smb_raw_search_first(cli->tree, mem_ctx,
781 &io, &result, multiple_search_callback);
782 CHECK_STATUS(status, NT_STATUS_OK);
783 CHECK_VALUE(result.count, 1);
785 printf("pulling the second file\n");
786 io2.generic.level = RAW_SEARCH_BOTH_DIRECTORY_INFO;
787 io2.t2fnext.in.handle = io.t2ffirst.out.handle;
788 io2.t2fnext.in.max_count = 1;
789 io2.t2fnext.in.resume_key = 0;
790 io2.t2fnext.in.flags = 0;
791 if (result.count == 0) {
792 io2.t2fnext.in.last_name = "";
794 io2.t2fnext.in.last_name = result.list[result.count-1].both_directory_info.name.s;
797 status = smb_raw_search_next(cli->tree, mem_ctx,
798 &io2, &result, multiple_search_callback);
799 CHECK_STATUS(status, NT_STATUS_OK);
800 CHECK_VALUE(result.count, 2);
802 printf("Changing attributes and deleting\n");
803 smbcli_open(cli->tree, BASEDIR "\\T003-03.txt.2", O_CREAT|O_RDWR, DENY_NONE);
804 smbcli_open(cli->tree, BASEDIR "\\T013-13.txt.2", O_CREAT|O_RDWR, DENY_NONE);
805 fnum = create_complex_file(cli, mem_ctx, BASEDIR "\\T013-13.txt.3");
806 smbcli_unlink(cli->tree, BASEDIR "\\T014-14.txt");
807 torture_set_file_attribute(cli->tree, BASEDIR "\\T015-15.txt", FILE_ATTRIBUTE_HIDDEN);
808 torture_set_file_attribute(cli->tree, BASEDIR "\\T016-16.txt", FILE_ATTRIBUTE_NORMAL);
809 torture_set_file_attribute(cli->tree, BASEDIR "\\T017-17.txt", FILE_ATTRIBUTE_SYSTEM);
810 torture_set_file_attribute(cli->tree, BASEDIR "\\T018-18.txt", 0);
811 sfinfo.generic.level = RAW_SFILEINFO_DISPOSITION_INFORMATION;
812 sfinfo.generic.file.fnum = fnum;
813 sfinfo.disposition_info.in.delete_on_close = 1;
814 status = smb_raw_setfileinfo(cli->tree, &sfinfo);
815 CHECK_STATUS(status, NT_STATUS_OK);
817 io2.generic.level = RAW_SEARCH_BOTH_DIRECTORY_INFO;
818 io2.t2fnext.in.handle = io.t2ffirst.out.handle;
819 io2.t2fnext.in.max_count = num_files - 1;
820 io2.t2fnext.in.resume_key = 0;
821 io2.t2fnext.in.flags = 0;
822 io2.t2fnext.in.last_name = result.list[result.count-2].both_directory_info.name.s;
824 status = smb_raw_search_next(cli->tree, mem_ctx,
825 &io2, &result, multiple_search_callback);
826 CHECK_STATUS(status, NT_STATUS_OK);
827 CHECK_VALUE(result.count, 21);
829 ret &= check_result(&result, "t009-9.txt", True, FILE_ATTRIBUTE_ARCHIVE);
830 ret &= check_result(&result, "t014-14.txt", False, 0);
831 ret &= check_result(&result, "t015-15.txt", False, 0);
832 ret &= check_result(&result, "t016-16.txt", True, FILE_ATTRIBUTE_NORMAL);
833 ret &= check_result(&result, "t017-17.txt", False, 0);
834 ret &= check_result(&result, "t018-18.txt", True, FILE_ATTRIBUTE_ARCHIVE);
835 ret &= check_result(&result, "t019-19.txt", True, FILE_ATTRIBUTE_ARCHIVE);
836 ret &= check_result(&result, "T013-13.txt.2", True, FILE_ATTRIBUTE_ARCHIVE);
837 ret &= check_result(&result, "T003-3.txt.2", False, 0);
838 ret &= check_result(&result, "T013-13.txt.3", True, FILE_ATTRIBUTE_ARCHIVE);
841 for (i=0;i<result.count;i++) {
842 printf("%s %s (0x%x)\n",
843 result.list[i].both_directory_info.name.s,
844 attrib_string(mem_ctx, result.list[i].both_directory_info.attrib),
845 result.list[i].both_directory_info.attrib);
850 smb_raw_exit(cli->session);
851 smbcli_deltree(cli->tree, BASEDIR);
858 testing if directories always come back sorted
860 static BOOL test_sorted(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
862 const int num_files = 700;
867 struct multiple_result result;
869 if (!torture_setup_dir(cli, BASEDIR)) {
873 printf("Creating %d files\n", num_files);
875 for (i=0;i<num_files;i++) {
876 asprintf(&fname, BASEDIR "\\%s.txt", generate_random_str_list(mem_ctx, 10, "abcdefgh"));
877 fnum = smbcli_open(cli->tree, fname, O_CREAT|O_RDWR, DENY_NONE);
879 printf("Failed to create %s - %s\n", fname, smbcli_errstr(cli->tree));
884 smbcli_close(cli->tree, fnum);
889 result.mem_ctx = mem_ctx;
891 status = multiple_search(cli, mem_ctx, BASEDIR "\\*.*",
892 RAW_SEARCH_BOTH_DIRECTORY_INFO,
894 CHECK_STATUS(status, NT_STATUS_OK);
895 CHECK_VALUE(result.count, num_files);
897 for (i=0;i<num_files-1;i++) {
898 const char *name1, *name2;
899 name1 = result.list[i].both_directory_info.name.s;
900 name2 = result.list[i+1].both_directory_info.name.s;
901 if (StrCaseCmp(name1, name2) > 0) {
902 printf("non-alphabetical order at entry %d '%s' '%s'\n",
904 printf("Server does not produce sorted directory listings (not an error)\n");
909 talloc_free(result.list);
912 smb_raw_exit(cli->session);
913 smbcli_deltree(cli->tree, BASEDIR);
921 basic testing of many old style search calls using separate dirs
923 static BOOL test_many_dirs(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
925 const int num_dirs = 300;
930 union smb_search_data *file, *file2, *file3;
932 if (!torture_setup_dir(cli, BASEDIR)) {
936 printf("Creating %d dirs\n", num_dirs);
938 for (i=0;i<num_dirs;i++) {
939 asprintf(&dname, BASEDIR "\\d%d", i);
940 status = smbcli_mkdir(cli->tree, dname);
941 if (!NT_STATUS_IS_OK(status)) {
942 printf("(%s) Failed to create %s - %s\n",
943 __location__, dname, nt_errstr(status));
949 asprintf(&fname, BASEDIR "\\d%d\\f%d-%d.txt", i, i, n);
950 fnum = smbcli_open(cli->tree, fname, O_CREAT|O_RDWR, DENY_NONE);
952 printf("(%s) Failed to create %s - %s\n",
953 __location__, fname, smbcli_errstr(cli->tree));
961 smbcli_close(cli->tree, fnum);
964 file = talloc_zero_array(mem_ctx, union smb_search_data, num_dirs);
965 file2 = talloc_zero_array(mem_ctx, union smb_search_data, num_dirs);
966 file3 = talloc_zero_array(mem_ctx, union smb_search_data, num_dirs);
968 printf("Search first on %d dirs\n", num_dirs);
970 for (i=0;i<num_dirs;i++) {
971 union smb_search_first io;
972 io.generic.level = RAW_SEARCH_SEARCH;
973 io.search_first.in.max_count = 1;
974 io.search_first.in.search_attrib = 0;
975 io.search_first.in.pattern = talloc_asprintf(mem_ctx, BASEDIR "\\d%d\\*.txt", i);
976 fname = talloc_asprintf(mem_ctx, "f%d-", i);
978 io.search_first.out.count = 0;
980 status = smb_raw_search_first(cli->tree, mem_ctx,
981 &io, (void *)&file[i], single_search_callback);
982 if (io.search_first.out.count != 1) {
983 printf("(%s) search first gave %d entries for dir %d - %s\n",
984 __location__, io.search_first.out.count, i, nt_errstr(status));
988 CHECK_STATUS(status, NT_STATUS_OK);
989 if (strncasecmp(file[i].search.name, fname, strlen(fname)) != 0) {
990 printf("(%s) incorrect name '%s' expected '%s'[12].txt\n",
991 __location__, file[i].search.name, fname);
999 printf("Search next on %d dirs\n", num_dirs);
1001 for (i=0;i<num_dirs;i++) {
1002 union smb_search_next io2;
1004 io2.generic.level = RAW_SEARCH_SEARCH;
1005 io2.search_next.in.max_count = 1;
1006 io2.search_next.in.search_attrib = 0;
1007 io2.search_next.in.id = file[i].search.id;
1008 fname = talloc_asprintf(mem_ctx, "f%d-", i);
1010 io2.search_next.out.count = 0;
1012 status = smb_raw_search_next(cli->tree, mem_ctx,
1013 &io2, (void *)&file2[i], single_search_callback);
1014 if (io2.search_next.out.count != 1) {
1015 printf("(%s) search next gave %d entries for dir %d - %s\n",
1016 __location__, io2.search_next.out.count, i, nt_errstr(status));
1020 CHECK_STATUS(status, NT_STATUS_OK);
1021 if (strncasecmp(file2[i].search.name, fname, strlen(fname)) != 0) {
1022 printf("(%s) incorrect name '%s' expected '%s'[12].txt\n",
1023 __location__, file2[i].search.name, fname);
1032 printf("Search next (rewind) on %d dirs\n", num_dirs);
1034 for (i=0;i<num_dirs;i++) {
1035 union smb_search_next io2;
1037 io2.generic.level = RAW_SEARCH_SEARCH;
1038 io2.search_next.in.max_count = 1;
1039 io2.search_next.in.search_attrib = 0;
1040 io2.search_next.in.id = file[i].search.id;
1041 fname = talloc_asprintf(mem_ctx, "f%d-", i);
1042 io2.search_next.out.count = 0;
1044 status = smb_raw_search_next(cli->tree, mem_ctx,
1045 &io2, (void *)&file3[i], single_search_callback);
1046 if (io2.search_next.out.count != 1) {
1047 printf("(%s) search next gave %d entries for dir %d - %s\n",
1048 __location__, io2.search_next.out.count, i, nt_errstr(status));
1052 CHECK_STATUS(status, NT_STATUS_OK);
1054 if (strncasecmp(file3[i].search.name, file2[i].search.name, 3) != 0) {
1055 printf("(%s) incorrect name '%s' on rewind at dir %d\n",
1056 __location__, file2[i].search.name, i);
1061 if (strcmp(file3[i].search.name, file2[i].search.name) != 0) {
1062 printf("(%s) server did not rewind - got '%s' expected '%s'\n",
1063 __location__, file3[i].search.name, file2[i].search.name);
1073 smb_raw_exit(cli->session);
1074 smbcli_deltree(cli->tree, BASEDIR);
1081 testing of OS/2 style delete
1083 static BOOL test_os2_delete(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
1085 const int num_files = 700;
1086 const int delete_count = 4;
1087 int total_deleted = 0;
1092 union smb_search_first io;
1093 union smb_search_next io2;
1094 struct multiple_result result;
1096 if (!torture_setup_dir(cli, BASEDIR)) {
1100 printf("Testing OS/2 style delete on %d files\n", num_files);
1102 for (i=0;i<num_files;i++) {
1103 asprintf(&fname, BASEDIR "\\file%u.txt", i);
1104 fnum = smbcli_open(cli->tree, fname, O_CREAT|O_RDWR, DENY_NONE);
1106 printf("Failed to create %s - %s\n", fname, smbcli_errstr(cli->tree));
1111 smbcli_close(cli->tree, fnum);
1115 ZERO_STRUCT(result);
1116 result.mem_ctx = mem_ctx;
1118 io.t2ffirst.level = RAW_SEARCH_EA_SIZE;
1119 io.t2ffirst.in.search_attrib = 0;
1120 io.t2ffirst.in.max_count = 100;
1121 io.t2ffirst.in.flags = FLAG_TRANS2_FIND_REQUIRE_RESUME;
1122 io.t2ffirst.in.storage_type = 0;
1123 io.t2ffirst.in.pattern = BASEDIR "\\*";
1125 status = smb_raw_search_first(cli->tree, mem_ctx,
1126 &io, &result, multiple_search_callback);
1127 CHECK_STATUS(status, NT_STATUS_OK);
1129 for (i=0;i<MIN(result.count, delete_count);i++) {
1130 asprintf(&fname, BASEDIR "\\%s", result.list[i].ea_size.name.s);
1131 status = smbcli_unlink(cli->tree, fname);
1132 CHECK_STATUS(status, NT_STATUS_OK);
1136 io2.t2fnext.level = RAW_SEARCH_EA_SIZE;
1137 io2.t2fnext.in.handle = io.t2ffirst.out.handle;
1138 io2.t2fnext.in.max_count = 100;
1139 io2.t2fnext.in.resume_key = result.list[i-1].ea_size.resume_key;
1140 io2.t2fnext.in.flags = FLAG_TRANS2_FIND_REQUIRE_RESUME;
1141 io2.t2fnext.in.last_name = result.list[i-1].ea_size.name.s;
1144 ZERO_STRUCT(result);
1145 result.mem_ctx = mem_ctx;
1147 status = smb_raw_search_next(cli->tree, mem_ctx,
1148 &io2, &result, multiple_search_callback);
1149 if (!NT_STATUS_IS_OK(status)) {
1153 for (i=0;i<MIN(result.count, delete_count);i++) {
1154 asprintf(&fname, BASEDIR "\\%s", result.list[i].ea_size.name.s);
1155 status = smbcli_unlink(cli->tree, fname);
1156 CHECK_STATUS(status, NT_STATUS_OK);
1161 io2.t2fnext.in.resume_key = result.list[i-1].ea_size.resume_key;
1162 io2.t2fnext.in.last_name = result.list[i-1].ea_size.name.s;
1164 } while (NT_STATUS_IS_OK(status) && result.count != 0);
1166 CHECK_STATUS(status, NT_STATUS_OK);
1168 if (total_deleted != num_files) {
1169 printf("error: deleted %d - expected to delete %d\n",
1170 total_deleted, num_files);
1175 smb_raw_exit(cli->session);
1176 smbcli_deltree(cli->tree, BASEDIR);
1183 testing of the rather strange ea_list level
1185 static BOOL test_ea_list(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
1190 union smb_search_first io;
1191 union smb_search_next nxt;
1192 struct multiple_result result;
1193 union smb_setfileinfo setfile;
1195 if (!torture_setup_dir(cli, BASEDIR)) {
1199 printf("Testing RAW_SEARCH_EA_LIST level\n");
1201 fnum = smbcli_open(cli->tree, BASEDIR "\\file1.txt", O_CREAT|O_RDWR, DENY_NONE);
1202 smbcli_close(cli->tree, fnum);
1204 fnum = smbcli_open(cli->tree, BASEDIR "\\file2.txt", O_CREAT|O_RDWR, DENY_NONE);
1205 smbcli_close(cli->tree, fnum);
1207 fnum = smbcli_open(cli->tree, BASEDIR "\\file3.txt", O_CREAT|O_RDWR, DENY_NONE);
1208 smbcli_close(cli->tree, fnum);
1210 setfile.generic.level = RAW_SFILEINFO_EA_SET;
1211 setfile.generic.file.fname = BASEDIR "\\file2.txt";
1212 setfile.ea_set.in.num_eas = 2;
1213 setfile.ea_set.in.eas = talloc_array(mem_ctx, struct ea_struct, 2);
1214 setfile.ea_set.in.eas[0].flags = 0;
1215 setfile.ea_set.in.eas[0].name.s = "EA ONE";
1216 setfile.ea_set.in.eas[0].value = data_blob_string_const("VALUE 1");
1217 setfile.ea_set.in.eas[1].flags = 0;
1218 setfile.ea_set.in.eas[1].name.s = "SECOND EA";
1219 setfile.ea_set.in.eas[1].value = data_blob_string_const("Value Two");
1221 status = smb_raw_setpathinfo(cli->tree, &setfile);
1222 CHECK_STATUS(status, NT_STATUS_OK);
1224 setfile.generic.file.fname = BASEDIR "\\file3.txt";
1225 status = smb_raw_setpathinfo(cli->tree, &setfile);
1226 CHECK_STATUS(status, NT_STATUS_OK);
1228 ZERO_STRUCT(result);
1229 result.mem_ctx = mem_ctx;
1231 io.t2ffirst.level = RAW_SEARCH_EA_LIST;
1232 io.t2ffirst.in.search_attrib = 0;
1233 io.t2ffirst.in.max_count = 2;
1234 io.t2ffirst.in.flags = FLAG_TRANS2_FIND_REQUIRE_RESUME;
1235 io.t2ffirst.in.storage_type = 0;
1236 io.t2ffirst.in.pattern = BASEDIR "\\*";
1237 io.t2ffirst.in.num_names = 2;
1238 io.t2ffirst.in.ea_names = talloc_array(mem_ctx, struct ea_name, 2);
1239 io.t2ffirst.in.ea_names[0].name.s = "SECOND EA";
1240 io.t2ffirst.in.ea_names[1].name.s = "THIRD EA";
1242 status = smb_raw_search_first(cli->tree, mem_ctx,
1243 &io, &result, multiple_search_callback);
1244 CHECK_STATUS(status, NT_STATUS_OK);
1245 CHECK_VALUE(result.count, 2);
1247 nxt.t2fnext.level = RAW_SEARCH_EA_LIST;
1248 nxt.t2fnext.in.handle = io.t2ffirst.out.handle;
1249 nxt.t2fnext.in.max_count = 2;
1250 nxt.t2fnext.in.resume_key = result.list[1].ea_list.resume_key;
1251 nxt.t2fnext.in.flags = FLAG_TRANS2_FIND_REQUIRE_RESUME | FLAG_TRANS2_FIND_CONTINUE;
1252 nxt.t2fnext.in.last_name = "file2.txt";
1253 nxt.t2fnext.in.num_names = 2;
1254 nxt.t2fnext.in.ea_names = talloc_array(mem_ctx, struct ea_name, 2);
1255 nxt.t2fnext.in.ea_names[0].name.s = "SECOND EA";
1256 nxt.t2fnext.in.ea_names[1].name.s = "THIRD EA";
1258 status = smb_raw_search_next(cli->tree, mem_ctx,
1259 &nxt, &result, multiple_search_callback);
1260 CHECK_STATUS(status, NT_STATUS_OK);
1263 CHECK_VALUE(result.count, 3);
1264 CHECK_VALUE(result.list[0].ea_list.eas.num_eas, 2);
1265 CHECK_STRING(result.list[0].ea_list.name.s, "file1.txt");
1266 CHECK_STRING(result.list[0].ea_list.eas.eas[0].name.s, "SECOND EA");
1267 CHECK_VALUE(result.list[0].ea_list.eas.eas[0].value.length, 0);
1268 CHECK_STRING(result.list[0].ea_list.eas.eas[1].name.s, "THIRD EA");
1269 CHECK_VALUE(result.list[0].ea_list.eas.eas[1].value.length, 0);
1271 CHECK_STRING(result.list[1].ea_list.name.s, "file2.txt");
1272 CHECK_STRING(result.list[1].ea_list.eas.eas[0].name.s, "SECOND EA");
1273 CHECK_VALUE(result.list[1].ea_list.eas.eas[0].value.length, 9);
1274 CHECK_STRING(result.list[1].ea_list.eas.eas[0].value.data, "Value Two");
1275 CHECK_STRING(result.list[1].ea_list.eas.eas[1].name.s, "THIRD EA");
1276 CHECK_VALUE(result.list[1].ea_list.eas.eas[1].value.length, 0);
1278 CHECK_STRING(result.list[2].ea_list.name.s, "file3.txt");
1279 CHECK_STRING(result.list[2].ea_list.eas.eas[0].name.s, "SECOND EA");
1280 CHECK_VALUE(result.list[2].ea_list.eas.eas[0].value.length, 9);
1281 CHECK_STRING(result.list[2].ea_list.eas.eas[0].value.data, "Value Two");
1282 CHECK_STRING(result.list[2].ea_list.eas.eas[1].name.s, "THIRD EA");
1283 CHECK_VALUE(result.list[2].ea_list.eas.eas[1].value.length, 0);
1286 smb_raw_exit(cli->session);
1287 smbcli_deltree(cli->tree, BASEDIR);
1295 basic testing of all RAW_SEARCH_* calls using a single file
1297 BOOL torture_raw_search(void)
1299 struct smbcli_state *cli;
1301 TALLOC_CTX *mem_ctx;
1303 if (!torture_open_connection(&cli)) {
1307 mem_ctx = talloc_init("torture_search");
1309 ret &= test_one_file(cli, mem_ctx);
1310 ret &= test_many_files(cli, mem_ctx);
1311 ret &= test_sorted(cli, mem_ctx);
1312 ret &= test_modify_search(cli, mem_ctx);
1313 ret &= test_many_dirs(cli, mem_ctx);
1314 ret &= test_os2_delete(cli, mem_ctx);
1315 ret &= test_ea_list(cli, mem_ctx);
1317 torture_close_connection(cli);
1318 talloc_free(mem_ctx);