Merge branch 'v4-0-test' of ssh://git.samba.org/data/git/samba into 4-0-local
[kai/samba.git] / source4 / torture / raw / open.c
index d28a8bd14eb562726fddec07c7736b6f97ebe495..b6979fa0d9868d6320abbe6c34ab00b11902e5a5 100644 (file)
@@ -954,6 +954,51 @@ static bool test_nttrans_create(struct smbcli_state *cli, struct torture_context
        CHECK_ALL_INFO(io.ntcreatex.out.is_directory, directory);
        CHECK_VAL(io.ntcreatex.out.file_type, FILE_TYPE_DISK);
        smbcli_close(cli->tree, fnum);
+
+       /* check no-recall - don't pull a file from tape on a HSM */
+       io.ntcreatex.in.create_options = NTCREATEX_OPTIONS_NO_RECALL;
+       status = smb_raw_open(cli->tree, tctx, &io);
+       CHECK_STATUS(status, NT_STATUS_OK);
+       fnum = io.ntcreatex.out.file.fnum;
+
+       CHECK_VAL(io.ntcreatex.out.oplock_level, 0);
+       CHECK_VAL(io.ntcreatex.out.create_action, NTCREATEX_ACTION_EXISTED);
+       CHECK_NTTIME(io.ntcreatex.out.create_time, create_time);
+       CHECK_NTTIME(io.ntcreatex.out.access_time, access_time);
+       CHECK_NTTIME(io.ntcreatex.out.write_time, write_time);
+       CHECK_NTTIME(io.ntcreatex.out.change_time, change_time);
+       CHECK_ALL_INFO(io.ntcreatex.out.attrib, attrib);
+       CHECK_ALL_INFO(io.ntcreatex.out.alloc_size, alloc_size);
+       CHECK_ALL_INFO(io.ntcreatex.out.size, size);
+       CHECK_ALL_INFO(io.ntcreatex.out.is_directory, directory);
+       CHECK_VAL(io.ntcreatex.out.file_type, FILE_TYPE_DISK);
+       smbcli_close(cli->tree, fnum);
+
+       /* Check some create options (these all should be ignored) */
+       for (i=0; i < 32; i++) {
+               uint32_t create_option = (1 << i) & NTCREATEX_OPTIONS_MUST_IGNORE_MASK;
+               if (create_option == 0) {
+                       continue;
+               }
+               io.ntcreatex.in.create_options = create_option;
+               status = smb_raw_open(cli->tree, tctx, &io);
+               CHECK_STATUS(status, NT_STATUS_OK);
+               fnum = io.ntcreatex.out.file.fnum;
+
+               CHECK_VAL(io.ntcreatex.out.oplock_level, 0);
+               CHECK_VAL(io.ntcreatex.out.create_action, NTCREATEX_ACTION_EXISTED);
+               CHECK_NTTIME(io.ntcreatex.out.create_time, create_time);
+               CHECK_NTTIME(io.ntcreatex.out.access_time, access_time);
+               CHECK_NTTIME(io.ntcreatex.out.write_time, write_time);
+               CHECK_NTTIME(io.ntcreatex.out.change_time, change_time);
+               CHECK_ALL_INFO(io.ntcreatex.out.attrib, attrib);
+               CHECK_ALL_INFO(io.ntcreatex.out.alloc_size, alloc_size);
+               CHECK_ALL_INFO(io.ntcreatex.out.size, size);
+               CHECK_ALL_INFO(io.ntcreatex.out.is_directory, directory);
+               CHECK_VAL(io.ntcreatex.out.file_type, FILE_TYPE_DISK);
+               smbcli_close(cli->tree, fnum);
+       }
+
        smbcli_unlink(cli->tree, fname);
 
 
@@ -1350,21 +1395,19 @@ static bool test_raw_open_multi(struct torture_context *tctx)
        const char *host = torture_setting_string(tctx, "host", NULL);
        const char *share = torture_setting_string(tctx, "share", NULL);
        int i, num_files = 3;
-       struct event_context *ev;
        int num_ok = 0;
        int num_collision = 0;
        
-       ev = cli_credentials_get_event_context(cmdline_credentials);
        clients = talloc_array(mem_ctx, struct smbcli_state *, num_files);
        requests = talloc_array(mem_ctx, struct smbcli_request *, num_files);
        ios = talloc_array(mem_ctx, union smb_open, num_files);
-       if ((ev == NULL) || (clients == NULL) || (requests == NULL) ||
+       if ((tctx->ev == NULL) || (clients == NULL) || (requests == NULL) ||
            (ios == NULL)) {
                DEBUG(0, ("talloc failed\n"));
                return false;
        }
 
-       if (!torture_open_connection_share(mem_ctx, &cli, tctx, host, share, ev)) {
+       if (!torture_open_connection_share(mem_ctx, &cli, tctx, host, share, tctx->ev)) {
                return false;
        }
 
@@ -1372,7 +1415,7 @@ static bool test_raw_open_multi(struct torture_context *tctx)
 
        for (i=0; i<num_files; i++) {
                if (!torture_open_connection_share(mem_ctx, &(clients[i]),
-                                                  tctx, host, share, ev)) {
+                                                  tctx, host, share, tctx->ev)) {
                        DEBUG(0, ("Could not open %d'th connection\n", i));
                        return false;
                }
@@ -1441,7 +1484,7 @@ static bool test_raw_open_multi(struct torture_context *tctx)
                        break;
                }
 
-               if (event_loop_once(ev) != 0) {
+               if (event_loop_once(tctx->ev) != 0) {
                        DEBUG(0, ("event_loop_once failed\n"));
                        return false;
                }