s4:torture: s/private/private_data
[samba.git] / source4 / torture / raw / qfileinfo.c
index 8cb80cecc12739340f30c57033d03b17e686a2ae..c7673be52633121714f4f81b3c420de56d9d26c1 100644 (file)
 #include "includes.h"
 #include "torture/torture.h"
 #include "libcli/raw/libcliraw.h"
+#include "libcli/raw/raw_proto.h"
 #include "libcli/libcli.h"
 #include "torture/util.h"
 #include "librpc/rpc/dcerpc.h"
 #include "torture/rpc/rpc.h"
+#include "torture/raw/proto.h"
+#include "param/param.h"
 
 static struct {
        const char *name;
@@ -185,7 +188,7 @@ static union smb_fileinfo *fname_find(bool is_ipc, const char *name)
                #n1, #v1, (uint_t)s1->n1.out.v1, \
                #n2, #v2, (uint_t)s2->n2.out.v2, \
               __FILE__, __LINE__); \
-        ret = False; \
+        ret = false; \
 }} while(0)
 
 #define STR_EQUAL(n1, v1, n2, v2) do {if (strcmp_safe(s1->n1.out.v1.s, s2->n2.out.v2.s) || \
@@ -194,7 +197,7 @@ static union smb_fileinfo *fname_find(bool is_ipc, const char *name)
                #n1, #v1, s1->n1.out.v1.s, s1->n1.out.v1.private_length, \
                #n2, #v2, s2->n2.out.v2.s, s2->n2.out.v2.private_length, \
               __FILE__, __LINE__); \
-        ret = False; \
+        ret = false; \
 }} while(0)
 
 #define STRUCT_EQUAL(n1, v1, n2, v2) do {if (memcmp(&s1->n1.out.v1,&s2->n2.out.v2,sizeof(s1->n1.out.v1))) { \
@@ -202,7 +205,7 @@ static union smb_fileinfo *fname_find(bool is_ipc, const char *name)
                #n1, #v1, \
                #n2, #v2, \
               __FILE__, __LINE__); \
-        ret = False; \
+        ret = false; \
 }} while(0)
 
 /* used to find hints on unknown values - and to make sure 
@@ -214,7 +217,7 @@ static union smb_fileinfo *fname_find(bool is_ipc, const char *name)
               (uint_t)s1->n1.out.v1, \
               (uint_t)s1->n1.out.v1, \
               __FILE__, __LINE__); \
-        ret = False; \
+        ret = false; \
 }} while(0)
 #endif
 
@@ -222,21 +225,21 @@ static union smb_fileinfo *fname_find(bool is_ipc, const char *name)
    for each call we test that it succeeds, and where possible test 
    for consistency between the calls. 
 */
-static BOOL torture_raw_qfileinfo_internals(struct torture_context *torture, 
+static bool torture_raw_qfileinfo_internals(struct torture_context *torture, 
                                            TALLOC_CTX *mem_ctx,        
                                            struct smbcli_tree *tree, 
                                            int fnum, const char *fname,
                                            bool is_ipc)
 {
        int i;
-       BOOL ret = True;
+       bool ret = true;
        int count;
        union smb_fileinfo *s1, *s2;    
        NTTIME correct_time;
        uint64_t correct_size;
        uint32_t correct_attrib;
        const char *correct_name;
-       BOOL skip_streams = False;
+       bool skip_streams = false;
 
        /* scan all the fileinfo and pathinfo levels */
        for (i=0; levels[i].name; i++) {
@@ -292,11 +295,10 @@ static BOOL torture_raw_qfileinfo_internals(struct torture_context *torture,
        }
 
        if (count != 0) {
-               ret = False;
+               ret = false;
                printf("%d levels failed\n", count);
                if (count > 35) {
-                       printf("too many level failures - giving up\n");
-                       goto done;
+                       torture_fail(torture, "too many level failures - giving up");
                }
        }
 
@@ -307,7 +309,7 @@ static BOOL torture_raw_qfileinfo_internals(struct torture_context *torture,
                        printf("STREAM_INFO broken (%d) - skipping streams checks\n",
                               s1 ? s1->stream_info.out.num_streams : -1);
                }
-               skip_streams = True;
+               skip_streams = true;
        }       
 
 
@@ -401,14 +403,14 @@ static BOOL torture_raw_qfileinfo_internals(struct torture_context *torture,
                printf("(%d) handle %s/%s incorrect - %s should be %s\n", __LINE__, #stype, #tfield,  \
                       nt_time_string(mem_ctx, s1->stype.out.tfield), \
                       nt_time_string(mem_ctx, correct_time)); \
-               ret = False; \
+               ret = false; \
        } \
        s1 = fname_find(is_ipc, sname); \
        if (s1 && memcmp(&s1->stype.out.tfield, &correct_time, sizeof(correct_time)) != 0) { \
                printf("(%d) path %s/%s incorrect - %s should be %s\n", __LINE__, #stype, #tfield,  \
                       nt_time_string(mem_ctx, s1->stype.out.tfield), \
                       nt_time_string(mem_ctx, correct_time)); \
-               ret = False; \
+               ret = false; \
        }} while (0)
 
 #define TIME_CHECK_DOS(sname, stype, tfield) do { \
@@ -417,14 +419,14 @@ static BOOL torture_raw_qfileinfo_internals(struct torture_context *torture,
                printf("(%d) handle %s/%s incorrect - %s should be %s\n", __LINE__, #stype, #tfield,  \
                       timestring(mem_ctx, s1->stype.out.tfield), \
                       nt_time_string(mem_ctx, correct_time)); \
-               ret = False; \
+               ret = false; \
        } \
        s1 = fname_find(is_ipc, sname); \
        if (s1 && dos_nt_time_cmp(s1->stype.out.tfield, correct_time) != 0) { \
                printf("(%d) path %s/%s incorrect - %s should be %s\n", __LINE__, #stype, #tfield,  \
                       timestring(mem_ctx, s1->stype.out.tfield), \
                       nt_time_string(mem_ctx, correct_time)); \
-               ret = False; \
+               ret = false; \
        }} while (0)
 
 #if 0 /* unused */
@@ -434,21 +436,21 @@ static BOOL torture_raw_qfileinfo_internals(struct torture_context *torture,
                printf("(%d) handle %s/%s incorrect - %s should be %s\n", __LINE__, #stype, #tfield,  \
                       timestring(mem_ctx, s1->stype.out.tfield), \
                       nt_time_string(mem_ctx, correct_time)); \
-               ret = False; \
+               ret = false; \
        } \
        s1 = fname_find(is_ipc, sname); \
        if (s1 && unx_nt_time_cmp(s1->stype.out.tfield, correct_time) != 0) { \
                printf("(%d) path %s/%s incorrect - %s should be %s\n", __LINE__, #stype, #tfield,  \
                       timestring(mem_ctx, s1->stype.out.tfield), \
                       nt_time_string(mem_ctx, correct_time)); \
-               ret = False; \
+               ret = false; \
        }} while (0)
 #endif
 
        /* now check that all the times that are supposed to be equal are correct */
        s1 = fnum_find("BASIC_INFO");
        correct_time = s1->basic_info.out.create_time;
-       printf("create_time: %s\n", nt_time_string(mem_ctx, correct_time));
+       torture_comment(torture, "create_time: %s\n", nt_time_string(mem_ctx, correct_time));
 
        TIME_CHECK_NT ("BASIC_INFO",               basic_info, create_time);
        TIME_CHECK_NT ("BASIC_INFORMATION",        basic_info, create_time);
@@ -460,7 +462,7 @@ static BOOL torture_raw_qfileinfo_internals(struct torture_context *torture,
 
        s1 = fnum_find("BASIC_INFO");
        correct_time = s1->basic_info.out.access_time;
-       printf("access_time: %s\n", nt_time_string(mem_ctx, correct_time));
+       torture_comment(torture, "access_time: %s\n", nt_time_string(mem_ctx, correct_time));
 
        TIME_CHECK_NT ("BASIC_INFO",               basic_info, access_time);
        TIME_CHECK_NT ("BASIC_INFORMATION",        basic_info, access_time);
@@ -472,7 +474,7 @@ static BOOL torture_raw_qfileinfo_internals(struct torture_context *torture,
 
        s1 = fnum_find("BASIC_INFO");
        correct_time = s1->basic_info.out.write_time;
-       printf("write_time : %s\n", nt_time_string(mem_ctx, correct_time));
+       torture_comment(torture, "write_time : %s\n", nt_time_string(mem_ctx, correct_time));
 
        TIME_CHECK_NT ("BASIC_INFO",               basic_info, write_time);
        TIME_CHECK_NT ("BASIC_INFORMATION",        basic_info, write_time);
@@ -485,7 +487,7 @@ static BOOL torture_raw_qfileinfo_internals(struct torture_context *torture,
 
        s1 = fnum_find("BASIC_INFO");
        correct_time = s1->basic_info.out.change_time;
-       printf("change_time: %s\n", nt_time_string(mem_ctx, correct_time));
+       torture_comment(torture, "change_time: %s\n", nt_time_string(mem_ctx, correct_time));
 
        TIME_CHECK_NT ("BASIC_INFO",               basic_info, change_time);
        TIME_CHECK_NT ("BASIC_INFORMATION",        basic_info, change_time);
@@ -499,19 +501,19 @@ static BOOL torture_raw_qfileinfo_internals(struct torture_context *torture,
                printf("(%d) handle %s/%s incorrect - %u should be %u\n", __LINE__, #stype, #tfield,  \
                       (uint_t)s1->stype.out.tfield, \
                       (uint_t)correct_size); \
-               ret = False; \
+               ret = false; \
        } \
        s1 = fname_find(is_ipc, sname); \
        if (s1 && s1->stype.out.tfield != correct_size) { \
                printf("(%d) path %s/%s incorrect - %u should be %u\n", __LINE__, #stype, #tfield,  \
                       (uint_t)s1->stype.out.tfield, \
                       (uint_t)correct_size); \
-               ret = False; \
+               ret = false; \
        }} while (0)
 
        s1 = fnum_find("STANDARD_INFO");
        correct_size = s1->standard_info.out.size;
-       printf("size: %u\n", (uint_t)correct_size);
+       torture_comment(torture, "size: %u\n", (uint_t)correct_size);
        
        SIZE_CHECK("GETATTR",                  getattr,                  size);
        SIZE_CHECK("GETATTRE",                 getattre,                 size);
@@ -532,7 +534,7 @@ static BOOL torture_raw_qfileinfo_internals(struct torture_context *torture,
 
        s1 = fnum_find("STANDARD_INFO");
        correct_size = s1->standard_info.out.alloc_size;
-       printf("alloc_size: %u\n", (uint_t)correct_size);
+       torture_comment(torture, "alloc_size: %u\n", (uint_t)correct_size);
        
        SIZE_CHECK("GETATTRE",                 getattre,                 alloc_size);
        SIZE_CHECK("STANDARD",                 standard,                 alloc_size);
@@ -553,19 +555,19 @@ static BOOL torture_raw_qfileinfo_internals(struct torture_context *torture,
                printf("(%d) handle %s/%s incorrect - 0x%x should be 0x%x\n", __LINE__, #stype, #tfield,  \
                       (uint_t)s1->stype.out.tfield, \
                       (uint_t)correct_attrib); \
-               ret = False; \
+               ret = false; \
        } \
        s1 = fname_find(is_ipc, sname); \
        if (s1 && s1->stype.out.tfield != correct_attrib) { \
                printf("(%d) path %s/%s incorrect - 0x%x should be 0x%x\n", __LINE__, #stype, #tfield,  \
                       (uint_t)s1->stype.out.tfield, \
                       (uint_t)correct_attrib); \
-               ret = False; \
+               ret = false; \
        }} while (0)
 
        s1 = fnum_find("BASIC_INFO");
        correct_attrib = s1->basic_info.out.attrib;
-       printf("attrib: 0x%x\n", (uint_t)correct_attrib);
+       torture_comment(torture, "attrib: 0x%x\n", (uint_t)correct_attrib);
        
        ATTRIB_CHECK("GETATTR",                   getattr,                   attrib);
        if (!is_ipc) {
@@ -581,7 +583,7 @@ static BOOL torture_raw_qfileinfo_internals(struct torture_context *torture,
        ATTRIB_CHECK("ATTRIBUTE_TAG_INFORMATION", attribute_tag_information, attrib);
 
        correct_name = fname;
-       printf("name: %s\n", correct_name);
+       torture_comment(torture, "name: %s\n", correct_name);
 
 #define NAME_CHECK(sname, stype, tfield, flags) do { \
        s1 = fnum_find(sname); \
@@ -589,14 +591,14 @@ static BOOL torture_raw_qfileinfo_internals(struct torture_context *torture,
                        wire_bad_flags(&s1->stype.out.tfield, flags, tree->session->transport))) { \
                printf("(%d) handle %s/%s incorrect - '%s/%d'\n", __LINE__, #stype, #tfield,  \
                       s1->stype.out.tfield.s, s1->stype.out.tfield.private_length); \
-               ret = False; \
+               ret = false; \
        } \
        s1 = fname_find(is_ipc, sname); \
        if (s1 && (strcmp_safe(s1->stype.out.tfield.s, correct_name) != 0 || \
                        wire_bad_flags(&s1->stype.out.tfield, flags, tree->session->transport))) { \
                printf("(%d) path %s/%s incorrect - '%s/%d'\n", __LINE__, #stype, #tfield,  \
                       s1->stype.out.tfield.s, s1->stype.out.tfield.private_length); \
-               ret = False; \
+               ret = false; \
        }} while (0)
 
        NAME_CHECK("NAME_INFO",        name_info, fname, STR_UNICODE);
@@ -605,32 +607,31 @@ static BOOL torture_raw_qfileinfo_internals(struct torture_context *torture,
        /* the ALL_INFO file name is the full path on the filesystem */
        s1 = fnum_find("ALL_INFO");
        if (s1 && !s1->all_info.out.fname.s) {
-               printf("ALL_INFO didn't give a filename\n");
-               ret = False;
+               torture_fail(torture, "ALL_INFO didn't give a filename");
        }
        if (s1 && s1->all_info.out.fname.s) {
                char *p = strrchr(s1->all_info.out.fname.s, '\\');
                if (!p) {
                        printf("Not a full path in all_info/fname? - '%s'\n", 
                               s1->all_info.out.fname.s);
-                       ret = False;
+                       ret = false;
                } else {
                        if (strcmp_safe(correct_name, p) != 0) {
                                printf("incorrect basename in all_info/fname - '%s'\n",
                                       s1->all_info.out.fname.s);
-                               ret = False;
+                               ret = false;
                        }
                }
                if (wire_bad_flags(&s1->all_info.out.fname, STR_UNICODE, tree->session->transport)) {
                        printf("Should not null terminate all_info/fname\n");
-                       ret = False;
+                       ret = false;
                }
        }
 
        s1 = fnum_find("ALT_NAME_INFO");
        if (s1) {
                correct_name = s1->alt_name_info.out.fname.s;
-               printf("alt_name: %s\n", correct_name);
+               torture_comment(torture, "alt_name: %s\n", correct_name);
                
                NAME_CHECK("ALT_NAME_INFO",        alt_name_info, fname, STR_UNICODE);
                NAME_CHECK("ALT_NAME_INFORMATION", alt_name_info, fname, STR_UNICODE);
@@ -647,12 +648,12 @@ static BOOL torture_raw_qfileinfo_internals(struct torture_context *torture,
                                             0, 0);
                if (fnum == -1) {
                        printf("Unable to open by alt_name - %s\n", smbcli_errstr(tree));
-                       ret = False;
+                       ret = false;
                }
                
                if (!skip_streams) {
                        correct_name = "::$DATA";
-                       printf("stream_name: %s\n", correct_name);
+                       torture_comment(torture, "stream_name: %s\n", correct_name);
                        
                        NAME_CHECK("STREAM_INFO",        stream_info, streams[0].stream_name, STR_UNICODE);
                        NAME_CHECK("STREAM_INFORMATION", stream_info, streams[0].stream_name, STR_UNICODE);
@@ -703,28 +704,28 @@ static BOOL torture_raw_qfileinfo_internals(struct torture_context *torture,
                printf("(%d) handle %s/%s != %s/%s - 0x%x vs 0x%x\n", __LINE__, \
                        #stype1, #tfield1, #stype2, #tfield2,  \
                       s1->stype1.out.tfield1, s2->stype2.out.tfield2); \
-               ret = False; \
+               ret = false; \
        } \
        s1 = fname_find(is_ipc, sname1); s2 = fname_find(is_ipc, sname2); \
        if (s1 && s2 && s1->stype1.out.tfield1 != s2->stype2.out.tfield2) { \
                printf("(%d) path %s/%s != %s/%s - 0x%x vs 0x%x\n", __LINE__, \
                        #stype1, #tfield1, #stype2, #tfield2,  \
                       s1->stype1.out.tfield1, s2->stype2.out.tfield2); \
-               ret = False; \
+               ret = false; \
        } \
        s1 = fnum_find(sname1); s2 = fname_find(is_ipc, sname2); \
        if (s1 && s2 && s1->stype1.out.tfield1 != s2->stype2.out.tfield2) { \
                printf("(%d) handle %s/%s != path %s/%s - 0x%x vs 0x%x\n", __LINE__, \
                        #stype1, #tfield1, #stype2, #tfield2,  \
                       s1->stype1.out.tfield1, s2->stype2.out.tfield2); \
-               ret = False; \
+               ret = false; \
        } \
        s1 = fname_find(is_ipc, sname1); s2 = fnum_find(sname2); \
        if (s1 && s2 && s1->stype1.out.tfield1 != s2->stype2.out.tfield2) { \
                printf("(%d) path %s/%s != handle %s/%s - 0x%x vs 0x%x\n", __LINE__, \
                        #stype1, #tfield1, #stype2, #tfield2,  \
                       s1->stype1.out.tfield1, s2->stype2.out.tfield2); \
-               ret = False; \
+               ret = false; \
        }} while (0)
 
        VAL_CHECK("STANDARD_INFO", standard_info, delete_pending, 
@@ -737,18 +738,18 @@ static BOOL torture_raw_qfileinfo_internals(struct torture_context *torture,
        if (s1 && is_ipc) {
                if (s1->basic_info.out.attrib != FILE_ATTRIBUTE_NORMAL) {
                        printf("(%d) attrib basic_info/nlink incorrect - %d should be %d\n", __LINE__, s1->basic_info.out.attrib, FILE_ATTRIBUTE_NORMAL);
-                       ret = False;
+                       ret = false;
                }
        }
        s1 = fnum_find("STANDARD_INFO");
        if (s1 && is_ipc) {
                if (s1->standard_info.out.nlink != 1) {
                        printf("(%d) nlinks standard_info/nlink incorrect - %d should be 1\n", __LINE__, s1->standard_info.out.nlink);
-                       ret = False;
+                       ret = false;
                }
                if (s1->standard_info.out.delete_pending != 1) {
                        printf("(%d) nlinks standard_info/delete_pending incorrect - %d should be 1\n", __LINE__, s1->standard_info.out.delete_pending);
-                       ret = False;
+                       ret = false;
                }
        }
        VAL_CHECK("EA_INFO",       ea_info,       ea_size, 
@@ -768,7 +769,7 @@ static BOOL torture_raw_qfileinfo_internals(struct torture_context *torture,
 
        s1 = fnum_find("INTERNAL_INFORMATION");
        if (s1) {
-               printf("file_id=%.0f\n", (double)s1->internal_information.out.file_id);
+               torture_comment(torture, "file_id=%.0f\n", (double)s1->internal_information.out.file_id);
        }
 
        NAME_PATH_CHECK("INTERNAL_INFORMATION", internal_information, file_id);
@@ -808,9 +809,6 @@ static BOOL torture_raw_qfileinfo_internals(struct torture_context *torture,
        /* when we set the delete disposition then the link count should drop
           to 0 and delete_pending should be 1 */
        
-
-done:
-
        return ret;
 }
 
@@ -831,7 +829,7 @@ bool torture_raw_qfileinfo(struct torture_context *torture,
                return false;
        }
 
-       ret = torture_raw_qfileinfo_internals(torture, torture, cli->tree, fnum, fname, False /* is_ipc */);
+       ret = torture_raw_qfileinfo_internals(torture, torture, cli->tree, fnum, fname, false /* is_ipc */);
        
        smbcli_close(cli->tree, fnum);
        smbcli_unlink(cli->tree, fname);
@@ -840,7 +838,7 @@ bool torture_raw_qfileinfo(struct torture_context *torture,
 }
 
 bool torture_raw_qfileinfo_pipe(struct torture_context *torture, 
-                                                               struct smbcli_state *cli)
+                               struct smbcli_state *cli)
 {
        bool ret = true;
        int fnum;
@@ -849,23 +847,18 @@ bool torture_raw_qfileinfo_pipe(struct torture_context *torture,
        struct smbcli_tree *ipc_tree;
        NTSTATUS status;
 
-       if (!(p = dcerpc_pipe_init(torture, 
-                                  cli->tree->session->transport->socket->event.ctx))) {
-               return False;
+       if (!(p = dcerpc_pipe_init(torture, cli->tree->session->transport->socket->event.ctx,
+                                  lp_iconv_convenience(torture->lp_ctx)))) {
+               return false;
        }
 
        status = dcerpc_pipe_open_smb(p, cli->tree, fname);
-       if (!NT_STATUS_IS_OK(status)) {
-               d_printf("dcerpc_pipe_open_smb failed: %s\n",
-                        nt_errstr(status));
-               talloc_free(p);
-               return False;
-       }
+       torture_assert_ntstatus_ok(torture, status, "dcerpc_pipe_open_smb failed");
 
        ipc_tree = dcerpc_smb_tree(p->conn);
        fnum = dcerpc_smb_fnum(p->conn);
 
-       ret = torture_raw_qfileinfo_internals(torture, torture, ipc_tree, fnum, fname, True /* is_ipc */);
+       ret = torture_raw_qfileinfo_internals(torture, torture, ipc_tree, fnum, fname, true /* is_ipc */);
        
        talloc_free(p);
        return ret;