r8117: fixed a bunch more dos error code handing.
authorAndrew Tridgell <tridge@samba.org>
Mon, 4 Jul 2005 05:05:28 +0000 (05:05 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 18:19:10 +0000 (13:19 -0500)
The biggest change was fixing the RAW-CONTEXT test. It was forcing
capabilities to zero in an attempt to not negotiated extended
security, but as a side effect it was forcing negotiation of dos error
codes. This confused the hell out of the test code!

Also fixed a bunch of places incorrectly using NT_STATUS_V() instead
of NT_STATUS_EQUAL() and several places that had the wrong dos status
codes

source/torture/basic/attr.c
source/torture/basic/delete.c
source/torture/basic/locking.c
source/torture/basic/scanner.c
source/torture/raw/context.c
source/torture/raw/eas.c
source/torture/raw/lock.c
source/torture/torture.c

index 07a36ea9502c2f7815ceb1501ebb927453d770af..daa0f98d6098346f5cddb093201463e4d7380dd2 100644 (file)
@@ -130,15 +130,15 @@ BOOL torture_openattrtest(void)
                        if (fnum1 == -1) {
                                for (l = 0; l < ARRAY_SIZE(attr_results); l++) {
                                        if (attr_results[l].num == k) {
-                                               printf("[%d] trunc open 0x%x -> 0x%x of %s failed - should have succeeded !(0x%x:%s)\n",
+                                               printf("[%d] trunc open 0x%x -> 0x%x of %s failed - should have succeeded !(%s)\n",
                                                                k, open_attrs_table[i],
                                                                open_attrs_table[j],
-                                                               fname, NT_STATUS_V(smbcli_nt_error(cli1->tree)), smbcli_errstr(cli1->tree));
+                                                               fname, smbcli_errstr(cli1->tree));
                                                correct = False;
                                                CHECK_MAX_FAILURES(error_exit);
                                        }
                                }
-                               if (NT_STATUS_V(smbcli_nt_error(cli1->tree)) != NT_STATUS_V(NT_STATUS_ACCESS_DENIED)) {
+                               if (!NT_STATUS_EQUAL(smbcli_nt_error(cli1->tree), NT_STATUS_ACCESS_DENIED)) {
                                        printf("[%d] trunc open 0x%x -> 0x%x failed with wrong error code %s\n",
                                                        k, open_attrs_table[i], open_attrs_table[j],
                                                        smbcli_errstr(cli1->tree));
index f3aef08ce1d4a2d8791af1c6050ae720428ebdad..7ddd39c1cb5507db65b4d21f137ddf83fbc362fa 100644 (file)
@@ -550,7 +550,7 @@ BOOL torture_test_delete(void)
 
        status = smbcli_nt_delete_on_close(cli1->tree, fnum1, True);
 
-       if (NT_STATUS_V(status) != NT_STATUS_V(NT_STATUS_CANNOT_DELETE)) {
+       if (!NT_STATUS_EQUAL(status, NT_STATUS_CANNOT_DELETE)) {
                printf("(%s) setting delete_on_close should fail with NT_STATUS_CANNOT_DELETE. Got %s instead)\n", 
                       __location__, smbcli_errstr(cli1->tree));
                correct = False;
@@ -585,7 +585,7 @@ BOOL torture_test_delete(void)
                goto fail;
        } else {
                status = smbcli_nt_error(cli1->tree);
-               if (NT_STATUS_V(status) != NT_STATUS_V(NT_STATUS_CANNOT_DELETE)) {
+               if (!NT_STATUS_EQUAL(status, NT_STATUS_CANNOT_DELETE)) {
                        printf("(%s) setting delete_on_close on open should fail with NT_STATUS_CANNOT_DELETE. Got %s instead)\n", 
                               __location__, smbcli_errstr(cli1->tree));
                        correct = False;
index c3feaae2eb2ea0af0074fc6b3a6de6643c8691bc..3f395f3907149ee2108ce8d67bbd7d49d16d2874 100644 (file)
@@ -281,7 +281,7 @@ BOOL torture_locktest2(void)
                correct = False;
        } else {
                if (!check_error(__location__, cli, 
-                                ERRDOS, ERRlock
+                                ERRDOS, ERRnotlocked
                                 NT_STATUS_RANGE_NOT_LOCKED)) return False;
        }
 
@@ -290,7 +290,7 @@ BOOL torture_locktest2(void)
                correct = False;
        } else {
                if (!check_error(__location__, cli, 
-                                ERRDOS, ERRlock
+                                ERRDOS, ERRnotlocked
                                 NT_STATUS_RANGE_NOT_LOCKED)) return False;
        }
 
@@ -851,7 +851,7 @@ BOOL torture_locktest7(void)
 
        if (smbcli_write(cli1->tree, fnum1, 0, buf, 130, 4) != 4) {
                printf("pid1 unable to write to the range 130:4, error was %s\n", smbcli_errstr(cli1->tree));
-               if (NT_STATUS_V(smbcli_nt_error(cli1->tree)) != NT_STATUS_V(NT_STATUS_FILE_LOCK_CONFLICT)) {
+               if (!NT_STATUS_EQUAL(smbcli_nt_error(cli1->tree), NT_STATUS_FILE_LOCK_CONFLICT)) {
                        printf("Incorrect error (should be NT_STATUS_FILE_LOCK_CONFLICT) (%s)\n", 
                               __location__);
                        goto fail;
@@ -872,7 +872,7 @@ BOOL torture_locktest7(void)
 
        if (smbcli_write(cli1->tree, fnum1, 0, buf, 130, 4) != 4) {
                printf("pid2 unable to write to the range 130:4, error was %s\n", smbcli_errstr(cli1->tree));
-               if (NT_STATUS_V(smbcli_nt_error(cli1->tree)) != NT_STATUS_V(NT_STATUS_FILE_LOCK_CONFLICT)) {
+               if (!NT_STATUS_EQUAL(smbcli_nt_error(cli1->tree), NT_STATUS_FILE_LOCK_CONFLICT)) {
                        printf("Incorrect error (should be NT_STATUS_FILE_LOCK_CONFLICT) (%s)\n",
                               __location__);
                        goto fail;
@@ -915,7 +915,7 @@ BOOL torture_locktest7(void)
        if (smbcli_read(cli1->tree, fnum1, buf, 130, 4) != 4) {
                printf("pid2 unable to read the range 130:4, error was %s\n", 
                       smbcli_errstr(cli1->tree));
-               if (NT_STATUS_V(smbcli_nt_error(cli1->tree)) != NT_STATUS_V(NT_STATUS_FILE_LOCK_CONFLICT)) {
+               if (!NT_STATUS_EQUAL(smbcli_nt_error(cli1->tree), NT_STATUS_FILE_LOCK_CONFLICT)) {
                        printf("Incorrect error (should be NT_STATUS_FILE_LOCK_CONFLICT) (%s)\n",
                               __location__);
                        goto fail;
@@ -929,7 +929,7 @@ BOOL torture_locktest7(void)
        if (smbcli_write(cli1->tree, fnum1, 0, buf, 130, 4) != 4) {
                printf("pid2 unable to write to the range 130:4, error was %s\n", 
                       smbcli_errstr(cli1->tree));
-               if (NT_STATUS_V(smbcli_nt_error(cli1->tree)) != NT_STATUS_V(NT_STATUS_FILE_LOCK_CONFLICT)) {
+               if (!NT_STATUS_EQUAL(smbcli_nt_error(cli1->tree), NT_STATUS_FILE_LOCK_CONFLICT)) {
                        printf("Incorrect error (should be NT_STATUS_FILE_LOCK_CONFLICT) (%s)\n",
                               __location__);
                        goto fail;
index df9234feca529cf1f78ff3040873f2efa9dc0435..06dff7e72c6a57e90059f42c1d828304d923cafa 100644 (file)
@@ -33,11 +33,11 @@ look for a partial hit
 ****************************************************************************/
 static void trans2_check_hit(const char *format, int op, int level, NTSTATUS status)
 {
-       if (NT_STATUS_V(status) == NT_STATUS_V(NT_STATUS_INVALID_LEVEL) ||
-           NT_STATUS_V(status) == NT_STATUS_V(NT_STATUS_NOT_IMPLEMENTED) ||
-           NT_STATUS_V(status) == NT_STATUS_V(NT_STATUS_NOT_SUPPORTED) ||
-           NT_STATUS_V(status) == NT_STATUS_V(NT_STATUS_UNSUCCESSFUL) ||
-           NT_STATUS_V(status) == NT_STATUS_V(NT_STATUS_INVALID_INFO_CLASS)) {
+       if (NT_STATUS_EQUAL(status, NT_STATUS_INVALID_LEVEL) ||
+           NT_STATUS_EQUAL(status, NT_STATUS_NOT_IMPLEMENTED) ||
+           NT_STATUS_EQUAL(status, NT_STATUS_NOT_SUPPORTED) ||
+           NT_STATUS_EQUAL(status, NT_STATUS_UNSUCCESSFUL) ||
+           NT_STATUS_EQUAL(status, NT_STATUS_INVALID_INFO_CLASS)) {
                return;
        }
 #if VERBOSE
@@ -311,11 +311,11 @@ look for a partial hit
 ****************************************************************************/
 static void nttrans_check_hit(const char *format, int op, int level, NTSTATUS status)
 {
-       if (NT_STATUS_V(status) == NT_STATUS_V(NT_STATUS_INVALID_LEVEL) ||
-           NT_STATUS_V(status) == NT_STATUS_V(NT_STATUS_NOT_IMPLEMENTED) ||
-           NT_STATUS_V(status) == NT_STATUS_V(NT_STATUS_NOT_SUPPORTED) ||
-           NT_STATUS_V(status) == NT_STATUS_V(NT_STATUS_UNSUCCESSFUL) ||
-           NT_STATUS_V(status) == NT_STATUS_V(NT_STATUS_INVALID_INFO_CLASS)) {
+       if (NT_STATUS_EQUAL(status, NT_STATUS_INVALID_LEVEL) ||
+           NT_STATUS_EQUAL(status, NT_STATUS_NOT_IMPLEMENTED) ||
+           NT_STATUS_EQUAL(status, NT_STATUS_NOT_SUPPORTED) ||
+           NT_STATUS_EQUAL(status, NT_STATUS_UNSUCCESSFUL) ||
+           NT_STATUS_EQUAL(status, NT_STATUS_INVALID_INFO_CLASS)) {
                return;
        }
 #if VERBOSE
index 830814f69c8a3a7c32874914c38fa861676a1db1..5a5c78b5f2e76ce7fb911af34886fbd860b9f15f 100644 (file)
@@ -31,7 +31,7 @@
        if (!NT_STATUS_EQUAL(status, correct)) { \
                printf("(%s) Incorrect status %s - should be %s\n", \
                       __location__, nt_errstr(status), nt_errstr(correct)); \
-               ret = False; \
+               ret = False; exit(1); \
                goto done; \
        }} while (0)
 
@@ -129,21 +129,21 @@ static BOOL test_session(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
 
                session3->vuid = session->vuid;
                setup.in.sesskey = cli->transport->negotiate.sesskey;
-               setup.in.capabilities = 0; /* force a non extended security login (should fail) */
+               setup.in.capabilities &= ~CAP_EXTENDED_SECURITY; /* force a non extended security login (should fail) */
                setup.in.workgroup = lp_workgroup();
        
                setup.in.credentials = cmdline_credentials;
        
 
                status = smb_composite_sesssetup(session3, &setup);
-               CHECK_STATUS(status, NT_STATUS_ACCESS_DENIED);
+               CHECK_STATUS(status, NT_STATUS_LOGON_FAILURE);
 
                printf("create a fouth anonymous security context on the same transport, without extended security\n");
                session4 = smbcli_session_init(cli->transport, mem_ctx, False);
 
                session4->vuid = session->vuid;
                setup.in.sesskey = cli->transport->negotiate.sesskey;
-               setup.in.capabilities = 0; /* force a non extended security login (should fail) */
+               setup.in.capabilities &= ~CAP_EXTENDED_SECURITY; /* force a non extended security login (should fail) */
                setup.in.workgroup = lp_workgroup();
                
                anon_creds = cli_credentials_init(mem_ctx);
@@ -202,7 +202,7 @@ static BOOL test_session(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
 
        printf("the new vuid should not now be accessible\n");
        status = smb_raw_write(tree, &wr);
-       CHECK_STATUS(status, NT_STATUS_DOS(ERRSRV, ERRbaduid));
+       CHECK_STATUS(status, NT_STATUS_INVALID_HANDLE);
 
        printf("second logoff for the new vuid should fail\n");
        status = smb_raw_ulogoff(session);
index 1fec54b38ae5207f4c8df281d1e37938312a13f0..14f00599d914a5c2bf88f9442e5c84a4b7b07798 100644 (file)
@@ -194,9 +194,8 @@ static int test_one_eamax(struct smbcli_state *cli, const int fnum,
                } else {
                        if (eadebug) {
                                printf ("[%s] EA size %d failed!    "
-                                       "(high=%d low=%d) [0x%08x %s]\n", 
+                                       "(high=%d low=%d) [%s]\n", 
                                        eaname, i, high, low, 
-                                       NT_STATUS_V(status), 
                                        nt_errstr(status));
                        }
                        high = i;
index 88bf6ccaff9b4dd45fb711c912121f54895fc71b..b2874351ec37f600a5e6ce7dc2f5737f565cd8f7 100644 (file)
@@ -496,14 +496,14 @@ static BOOL test_async(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
        io.lockx.in.timeout = 0;
        io.lockx.in.mode = LOCKING_ANDX_CANCEL_LOCK;
        status = smb_raw_lock(cli->tree, &io);
-       CHECK_STATUS(status, NT_STATUS_UNSUCCESSFUL);
+       CHECK_STATUS(status, NT_STATUS_DOS(ERRDOS, ERRcancelviolation));
 
        /* cancel with the wrong bits set */
        lock[0].offset = 100;
        io.lockx.in.timeout = 0;
        io.lockx.in.mode = LOCKING_ANDX_CANCEL_LOCK;
        status = smb_raw_lock(cli->tree, &io);
-       CHECK_STATUS(status, NT_STATUS_UNSUCCESSFUL);
+       CHECK_STATUS(status, NT_STATUS_DOS(ERRDOS, ERRcancelviolation));
 
        /* cancel the right range */
        lock[0].offset = 100;
@@ -640,7 +640,7 @@ static BOOL test_changetype(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
        /* windows server don't seem to support this */
        io.lockx.in.mode = LOCKING_ANDX_CHANGE_LOCKTYPE;
        status = smb_raw_lock(cli->tree, &io);
-       CHECK_STATUS(status, NT_STATUS_UNSUCCESSFUL);
+       CHECK_STATUS(status, NT_STATUS_DOS(ERRDOS, ERRnoatomiclocks));
 
        if (smbcli_write(cli->tree, fnum, 0, &c, 100, 1) == 1) {
                printf("allowed write after lock change (%s)\n", __location__);
index 157233d43df4c3a4a48b88a6cbf72f6eb8a91b08..d7dbbc43cf1753a4f4e11880c8f1dcbf81304e32 100644 (file)
@@ -193,10 +193,10 @@ BOOL check_error(const char *location, struct smbcli_state *c,
                class = NT_STATUS_DOS_CLASS(status);
                num = NT_STATUS_DOS_CODE(status);
                 if (eclass != class || ecode != num) {
-                        printf("unexpected error code class=%d code=%d\n", 
-                               (int)class, (int)num);
-                        printf(" expected %d/%d %s (at %s)\n"
-                               (int)eclass, (int)ecode, nt_errstr(nterr), location);
+                        printf("unexpected error code %s\n", nt_errstr(status));
+                        printf(" expected %s or %s (at %s)\n", 
+                              nt_errstr(NT_STATUS_DOS(eclass, ecode))
+                               nt_errstr(nterr), location);
                         return False;
                 }
         } else {