lib/util: remove extra safe_string.h file
[bbaumbach/samba-autobuild/.git] / source4 / torture / raw / search.c
1 /* 
2    Unix SMB/CIFS implementation.
3    RAW_SEARCH_* individual test suite
4    Copyright (C) Andrew Tridgell 2003
5    
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.
10    
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.
15    
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/>.
18 */
19
20 #include "includes.h"
21 #include "system/filesys.h"
22 #include "libcli/raw/libcliraw.h"
23 #include "libcli/raw/raw_proto.h"
24 #include "libcli/libcli.h"
25 #include "torture/util.h"
26 #include "lib/util/tsort.h"
27 #include "torture/raw/proto.h"
28
29 #undef strncasecmp
30
31 #define BASEDIR "\\testsearch"
32
33 #define CHECK_STATUS_LEVEL(__tctx, __status, __level, __supp)           \
34         do {                                                            \
35                 if (NT_STATUS_EQUAL(__status,                           \
36                         NT_STATUS_NOT_SUPPORTED) ||                     \
37                     NT_STATUS_EQUAL(__status,                           \
38                         NT_STATUS_NOT_IMPLEMENTED)) {                   \
39                         __supp = false;                                 \
40                 } else {                                                \
41                         __supp = true;                                  \
42                 }                                                       \
43                 if (__supp) {                                           \
44                         torture_assert_ntstatus_ok_goto(__tctx,         \
45                             __status, ret, done, #__level" failed");    \
46                 } else {                                                \
47                         torture_warning(__tctx, "(%s) Info "            \
48                             "level "#__level" is %s",                   \
49                             __location__, nt_errstr(__status));         \
50                 }                                                       \
51         } while (0)
52
53 /*
54   callback function for single_search
55 */
56 static bool single_search_callback(void *private_data, const union smb_search_data *file)
57 {
58         union smb_search_data *data = (union smb_search_data *)private_data;
59
60         *data = *file;
61
62         return true;
63 }
64
65 /*
66   do a single file (non-wildcard) search 
67 */
68 NTSTATUS torture_single_search(struct smbcli_state *cli, 
69                                TALLOC_CTX *tctx,
70                                const char *pattern,
71                                enum smb_search_level level,
72                                enum smb_search_data_level data_level,
73                                uint16_t attrib,
74                                union smb_search_data *data)
75 {
76         union smb_search_first io;
77         union smb_search_close c;
78         NTSTATUS status;
79
80         switch (level) {
81         case RAW_SEARCH_SEARCH:
82         case RAW_SEARCH_FFIRST:
83         case RAW_SEARCH_FUNIQUE:
84                 io.search_first.level = level;
85                 io.search_first.data_level = RAW_SEARCH_DATA_SEARCH;
86                 io.search_first.in.max_count = 1;
87                 io.search_first.in.search_attrib = attrib;
88                 io.search_first.in.pattern = pattern;
89                 break;
90
91         case RAW_SEARCH_TRANS2:
92                 io.t2ffirst.level = RAW_SEARCH_TRANS2;
93                 io.t2ffirst.data_level = data_level;
94                 io.t2ffirst.in.search_attrib = attrib;
95                 io.t2ffirst.in.max_count = 1;
96                 io.t2ffirst.in.flags = FLAG_TRANS2_FIND_CLOSE;
97                 io.t2ffirst.in.storage_type = 0;
98                 io.t2ffirst.in.pattern = pattern;
99                 break;
100
101         case RAW_SEARCH_SMB2:
102                 return NT_STATUS_INVALID_LEVEL;
103         }
104
105         status = smb_raw_search_first(cli->tree, tctx,
106                                       &io, (void *)data, single_search_callback);
107
108         if (NT_STATUS_IS_OK(status) && level == RAW_SEARCH_FFIRST) {
109                 c.fclose.level = RAW_FINDCLOSE_FCLOSE;
110                 c.fclose.in.max_count = 1;
111                 c.fclose.in.search_attrib = 0;
112                 c.fclose.in.id = data->search.id;
113                 status = smb_raw_search_close(cli->tree, &c);
114         }
115         
116         return status;
117 }
118
119
120 static struct {
121         const char *name;
122         enum smb_search_level level;
123         enum smb_search_data_level data_level;
124         int name_offset;
125         int resume_key_offset;
126         uint32_t capability_mask;
127         NTSTATUS status;
128         union smb_search_data data;
129 } levels[] = {
130         {
131                 .name              = "FFIRST",
132                 .level             = RAW_SEARCH_FFIRST,
133                 .data_level        = RAW_SEARCH_DATA_SEARCH,
134                 .name_offset       = offsetof(union smb_search_data,
135                                               search.name),
136                 .resume_key_offset = -1,
137         },
138         {
139                 .name              = "FUNIQUE",
140                 .level             = RAW_SEARCH_FUNIQUE,
141                 .data_level        = RAW_SEARCH_DATA_SEARCH,
142                 .name_offset       = offsetof(union smb_search_data,
143                                               search.name),
144                 .resume_key_offset = -1,
145         },
146         {
147                 .name              = "SEARCH",
148                 .level             = RAW_SEARCH_SEARCH,
149                 .data_level        = RAW_SEARCH_DATA_SEARCH,
150                 .name_offset       = offsetof(union smb_search_data,
151                                               search.name),
152                 .resume_key_offset = -1,
153         },
154         {
155                 .name              = "STANDARD",
156                 .level             = RAW_SEARCH_TRANS2,
157                 .data_level        = RAW_SEARCH_DATA_STANDARD,
158                 .name_offset       =  offsetof(union smb_search_data,
159                                                standard.name.s),
160                 .resume_key_offset =  offsetof(union smb_search_data,
161                                                standard.resume_key),
162         },
163         {
164                 .name              = "EA_SIZE",
165                 .level             = RAW_SEARCH_TRANS2,
166                 .data_level        = RAW_SEARCH_DATA_EA_SIZE,
167                 .name_offset       = offsetof(union smb_search_data,
168                                               ea_size.name.s),
169                 .resume_key_offset = offsetof(union smb_search_data,
170                                               ea_size.resume_key),
171         },
172         {
173                 .name              = "DIRECTORY_INFO",
174                 .level             = RAW_SEARCH_TRANS2,
175                 .data_level        = RAW_SEARCH_DATA_DIRECTORY_INFO,
176                 .name_offset       = offsetof(union smb_search_data,
177                                               directory_info.name.s),
178                 .resume_key_offset = offsetof(union smb_search_data,
179                                               directory_info.file_index),
180         },
181         {
182                 .name              = "FULL_DIRECTORY_INFO",
183                 .level             = RAW_SEARCH_TRANS2,
184                 .data_level        = RAW_SEARCH_DATA_FULL_DIRECTORY_INFO,
185                 .name_offset       = offsetof(union smb_search_data,
186                                               full_directory_info.name.s),
187                 .resume_key_offset = offsetof(union smb_search_data,
188                                               full_directory_info.file_index),
189         },
190         {
191                 .name              = "NAME_INFO",
192                 .level             = RAW_SEARCH_TRANS2,
193                 .data_level        = RAW_SEARCH_DATA_NAME_INFO,
194                 .name_offset       =  offsetof(union smb_search_data,
195                                                name_info.name.s),
196                 .resume_key_offset =  offsetof(union smb_search_data,
197                                                name_info.file_index),
198         },
199         {
200                 .name              = "BOTH_DIRECTORY_INFO",
201                 .level             = RAW_SEARCH_TRANS2,
202                 .data_level        = RAW_SEARCH_DATA_BOTH_DIRECTORY_INFO,
203                 .name_offset       = offsetof(union smb_search_data,
204                                               both_directory_info.name.s),
205                 .resume_key_offset = offsetof(union smb_search_data,
206                                               both_directory_info.file_index),
207         },
208         {
209                 .name              = "ID_FULL_DIRECTORY_INFO",
210                 .level             = RAW_SEARCH_TRANS2,
211                 .data_level        = RAW_SEARCH_DATA_ID_FULL_DIRECTORY_INFO,
212                 .name_offset       = offsetof(union smb_search_data,
213                                               id_full_directory_info.name.s),
214                 .resume_key_offset = offsetof(union smb_search_data,
215                                               id_full_directory_info.file_index),
216         },
217         {
218                 .name              = "ID_BOTH_DIRECTORY_INFO",
219                 .level             = RAW_SEARCH_TRANS2,
220                 .data_level        = RAW_SEARCH_DATA_ID_BOTH_DIRECTORY_INFO,
221                 .name_offset       = offsetof(union smb_search_data,
222                                               id_both_directory_info.name.s),
223                 .resume_key_offset = offsetof(union smb_search_data,
224                                               id_both_directory_info.file_index),
225         },
226         {
227                 .name              = "UNIX_INFO",
228                 .level             = RAW_SEARCH_TRANS2,
229                 .data_level        = RAW_SEARCH_DATA_UNIX_INFO,
230                 .name_offset       = offsetof(union smb_search_data,
231                                               unix_info.name),
232                 .resume_key_offset = offsetof(union smb_search_data,
233                                               unix_info.file_index),
234                 .capability_mask = CAP_UNIX
235         },
236 };
237
238
239 /*
240   return level name
241 */
242 static const char *level_name(enum smb_search_level level,
243                               enum smb_search_data_level data_level)
244 {
245         int i;
246         for (i=0;i<ARRAY_SIZE(levels);i++) {
247                 if (level == levels[i].level &&
248                     data_level == levels[i].data_level) {
249                         return levels[i].name;
250                 }
251         }
252         return NULL;
253 }
254
255 /*
256   extract the name from a smb_data structure and level
257 */
258 static const char *extract_name(void *data, enum smb_search_level level,
259                                 enum smb_search_data_level data_level)
260 {
261         int i;
262         for (i=0;i<ARRAY_SIZE(levels);i++) {
263                 if (level == levels[i].level &&
264                     data_level == levels[i].data_level) {
265                         return *(const char **)(levels[i].name_offset + (char *)data);
266                 }
267         }
268         return NULL;
269 }
270
271 /*
272   extract the name from a smb_data structure and level
273 */
274 static uint32_t extract_resume_key(void *data, enum smb_search_level level,
275                                    enum smb_search_data_level data_level)
276 {
277         int i;
278         for (i=0;i<ARRAY_SIZE(levels);i++) {
279                 if (level == levels[i].level &&
280                     data_level == levels[i].data_level) {
281                         return *(uint32_t *)(levels[i].resume_key_offset + (char *)data);
282                 }
283         }
284         return 0;
285 }
286
287 /* find a level in the table by name */
288 static union smb_search_data *find(const char *name)
289 {
290         int i;
291         for (i=0;i<ARRAY_SIZE(levels);i++) {
292                 if (NT_STATUS_IS_OK(levels[i].status) && 
293                     strcmp(levels[i].name, name) == 0) {
294                         return &levels[i].data;
295                 }
296         }
297         return NULL;
298 }
299
300 /* 
301    basic testing of all RAW_SEARCH_* calls using a single file
302 */
303 static bool test_one_file(struct torture_context *tctx, 
304                           struct smbcli_state *cli)
305 {
306         bool ret = true;
307         int fnum;
308         const char *fname = "\\torture_search.txt";
309         const char *fname2 = "\\torture_search-NOTEXIST.txt";
310         NTSTATUS status;
311         int i;
312         union smb_fileinfo all_info, alt_info, name_info, internal_info;
313         bool all_info_supported, alt_info_supported, name_info_supported,
314             internal_info_supported;
315         union smb_search_data *s;
316
317         fnum = create_complex_file(cli, tctx, fname);
318         if (fnum == -1) {
319                 printf("ERROR: open of %s failed (%s)\n", fname, smbcli_errstr(cli->tree));
320                 ret = false;
321                 goto done;
322         }
323
324         /* call all the levels */
325         for (i=0;i<ARRAY_SIZE(levels);i++) {
326                 NTSTATUS expected_status;
327                 uint32_t cap = cli->transport->negotiate.capabilities;
328
329                 torture_comment(tctx, "Testing %s\n", levels[i].name);
330
331                 levels[i].status = torture_single_search(cli, tctx, fname, 
332                                                          levels[i].level,
333                                                          levels[i].data_level,
334                                                          0,
335                                                          &levels[i].data);
336
337                 /* see if this server claims to support this level */
338                 if (((cap & levels[i].capability_mask) != levels[i].capability_mask)
339                     || NT_STATUS_EQUAL(levels[i].status, NT_STATUS_NOT_SUPPORTED)) {
340                         printf("search level %s(%d) not supported by server\n",
341                                levels[i].name, (int)levels[i].level);
342                         continue;
343                 }
344
345                 if (!NT_STATUS_IS_OK(levels[i].status)) {
346                         printf("search level %s(%d) failed - %s\n",
347                                levels[i].name, (int)levels[i].level, 
348                                nt_errstr(levels[i].status));
349                         ret = false;
350                         continue;
351                 }
352
353                 status = torture_single_search(cli, tctx, fname2, 
354                                                levels[i].level,
355                                                levels[i].data_level,
356                                                0,
357                                                &levels[i].data);
358                 
359                 expected_status = NT_STATUS_NO_SUCH_FILE;
360                 if (levels[i].level == RAW_SEARCH_SEARCH ||
361                     levels[i].level == RAW_SEARCH_FFIRST ||
362                     levels[i].level == RAW_SEARCH_FUNIQUE) {
363                         expected_status = STATUS_NO_MORE_FILES;
364                 }
365                 if (!NT_STATUS_EQUAL(status, expected_status)) {
366                         printf("search level %s(%d) should fail with %s - %s\n",
367                                levels[i].name, (int)levels[i].level, 
368                                nt_errstr(expected_status),
369                                nt_errstr(status));
370                         ret = false;
371                 }
372         }
373
374         /* get the all_info file into to check against */
375         all_info.generic.level = RAW_FILEINFO_ALL_INFO;
376         all_info.generic.in.file.path = fname;
377         status = smb_raw_pathinfo(cli->tree, tctx, &all_info);
378         CHECK_STATUS_LEVEL(tctx, status, "RAW_FILEINFO_ALL_INFO",
379             all_info_supported);
380
381         alt_info.generic.level = RAW_FILEINFO_ALT_NAME_INFO;
382         alt_info.generic.in.file.path = fname;
383         status = smb_raw_pathinfo(cli->tree, tctx, &alt_info);
384         CHECK_STATUS_LEVEL(tctx, status, "RAW_FILEINFO_ALT_NAME_INFO",
385             alt_info_supported);
386
387         internal_info.generic.level = RAW_FILEINFO_INTERNAL_INFORMATION;
388         internal_info.generic.in.file.path = fname;
389         status = smb_raw_pathinfo(cli->tree, tctx, &internal_info);
390         CHECK_STATUS_LEVEL(tctx, status, "RAW_FILEINFO_INTERNAL_INFORMATION",
391             internal_info_supported);
392
393         name_info.generic.level = RAW_FILEINFO_NAME_INFO;
394         name_info.generic.in.file.path = fname;
395         status = smb_raw_pathinfo(cli->tree, tctx, &name_info);
396         CHECK_STATUS_LEVEL(tctx, status, "RAW_FILEINFO_NAME_INFO",
397             name_info_supported);
398
399 #define CHECK_VAL(name, sname1, field1, v, sname2, field2) do { \
400         s = find(name); \
401         if (s) { \
402                 if ((s->sname1.field1) != (v.sname2.out.field2)) { \
403                         printf("(%s) %s/%s [0x%x] != %s/%s [0x%x]\n", \
404                                __location__, \
405                                 #sname1, #field1, (int)s->sname1.field1, \
406                                 #sname2, #field2, (int)v.sname2.out.field2); \
407                         ret = false; \
408                 } \
409         }} while (0)
410
411 #define CHECK_TIME(name, sname1, field1, v, sname2, field2) do { \
412         s = find(name); \
413         if (s) { \
414                 if (s->sname1.field1 != (~1 & nt_time_to_unix(v.sname2.out.field2))) { \
415                         printf("(%s) %s/%s [%s] != %s/%s [%s]\n", \
416                                __location__, \
417                                 #sname1, #field1, timestring(tctx, s->sname1.field1), \
418                                 #sname2, #field2, nt_time_string(tctx, v.sname2.out.field2)); \
419                         ret = false; \
420                 } \
421         }} while (0)
422
423 #define CHECK_NTTIME(name, sname1, field1, v, sname2, field2) do { \
424         s = find(name); \
425         if (s) { \
426                 if (s->sname1.field1 != v.sname2.out.field2) { \
427                         printf("(%s) %s/%s [%s] != %s/%s [%s]\n", \
428                                __location__, \
429                                 #sname1, #field1, nt_time_string(tctx, s->sname1.field1), \
430                                 #sname2, #field2, nt_time_string(tctx, v.sname2.out.field2)); \
431                         ret = false; \
432                 } \
433         }} while (0)
434
435 #define CHECK_STR(name, sname1, field1, v, sname2, field2) do { \
436         s = find(name); \
437         if (s) { \
438                 if (!s->sname1.field1 || strcmp(s->sname1.field1, v.sname2.out.field2.s)) { \
439                         printf("(%s) %s/%s [%s] != %s/%s [%s]\n", \
440                                __location__, \
441                                 #sname1, #field1, s->sname1.field1, \
442                                 #sname2, #field2, v.sname2.out.field2.s); \
443                         ret = false; \
444                 } \
445         }} while (0)
446
447 #define CHECK_WSTR(name, sname1, field1, v, sname2, field2, flags) do { \
448         s = find(name); \
449         if (s) { \
450                 if (!s->sname1.field1.s || \
451                     strcmp(s->sname1.field1.s, v.sname2.out.field2.s) || \
452                     wire_bad_flags(&s->sname1.field1, flags, cli->transport)) { \
453                         printf("(%s) %s/%s [%s] != %s/%s [%s]\n", \
454                                __location__, \
455                                 #sname1, #field1, s->sname1.field1.s, \
456                                 #sname2, #field2, v.sname2.out.field2.s); \
457                         ret = false; \
458                 } \
459         }} while (0)
460
461 #define CHECK_NAME(name, sname1, field1, fname, flags) do { \
462         s = find(name); \
463         if (s) { \
464                 if (!s->sname1.field1.s || \
465                     strcmp(s->sname1.field1.s, fname) || \
466                     wire_bad_flags(&s->sname1.field1, flags, cli->transport)) { \
467                         printf("(%s) %s/%s [%s] != %s\n", \
468                                __location__, \
469                                 #sname1, #field1, s->sname1.field1.s, \
470                                 fname); \
471                         ret = false; \
472                 } \
473         }} while (0)
474
475 #define CHECK_UNIX_NAME(name, sname1, field1, fname, flags) do { \
476         s = find(name); \
477         if (s) { \
478                 if (!s->sname1.field1 || \
479                     strcmp(s->sname1.field1, fname)) { \
480                         printf("(%s) %s/%s [%s] != %s\n", \
481                                __location__, \
482                                 #sname1, #field1, s->sname1.field1, \
483                                 fname); \
484                         ret = false; \
485                 } \
486         }} while (0)
487         
488         /* check that all the results are as expected */
489         CHECK_VAL("SEARCH",              search,              attrib, all_info, all_info, attrib&0xFFF);
490         CHECK_VAL("STANDARD",            standard,            attrib, all_info, all_info, attrib&0xFFF);
491         CHECK_VAL("EA_SIZE",             ea_size,             attrib, all_info, all_info, attrib&0xFFF);
492         CHECK_VAL("DIRECTORY_INFO",      directory_info,      attrib, all_info, all_info, attrib);
493         CHECK_VAL("FULL_DIRECTORY_INFO", full_directory_info, attrib, all_info, all_info, attrib);
494         CHECK_VAL("BOTH_DIRECTORY_INFO", both_directory_info, attrib, all_info, all_info, attrib);
495         CHECK_VAL("ID_FULL_DIRECTORY_INFO", id_full_directory_info,           attrib, all_info, all_info, attrib);
496         CHECK_VAL("ID_BOTH_DIRECTORY_INFO", id_both_directory_info,           attrib, all_info, all_info, attrib);
497
498         CHECK_TIME("SEARCH",             search,              write_time, all_info, all_info, write_time);
499         CHECK_TIME("STANDARD",           standard,            write_time, all_info, all_info, write_time);
500         CHECK_TIME("EA_SIZE",            ea_size,             write_time, all_info, all_info, write_time);
501         CHECK_TIME("STANDARD",           standard,            create_time, all_info, all_info, create_time);
502         CHECK_TIME("EA_SIZE",            ea_size,             create_time, all_info, all_info, create_time);
503         CHECK_TIME("STANDARD",           standard,            access_time, all_info, all_info, access_time);
504         CHECK_TIME("EA_SIZE",            ea_size,             access_time, all_info, all_info, access_time);
505
506         CHECK_NTTIME("DIRECTORY_INFO",      directory_info,      write_time, all_info, all_info, write_time);
507         CHECK_NTTIME("FULL_DIRECTORY_INFO", full_directory_info, write_time, all_info, all_info, write_time);
508         CHECK_NTTIME("BOTH_DIRECTORY_INFO", both_directory_info, write_time, all_info, all_info, write_time);
509         CHECK_NTTIME("ID_FULL_DIRECTORY_INFO", id_full_directory_info,           write_time, all_info, all_info, write_time);
510         CHECK_NTTIME("ID_BOTH_DIRECTORY_INFO", id_both_directory_info,           write_time, all_info, all_info, write_time);
511
512         CHECK_NTTIME("DIRECTORY_INFO",      directory_info,      create_time, all_info, all_info, create_time);
513         CHECK_NTTIME("FULL_DIRECTORY_INFO", full_directory_info, create_time, all_info, all_info, create_time);
514         CHECK_NTTIME("BOTH_DIRECTORY_INFO", both_directory_info, create_time, all_info, all_info, create_time);
515         CHECK_NTTIME("ID_FULL_DIRECTORY_INFO", id_full_directory_info,           create_time, all_info, all_info, create_time);
516         CHECK_NTTIME("ID_BOTH_DIRECTORY_INFO", id_both_directory_info,           create_time, all_info, all_info, create_time);
517
518         CHECK_NTTIME("DIRECTORY_INFO",      directory_info,      access_time, all_info, all_info, access_time);
519         CHECK_NTTIME("FULL_DIRECTORY_INFO", full_directory_info, access_time, all_info, all_info, access_time);
520         CHECK_NTTIME("BOTH_DIRECTORY_INFO", both_directory_info, access_time, all_info, all_info, access_time);
521         CHECK_NTTIME("ID_FULL_DIRECTORY_INFO", id_full_directory_info,           access_time, all_info, all_info, access_time);
522         CHECK_NTTIME("ID_BOTH_DIRECTORY_INFO", id_both_directory_info,           access_time, all_info, all_info, access_time);
523
524         CHECK_NTTIME("DIRECTORY_INFO",      directory_info,      change_time, all_info, all_info, change_time);
525         CHECK_NTTIME("FULL_DIRECTORY_INFO", full_directory_info, change_time, all_info, all_info, change_time);
526         CHECK_NTTIME("BOTH_DIRECTORY_INFO", both_directory_info, change_time, all_info, all_info, change_time);
527         CHECK_NTTIME("ID_FULL_DIRECTORY_INFO", id_full_directory_info,           change_time, all_info, all_info, change_time);
528         CHECK_NTTIME("ID_BOTH_DIRECTORY_INFO", id_both_directory_info,           change_time, all_info, all_info, change_time);
529
530         CHECK_VAL("SEARCH",              search,              size, all_info, all_info, size);
531         CHECK_VAL("STANDARD",            standard,            size, all_info, all_info, size);
532         CHECK_VAL("EA_SIZE",             ea_size,             size, all_info, all_info, size);
533         CHECK_VAL("DIRECTORY_INFO",      directory_info,      size, all_info, all_info, size);
534         CHECK_VAL("FULL_DIRECTORY_INFO", full_directory_info, size, all_info, all_info, size);
535         CHECK_VAL("BOTH_DIRECTORY_INFO", both_directory_info, size, all_info, all_info, size);
536         CHECK_VAL("ID_FULL_DIRECTORY_INFO", id_full_directory_info,           size, all_info, all_info, size);
537         CHECK_VAL("ID_BOTH_DIRECTORY_INFO", id_both_directory_info,           size, all_info, all_info, size);
538         CHECK_VAL("UNIX_INFO",           unix_info,           size, all_info, all_info, size);
539
540         CHECK_VAL("STANDARD",            standard,            alloc_size, all_info, all_info, alloc_size);
541         CHECK_VAL("EA_SIZE",             ea_size,             alloc_size, all_info, all_info, alloc_size);
542         CHECK_VAL("DIRECTORY_INFO",      directory_info,      alloc_size, all_info, all_info, alloc_size);
543         CHECK_VAL("FULL_DIRECTORY_INFO", full_directory_info, alloc_size, all_info, all_info, alloc_size);
544         CHECK_VAL("BOTH_DIRECTORY_INFO", both_directory_info, alloc_size, all_info, all_info, alloc_size);
545         CHECK_VAL("ID_FULL_DIRECTORY_INFO", id_full_directory_info,           alloc_size, all_info, all_info, alloc_size);
546         CHECK_VAL("ID_BOTH_DIRECTORY_INFO", id_both_directory_info,           alloc_size, all_info, all_info, alloc_size);
547         CHECK_VAL("UNIX_INFO",           unix_info,           alloc_size, all_info, all_info, alloc_size);
548
549         CHECK_VAL("EA_SIZE",             ea_size,             ea_size, all_info, all_info, ea_size);
550         CHECK_VAL("FULL_DIRECTORY_INFO", full_directory_info, ea_size, all_info, all_info, ea_size);
551         CHECK_VAL("BOTH_DIRECTORY_INFO", both_directory_info, ea_size, all_info, all_info, ea_size);
552         CHECK_VAL("ID_FULL_DIRECTORY_INFO", id_full_directory_info,           ea_size, all_info, all_info, ea_size);
553         CHECK_VAL("ID_BOTH_DIRECTORY_INFO", id_both_directory_info,           ea_size, all_info, all_info, ea_size);
554
555         if (alt_info_supported) {
556                 CHECK_STR("SEARCH", search, name, alt_info, alt_name_info,
557                     fname);
558                 CHECK_WSTR("BOTH_DIRECTORY_INFO", both_directory_info,
559                     short_name, alt_info, alt_name_info, fname, STR_UNICODE);
560         }
561
562         CHECK_NAME("STANDARD",            standard,            name, fname+1, 0);
563         CHECK_NAME("EA_SIZE",             ea_size,             name, fname+1, 0);
564         CHECK_NAME("DIRECTORY_INFO",      directory_info,      name, fname+1, STR_TERMINATE_ASCII);
565         CHECK_NAME("FULL_DIRECTORY_INFO", full_directory_info, name, fname+1, STR_TERMINATE_ASCII);
566
567         if (name_info_supported) {
568                 CHECK_NAME("NAME_INFO", name_info, name, fname+1,
569                     STR_TERMINATE_ASCII);
570         }
571
572         CHECK_NAME("BOTH_DIRECTORY_INFO", both_directory_info, name, fname+1, STR_TERMINATE_ASCII);
573         CHECK_NAME("ID_FULL_DIRECTORY_INFO", id_full_directory_info,           name, fname+1, STR_TERMINATE_ASCII);
574         CHECK_NAME("ID_BOTH_DIRECTORY_INFO", id_both_directory_info,           name, fname+1, STR_TERMINATE_ASCII);
575         CHECK_UNIX_NAME("UNIX_INFO",           unix_info,           name, fname+1, STR_TERMINATE_ASCII);
576
577         if (internal_info_supported) {
578                 CHECK_VAL("ID_FULL_DIRECTORY_INFO", id_full_directory_info,
579                     file_id, internal_info, internal_information, file_id);
580                 CHECK_VAL("ID_BOTH_DIRECTORY_INFO", id_both_directory_info,
581                     file_id, internal_info, internal_information, file_id);
582         }
583
584 done:
585         smb_raw_exit(cli->session);
586         smbcli_unlink(cli->tree, fname);
587
588         return ret;
589 }
590
591
592 struct multiple_result {
593         TALLOC_CTX *tctx;
594         int count;
595         union smb_search_data *list;
596 };
597
598 /*
599   callback function for multiple_search
600 */
601 static bool multiple_search_callback(void *private_data, const union smb_search_data *file)
602 {
603         struct multiple_result *data = (struct multiple_result *)private_data;
604
605
606         data->count++;
607         data->list = talloc_realloc(data->tctx,
608                                       data->list, 
609                                       union smb_search_data,
610                                       data->count);
611
612         data->list[data->count-1] = *file;
613
614         return true;
615 }
616
617 enum continue_type {CONT_FLAGS, CONT_NAME, CONT_RESUME_KEY};
618
619 /*
620   do a single file (non-wildcard) search 
621 */
622 static NTSTATUS multiple_search(struct smbcli_state *cli, 
623                                 TALLOC_CTX *tctx,
624                                 const char *pattern,
625                                 enum smb_search_data_level data_level,
626                                 enum continue_type cont_type,
627                                 void *data)
628 {
629         union smb_search_first io;
630         union smb_search_next io2;
631         NTSTATUS status;
632         const int per_search = 100;
633         struct multiple_result *result = (struct multiple_result *)data;
634
635         if (data_level == RAW_SEARCH_DATA_SEARCH) {
636                 io.search_first.level = RAW_SEARCH_SEARCH;
637                 io.search_first.data_level = RAW_SEARCH_DATA_SEARCH;
638                 io.search_first.in.max_count = per_search;
639                 io.search_first.in.search_attrib = 0;
640                 io.search_first.in.pattern = pattern;
641         } else {
642                 io.t2ffirst.level = RAW_SEARCH_TRANS2;
643                 io.t2ffirst.data_level = data_level;
644                 io.t2ffirst.in.search_attrib = 0;
645                 io.t2ffirst.in.max_count = per_search;
646                 io.t2ffirst.in.flags = FLAG_TRANS2_FIND_CLOSE_IF_END;
647                 io.t2ffirst.in.storage_type = 0;
648                 io.t2ffirst.in.pattern = pattern;
649                 if (cont_type == CONT_RESUME_KEY) {
650                         io.t2ffirst.in.flags |= FLAG_TRANS2_FIND_REQUIRE_RESUME | 
651                                 FLAG_TRANS2_FIND_BACKUP_INTENT;
652                 }
653         }
654
655         status = smb_raw_search_first(cli->tree, tctx,
656                                       &io, data, multiple_search_callback);
657         
658
659         while (NT_STATUS_IS_OK(status)) {
660                 if (data_level == RAW_SEARCH_DATA_SEARCH) {
661                         io2.search_next.level = RAW_SEARCH_SEARCH;
662                         io2.search_next.data_level = RAW_SEARCH_DATA_SEARCH;
663                         io2.search_next.in.max_count = per_search;
664                         io2.search_next.in.search_attrib = 0;
665                         io2.search_next.in.id = result->list[result->count-1].search.id;
666                 } else {
667                         io2.t2fnext.level = RAW_SEARCH_TRANS2;
668                         io2.t2fnext.data_level = data_level;
669                         io2.t2fnext.in.handle = io.t2ffirst.out.handle;
670                         io2.t2fnext.in.max_count = per_search;
671                         io2.t2fnext.in.resume_key = 0;
672                         io2.t2fnext.in.flags = FLAG_TRANS2_FIND_CLOSE_IF_END;
673                         io2.t2fnext.in.last_name = "";
674                         switch (cont_type) {
675                         case CONT_RESUME_KEY:
676                                 io2.t2fnext.in.resume_key = extract_resume_key(&result->list[result->count-1],
677                                                                                io2.t2fnext.level, io2.t2fnext.data_level);
678                                 if (io2.t2fnext.in.resume_key == 0) {
679                                         printf("Server does not support resume by key for level %s\n",
680                                                level_name(io2.t2fnext.level, io2.t2fnext.data_level));
681                                         return NT_STATUS_NOT_SUPPORTED;
682                                 }
683                                 io2.t2fnext.in.flags |= FLAG_TRANS2_FIND_REQUIRE_RESUME |
684                                         FLAG_TRANS2_FIND_BACKUP_INTENT;
685                                 break;
686                         case CONT_NAME:
687                                 io2.t2fnext.in.last_name = extract_name(&result->list[result->count-1],
688                                                                         io2.t2fnext.level, io2.t2fnext.data_level);
689                                 break;
690                         case CONT_FLAGS:
691                                 io2.t2fnext.in.flags |= FLAG_TRANS2_FIND_CONTINUE;
692                                 break;
693                         }
694                 }
695
696                 status = smb_raw_search_next(cli->tree, tctx,
697                                              &io2, data, multiple_search_callback);
698                 if (!NT_STATUS_IS_OK(status)) {
699                         break;
700                 }
701                 if (data_level == RAW_SEARCH_DATA_SEARCH) {
702                         if (io2.search_next.out.count == 0) {
703                                 break;
704                         }
705                 } else if (io2.t2fnext.out.count == 0 ||
706                            io2.t2fnext.out.end_of_search) {
707                         break;
708                 }
709         }
710
711         return status;
712 }
713
714 #define CHECK_STATUS(status, correct) torture_assert_ntstatus_equal(tctx, status, correct, "incorrect status")
715
716 #define CHECK_VALUE(v, correct) torture_assert_int_equal(tctx, (v), (correct), "incorrect value");
717
718 #define CHECK_STRING(v, correct) torture_assert_casestr_equal(tctx, v, correct, "incorrect value");
719
720
721 static enum smb_search_data_level compare_data_level;
722
723 static int search_compare(union smb_search_data *d1, union smb_search_data *d2)
724 {
725         const char *s1, *s2;
726         enum smb_search_level level;
727
728         if (compare_data_level == RAW_SEARCH_DATA_SEARCH) {
729                 level = RAW_SEARCH_SEARCH;
730         } else {
731                 level = RAW_SEARCH_TRANS2;
732         }
733
734         s1 = extract_name(d1, level, compare_data_level);
735         s2 = extract_name(d2, level, compare_data_level);
736         return strcmp_safe(s1, s2);
737 }
738
739
740
741 /* 
742    basic testing of search calls using many files
743 */
744 static bool test_many_files(struct torture_context *tctx, 
745                             struct smbcli_state *cli)
746 {
747         const int num_files = 700;
748         int i, fnum, t;
749         char *fname;
750         bool ret = true;
751         NTSTATUS status;
752         struct multiple_result result;
753         struct {
754                 const char *name;
755                 const char *cont_name;
756                 enum smb_search_data_level data_level;
757                 enum continue_type cont_type;
758         } search_types[] = {
759                 {"SEARCH",              "ID",    RAW_SEARCH_DATA_SEARCH,              CONT_RESUME_KEY},
760                 {"BOTH_DIRECTORY_INFO", "NAME",  RAW_SEARCH_DATA_BOTH_DIRECTORY_INFO, CONT_NAME},
761                 {"BOTH_DIRECTORY_INFO", "FLAGS", RAW_SEARCH_DATA_BOTH_DIRECTORY_INFO, CONT_FLAGS},
762                 {"BOTH_DIRECTORY_INFO", "KEY",   RAW_SEARCH_DATA_BOTH_DIRECTORY_INFO, CONT_RESUME_KEY},
763                 {"STANDARD",            "FLAGS", RAW_SEARCH_DATA_STANDARD,            CONT_FLAGS},
764                 {"STANDARD",            "KEY",   RAW_SEARCH_DATA_STANDARD,            CONT_RESUME_KEY},
765                 {"STANDARD",            "NAME",  RAW_SEARCH_DATA_STANDARD,            CONT_NAME},
766                 {"EA_SIZE",             "FLAGS", RAW_SEARCH_DATA_EA_SIZE,             CONT_FLAGS},
767                 {"EA_SIZE",             "KEY",   RAW_SEARCH_DATA_EA_SIZE,             CONT_RESUME_KEY},
768                 {"EA_SIZE",             "NAME",  RAW_SEARCH_DATA_EA_SIZE,             CONT_NAME},
769                 {"DIRECTORY_INFO",      "FLAGS", RAW_SEARCH_DATA_DIRECTORY_INFO,      CONT_FLAGS},
770                 {"DIRECTORY_INFO",      "KEY",   RAW_SEARCH_DATA_DIRECTORY_INFO,      CONT_RESUME_KEY},
771                 {"DIRECTORY_INFO",      "NAME",  RAW_SEARCH_DATA_DIRECTORY_INFO,      CONT_NAME},
772                 {"FULL_DIRECTORY_INFO",    "FLAGS", RAW_SEARCH_DATA_FULL_DIRECTORY_INFO,    CONT_FLAGS},
773                 {"FULL_DIRECTORY_INFO",    "KEY",   RAW_SEARCH_DATA_FULL_DIRECTORY_INFO,    CONT_RESUME_KEY},
774                 {"FULL_DIRECTORY_INFO",    "NAME",  RAW_SEARCH_DATA_FULL_DIRECTORY_INFO,    CONT_NAME},
775                 {"ID_FULL_DIRECTORY_INFO", "FLAGS", RAW_SEARCH_DATA_ID_FULL_DIRECTORY_INFO, CONT_FLAGS},
776                 {"ID_FULL_DIRECTORY_INFO", "KEY",   RAW_SEARCH_DATA_ID_FULL_DIRECTORY_INFO, CONT_RESUME_KEY},
777                 {"ID_FULL_DIRECTORY_INFO", "NAME",  RAW_SEARCH_DATA_ID_FULL_DIRECTORY_INFO, CONT_NAME},
778                 {"ID_BOTH_DIRECTORY_INFO", "NAME",  RAW_SEARCH_DATA_ID_BOTH_DIRECTORY_INFO, CONT_NAME},
779                 {"ID_BOTH_DIRECTORY_INFO", "FLAGS", RAW_SEARCH_DATA_ID_BOTH_DIRECTORY_INFO, CONT_FLAGS},
780                 {"ID_BOTH_DIRECTORY_INFO", "KEY",   RAW_SEARCH_DATA_ID_BOTH_DIRECTORY_INFO, CONT_RESUME_KEY}
781         };
782
783         torture_assert(tctx, torture_setup_dir(cli, BASEDIR), "Failed to setup up test directory: " BASEDIR);
784
785         torture_comment(tctx, "Testing with %d files\n", num_files);
786
787         for (i=0;i<num_files;i++) {
788                 fname = talloc_asprintf(cli, BASEDIR "\\t%03d-%d.txt", i, i);
789                 fnum = smbcli_open(cli->tree, fname, O_CREAT|O_RDWR, DENY_NONE);
790                 torture_assert(tctx, fnum != -1, "Failed to create");
791                 talloc_free(fname);
792                 smbcli_close(cli->tree, fnum);
793         }
794
795
796         for (t=0;t<ARRAY_SIZE(search_types);t++) {
797                 ZERO_STRUCT(result);
798
799                 if ((search_types[t].cont_type == CONT_RESUME_KEY) &&
800                     (search_types[t].data_level != RAW_SEARCH_DATA_SEARCH) &&
801                     !torture_setting_bool(tctx, "resume_key_support", true)) {
802                         torture_comment(tctx,
803                                         "SKIP: Continue %s via %s\n",
804                                         search_types[t].name, search_types[t].cont_name);
805                         continue;
806                 }
807
808                 result.tctx = talloc_new(tctx);
809         
810                 torture_comment(tctx,
811                                 "Continue %s via %s\n", search_types[t].name, search_types[t].cont_name);
812
813                 status = multiple_search(cli, tctx, BASEDIR "\\*.*", 
814                                          search_types[t].data_level,
815                                          search_types[t].cont_type,
816                                          &result);
817                 if (NT_STATUS_EQUAL(status, NT_STATUS_NOT_SUPPORTED)) {
818                         torture_warning(tctx, "search level %s not supported "
819                                         "by server",
820                                         search_types[t].name);
821                         continue;
822                 }
823                 torture_assert_ntstatus_ok(tctx, status, "search failed");
824                 CHECK_VALUE(result.count, num_files);
825
826                 compare_data_level = search_types[t].data_level;
827
828                 TYPESAFE_QSORT(result.list, result.count, search_compare);
829
830                 for (i=0;i<result.count;i++) {
831                         const char *s;
832                         enum smb_search_level level;
833                         if (compare_data_level == RAW_SEARCH_DATA_SEARCH) {
834                                 level = RAW_SEARCH_SEARCH;
835                         } else {
836                                 level = RAW_SEARCH_TRANS2;
837                         }
838                         s = extract_name(&result.list[i], level, compare_data_level);
839                         fname = talloc_asprintf(cli, "t%03d-%d.txt", i, i);
840                         torture_assert_str_equal(tctx, fname, s, "Incorrect name");
841                         talloc_free(fname);
842                 }
843                 talloc_free(result.tctx);
844         }
845
846         smb_raw_exit(cli->session);
847         smbcli_deltree(cli->tree, BASEDIR);
848
849         return ret;
850 }
851
852 /*
853   check a individual file result
854 */
855 static bool check_result(struct multiple_result *result, const char *name, bool exist, uint32_t attrib)
856 {
857         int i;
858         for (i=0;i<result->count;i++) {
859                 if (strcmp(name, result->list[i].both_directory_info.name.s) == 0) break;
860         }
861         if (i == result->count) {
862                 if (exist) {
863                         printf("failed: '%s' should exist with attribute %s\n", 
864                                name, attrib_string(result->list, attrib));
865                         return false;
866                 }
867                 return true;
868         }
869
870         if (!exist) {
871                 printf("failed: '%s' should NOT exist (has attribute %s)\n", 
872                        name, attrib_string(result->list, result->list[i].both_directory_info.attrib));
873                 return false;
874         }
875
876         if ((result->list[i].both_directory_info.attrib&0xFFF) != attrib) {
877                 printf("failed: '%s' should have attribute 0x%x (has 0x%x)\n",
878                        name, 
879                        attrib, result->list[i].both_directory_info.attrib);
880                 return false;
881         }
882         return true;
883 }
884
885 /* 
886    test what happens when the directory is modified during a search
887 */
888 static bool test_modify_search(struct torture_context *tctx, 
889                                                            struct smbcli_state *cli)
890 {
891         const int num_files = 20;
892         int i, fnum;
893         char *fname;
894         bool ret = true;
895         NTSTATUS status;
896         struct multiple_result result;
897         union smb_search_first io;
898         union smb_search_next io2;
899         union smb_setfileinfo sfinfo;
900
901         torture_assert(tctx, torture_setup_dir(cli, BASEDIR), "Failed to setup up test directory: " BASEDIR);
902
903         printf("Creating %d files\n", num_files);
904
905         for (i=num_files-1;i>=0;i--) {
906                 fname = talloc_asprintf(cli, BASEDIR "\\t%03d-%d.txt", i, i);
907                 fnum = smbcli_open(cli->tree, fname, O_CREAT|O_RDWR, DENY_NONE);
908                 if (fnum == -1) {
909                         printf("Failed to create %s - %s\n", fname, smbcli_errstr(cli->tree));
910                         ret = false;
911                         goto done;
912                 }
913                 talloc_free(fname);
914                 smbcli_close(cli->tree, fnum);
915         }
916
917         printf("pulling the first file\n");
918         ZERO_STRUCT(result);
919         result.tctx = talloc_new(tctx);
920
921         io.t2ffirst.level = RAW_SEARCH_TRANS2;
922         io.t2ffirst.data_level = RAW_SEARCH_DATA_BOTH_DIRECTORY_INFO;
923         io.t2ffirst.in.search_attrib = 0;
924         io.t2ffirst.in.max_count = 0;
925         io.t2ffirst.in.flags = 0;
926         io.t2ffirst.in.storage_type = 0;
927         io.t2ffirst.in.pattern = BASEDIR "\\*.*";
928
929         status = smb_raw_search_first(cli->tree, tctx,
930                                       &io, &result, multiple_search_callback);
931         CHECK_STATUS(status, NT_STATUS_OK);
932         CHECK_VALUE(result.count, 1);
933         
934         printf("pulling the second file\n");
935         io2.t2fnext.level = RAW_SEARCH_TRANS2;
936         io2.t2fnext.data_level = RAW_SEARCH_DATA_BOTH_DIRECTORY_INFO;
937         io2.t2fnext.in.handle = io.t2ffirst.out.handle;
938         io2.t2fnext.in.max_count = 1;
939         io2.t2fnext.in.resume_key = 0;
940         io2.t2fnext.in.flags = 0;
941         io2.t2fnext.in.last_name = result.list[result.count-1].both_directory_info.name.s;
942
943         status = smb_raw_search_next(cli->tree, tctx,
944                                      &io2, &result, multiple_search_callback);
945         CHECK_STATUS(status, NT_STATUS_OK);
946         CHECK_VALUE(result.count, 2);
947
948         result.count = 0;
949
950         printf("Changing attributes and deleting\n");
951         smbcli_open(cli->tree, BASEDIR "\\T003-03.txt.2", O_CREAT|O_RDWR, DENY_NONE);
952         smbcli_open(cli->tree, BASEDIR "\\T013-13.txt.2", O_CREAT|O_RDWR, DENY_NONE);
953         fnum = create_complex_file(cli, tctx, BASEDIR "\\T013-13.txt.3");
954         smbcli_unlink(cli->tree, BASEDIR "\\T014-14.txt");
955         torture_set_file_attribute(cli->tree, BASEDIR "\\T015-15.txt", FILE_ATTRIBUTE_HIDDEN);
956         torture_set_file_attribute(cli->tree, BASEDIR "\\T016-16.txt", FILE_ATTRIBUTE_NORMAL);
957         torture_set_file_attribute(cli->tree, BASEDIR "\\T017-17.txt", FILE_ATTRIBUTE_SYSTEM);  
958         torture_set_file_attribute(cli->tree, BASEDIR "\\T018-18.txt", 0);      
959         sfinfo.generic.level = RAW_SFILEINFO_DISPOSITION_INFORMATION;
960         sfinfo.generic.in.file.fnum = fnum;
961         sfinfo.disposition_info.in.delete_on_close = 1;
962         status = smb_raw_setfileinfo(cli->tree, &sfinfo);
963         CHECK_STATUS(status, NT_STATUS_OK);
964
965         io2.t2fnext.level = RAW_SEARCH_TRANS2;
966         io2.t2fnext.data_level = RAW_SEARCH_DATA_BOTH_DIRECTORY_INFO;
967         io2.t2fnext.in.handle = io.t2ffirst.out.handle;
968         io2.t2fnext.in.max_count = num_files + 3;
969         io2.t2fnext.in.resume_key = 0;
970         io2.t2fnext.in.flags = 0;
971         io2.t2fnext.in.last_name = ".";
972
973         status = smb_raw_search_next(cli->tree, tctx,
974                                      &io2, &result, multiple_search_callback);
975         CHECK_STATUS(status, NT_STATUS_OK);
976         CHECK_VALUE(result.count, 20);
977
978         ret &= check_result(&result, "t009-9.txt", true, FILE_ATTRIBUTE_ARCHIVE);
979         ret &= check_result(&result, "t014-14.txt", false, 0);
980         ret &= check_result(&result, "t015-15.txt", false, 0);
981         ret &= check_result(&result, "t016-16.txt", true, FILE_ATTRIBUTE_NORMAL);
982         ret &= check_result(&result, "t017-17.txt", false, 0);
983         ret &= check_result(&result, "t018-18.txt", true, FILE_ATTRIBUTE_ARCHIVE);
984         ret &= check_result(&result, "t019-19.txt", true, FILE_ATTRIBUTE_ARCHIVE);
985         ret &= check_result(&result, "T013-13.txt.2", true, FILE_ATTRIBUTE_ARCHIVE);
986         ret &= check_result(&result, "T003-3.txt.2", false, 0);
987         ret &= check_result(&result, "T013-13.txt.3", true, FILE_ATTRIBUTE_ARCHIVE);
988
989         if (!ret) {
990                 for (i=0;i<result.count;i++) {
991                         printf("%s %s (0x%x)\n", 
992                                result.list[i].both_directory_info.name.s, 
993                                attrib_string(tctx, result.list[i].both_directory_info.attrib),
994                                result.list[i].both_directory_info.attrib);
995                 }
996         }
997
998 done:
999         smb_raw_exit(cli->session);
1000         smbcli_deltree(cli->tree, BASEDIR);
1001
1002         return ret;
1003 }
1004
1005
1006 /* 
1007    testing if directories always come back sorted
1008 */
1009 static bool test_sorted(struct torture_context *tctx, struct smbcli_state *cli)
1010 {
1011         const int num_files = 700;
1012         int i, fnum;
1013         char *fname;
1014         bool ret = true;
1015         NTSTATUS status;
1016         struct multiple_result result;
1017
1018         torture_assert(tctx, torture_setup_dir(cli, BASEDIR), "Failed to setup up test directory: " BASEDIR);
1019
1020         printf("Creating %d files\n", num_files);
1021
1022         for (i=0;i<num_files;i++) {
1023                 fname = talloc_asprintf(cli, BASEDIR "\\%s.txt", generate_random_str_list(tctx, 10, "abcdefgh"));
1024                 fnum = smbcli_open(cli->tree, fname, O_CREAT|O_RDWR, DENY_NONE);
1025                 if (fnum == -1) {
1026                         printf("Failed to create %s - %s\n", fname, smbcli_errstr(cli->tree));
1027                         ret = false;
1028                         goto done;
1029                 }
1030                 talloc_free(fname);
1031                 smbcli_close(cli->tree, fnum);
1032         }
1033
1034
1035         ZERO_STRUCT(result);
1036         result.tctx = tctx;
1037         
1038         status = multiple_search(cli, tctx, BASEDIR "\\*.*", 
1039                                  RAW_SEARCH_DATA_BOTH_DIRECTORY_INFO,
1040                                  CONT_NAME, &result);   
1041         CHECK_STATUS(status, NT_STATUS_OK);
1042         CHECK_VALUE(result.count, num_files);
1043
1044         for (i=0;i<num_files-1;i++) {
1045                 const char *name1, *name2;
1046                 name1 = result.list[i].both_directory_info.name.s;
1047                 name2 = result.list[i+1].both_directory_info.name.s;
1048                 if (strcasecmp_m(name1, name2) > 0) {
1049                         printf("non-alphabetical order at entry %d  '%s' '%s'\n", 
1050                                i, name1, name2);
1051                         printf("Server does not produce sorted directory listings (not an error)\n");
1052                         goto done;
1053                 }
1054         }
1055
1056         talloc_free(result.list);
1057
1058 done:
1059         smb_raw_exit(cli->session);
1060         smbcli_deltree(cli->tree, BASEDIR);
1061
1062         return ret;
1063 }
1064
1065
1066
1067 /* 
1068    basic testing of many old style search calls using separate dirs
1069 */
1070 static bool test_many_dirs(struct torture_context *tctx, 
1071                                                    struct smbcli_state *cli)
1072 {
1073         const int num_dirs = 20;
1074         int i, fnum, n;
1075         char *fname, *dname;
1076         bool ret = true;
1077         NTSTATUS status;
1078         union smb_search_data *file, *file2, *file3;
1079
1080         if (!torture_setting_bool(tctx, "raw_search_search", true)) {
1081                 torture_comment(tctx, "Skipping these tests as the server "
1082                         "doesn't support old style search calls\n");
1083                 return true;
1084         }
1085         torture_assert(tctx, torture_setup_dir(cli, BASEDIR), "Failed to setup up test directory: " BASEDIR);
1086
1087         printf("Creating %d dirs\n", num_dirs);
1088
1089         for (i=0;i<num_dirs;i++) {
1090                 dname = talloc_asprintf(cli, BASEDIR "\\d%d", i);
1091                 status = smbcli_mkdir(cli->tree, dname);
1092                 if (!NT_STATUS_IS_OK(status)) {
1093                         printf("(%s) Failed to create %s - %s\n", 
1094                                __location__, dname, nt_errstr(status));
1095                         ret = false;
1096                         goto done;
1097                 }
1098
1099                 for (n=0;n<3;n++) {
1100                         fname = talloc_asprintf(cli, BASEDIR "\\d%d\\f%d-%d.txt", i, i, n);
1101                         fnum = smbcli_open(cli->tree, fname, O_CREAT|O_RDWR, DENY_NONE);
1102                         if (fnum == -1) {
1103                                 printf("(%s) Failed to create %s - %s\n", 
1104                                        __location__, fname, smbcli_errstr(cli->tree));
1105                                 ret = false;
1106                                 goto done;
1107                         }
1108                         talloc_free(fname);
1109                         smbcli_close(cli->tree, fnum);
1110                 }
1111
1112                 talloc_free(dname);
1113         }
1114
1115         file  = talloc_zero_array(tctx, union smb_search_data, num_dirs);
1116         file2 = talloc_zero_array(tctx, union smb_search_data, num_dirs);
1117         file3 = talloc_zero_array(tctx, union smb_search_data, num_dirs);
1118
1119         printf("Search first on %d dirs\n", num_dirs);
1120
1121         for (i=0;i<num_dirs;i++) {
1122                 union smb_search_first io;
1123                 io.search_first.level = RAW_SEARCH_SEARCH;
1124                 io.search_first.data_level = RAW_SEARCH_DATA_SEARCH;
1125                 io.search_first.in.max_count = 1;
1126                 io.search_first.in.search_attrib = 0;
1127                 io.search_first.in.pattern = talloc_asprintf(tctx, BASEDIR "\\d%d\\*.txt", i);
1128                 fname = talloc_asprintf(tctx, "f%d-", i);
1129
1130                 io.search_first.out.count = 0;
1131
1132                 status = smb_raw_search_first(cli->tree, tctx,
1133                                               &io, (void *)&file[i], single_search_callback);
1134                 if (io.search_first.out.count != 1) {
1135                         printf("(%s) search first gave %d entries for dir %d - %s\n",
1136                                __location__, io.search_first.out.count, i, nt_errstr(status));
1137                         ret = false;
1138                         goto done;
1139                 }
1140                 CHECK_STATUS(status, NT_STATUS_OK);
1141                 if (strncasecmp(file[i].search.name, fname, strlen(fname)) != 0) {
1142                         printf("(%s) incorrect name '%s' expected '%s'[12].txt\n", 
1143                                __location__, file[i].search.name, fname);
1144                         ret = false;
1145                         goto done;
1146                 }
1147
1148                 talloc_free(fname);
1149         }
1150
1151         printf("Search next on %d dirs\n", num_dirs);
1152
1153         for (i=0;i<num_dirs;i++) {
1154                 union smb_search_next io2;
1155
1156                 io2.search_next.level = RAW_SEARCH_SEARCH;
1157                 io2.search_next.data_level = RAW_SEARCH_DATA_SEARCH;
1158                 io2.search_next.in.max_count = 1;
1159                 io2.search_next.in.search_attrib = 0;
1160                 io2.search_next.in.id = file[i].search.id;
1161                 fname = talloc_asprintf(tctx, "f%d-", i);
1162
1163                 io2.search_next.out.count = 0;
1164
1165                 status = smb_raw_search_next(cli->tree, tctx,
1166                                              &io2, (void *)&file2[i], single_search_callback);
1167                 if (io2.search_next.out.count != 1) {
1168                         printf("(%s) search next gave %d entries for dir %d - %s\n",
1169                                __location__, io2.search_next.out.count, i, nt_errstr(status));
1170                         ret = false;
1171                         goto done;
1172                 }
1173                 CHECK_STATUS(status, NT_STATUS_OK);
1174                 if (strncasecmp(file2[i].search.name, fname, strlen(fname)) != 0) {
1175                         printf("(%s) incorrect name '%s' expected '%s'[12].txt\n", 
1176                                __location__, file2[i].search.name, fname);
1177                         ret = false;
1178                         goto done;
1179                 }
1180
1181                 talloc_free(fname);
1182         }
1183
1184
1185         printf("Search next (rewind) on %d dirs\n", num_dirs);
1186
1187         for (i=0;i<num_dirs;i++) {
1188                 union smb_search_next io2;
1189
1190                 io2.search_next.level = RAW_SEARCH_SEARCH;
1191                 io2.search_next.data_level = RAW_SEARCH_DATA_SEARCH;
1192                 io2.search_next.in.max_count = 1;
1193                 io2.search_next.in.search_attrib = 0;
1194                 io2.search_next.in.id = file[i].search.id;
1195                 fname = talloc_asprintf(tctx, "f%d-", i);
1196                 io2.search_next.out.count = 0;
1197
1198                 status = smb_raw_search_next(cli->tree, tctx,
1199                                              &io2, (void *)&file3[i], single_search_callback);
1200                 if (io2.search_next.out.count != 1) {
1201                         printf("(%s) search next gave %d entries for dir %d - %s\n",
1202                                __location__, io2.search_next.out.count, i, nt_errstr(status));
1203                         ret = false;
1204                         goto done;
1205                 }
1206                 CHECK_STATUS(status, NT_STATUS_OK);
1207
1208                 if (strncasecmp(file3[i].search.name, file2[i].search.name, 3) != 0) {
1209                         printf("(%s) incorrect name '%s' on rewind at dir %d\n", 
1210                                __location__, file2[i].search.name, i);
1211                         ret = false;
1212                         goto done;
1213                 }
1214
1215                 if (torture_setting_bool(tctx, "rewind_support", true) &&
1216                     strcmp(file3[i].search.name, file2[i].search.name) != 0) {
1217                         printf("(%s) server did not rewind - got '%s' expected '%s'\n", 
1218                                __location__, file3[i].search.name, file2[i].search.name);
1219                         ret = false;
1220                         goto done;
1221                 }
1222
1223                 talloc_free(fname);
1224         }
1225
1226
1227 done:
1228         smb_raw_exit(cli->session);
1229         smbcli_deltree(cli->tree, BASEDIR);
1230
1231         return ret;
1232 }
1233
1234
1235 /* 
1236    testing of OS/2 style delete
1237 */
1238 static bool test_os2_delete(struct torture_context *tctx, 
1239                                                         struct smbcli_state *cli)
1240 {
1241         const int num_files = 700;
1242         const int delete_count = 4;
1243         int total_deleted = 0;
1244         int i, fnum;
1245         char *fname;
1246         bool ret = true;
1247         NTSTATUS status;
1248         union smb_search_first io;
1249         union smb_search_next io2;
1250         struct multiple_result result;
1251
1252         if (!torture_setting_bool(tctx, "search_ea_size", true)){
1253                 torture_comment(tctx,
1254                                 "Server does not support RAW_SEARCH_EA_SIZE "
1255                                 "level. Skipping this test\n");
1256                 return true;
1257         }
1258
1259         torture_assert(tctx, torture_setup_dir(cli, BASEDIR), "Failed to setup up test directory: " BASEDIR);
1260
1261         printf("Testing OS/2 style delete on %d files\n", num_files);
1262
1263         for (i=0;i<num_files;i++) {
1264                 fname = talloc_asprintf(cli, BASEDIR "\\file%u.txt", i);
1265                 fnum = smbcli_open(cli->tree, fname, O_CREAT|O_RDWR, DENY_NONE);
1266                 if (fnum == -1) {
1267                         printf("Failed to create %s - %s\n", fname, smbcli_errstr(cli->tree));
1268                         ret = false;
1269                         goto done;
1270                 }
1271                 talloc_free(fname);
1272                 smbcli_close(cli->tree, fnum);
1273         }
1274
1275
1276         ZERO_STRUCT(result);
1277         result.tctx = tctx;
1278
1279         io.t2ffirst.level = RAW_SEARCH_TRANS2;
1280         io.t2ffirst.data_level = RAW_SEARCH_DATA_EA_SIZE;
1281         io.t2ffirst.in.search_attrib = 0;
1282         io.t2ffirst.in.max_count = 100;
1283         io.t2ffirst.in.flags = FLAG_TRANS2_FIND_REQUIRE_RESUME;
1284         io.t2ffirst.in.storage_type = 0;
1285         io.t2ffirst.in.pattern = BASEDIR "\\*";
1286
1287         status = smb_raw_search_first(cli->tree, tctx,
1288                                       &io, &result, multiple_search_callback);
1289         CHECK_STATUS(status, NT_STATUS_OK);
1290
1291         for (i=0;i<MIN(result.count, delete_count);i++) {
1292                 fname = talloc_asprintf(cli, BASEDIR "\\%s", result.list[i].ea_size.name.s);
1293                 status = smbcli_unlink(cli->tree, fname);
1294                 CHECK_STATUS(status, NT_STATUS_OK);
1295                 total_deleted++;
1296                 talloc_free(fname);
1297         }
1298
1299         io2.t2fnext.level = RAW_SEARCH_TRANS2;
1300         io2.t2fnext.data_level = RAW_SEARCH_DATA_EA_SIZE;
1301         io2.t2fnext.in.handle = io.t2ffirst.out.handle;
1302         io2.t2fnext.in.max_count = 100;
1303         io2.t2fnext.in.resume_key = result.list[i-1].ea_size.resume_key;
1304         io2.t2fnext.in.flags = FLAG_TRANS2_FIND_REQUIRE_RESUME;
1305         io2.t2fnext.in.last_name = result.list[i-1].ea_size.name.s;
1306
1307         do {
1308                 ZERO_STRUCT(result);
1309                 result.tctx = tctx;
1310
1311                 status = smb_raw_search_next(cli->tree, tctx,
1312                                              &io2, &result, multiple_search_callback);
1313                 if (!NT_STATUS_IS_OK(status)) {
1314                         break;
1315                 }
1316
1317                 for (i=0;i<MIN(result.count, delete_count);i++) {
1318                         fname = talloc_asprintf(cli, BASEDIR "\\%s", result.list[i].ea_size.name.s);
1319                         status = smbcli_unlink(cli->tree, fname);
1320                         CHECK_STATUS(status, NT_STATUS_OK);
1321                         total_deleted++;
1322                         talloc_free(fname);
1323                 }
1324
1325                 if (i>0) {
1326                         io2.t2fnext.in.resume_key = result.list[i-1].ea_size.resume_key;
1327                         io2.t2fnext.in.last_name = result.list[i-1].ea_size.name.s;
1328                 }
1329         } while (NT_STATUS_IS_OK(status) && result.count != 0);
1330
1331         CHECK_STATUS(status, NT_STATUS_OK);
1332
1333         if (total_deleted != num_files) {
1334                 printf("error: deleted %d - expected to delete %d\n", 
1335                        total_deleted, num_files);
1336                 ret = false;
1337         }
1338
1339 done:
1340         smb_raw_exit(cli->session);
1341         smbcli_deltree(cli->tree, BASEDIR);
1342
1343         return ret;
1344 }
1345
1346
1347 static int ealist_cmp(union smb_search_data *r1, union smb_search_data *r2)
1348 {
1349         return strcmp(r1->ea_list.name.s, r2->ea_list.name.s);
1350 }
1351
1352 /* 
1353    testing of the rather strange ea_list level
1354 */
1355 static bool test_ea_list(struct torture_context *tctx, 
1356                                                  struct smbcli_state *cli)
1357 {
1358         int  fnum;
1359         bool ret = true;
1360         NTSTATUS status;
1361         union smb_search_first io;
1362         union smb_search_next nxt;
1363         struct multiple_result result;
1364         union smb_setfileinfo setfile;
1365
1366         torture_assert(tctx, torture_setup_dir(cli, BASEDIR), "Failed to setup up test directory: " BASEDIR);
1367
1368         printf("Testing RAW_SEARCH_EA_LIST level\n");
1369
1370         if (!torture_setting_bool(tctx, "search_ea_support", true) ||
1371             !torture_setting_bool(tctx, "ea_support", true)) {
1372                 printf("..skipped per target configuration.\n");
1373                 return true;
1374         }
1375
1376         fnum = smbcli_open(cli->tree, BASEDIR "\\file1.txt", O_CREAT|O_RDWR, DENY_NONE);
1377         smbcli_close(cli->tree, fnum);
1378
1379         fnum = smbcli_open(cli->tree, BASEDIR "\\file2.txt", O_CREAT|O_RDWR, DENY_NONE);
1380         smbcli_close(cli->tree, fnum);
1381
1382         fnum = smbcli_open(cli->tree, BASEDIR "\\file3.txt", O_CREAT|O_RDWR, DENY_NONE);
1383         smbcli_close(cli->tree, fnum);
1384
1385         setfile.generic.level = RAW_SFILEINFO_EA_SET;
1386         setfile.generic.in.file.path = BASEDIR "\\file2.txt";
1387         setfile.ea_set.in.num_eas = 2;
1388         setfile.ea_set.in.eas = talloc_array(tctx, struct ea_struct, 2);
1389         setfile.ea_set.in.eas[0].flags = 0;
1390         setfile.ea_set.in.eas[0].name.s = "EA ONE";
1391         setfile.ea_set.in.eas[0].value = data_blob_string_const("VALUE 1");
1392         setfile.ea_set.in.eas[1].flags = 0;
1393         setfile.ea_set.in.eas[1].name.s = "SECOND EA";
1394         setfile.ea_set.in.eas[1].value = data_blob_string_const("Value Two");
1395
1396         status = smb_raw_setpathinfo(cli->tree, &setfile);
1397         CHECK_STATUS(status, NT_STATUS_OK);
1398
1399         setfile.generic.in.file.path = BASEDIR "\\file3.txt";
1400         status = smb_raw_setpathinfo(cli->tree, &setfile);
1401         CHECK_STATUS(status, NT_STATUS_OK);
1402         
1403         ZERO_STRUCT(result);
1404         result.tctx = tctx;
1405
1406         io.t2ffirst.level = RAW_SEARCH_TRANS2;
1407         io.t2ffirst.data_level = RAW_SEARCH_DATA_EA_LIST;
1408         io.t2ffirst.in.search_attrib = 0;
1409         io.t2ffirst.in.max_count = 2;
1410         io.t2ffirst.in.flags = FLAG_TRANS2_FIND_REQUIRE_RESUME;
1411         io.t2ffirst.in.storage_type = 0;
1412         io.t2ffirst.in.pattern = BASEDIR "\\*";
1413         io.t2ffirst.in.num_names = 2;
1414         io.t2ffirst.in.ea_names = talloc_array(tctx, struct ea_name, 2);
1415         io.t2ffirst.in.ea_names[0].name.s = "SECOND EA";
1416         io.t2ffirst.in.ea_names[1].name.s = "THIRD EA";
1417
1418         status = smb_raw_search_first(cli->tree, tctx,
1419                                       &io, &result, multiple_search_callback);
1420         CHECK_STATUS(status, NT_STATUS_OK);
1421         CHECK_VALUE(result.count, 2);
1422
1423         nxt.t2fnext.level = RAW_SEARCH_TRANS2;
1424         nxt.t2fnext.data_level = RAW_SEARCH_DATA_EA_LIST;
1425         nxt.t2fnext.in.handle = io.t2ffirst.out.handle;
1426         nxt.t2fnext.in.max_count = 2;
1427         nxt.t2fnext.in.resume_key = result.list[1].ea_list.resume_key;
1428         nxt.t2fnext.in.flags = FLAG_TRANS2_FIND_REQUIRE_RESUME | FLAG_TRANS2_FIND_CONTINUE;
1429         nxt.t2fnext.in.last_name = result.list[1].ea_list.name.s;
1430         nxt.t2fnext.in.num_names = 2;
1431         nxt.t2fnext.in.ea_names = talloc_array(tctx, struct ea_name, 2);
1432         nxt.t2fnext.in.ea_names[0].name.s = "SECOND EA";
1433         nxt.t2fnext.in.ea_names[1].name.s = "THIRD EA";
1434
1435         status = smb_raw_search_next(cli->tree, tctx,
1436                                      &nxt, &result, multiple_search_callback);
1437         CHECK_STATUS(status, NT_STATUS_OK);
1438
1439         /* we have to sort the result as different servers can return directories
1440            in different orders */
1441         TYPESAFE_QSORT(result.list, result.count, ealist_cmp);
1442
1443         CHECK_VALUE(result.count, 3);
1444         CHECK_VALUE(result.list[0].ea_list.eas.num_eas, 2);
1445         CHECK_STRING(result.list[0].ea_list.name.s, "file1.txt");
1446         CHECK_STRING(result.list[0].ea_list.eas.eas[0].name.s, "SECOND EA");
1447         CHECK_VALUE(result.list[0].ea_list.eas.eas[0].value.length, 0);
1448         CHECK_STRING(result.list[0].ea_list.eas.eas[1].name.s, "THIRD EA");
1449         CHECK_VALUE(result.list[0].ea_list.eas.eas[1].value.length, 0);
1450
1451         CHECK_STRING(result.list[1].ea_list.name.s, "file2.txt");
1452         CHECK_STRING(result.list[1].ea_list.eas.eas[0].name.s, "SECOND EA");
1453         CHECK_VALUE(result.list[1].ea_list.eas.eas[0].value.length, 9);
1454         CHECK_STRING((const char *)result.list[1].ea_list.eas.eas[0].value.data, "Value Two");
1455         CHECK_STRING(result.list[1].ea_list.eas.eas[1].name.s, "THIRD EA");
1456         CHECK_VALUE(result.list[1].ea_list.eas.eas[1].value.length, 0);
1457
1458         CHECK_STRING(result.list[2].ea_list.name.s, "file3.txt");
1459         CHECK_STRING(result.list[2].ea_list.eas.eas[0].name.s, "SECOND EA");
1460         CHECK_VALUE(result.list[2].ea_list.eas.eas[0].value.length, 9);
1461         CHECK_STRING((const char *)result.list[2].ea_list.eas.eas[0].value.data, "Value Two");
1462         CHECK_STRING(result.list[2].ea_list.eas.eas[1].name.s, "THIRD EA");
1463         CHECK_VALUE(result.list[2].ea_list.eas.eas[1].value.length, 0);
1464
1465         smb_raw_exit(cli->session);
1466         smbcli_deltree(cli->tree, BASEDIR);
1467
1468         return ret;
1469 }
1470
1471 /*
1472  Test the behavior of max count parameter in TRANS2_FIND_FIRST2 and
1473  TRANS2_FIND_NEXT2 queries
1474 */
1475 static bool test_max_count(struct torture_context *tctx,
1476                            struct smbcli_state *cli)
1477 {
1478         const int num_files = 2;
1479         int i, fnum;
1480         char *fname;
1481         bool ret = true;
1482         NTSTATUS status;
1483         struct multiple_result result;
1484         union smb_search_first io;
1485         union smb_search_next io2;
1486
1487         torture_assert(tctx, torture_setup_dir(cli, BASEDIR), "Failed to setup up test directory: " BASEDIR);
1488
1489         torture_comment(tctx, "Creating %d files\n", num_files);
1490
1491         for (i=num_files-1;i>=0;i--) {
1492                 fname = talloc_asprintf(cli, BASEDIR "\\t%03d-%d.txt", i, i);
1493                 fnum = smbcli_open(cli->tree, fname, O_CREAT|O_RDWR, DENY_NONE);
1494                 if (fnum == -1) {
1495                         torture_comment(tctx,
1496                                 "Failed to create %s - %s\n",
1497                                 fname, smbcli_errstr(cli->tree));
1498                         ret = false;
1499                         goto done;
1500                 }
1501                 talloc_free(fname);
1502                 smbcli_close(cli->tree, fnum);
1503         }
1504
1505         torture_comment(tctx, "Set max_count parameter to 0. "
1506                         "This should return 1 entry\n");
1507         ZERO_STRUCT(result);
1508         result.tctx = talloc_new(tctx);
1509
1510         io.t2ffirst.level = RAW_SEARCH_TRANS2;
1511         io.t2ffirst.data_level = RAW_SEARCH_DATA_BOTH_DIRECTORY_INFO;
1512         io.t2ffirst.in.search_attrib = 0;
1513         io.t2ffirst.in.max_count = 0;
1514         io.t2ffirst.in.flags = 0;
1515         io.t2ffirst.in.storage_type = 0;
1516         io.t2ffirst.in.pattern = BASEDIR "\\*.*";
1517
1518         status = smb_raw_search_first(cli->tree, tctx,
1519                                       &io, &result, multiple_search_callback);
1520         CHECK_STATUS(status, NT_STATUS_OK);
1521         CHECK_VALUE(result.count, 1);
1522
1523         torture_comment(tctx, "Set max_count to 1. This should also "
1524                         "return 1 entry\n");
1525         io2.t2fnext.level = RAW_SEARCH_TRANS2;
1526         io2.t2fnext.data_level = RAW_SEARCH_DATA_BOTH_DIRECTORY_INFO;
1527         io2.t2fnext.in.handle = io.t2ffirst.out.handle;
1528         io2.t2fnext.in.max_count = 1;
1529         io2.t2fnext.in.resume_key = 0;
1530         io2.t2fnext.in.flags = 0;
1531         io2.t2fnext.in.last_name =
1532                 result.list[result.count-1].both_directory_info.name.s;
1533
1534         status = smb_raw_search_next(cli->tree, tctx,
1535                                      &io2, &result, multiple_search_callback);
1536         CHECK_STATUS(status, NT_STATUS_OK);
1537         CHECK_VALUE(result.count, 2);
1538 done:
1539         smb_raw_exit(cli->session);
1540         smbcli_deltree(cli->tree, BASEDIR);
1541
1542         return ret;
1543 }
1544
1545 /* 
1546    basic testing of all RAW_SEARCH_* calls using a single file
1547 */
1548 struct torture_suite *torture_raw_search(TALLOC_CTX *mem_ctx)
1549 {
1550         struct torture_suite *suite = torture_suite_create(mem_ctx, "search");
1551
1552         torture_suite_add_1smb_test(suite, "one file search", test_one_file);
1553         torture_suite_add_1smb_test(suite, "many files", test_many_files);
1554         torture_suite_add_1smb_test(suite, "sorted", test_sorted);
1555         torture_suite_add_1smb_test(suite, "modify search", test_modify_search);
1556         torture_suite_add_1smb_test(suite, "many dirs", test_many_dirs);
1557         torture_suite_add_1smb_test(suite, "os2 delete", test_os2_delete);
1558         torture_suite_add_1smb_test(suite, "ea list", test_ea_list);
1559         torture_suite_add_1smb_test(suite, "max count", test_max_count);
1560
1561         return suite;
1562 }