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 NTSTATUS torture_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 = torture_single_search(cli, mem_ctx, fname,
151 /* see if this server claims to support this level */
152 if ((cap & levels[i].capability_mask) != levels[i].capability_mask) {
153 printf("search level %s(%d) not supported by server\n",
154 levels[i].name, (int)levels[i].level);
158 if (!NT_STATUS_IS_OK(levels[i].status)) {
159 printf("search level %s(%d) failed - %s\n",
160 levels[i].name, (int)levels[i].level,
161 nt_errstr(levels[i].status));
166 status = torture_single_search(cli, mem_ctx, fname2,
170 expected_status = NT_STATUS_NO_SUCH_FILE;
171 if (levels[i].level == RAW_SEARCH_SEARCH ||
172 levels[i].level == RAW_SEARCH_FFIRST ||
173 levels[i].level == RAW_SEARCH_FUNIQUE) {
174 expected_status = STATUS_NO_MORE_FILES;
176 if (!NT_STATUS_EQUAL(status, expected_status)) {
177 printf("search level %s(%d) should fail with %s - %s\n",
178 levels[i].name, (int)levels[i].level,
179 nt_errstr(expected_status),
185 /* get the all_info file into to check against */
186 all_info.generic.level = RAW_FILEINFO_ALL_INFO;
187 all_info.generic.in.fname = fname;
188 status = smb_raw_pathinfo(cli->tree, mem_ctx, &all_info);
189 if (!NT_STATUS_IS_OK(status)) {
190 printf("RAW_FILEINFO_ALL_INFO failed - %s\n", nt_errstr(status));
195 alt_info.generic.level = RAW_FILEINFO_ALT_NAME_INFO;
196 alt_info.generic.in.fname = fname;
197 status = smb_raw_pathinfo(cli->tree, mem_ctx, &alt_info);
198 if (!NT_STATUS_IS_OK(status)) {
199 printf("RAW_FILEINFO_ALT_NAME_INFO failed - %s\n", nt_errstr(status));
204 internal_info.generic.level = RAW_FILEINFO_INTERNAL_INFORMATION;
205 internal_info.generic.in.fname = fname;
206 status = smb_raw_pathinfo(cli->tree, mem_ctx, &internal_info);
207 if (!NT_STATUS_IS_OK(status)) {
208 printf("RAW_FILEINFO_INTERNAL_INFORMATION failed - %s\n", nt_errstr(status));
213 name_info.generic.level = RAW_FILEINFO_NAME_INFO;
214 name_info.generic.in.fname = fname;
215 status = smb_raw_pathinfo(cli->tree, mem_ctx, &name_info);
216 if (!NT_STATUS_IS_OK(status)) {
217 printf("RAW_FILEINFO_NAME_INFO failed - %s\n", nt_errstr(status));
222 #define CHECK_VAL(name, sname1, field1, v, sname2, field2) do { \
225 if ((s->sname1.field1) != (v.sname2.out.field2)) { \
226 printf("(%s) %s/%s [0x%x] != %s/%s [0x%x]\n", \
228 #sname1, #field1, (int)s->sname1.field1, \
229 #sname2, #field2, (int)v.sname2.out.field2); \
234 #define CHECK_TIME(name, sname1, field1, v, sname2, field2) do { \
237 if (s->sname1.field1 != (~1 & nt_time_to_unix(v.sname2.out.field2))) { \
238 printf("(%s) %s/%s [%s] != %s/%s [%s]\n", \
240 #sname1, #field1, timestring(mem_ctx, s->sname1.field1), \
241 #sname2, #field2, nt_time_string(mem_ctx, v.sname2.out.field2)); \
246 #define CHECK_NTTIME(name, sname1, field1, v, sname2, field2) do { \
249 if (s->sname1.field1 != v.sname2.out.field2) { \
250 printf("(%s) %s/%s [%s] != %s/%s [%s]\n", \
252 #sname1, #field1, nt_time_string(mem_ctx, s->sname1.field1), \
253 #sname2, #field2, nt_time_string(mem_ctx, v.sname2.out.field2)); \
258 #define CHECK_STR(name, sname1, field1, v, sname2, field2) do { \
261 if (!s->sname1.field1 || strcmp(s->sname1.field1, v.sname2.out.field2.s)) { \
262 printf("(%s) %s/%s [%s] != %s/%s [%s]\n", \
264 #sname1, #field1, s->sname1.field1, \
265 #sname2, #field2, v.sname2.out.field2.s); \
270 #define CHECK_WSTR(name, sname1, field1, v, sname2, field2, flags) do { \
273 if (!s->sname1.field1.s || \
274 strcmp(s->sname1.field1.s, v.sname2.out.field2.s) || \
275 wire_bad_flags(&s->sname1.field1, flags, cli)) { \
276 printf("(%s) %s/%s [%s] != %s/%s [%s]\n", \
278 #sname1, #field1, s->sname1.field1.s, \
279 #sname2, #field2, v.sname2.out.field2.s); \
284 #define CHECK_NAME(name, sname1, field1, fname, flags) do { \
287 if (!s->sname1.field1.s || \
288 strcmp(s->sname1.field1.s, fname) || \
289 wire_bad_flags(&s->sname1.field1, flags, cli)) { \
290 printf("(%s) %s/%s [%s] != %s\n", \
292 #sname1, #field1, s->sname1.field1.s, \
298 #define CHECK_UNIX_NAME(name, sname1, field1, fname, flags) do { \
301 if (!s->sname1.field1 || \
302 strcmp(s->sname1.field1, fname)) { \
303 printf("(%s) %s/%s [%s] != %s\n", \
305 #sname1, #field1, s->sname1.field1, \
311 /* check that all the results are as expected */
312 CHECK_VAL("SEARCH", search, attrib, all_info, all_info, attrib&0xFFF);
313 CHECK_VAL("STANDARD", standard, attrib, all_info, all_info, attrib&0xFFF);
314 CHECK_VAL("EA_SIZE", ea_size, attrib, all_info, all_info, attrib&0xFFF);
315 CHECK_VAL("DIRECTORY_INFO", directory_info, attrib, all_info, all_info, attrib);
316 CHECK_VAL("FULL_DIRECTORY_INFO", full_directory_info, attrib, all_info, all_info, attrib);
317 CHECK_VAL("BOTH_DIRECTORY_INFO", both_directory_info, attrib, all_info, all_info, attrib);
318 CHECK_VAL("ID_FULL_DIRECTORY_INFO", id_full_directory_info, attrib, all_info, all_info, attrib);
319 CHECK_VAL("ID_BOTH_DIRECTORY_INFO", id_both_directory_info, attrib, all_info, all_info, attrib);
321 CHECK_TIME("SEARCH", search, write_time, all_info, all_info, write_time);
322 CHECK_TIME("STANDARD", standard, write_time, all_info, all_info, write_time);
323 CHECK_TIME("EA_SIZE", ea_size, write_time, all_info, all_info, write_time);
324 CHECK_TIME("STANDARD", standard, create_time, all_info, all_info, create_time);
325 CHECK_TIME("EA_SIZE", ea_size, create_time, all_info, all_info, create_time);
326 CHECK_TIME("STANDARD", standard, access_time, all_info, all_info, access_time);
327 CHECK_TIME("EA_SIZE", ea_size, access_time, all_info, all_info, access_time);
329 CHECK_NTTIME("DIRECTORY_INFO", directory_info, write_time, all_info, all_info, write_time);
330 CHECK_NTTIME("FULL_DIRECTORY_INFO", full_directory_info, write_time, all_info, all_info, write_time);
331 CHECK_NTTIME("BOTH_DIRECTORY_INFO", both_directory_info, write_time, all_info, all_info, write_time);
332 CHECK_NTTIME("ID_FULL_DIRECTORY_INFO", id_full_directory_info, write_time, all_info, all_info, write_time);
333 CHECK_NTTIME("ID_BOTH_DIRECTORY_INFO", id_both_directory_info, write_time, all_info, all_info, write_time);
335 CHECK_NTTIME("DIRECTORY_INFO", directory_info, create_time, all_info, all_info, create_time);
336 CHECK_NTTIME("FULL_DIRECTORY_INFO", full_directory_info, create_time, all_info, all_info, create_time);
337 CHECK_NTTIME("BOTH_DIRECTORY_INFO", both_directory_info, create_time, all_info, all_info, create_time);
338 CHECK_NTTIME("ID_FULL_DIRECTORY_INFO", id_full_directory_info, create_time, all_info, all_info, create_time);
339 CHECK_NTTIME("ID_BOTH_DIRECTORY_INFO", id_both_directory_info, create_time, all_info, all_info, create_time);
341 CHECK_NTTIME("DIRECTORY_INFO", directory_info, access_time, all_info, all_info, access_time);
342 CHECK_NTTIME("FULL_DIRECTORY_INFO", full_directory_info, access_time, all_info, all_info, access_time);
343 CHECK_NTTIME("BOTH_DIRECTORY_INFO", both_directory_info, access_time, all_info, all_info, access_time);
344 CHECK_NTTIME("ID_FULL_DIRECTORY_INFO", id_full_directory_info, access_time, all_info, all_info, access_time);
345 CHECK_NTTIME("ID_BOTH_DIRECTORY_INFO", id_both_directory_info, access_time, all_info, all_info, access_time);
347 CHECK_NTTIME("DIRECTORY_INFO", directory_info, create_time, all_info, all_info, create_time);
348 CHECK_NTTIME("FULL_DIRECTORY_INFO", full_directory_info, create_time, all_info, all_info, create_time);
349 CHECK_NTTIME("BOTH_DIRECTORY_INFO", both_directory_info, create_time, all_info, all_info, create_time);
350 CHECK_NTTIME("ID_FULL_DIRECTORY_INFO", id_full_directory_info, create_time, all_info, all_info, create_time);
351 CHECK_NTTIME("ID_BOTH_DIRECTORY_INFO", id_both_directory_info, create_time, all_info, all_info, create_time);
353 CHECK_VAL("SEARCH", search, size, all_info, all_info, size);
354 CHECK_VAL("STANDARD", standard, size, all_info, all_info, size);
355 CHECK_VAL("EA_SIZE", ea_size, size, all_info, all_info, size);
356 CHECK_VAL("DIRECTORY_INFO", directory_info, size, all_info, all_info, size);
357 CHECK_VAL("FULL_DIRECTORY_INFO", full_directory_info, size, all_info, all_info, size);
358 CHECK_VAL("BOTH_DIRECTORY_INFO", both_directory_info, size, all_info, all_info, size);
359 CHECK_VAL("ID_FULL_DIRECTORY_INFO", id_full_directory_info, size, all_info, all_info, size);
360 CHECK_VAL("ID_BOTH_DIRECTORY_INFO", id_both_directory_info, size, all_info, all_info, size);
361 CHECK_VAL("UNIX_INFO", unix_info, size, all_info, all_info, size);
363 CHECK_VAL("STANDARD", standard, alloc_size, all_info, all_info, alloc_size);
364 CHECK_VAL("EA_SIZE", ea_size, alloc_size, all_info, all_info, alloc_size);
365 CHECK_VAL("DIRECTORY_INFO", directory_info, alloc_size, all_info, all_info, alloc_size);
366 CHECK_VAL("FULL_DIRECTORY_INFO", full_directory_info, alloc_size, all_info, all_info, alloc_size);
367 CHECK_VAL("BOTH_DIRECTORY_INFO", both_directory_info, alloc_size, all_info, all_info, alloc_size);
368 CHECK_VAL("ID_FULL_DIRECTORY_INFO", id_full_directory_info, alloc_size, all_info, all_info, alloc_size);
369 CHECK_VAL("ID_BOTH_DIRECTORY_INFO", id_both_directory_info, alloc_size, all_info, all_info, alloc_size);
370 CHECK_VAL("UNIX_INFO", unix_info, alloc_size, all_info, all_info, alloc_size);
372 CHECK_VAL("EA_SIZE", ea_size, ea_size, all_info, all_info, ea_size);
373 CHECK_VAL("FULL_DIRECTORY_INFO", full_directory_info, ea_size, all_info, all_info, ea_size);
374 CHECK_VAL("BOTH_DIRECTORY_INFO", both_directory_info, ea_size, all_info, all_info, ea_size);
375 CHECK_VAL("ID_FULL_DIRECTORY_INFO", id_full_directory_info, ea_size, all_info, all_info, ea_size);
376 CHECK_VAL("ID_BOTH_DIRECTORY_INFO", id_both_directory_info, ea_size, all_info, all_info, ea_size);
378 CHECK_STR("SEARCH", search, name, alt_info, alt_name_info, fname);
379 CHECK_WSTR("BOTH_DIRECTORY_INFO", both_directory_info, short_name, alt_info, alt_name_info, fname, STR_UNICODE);
381 CHECK_NAME("STANDARD", standard, name, fname+1, 0);
382 CHECK_NAME("EA_SIZE", ea_size, name, fname+1, 0);
383 CHECK_NAME("DIRECTORY_INFO", directory_info, name, fname+1, STR_TERMINATE_ASCII);
384 CHECK_NAME("FULL_DIRECTORY_INFO", full_directory_info, name, fname+1, STR_TERMINATE_ASCII);
385 CHECK_NAME("NAME_INFO", name_info, name, fname+1, STR_TERMINATE_ASCII);
386 CHECK_NAME("BOTH_DIRECTORY_INFO", both_directory_info, name, fname+1, STR_TERMINATE_ASCII);
387 CHECK_NAME("ID_FULL_DIRECTORY_INFO", id_full_directory_info, name, fname+1, STR_TERMINATE_ASCII);
388 CHECK_NAME("ID_BOTH_DIRECTORY_INFO", id_both_directory_info, name, fname+1, STR_TERMINATE_ASCII);
389 CHECK_UNIX_NAME("UNIX_INFO", unix_info, name, fname+1, STR_TERMINATE_ASCII);
391 CHECK_VAL("ID_FULL_DIRECTORY_INFO", id_full_directory_info, file_id, internal_info, internal_information, file_id);
392 CHECK_VAL("ID_BOTH_DIRECTORY_INFO", id_both_directory_info, file_id, internal_info, internal_information, file_id);
395 smb_raw_exit(cli->session);
396 smbcli_unlink(cli->tree, fname);
402 struct multiple_result {
405 union smb_search_data *list;
409 callback function for multiple_search
411 static BOOL multiple_search_callback(void *private, union smb_search_data *file)
413 struct multiple_result *data = private;
417 data->list = talloc_realloc(data->mem_ctx,
419 union smb_search_data,
422 data->list[data->count-1] = *file;
427 enum continue_type {CONT_FLAGS, CONT_NAME, CONT_RESUME_KEY};
430 do a single file (non-wildcard) search
432 static NTSTATUS multiple_search(struct smbcli_state *cli,
435 enum smb_search_level level,
436 enum continue_type cont_type,
439 union smb_search_first io;
440 union smb_search_next io2;
442 const int per_search = 300;
443 struct multiple_result *result = data;
445 io.generic.level = level;
446 if (level == RAW_SEARCH_SEARCH) {
447 io.search_first.in.max_count = per_search;
448 io.search_first.in.search_attrib = 0;
449 io.search_first.in.pattern = pattern;
451 io.t2ffirst.in.search_attrib = 0;
452 io.t2ffirst.in.max_count = per_search;
453 io.t2ffirst.in.flags = FLAG_TRANS2_FIND_CLOSE_IF_END;
454 io.t2ffirst.in.storage_type = 0;
455 io.t2ffirst.in.pattern = pattern;
456 if (cont_type == CONT_RESUME_KEY) {
457 io.t2ffirst.in.flags |= FLAG_TRANS2_FIND_REQUIRE_RESUME |
458 FLAG_TRANS2_FIND_BACKUP_INTENT;
462 status = smb_raw_search_first(cli->tree, mem_ctx,
463 &io, data, multiple_search_callback);
466 while (NT_STATUS_IS_OK(status)) {
467 io2.generic.level = level;
468 if (level == RAW_SEARCH_SEARCH) {
469 io2.search_next.in.max_count = per_search;
470 io2.search_next.in.search_attrib = 0;
471 io2.search_next.in.id = result->list[result->count-1].search.id;
473 io2.t2fnext.in.handle = io.t2ffirst.out.handle;
474 io2.t2fnext.in.max_count = per_search;
475 io2.t2fnext.in.resume_key = 0;
476 io2.t2fnext.in.flags = FLAG_TRANS2_FIND_CLOSE_IF_END;
477 io2.t2fnext.in.last_name = "";
479 case CONT_RESUME_KEY:
480 if (level == RAW_SEARCH_STANDARD) {
481 io2.t2fnext.in.resume_key =
482 result->list[result->count-1].standard.resume_key;
483 } else if (level == RAW_SEARCH_EA_SIZE) {
484 io2.t2fnext.in.resume_key =
485 result->list[result->count-1].ea_size.resume_key;
486 } else if (level == RAW_SEARCH_DIRECTORY_INFO) {
487 io2.t2fnext.in.resume_key =
488 result->list[result->count-1].directory_info.file_index;
490 io2.t2fnext.in.resume_key =
491 result->list[result->count-1].both_directory_info.file_index;
493 if (io2.t2fnext.in.resume_key == 0) {
494 printf("Server does not support resume by key\n");
495 return NT_STATUS_NOT_SUPPORTED;
497 io2.t2fnext.in.flags |= FLAG_TRANS2_FIND_REQUIRE_RESUME |
498 FLAG_TRANS2_FIND_BACKUP_INTENT;
501 if (level == RAW_SEARCH_STANDARD) {
502 io2.t2fnext.in.last_name =
503 result->list[result->count-1].standard.name.s;
504 } else if (level == RAW_SEARCH_EA_SIZE) {
505 io2.t2fnext.in.last_name =
506 result->list[result->count-1].ea_size.name.s;
507 } else if (level == RAW_SEARCH_DIRECTORY_INFO) {
508 io2.t2fnext.in.last_name =
509 result->list[result->count-1].directory_info.name.s;
511 io2.t2fnext.in.last_name =
512 result->list[result->count-1].both_directory_info.name.s;
516 io2.t2fnext.in.flags |= FLAG_TRANS2_FIND_CONTINUE;
521 status = smb_raw_search_next(cli->tree, mem_ctx,
522 &io2, data, multiple_search_callback);
523 if (!NT_STATUS_IS_OK(status)) {
526 if (level == RAW_SEARCH_SEARCH) {
527 if (io2.search_next.out.count == 0) {
530 } else if (io2.t2fnext.out.count == 0 ||
531 io2.t2fnext.out.end_of_search) {
539 #define CHECK_STATUS(status, correct) do { \
540 if (!NT_STATUS_EQUAL(status, correct)) { \
541 printf("(%s) Incorrect status %s - should be %s\n", \
542 __location__, nt_errstr(status), nt_errstr(correct)); \
547 #define CHECK_VALUE(v, correct) do { \
548 if ((v) != (correct)) { \
549 printf("(%s) Incorrect value %s=%d - should be %d\n", \
550 __location__, #v, v, correct); \
554 #define CHECK_STRING(v, correct) do { \
555 if (StrCaseCmp(v, correct) != 0) { \
556 printf("(%s) Incorrect value %s='%s' - should be '%s'\n", \
557 __location__, #v, v, correct); \
562 static int search_both_compare(union smb_search_data *d1, union smb_search_data *d2)
564 return strcmp_safe(d1->both_directory_info.name.s, d2->both_directory_info.name.s);
567 static int search_standard_compare(union smb_search_data *d1, union smb_search_data *d2)
569 return strcmp_safe(d1->standard.name.s, d2->standard.name.s);
572 static int search_ea_size_compare(union smb_search_data *d1, union smb_search_data *d2)
574 return strcmp_safe(d1->ea_size.name.s, d2->ea_size.name.s);
577 static int search_directory_info_compare(union smb_search_data *d1, union smb_search_data *d2)
579 return strcmp_safe(d1->directory_info.name.s, d2->directory_info.name.s);
582 static int search_old_compare(union smb_search_data *d1, union smb_search_data *d2)
584 return strcmp_safe(d1->search.name, d2->search.name);
589 basic testing of search calls using many files
591 static BOOL test_many_files(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
593 const int num_files = 700;
598 struct multiple_result result;
601 const char *cont_name;
602 enum smb_search_level level;
603 enum continue_type cont_type;
605 {"SEARCH", "ID", RAW_SEARCH_SEARCH, CONT_RESUME_KEY},
606 {"BOTH_DIRECTORY_INFO", "NAME", RAW_SEARCH_BOTH_DIRECTORY_INFO, CONT_NAME},
607 {"BOTH_DIRECTORY_INFO", "FLAGS", RAW_SEARCH_BOTH_DIRECTORY_INFO, CONT_FLAGS},
608 {"BOTH_DIRECTORY_INFO", "KEY", RAW_SEARCH_BOTH_DIRECTORY_INFO, CONT_RESUME_KEY},
609 {"STANDARD", "FLAGS", RAW_SEARCH_STANDARD, CONT_FLAGS},
610 {"STANDARD", "KEY", RAW_SEARCH_STANDARD, CONT_RESUME_KEY},
611 {"STANDARD", "NAME", RAW_SEARCH_STANDARD, CONT_NAME},
612 {"EA_SIZE", "FLAGS", RAW_SEARCH_EA_SIZE, CONT_FLAGS},
613 {"EA_SIZE", "KEY", RAW_SEARCH_EA_SIZE, CONT_RESUME_KEY},
614 {"EA_SIZE", "NAME", RAW_SEARCH_EA_SIZE, CONT_NAME},
615 {"DIRECTORY_INFO", "FLAGS", RAW_SEARCH_DIRECTORY_INFO, CONT_FLAGS},
616 {"DIRECTORY_INFO", "KEY", RAW_SEARCH_DIRECTORY_INFO, CONT_RESUME_KEY},
617 {"DIRECTORY_INFO", "NAME", RAW_SEARCH_DIRECTORY_INFO, CONT_NAME}
620 if (!torture_setup_dir(cli, BASEDIR)) {
624 printf("Creating %d files\n", num_files);
626 for (i=0;i<num_files;i++) {
627 asprintf(&fname, BASEDIR "\\t%03d-%d.txt", i, i);
628 fnum = smbcli_open(cli->tree, fname, O_CREAT|O_RDWR, DENY_NONE);
630 printf("Failed to create %s - %s\n", fname, smbcli_errstr(cli->tree));
635 smbcli_close(cli->tree, fnum);
639 for (t=0;t<ARRAY_SIZE(search_types);t++) {
641 result.mem_ctx = talloc_new(mem_ctx);
643 printf("Continue %s via %s\n", search_types[t].name, search_types[t].cont_name);
645 status = multiple_search(cli, mem_ctx, BASEDIR "\\*.*",
646 search_types[t].level,
647 search_types[t].cont_type,
650 if (!NT_STATUS_IS_OK(status)) {
651 printf("search failed - %s\n", nt_errstr(status));
655 CHECK_VALUE(result.count, num_files);
657 if (search_types[t].level == RAW_SEARCH_BOTH_DIRECTORY_INFO) {
658 qsort(result.list, result.count, sizeof(result.list[0]),
659 QSORT_CAST search_both_compare);
660 } else if (search_types[t].level == RAW_SEARCH_STANDARD) {
661 qsort(result.list, result.count, sizeof(result.list[0]),
662 QSORT_CAST search_standard_compare);
663 } else if (search_types[t].level == RAW_SEARCH_EA_SIZE) {
664 qsort(result.list, result.count, sizeof(result.list[0]),
665 QSORT_CAST search_ea_size_compare);
666 } else if (search_types[t].level == RAW_SEARCH_DIRECTORY_INFO) {
667 qsort(result.list, result.count, sizeof(result.list[0]),
668 QSORT_CAST search_directory_info_compare);
670 qsort(result.list, result.count, sizeof(result.list[0]),
671 QSORT_CAST search_old_compare);
674 for (i=0;i<result.count;i++) {
676 if (search_types[t].level == RAW_SEARCH_BOTH_DIRECTORY_INFO) {
677 s = result.list[i].both_directory_info.name.s;
678 } else if (search_types[t].level == RAW_SEARCH_STANDARD) {
679 s = result.list[i].standard.name.s;
680 } else if (search_types[t].level == RAW_SEARCH_EA_SIZE) {
681 s = result.list[i].ea_size.name.s;
682 } else if (search_types[t].level == RAW_SEARCH_DIRECTORY_INFO) {
683 s = result.list[i].directory_info.name.s;
685 s = result.list[i].search.name;
687 asprintf(&fname, "t%03d-%d.txt", i, i);
688 if (strcmp(fname, s)) {
689 printf("Incorrect name %s at entry %d\n", s, i);
695 talloc_free(result.mem_ctx);
699 smb_raw_exit(cli->session);
700 smbcli_deltree(cli->tree, BASEDIR);
706 check a individual file result
708 static BOOL check_result(struct multiple_result *result, const char *name, BOOL exist, uint32_t attrib)
711 for (i=0;i<result->count;i++) {
712 if (strcmp(name, result->list[i].both_directory_info.name.s) == 0) break;
714 if (i == result->count) {
716 printf("failed: '%s' should exist with attribute %s\n",
717 name, attrib_string(result->list, attrib));
724 printf("failed: '%s' should NOT exist (has attribute %s)\n",
725 name, attrib_string(result->list, result->list[i].both_directory_info.attrib));
729 if ((result->list[i].both_directory_info.attrib&0xFFF) != attrib) {
730 printf("failed: '%s' should have attribute 0x%x (has 0x%x)\n",
732 attrib, result->list[i].both_directory_info.attrib);
739 test what happens when the directory is modified during a search
741 static BOOL test_modify_search(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
743 const int num_files = 20;
748 struct multiple_result result;
749 union smb_search_first io;
750 union smb_search_next io2;
751 union smb_setfileinfo sfinfo;
753 if (!torture_setup_dir(cli, BASEDIR)) {
757 printf("Creating %d files\n", num_files);
759 for (i=num_files-1;i>=0;i--) {
760 asprintf(&fname, BASEDIR "\\t%03d-%d.txt", i, i);
761 fnum = smbcli_open(cli->tree, fname, O_CREAT|O_RDWR, DENY_NONE);
763 printf("Failed to create %s - %s\n", fname, smbcli_errstr(cli->tree));
768 smbcli_close(cli->tree, fnum);
771 printf("pulling the first file\n");
773 result.mem_ctx = talloc_new(mem_ctx);
775 io.generic.level = RAW_SEARCH_BOTH_DIRECTORY_INFO;
776 io.t2ffirst.in.search_attrib = 0;
777 io.t2ffirst.in.max_count = 0;
778 io.t2ffirst.in.flags = 0;
779 io.t2ffirst.in.storage_type = 0;
780 io.t2ffirst.in.pattern = BASEDIR "\\*.*";
782 status = smb_raw_search_first(cli->tree, mem_ctx,
783 &io, &result, multiple_search_callback);
784 CHECK_STATUS(status, NT_STATUS_OK);
785 CHECK_VALUE(result.count, 1);
787 printf("pulling the second file\n");
788 io2.generic.level = RAW_SEARCH_BOTH_DIRECTORY_INFO;
789 io2.t2fnext.in.handle = io.t2ffirst.out.handle;
790 io2.t2fnext.in.max_count = 1;
791 io2.t2fnext.in.resume_key = 0;
792 io2.t2fnext.in.flags = 0;
793 if (result.count == 0) {
794 io2.t2fnext.in.last_name = "";
796 io2.t2fnext.in.last_name = result.list[result.count-1].both_directory_info.name.s;
799 status = smb_raw_search_next(cli->tree, mem_ctx,
800 &io2, &result, multiple_search_callback);
801 CHECK_STATUS(status, NT_STATUS_OK);
802 CHECK_VALUE(result.count, 2);
804 printf("Changing attributes and deleting\n");
805 smbcli_open(cli->tree, BASEDIR "\\T003-03.txt.2", O_CREAT|O_RDWR, DENY_NONE);
806 smbcli_open(cli->tree, BASEDIR "\\T013-13.txt.2", O_CREAT|O_RDWR, DENY_NONE);
807 fnum = create_complex_file(cli, mem_ctx, BASEDIR "\\T013-13.txt.3");
808 smbcli_unlink(cli->tree, BASEDIR "\\T014-14.txt");
809 torture_set_file_attribute(cli->tree, BASEDIR "\\T015-15.txt", FILE_ATTRIBUTE_HIDDEN);
810 torture_set_file_attribute(cli->tree, BASEDIR "\\T016-16.txt", FILE_ATTRIBUTE_NORMAL);
811 torture_set_file_attribute(cli->tree, BASEDIR "\\T017-17.txt", FILE_ATTRIBUTE_SYSTEM);
812 torture_set_file_attribute(cli->tree, BASEDIR "\\T018-18.txt", 0);
813 sfinfo.generic.level = RAW_SFILEINFO_DISPOSITION_INFORMATION;
814 sfinfo.generic.file.fnum = fnum;
815 sfinfo.disposition_info.in.delete_on_close = 1;
816 status = smb_raw_setfileinfo(cli->tree, &sfinfo);
817 CHECK_STATUS(status, NT_STATUS_OK);
819 io2.generic.level = RAW_SEARCH_BOTH_DIRECTORY_INFO;
820 io2.t2fnext.in.handle = io.t2ffirst.out.handle;
821 io2.t2fnext.in.max_count = num_files - 1;
822 io2.t2fnext.in.resume_key = 0;
823 io2.t2fnext.in.flags = 0;
824 io2.t2fnext.in.last_name = result.list[result.count-2].both_directory_info.name.s;
826 status = smb_raw_search_next(cli->tree, mem_ctx,
827 &io2, &result, multiple_search_callback);
828 CHECK_STATUS(status, NT_STATUS_OK);
829 CHECK_VALUE(result.count, 21);
831 ret &= check_result(&result, "t009-9.txt", True, FILE_ATTRIBUTE_ARCHIVE);
832 ret &= check_result(&result, "t014-14.txt", False, 0);
833 ret &= check_result(&result, "t015-15.txt", False, 0);
834 ret &= check_result(&result, "t016-16.txt", True, FILE_ATTRIBUTE_NORMAL);
835 ret &= check_result(&result, "t017-17.txt", False, 0);
836 ret &= check_result(&result, "t018-18.txt", True, FILE_ATTRIBUTE_ARCHIVE);
837 ret &= check_result(&result, "t019-19.txt", True, FILE_ATTRIBUTE_ARCHIVE);
838 ret &= check_result(&result, "T013-13.txt.2", True, FILE_ATTRIBUTE_ARCHIVE);
839 ret &= check_result(&result, "T003-3.txt.2", False, 0);
840 ret &= check_result(&result, "T013-13.txt.3", True, FILE_ATTRIBUTE_ARCHIVE);
843 for (i=0;i<result.count;i++) {
844 printf("%s %s (0x%x)\n",
845 result.list[i].both_directory_info.name.s,
846 attrib_string(mem_ctx, result.list[i].both_directory_info.attrib),
847 result.list[i].both_directory_info.attrib);
852 smb_raw_exit(cli->session);
853 smbcli_deltree(cli->tree, BASEDIR);
860 testing if directories always come back sorted
862 static BOOL test_sorted(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
864 const int num_files = 700;
869 struct multiple_result result;
871 if (!torture_setup_dir(cli, BASEDIR)) {
875 printf("Creating %d files\n", num_files);
877 for (i=0;i<num_files;i++) {
878 asprintf(&fname, BASEDIR "\\%s.txt", generate_random_str_list(mem_ctx, 10, "abcdefgh"));
879 fnum = smbcli_open(cli->tree, fname, O_CREAT|O_RDWR, DENY_NONE);
881 printf("Failed to create %s - %s\n", fname, smbcli_errstr(cli->tree));
886 smbcli_close(cli->tree, fnum);
891 result.mem_ctx = mem_ctx;
893 status = multiple_search(cli, mem_ctx, BASEDIR "\\*.*",
894 RAW_SEARCH_BOTH_DIRECTORY_INFO,
896 CHECK_STATUS(status, NT_STATUS_OK);
897 CHECK_VALUE(result.count, num_files);
899 for (i=0;i<num_files-1;i++) {
900 const char *name1, *name2;
901 name1 = result.list[i].both_directory_info.name.s;
902 name2 = result.list[i+1].both_directory_info.name.s;
903 if (StrCaseCmp(name1, name2) > 0) {
904 printf("non-alphabetical order at entry %d '%s' '%s'\n",
906 printf("Server does not produce sorted directory listings (not an error)\n");
911 talloc_free(result.list);
914 smb_raw_exit(cli->session);
915 smbcli_deltree(cli->tree, BASEDIR);
923 basic testing of many old style search calls using separate dirs
925 static BOOL test_many_dirs(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
927 const int num_dirs = 300;
932 union smb_search_data *file, *file2, *file3;
934 if (!torture_setup_dir(cli, BASEDIR)) {
938 printf("Creating %d dirs\n", num_dirs);
940 for (i=0;i<num_dirs;i++) {
941 asprintf(&dname, BASEDIR "\\d%d", i);
942 status = smbcli_mkdir(cli->tree, dname);
943 if (!NT_STATUS_IS_OK(status)) {
944 printf("(%s) Failed to create %s - %s\n",
945 __location__, dname, nt_errstr(status));
951 asprintf(&fname, BASEDIR "\\d%d\\f%d-%d.txt", i, i, n);
952 fnum = smbcli_open(cli->tree, fname, O_CREAT|O_RDWR, DENY_NONE);
954 printf("(%s) Failed to create %s - %s\n",
955 __location__, fname, smbcli_errstr(cli->tree));
963 smbcli_close(cli->tree, fnum);
966 file = talloc_zero_array(mem_ctx, union smb_search_data, num_dirs);
967 file2 = talloc_zero_array(mem_ctx, union smb_search_data, num_dirs);
968 file3 = talloc_zero_array(mem_ctx, union smb_search_data, num_dirs);
970 printf("Search first on %d dirs\n", num_dirs);
972 for (i=0;i<num_dirs;i++) {
973 union smb_search_first io;
974 io.generic.level = RAW_SEARCH_SEARCH;
975 io.search_first.in.max_count = 1;
976 io.search_first.in.search_attrib = 0;
977 io.search_first.in.pattern = talloc_asprintf(mem_ctx, BASEDIR "\\d%d\\*.txt", i);
978 fname = talloc_asprintf(mem_ctx, "f%d-", i);
980 io.search_first.out.count = 0;
982 status = smb_raw_search_first(cli->tree, mem_ctx,
983 &io, (void *)&file[i], single_search_callback);
984 if (io.search_first.out.count != 1) {
985 printf("(%s) search first gave %d entries for dir %d - %s\n",
986 __location__, io.search_first.out.count, i, nt_errstr(status));
990 CHECK_STATUS(status, NT_STATUS_OK);
991 if (strncasecmp(file[i].search.name, fname, strlen(fname)) != 0) {
992 printf("(%s) incorrect name '%s' expected '%s'[12].txt\n",
993 __location__, file[i].search.name, fname);
1001 printf("Search next on %d dirs\n", num_dirs);
1003 for (i=0;i<num_dirs;i++) {
1004 union smb_search_next io2;
1006 io2.generic.level = RAW_SEARCH_SEARCH;
1007 io2.search_next.in.max_count = 1;
1008 io2.search_next.in.search_attrib = 0;
1009 io2.search_next.in.id = file[i].search.id;
1010 fname = talloc_asprintf(mem_ctx, "f%d-", i);
1012 io2.search_next.out.count = 0;
1014 status = smb_raw_search_next(cli->tree, mem_ctx,
1015 &io2, (void *)&file2[i], single_search_callback);
1016 if (io2.search_next.out.count != 1) {
1017 printf("(%s) search next gave %d entries for dir %d - %s\n",
1018 __location__, io2.search_next.out.count, i, nt_errstr(status));
1022 CHECK_STATUS(status, NT_STATUS_OK);
1023 if (strncasecmp(file2[i].search.name, fname, strlen(fname)) != 0) {
1024 printf("(%s) incorrect name '%s' expected '%s'[12].txt\n",
1025 __location__, file2[i].search.name, fname);
1034 printf("Search next (rewind) on %d dirs\n", num_dirs);
1036 for (i=0;i<num_dirs;i++) {
1037 union smb_search_next io2;
1039 io2.generic.level = RAW_SEARCH_SEARCH;
1040 io2.search_next.in.max_count = 1;
1041 io2.search_next.in.search_attrib = 0;
1042 io2.search_next.in.id = file[i].search.id;
1043 fname = talloc_asprintf(mem_ctx, "f%d-", i);
1044 io2.search_next.out.count = 0;
1046 status = smb_raw_search_next(cli->tree, mem_ctx,
1047 &io2, (void *)&file3[i], single_search_callback);
1048 if (io2.search_next.out.count != 1) {
1049 printf("(%s) search next gave %d entries for dir %d - %s\n",
1050 __location__, io2.search_next.out.count, i, nt_errstr(status));
1054 CHECK_STATUS(status, NT_STATUS_OK);
1056 if (strncasecmp(file3[i].search.name, file2[i].search.name, 3) != 0) {
1057 printf("(%s) incorrect name '%s' on rewind at dir %d\n",
1058 __location__, file2[i].search.name, i);
1063 if (strcmp(file3[i].search.name, file2[i].search.name) != 0) {
1064 printf("(%s) server did not rewind - got '%s' expected '%s'\n",
1065 __location__, file3[i].search.name, file2[i].search.name);
1075 smb_raw_exit(cli->session);
1076 smbcli_deltree(cli->tree, BASEDIR);
1083 testing of OS/2 style delete
1085 static BOOL test_os2_delete(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
1087 const int num_files = 700;
1088 const int delete_count = 4;
1089 int total_deleted = 0;
1094 union smb_search_first io;
1095 union smb_search_next io2;
1096 struct multiple_result result;
1098 if (!torture_setup_dir(cli, BASEDIR)) {
1102 printf("Testing OS/2 style delete on %d files\n", num_files);
1104 for (i=0;i<num_files;i++) {
1105 asprintf(&fname, BASEDIR "\\file%u.txt", i);
1106 fnum = smbcli_open(cli->tree, fname, O_CREAT|O_RDWR, DENY_NONE);
1108 printf("Failed to create %s - %s\n", fname, smbcli_errstr(cli->tree));
1113 smbcli_close(cli->tree, fnum);
1117 ZERO_STRUCT(result);
1118 result.mem_ctx = mem_ctx;
1120 io.t2ffirst.level = RAW_SEARCH_EA_SIZE;
1121 io.t2ffirst.in.search_attrib = 0;
1122 io.t2ffirst.in.max_count = 100;
1123 io.t2ffirst.in.flags = FLAG_TRANS2_FIND_REQUIRE_RESUME;
1124 io.t2ffirst.in.storage_type = 0;
1125 io.t2ffirst.in.pattern = BASEDIR "\\*";
1127 status = smb_raw_search_first(cli->tree, mem_ctx,
1128 &io, &result, multiple_search_callback);
1129 CHECK_STATUS(status, NT_STATUS_OK);
1131 for (i=0;i<MIN(result.count, delete_count);i++) {
1132 asprintf(&fname, BASEDIR "\\%s", result.list[i].ea_size.name.s);
1133 status = smbcli_unlink(cli->tree, fname);
1134 CHECK_STATUS(status, NT_STATUS_OK);
1138 io2.t2fnext.level = RAW_SEARCH_EA_SIZE;
1139 io2.t2fnext.in.handle = io.t2ffirst.out.handle;
1140 io2.t2fnext.in.max_count = 100;
1141 io2.t2fnext.in.resume_key = result.list[i-1].ea_size.resume_key;
1142 io2.t2fnext.in.flags = FLAG_TRANS2_FIND_REQUIRE_RESUME;
1143 io2.t2fnext.in.last_name = result.list[i-1].ea_size.name.s;
1146 ZERO_STRUCT(result);
1147 result.mem_ctx = mem_ctx;
1149 status = smb_raw_search_next(cli->tree, mem_ctx,
1150 &io2, &result, multiple_search_callback);
1151 if (!NT_STATUS_IS_OK(status)) {
1155 for (i=0;i<MIN(result.count, delete_count);i++) {
1156 asprintf(&fname, BASEDIR "\\%s", result.list[i].ea_size.name.s);
1157 status = smbcli_unlink(cli->tree, fname);
1158 CHECK_STATUS(status, NT_STATUS_OK);
1163 io2.t2fnext.in.resume_key = result.list[i-1].ea_size.resume_key;
1164 io2.t2fnext.in.last_name = result.list[i-1].ea_size.name.s;
1166 } while (NT_STATUS_IS_OK(status) && result.count != 0);
1168 CHECK_STATUS(status, NT_STATUS_OK);
1170 if (total_deleted != num_files) {
1171 printf("error: deleted %d - expected to delete %d\n",
1172 total_deleted, num_files);
1177 smb_raw_exit(cli->session);
1178 smbcli_deltree(cli->tree, BASEDIR);
1185 testing of the rather strange ea_list level
1187 static BOOL test_ea_list(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
1192 union smb_search_first io;
1193 union smb_search_next nxt;
1194 struct multiple_result result;
1195 union smb_setfileinfo setfile;
1197 if (!torture_setup_dir(cli, BASEDIR)) {
1201 printf("Testing RAW_SEARCH_EA_LIST level\n");
1203 fnum = smbcli_open(cli->tree, BASEDIR "\\file1.txt", O_CREAT|O_RDWR, DENY_NONE);
1204 smbcli_close(cli->tree, fnum);
1206 fnum = smbcli_open(cli->tree, BASEDIR "\\file2.txt", O_CREAT|O_RDWR, DENY_NONE);
1207 smbcli_close(cli->tree, fnum);
1209 fnum = smbcli_open(cli->tree, BASEDIR "\\file3.txt", O_CREAT|O_RDWR, DENY_NONE);
1210 smbcli_close(cli->tree, fnum);
1212 setfile.generic.level = RAW_SFILEINFO_EA_SET;
1213 setfile.generic.file.fname = BASEDIR "\\file2.txt";
1214 setfile.ea_set.in.num_eas = 2;
1215 setfile.ea_set.in.eas = talloc_array(mem_ctx, struct ea_struct, 2);
1216 setfile.ea_set.in.eas[0].flags = 0;
1217 setfile.ea_set.in.eas[0].name.s = "EA ONE";
1218 setfile.ea_set.in.eas[0].value = data_blob_string_const("VALUE 1");
1219 setfile.ea_set.in.eas[1].flags = 0;
1220 setfile.ea_set.in.eas[1].name.s = "SECOND EA";
1221 setfile.ea_set.in.eas[1].value = data_blob_string_const("Value Two");
1223 status = smb_raw_setpathinfo(cli->tree, &setfile);
1224 CHECK_STATUS(status, NT_STATUS_OK);
1226 setfile.generic.file.fname = BASEDIR "\\file3.txt";
1227 status = smb_raw_setpathinfo(cli->tree, &setfile);
1228 CHECK_STATUS(status, NT_STATUS_OK);
1230 ZERO_STRUCT(result);
1231 result.mem_ctx = mem_ctx;
1233 io.t2ffirst.level = RAW_SEARCH_EA_LIST;
1234 io.t2ffirst.in.search_attrib = 0;
1235 io.t2ffirst.in.max_count = 2;
1236 io.t2ffirst.in.flags = FLAG_TRANS2_FIND_REQUIRE_RESUME;
1237 io.t2ffirst.in.storage_type = 0;
1238 io.t2ffirst.in.pattern = BASEDIR "\\*";
1239 io.t2ffirst.in.num_names = 2;
1240 io.t2ffirst.in.ea_names = talloc_array(mem_ctx, struct ea_name, 2);
1241 io.t2ffirst.in.ea_names[0].name.s = "SECOND EA";
1242 io.t2ffirst.in.ea_names[1].name.s = "THIRD EA";
1244 status = smb_raw_search_first(cli->tree, mem_ctx,
1245 &io, &result, multiple_search_callback);
1246 CHECK_STATUS(status, NT_STATUS_OK);
1247 CHECK_VALUE(result.count, 2);
1249 nxt.t2fnext.level = RAW_SEARCH_EA_LIST;
1250 nxt.t2fnext.in.handle = io.t2ffirst.out.handle;
1251 nxt.t2fnext.in.max_count = 2;
1252 nxt.t2fnext.in.resume_key = result.list[1].ea_list.resume_key;
1253 nxt.t2fnext.in.flags = FLAG_TRANS2_FIND_REQUIRE_RESUME | FLAG_TRANS2_FIND_CONTINUE;
1254 nxt.t2fnext.in.last_name = "file2.txt";
1255 nxt.t2fnext.in.num_names = 2;
1256 nxt.t2fnext.in.ea_names = talloc_array(mem_ctx, struct ea_name, 2);
1257 nxt.t2fnext.in.ea_names[0].name.s = "SECOND EA";
1258 nxt.t2fnext.in.ea_names[1].name.s = "THIRD EA";
1260 status = smb_raw_search_next(cli->tree, mem_ctx,
1261 &nxt, &result, multiple_search_callback);
1262 CHECK_STATUS(status, NT_STATUS_OK);
1265 CHECK_VALUE(result.count, 3);
1266 CHECK_VALUE(result.list[0].ea_list.eas.num_eas, 2);
1267 CHECK_STRING(result.list[0].ea_list.name.s, "file1.txt");
1268 CHECK_STRING(result.list[0].ea_list.eas.eas[0].name.s, "SECOND EA");
1269 CHECK_VALUE(result.list[0].ea_list.eas.eas[0].value.length, 0);
1270 CHECK_STRING(result.list[0].ea_list.eas.eas[1].name.s, "THIRD EA");
1271 CHECK_VALUE(result.list[0].ea_list.eas.eas[1].value.length, 0);
1273 CHECK_STRING(result.list[1].ea_list.name.s, "file2.txt");
1274 CHECK_STRING(result.list[1].ea_list.eas.eas[0].name.s, "SECOND EA");
1275 CHECK_VALUE(result.list[1].ea_list.eas.eas[0].value.length, 9);
1276 CHECK_STRING(result.list[1].ea_list.eas.eas[0].value.data, "Value Two");
1277 CHECK_STRING(result.list[1].ea_list.eas.eas[1].name.s, "THIRD EA");
1278 CHECK_VALUE(result.list[1].ea_list.eas.eas[1].value.length, 0);
1280 CHECK_STRING(result.list[2].ea_list.name.s, "file3.txt");
1281 CHECK_STRING(result.list[2].ea_list.eas.eas[0].name.s, "SECOND EA");
1282 CHECK_VALUE(result.list[2].ea_list.eas.eas[0].value.length, 9);
1283 CHECK_STRING(result.list[2].ea_list.eas.eas[0].value.data, "Value Two");
1284 CHECK_STRING(result.list[2].ea_list.eas.eas[1].name.s, "THIRD EA");
1285 CHECK_VALUE(result.list[2].ea_list.eas.eas[1].value.length, 0);
1288 smb_raw_exit(cli->session);
1289 smbcli_deltree(cli->tree, BASEDIR);
1297 basic testing of all RAW_SEARCH_* calls using a single file
1299 BOOL torture_raw_search(void)
1301 struct smbcli_state *cli;
1303 TALLOC_CTX *mem_ctx;
1305 if (!torture_open_connection(&cli)) {
1309 mem_ctx = talloc_init("torture_search");
1311 ret &= test_one_file(cli, mem_ctx);
1312 ret &= test_many_files(cli, mem_ctx);
1313 ret &= test_sorted(cli, mem_ctx);
1314 ret &= test_modify_search(cli, mem_ctx);
1315 ret &= test_many_dirs(cli, mem_ctx);
1316 ret &= test_os2_delete(cli, mem_ctx);
1317 ret &= test_ea_list(cli, mem_ctx);
1319 torture_close_connection(cli);
1320 talloc_free(mem_ctx);