s4:lib/tevent: rename structs
[sfrench/samba-autobuild/.git] / source4 / torture / gentest.c
index 60243a5d1b8f961e07bc2309381016225dbef004..0677d9ac8e29e0ecb19686dcfd1871d4623241e8 100644 (file)
@@ -183,7 +183,7 @@ static bool connect_servers_fast(void)
 /***************************************************** 
 connect to the servers
 *******************************************************/
-static bool connect_servers(struct event_context *ev,
+static bool connect_servers(struct tevent_context *ev,
                            struct loadparm_context *lp_ctx)
 {
        int i, j;
@@ -214,7 +214,9 @@ static bool connect_servers(struct event_context *ev,
                for (j=0;j<NINSTANCES;j++) {
                        NTSTATUS status;
                        struct smbcli_options smb_options;
+                       struct smbcli_session_options smb_session_options;
                        lp_smbcli_options(lp_ctx, &smb_options);
+                       lp_smbcli_session_options(lp_ctx, &smb_session_options);
 
                        printf("Connecting to \\\\%s\\%s as %s - instance %d\n",
                               servers[i].server_name, servers[i].share_name, 
@@ -225,20 +227,28 @@ static bool connect_servers(struct event_context *ev,
 
                        if (options.smb2) {
                                status = smb2_connect(NULL, servers[i].server_name, 
+                                                                         lp_smb_ports(lp_ctx),
                                                      servers[i].share_name,
                                                      lp_resolve_context(lp_ctx),
                                                      servers[i].credentials,
                                                      &servers[i].smb2_tree[j],
-                                                     ev, &smb_options);
+                                                     ev, &smb_options,
+                                                         lp_socket_options(lp_ctx),
+                                                         lp_gensec_settings(lp_ctx, lp_ctx)
+                                                         );
                        } else {
                                status = smbcli_tree_full_connection(NULL,
                                                                     &servers[i].smb_tree[j], 
                                                                     servers[i].server_name, 
                                                                     lp_smb_ports(lp_ctx),
                                                                     servers[i].share_name, "A:",
+                                                                        lp_socket_options(lp_ctx),
                                                                     servers[i].credentials,
                                                                     lp_resolve_context(lp_ctx), ev,
-                                                                    &smb_options);
+                                                                    &smb_options,
+                                                                    &smb_session_options,
+                                                                        lp_iconv_convenience(lp_ctx),
+                                                                        lp_gensec_settings(lp_ctx, lp_ctx));
                        }
                        if (!NT_STATUS_IS_OK(status)) {
                                printf("Failed to connect to \\\\%s\\%s - %s\n",
@@ -1165,6 +1175,8 @@ static void idle_func_smb2(struct smb2_transport *transport, void *private)
 */
 static bool compare_status(NTSTATUS status1, NTSTATUS status2)
 {
+       char *s;
+
        if (NT_STATUS_EQUAL(status1, status2)) return true;
 
        /* one code being an error and the other OK is always an error */
@@ -1178,6 +1190,17 @@ static bool compare_status(NTSTATUS status1, NTSTATUS status2)
            ignore_pattern(nt_errstr(status2))) {
                return true;
        }
+
+       /* also support ignore patterns of the form NT_STATUS_XX:NT_STATUS_YY
+          meaning that the first server returns NT_STATUS_XX and the 2nd
+          returns NT_STATUS_YY */
+       s = talloc_asprintf(current_op.mem_ctx, "%s:%s", 
+                           nt_errstr(status1), 
+                           nt_errstr(status2));
+       if (ignore_pattern(s)) {
+               return true;
+       }
+
        current_op.mismatch = nt_errstr(status1);
        return false;
 }
@@ -1348,7 +1371,7 @@ again:
        } \
        current_op.status = status[0]; \
        for (i=1;i<NSERVERS;i++) { \
-               if (!compare_status(status[i], status[0])) { \
+               if (!compare_status(status[0], status[1])) { \
                        printf("status different in %s - %s %s\n", #call, \
                               nt_errstr(status[0]), nt_errstr(status[i])); \
                        current_op.mismatch = nt_errstr(status[0]); \
@@ -1459,7 +1482,9 @@ again:
 } while(0)
 
 #define CHECK_BLOB_EQUAL(field) do { \
-       if (memcmp(parm[0].field.data, parm[1].field.data, parm[0].field.length) != 0 && !ignore_pattern(#field)) { \
+       if (((parm[0].field.data == NULL && parm[1].field.data != NULL) || \
+           (parm[1].field.data == NULL && parm[0].field.data != NULL) || \
+           (memcmp(parm[0].field.data, parm[1].field.data, parm[0].field.length) != 0)) && !ignore_pattern(#field)) { \
                current_op.mismatch = #field; \
                printf("Mismatch in %s\n", #field); \
                return false; \
@@ -2164,6 +2189,9 @@ static void gen_setfileinfo(int instance, union smb_setfileinfo *info)
        case RAW_SFILEINFO_MODE_INFORMATION:
                info->mode_information.in.mode = gen_bits_mask(0xFFFFFFFF);
                break;
+       case RAW_SFILEINFO_FULL_EA_INFORMATION:
+               info->full_ea_information.in.eas = gen_ea_list();
+               break;
        case RAW_SFILEINFO_GENERIC:
        case RAW_SFILEINFO_SEC_DESC:
        case RAW_SFILEINFO_UNIX_BASIC:
@@ -2220,7 +2248,8 @@ static void gen_setfileinfo(int instance, union smb_setfileinfo *info)
        do {
                i = gen_int_range(0, num_levels-1);
        } while (ignore_pattern(levels[i].name));
-       
+
+       ZERO_STRUCTP(info);
        info->generic.level = levels[i].level;
 
        switch (info->generic.level) {
@@ -2277,6 +2306,9 @@ static void gen_setfileinfo(int instance, union smb_setfileinfo *info)
        case RAW_SFILEINFO_MODE_INFORMATION:
                info->mode_information.in.mode = gen_bits_mask(0xFFFFFFFF);
                break;
+       case RAW_SFILEINFO_FULL_EA_INFORMATION:
+               info->full_ea_information.in.eas = gen_ea_list();
+               break;
 
        case RAW_SFILEINFO_GENERIC:
        case RAW_SFILEINFO_SEC_DESC:
@@ -2370,9 +2402,8 @@ static bool handler_smb_spathinfo(int instance)
        union smb_setfileinfo parm[NSERVERS];
        NTSTATUS status[NSERVERS];
 
-       parm[0].generic.in.file.path = gen_fname_open(instance);
-
        gen_setfileinfo(instance, &parm[0]);
+       parm[0].generic.in.file.path = gen_fname_open(instance);
 
        GEN_COPY_PARM;
 
@@ -2741,9 +2772,8 @@ static bool handler_smb2_sfileinfo(int instance)
        union smb_setfileinfo parm[NSERVERS];
        NTSTATUS status[NSERVERS];
 
-       parm[0].generic.in.file.fnum = gen_fnum(instance);
-
        gen_setfileinfo(instance, &parm[0]);
+       parm[0].generic.in.file.fnum = gen_fnum(instance);
 
        GEN_COPY_PARM;
        GEN_SET_FNUM_SMB2(generic.in.file.handle);
@@ -2859,7 +2889,7 @@ static struct {
   run the test with the current set of op_parms parameters
   return the number of operations that completed successfully
 */
-static int run_test(struct event_context *ev, struct loadparm_context *lp_ctx)
+static int run_test(struct tevent_context *ev, struct loadparm_context *lp_ctx)
 {
        int op, i;
 
@@ -2905,12 +2935,11 @@ static int run_test(struct event_context *ev, struct loadparm_context *lp_ctx)
                current_op.opnum = op;
                current_op.name = gen_ops[which_op].name;
                current_op.status = NT_STATUS_OK;
+               talloc_free(current_op.mem_ctx);
                current_op.mem_ctx = talloc_named(NULL, 0, "%s", current_op.name);
 
                ret = gen_ops[which_op].handler(instance);
 
-               talloc_free(current_op.mem_ctx);
-
                gen_ops[which_op].count++;
                if (NT_STATUS_IS_OK(current_op.status)) {
                        gen_ops[which_op].success_count++;                      
@@ -2941,7 +2970,7 @@ static int run_test(struct event_context *ev, struct loadparm_context *lp_ctx)
    perform a backtracking analysis of the minimal set of operations
    to generate an error
 */
-static void backtrack_analyze(struct event_context *ev,
+static void backtrack_analyze(struct tevent_context *ev,
                              struct loadparm_context *lp_ctx)
 {
        int chunk, ret;
@@ -3009,7 +3038,7 @@ static void backtrack_analyze(struct event_context *ev,
 /* 
    start the main gentest process
 */
-static bool start_gentest(struct event_context *ev,
+static bool start_gentest(struct tevent_context *ev,
                          struct loadparm_context *lp_ctx)
 {
        int op;
@@ -3024,7 +3053,7 @@ static bool start_gentest(struct event_context *ev,
        /* generate the seeds - after this everything is deterministic */
        if (options.use_preset_seeds) {
                int numops;
-               char **preset = file_lines_load(options.seeds_file, &numops, NULL);
+               char **preset = file_lines_load(options.seeds_file, &numops, 0, NULL);
                if (!preset) {
                        printf("Failed to load %s - %s\n", options.seeds_file, strerror(errno));
                        exit(1);
@@ -3101,7 +3130,7 @@ static bool split_unc_name(const char *unc, char **server, char **share)
        int i, username_count=0;
        bool ret;
        char *ignore_file=NULL;
-       struct event_context *ev;
+       struct tevent_context *ev;
        struct loadparm_context *lp_ctx;
        poptContext pc;
        int argc_new;
@@ -3171,7 +3200,7 @@ static bool split_unc_name(const char *unc, char **server, char **share)
        }
 
        if (ignore_file) {
-               options.ignore_patterns = file_lines_load(ignore_file, NULL, NULL);
+               options.ignore_patterns = file_lines_load(ignore_file, NULL, 0, NULL);
        }
 
        argv_new = discard_const_p(char *, poptGetArgs(pc));
@@ -3217,7 +3246,7 @@ static bool split_unc_name(const char *unc, char **server, char **share)
 
        printf("seed=%u\n", options.seed);
 
-       ev = event_context_init(talloc_autofree_context());
+       ev = s4_event_context_init(talloc_autofree_context());
 
        gensec_init(lp_ctx);