- expanded the ntrename test
authorAndrew Tridgell <tridge@samba.org>
Wed, 13 Aug 2003 20:19:23 +0000 (20:19 +0000)
committerAndrew Tridgell <tridge@samba.org>
Wed, 13 Aug 2003 20:19:23 +0000 (20:19 +0000)
- expanded seek test - the position information is handle specific!
(This used to be commit 163970bda6dba4a6c98943eee49d6610a156c070)

source4/torture/raw/rename.c
source4/torture/raw/seek.c

index 0e411299d0a74410a91a08014af44a77b97f4037..1766511ee6cf17d77985e9196acb3df9de7b1c95 100644 (file)
@@ -133,7 +133,7 @@ static BOOL test_ntrename(struct cli_state *cli, TALLOC_CTX *mem_ctx)
        union smb_rename io;
        NTSTATUS status;
        BOOL ret = True;
-       int fnum;
+       int fnum, i;
        const char *fname1 = BASEDIR "\\test1.txt";
        const char *fname2 = BASEDIR "\\test2.txt";
        union smb_fileinfo finfo;
@@ -154,7 +154,7 @@ static BOOL test_ntrename(struct cli_state *cli, TALLOC_CTX *mem_ctx)
        io.ntrename.in.old_name = fname1;
        io.ntrename.in.new_name = fname2;
        io.ntrename.in.attrib = 0;
-       io.ntrename.in.root_fid = 0;
+       io.ntrename.in.unknown = 0;
        io.ntrename.in.flags = RENAME_FLAG_RENAME;
        
        status = smb_raw_rename(cli->tree, &io);
@@ -275,6 +275,55 @@ static BOOL test_ntrename(struct cli_state *cli, TALLOC_CTX *mem_ctx)
        io.ntrename.in.flags = 0x106;
        status = smb_raw_rename(cli->tree, &io);
        CHECK_STATUS(status, NT_STATUS_ACCESS_DENIED);
+
+       printf("Checking unknown field\n");
+       io.ntrename.in.old_name = fname1;
+       io.ntrename.in.new_name = fname2;
+       io.ntrename.in.attrib = 0;
+       io.ntrename.in.flags = RENAME_FLAG_RENAME;
+       io.ntrename.in.unknown = 0xff;
+       status = smb_raw_rename(cli->tree, &io);
+       CHECK_STATUS(status, NT_STATUS_OK);
+
+       fnum = create_directory_handle(cli, BASEDIR "\\testdir");
+       printf("Trying flags 0x102 fnum=%d\n", fnum);
+
+       io.ntrename.in.old_name = fname2;
+       io.ntrename.in.new_name = fname1;
+       io.ntrename.in.attrib = 0;
+       io.ntrename.in.flags = 0x102;
+       io.ntrename.in.unknown = fnum;
+       status = smb_raw_rename(cli->tree, &io);
+       CHECK_STATUS(status, NT_STATUS_INVALID_PARAMETER);
+
+       for (i=0;i<32;i++) {
+               io.ntrename.in.unknown = (1<<i);
+               status = smb_raw_rename(cli->tree, &io);
+               if (!NT_STATUS_EQUAL(status, NT_STATUS_INVALID_PARAMETER)) {
+                       printf("i=0x%x status=%s\n", i, nt_errstr(status));
+               }
+               CHECK_STATUS(status, NT_STATUS_INVALID_PARAMETER);
+       }
+
+       printf("Checking other flags\n");
+
+       for (i=0;i<0xFFF;i++) {
+               if (i == RENAME_FLAG_RENAME ||
+                   i == RENAME_FLAG_HARD_LINK ||
+                   i == RENAME_FLAG_COPY) {
+                       continue;
+               }
+
+               io.ntrename.in.old_name = fname2;
+               io.ntrename.in.new_name = fname1;
+               io.ntrename.in.flags = i;
+               io.ntrename.in.attrib = 0;
+               io.ntrename.in.unknown = 0;
+               status = smb_raw_rename(cli->tree, &io);
+               if (!NT_STATUS_EQUAL(status, NT_STATUS_ACCESS_DENIED)) {
+                       printf("flags=0x%x status=%s\n", i, nt_errstr(status));
+               }
+       }
        
 done:
        smb_raw_exit(cli->session);
index 9379b676ab7cc598055a64eb4c2056a4253ff9a9..a0980a7aea8694b7347f3a39cb0a75d706d213f6 100644 (file)
@@ -31,7 +31,7 @@
 #define CHECK_VALUE(v, correct) do { \
        if ((v) != (correct)) { \
                printf("(%d) Incorrect value %s=%d - should be %d\n", \
-                      __LINE__, #v, v, correct); \
+                      __LINE__, #v, (int)v, (int)correct); \
                ret = False; \
                goto done; \
        }} while (0)
@@ -45,9 +45,10 @@ static BOOL test_seek(struct cli_state *cli, TALLOC_CTX *mem_ctx)
 {
        struct smb_seek io;
        union smb_fileinfo finfo;
+       union smb_setfileinfo sfinfo;
        NTSTATUS status;
        BOOL ret = True;
-       int fnum;
+       int fnum, fnum2;
        const char *fname = BASEDIR "\\test.txt";
 
        if (cli_deltree(cli, BASEDIR) == -1 ||
@@ -56,7 +57,7 @@ static BOOL test_seek(struct cli_state *cli, TALLOC_CTX *mem_ctx)
                return False;
        }
 
-       fnum = create_complex_file(cli, mem_ctx, fname);
+       fnum = cli_open(cli, fname, O_RDWR|O_CREAT|O_TRUNC, DENY_NONE);
        if (fnum == -1) {
                printf("Failed to open test.txt - %s\n", cli_errstr(cli));
                ret = False;
@@ -120,6 +121,32 @@ static BOOL test_seek(struct cli_state *cli, TALLOC_CTX *mem_ctx)
        CHECK_STATUS(status, NT_STATUS_OK);
        CHECK_VALUE(io.out.offset, 999);
 
+       printf("Testing position information\n");
+       fnum2 = cli_open(cli, fname, O_RDWR, DENY_NONE);
+       if (fnum2 == -1) {
+               printf("2nd open failed - %s\n", cli_errstr(cli));
+               ret = False;
+               goto done;
+       }
+       sfinfo.generic.level = RAW_SFILEINFO_POSITION_INFORMATION;
+       sfinfo.position_information.file.fnum = fnum2;
+       sfinfo.position_information.in.position = 25;
+       status = smb_raw_setfileinfo(cli->tree, &sfinfo);
+       CHECK_STATUS(status, NT_STATUS_OK);
+
+       finfo.generic.level = RAW_FILEINFO_POSITION_INFORMATION;
+       finfo.position_information.in.fnum = fnum2;
+       status = smb_raw_fileinfo(cli->tree, mem_ctx, &finfo);
+       CHECK_STATUS(status, NT_STATUS_OK);
+       CHECK_VALUE(finfo.position_information.out.position, 25);
+
+       finfo.generic.level = RAW_FILEINFO_POSITION_INFORMATION;
+       finfo.position_information.in.fnum = fnum;
+       status = smb_raw_fileinfo(cli->tree, mem_ctx, &finfo);
+       CHECK_STATUS(status, NT_STATUS_OK);
+       CHECK_VALUE(finfo.position_information.out.position, 0);
+       
+
 done:
        smb_raw_exit(cli->session);
        cli_deltree(cli, BASEDIR);