s3-torture: introduce check_both_error()
authorBjörn Baumbach <bb@sernet.de>
Thu, 7 Jul 2011 14:27:39 +0000 (16:27 +0200)
committerStefan Metzmacher <metze@samba.org>
Thu, 7 Jul 2011 17:16:28 +0000 (19:16 +0200)
Check if the server produced the expected dos or nt error code like
check_error(), but without a cli_state struct.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
source3/torture/torture.c

index 8f251b7f2bb43bae0bf381ded26740eb4d2b807f..2243fe6c0b07ea56ea378e04413f20422555d8a7 100644 (file)
@@ -455,6 +455,40 @@ bool torture_close_connection(struct cli_state *c)
 }
 
 
+/* check if the server produced the expected dos or nt error code */
+static bool check_both_error(int line, NTSTATUS status,
+                            uint8 eclass, uint32 ecode, NTSTATUS nterr)
+{
+       if (NT_STATUS_IS_DOS(status)) {
+               uint8 cclass;
+               uint32 num;
+
+               /* Check DOS error */
+               cclass = NT_STATUS_DOS_CLASS(status);
+               num = NT_STATUS_DOS_CODE(status);
+
+               if (eclass != cclass || ecode != num) {
+                       printf("unexpected error code class=%d code=%d\n",
+                              (int)cclass, (int)num);
+                       printf(" expected %d/%d %s (line=%d)\n",
+                              (int)eclass, (int)ecode, nt_errstr(nterr), line);
+                       return false;
+               }
+       } else {
+               /* Check NT error */
+               if (!NT_STATUS_EQUAL(nterr, status)) {
+                       printf("unexpected error code %s\n",
+                               nt_errstr(status));
+                       printf(" expected %s (line=%d)\n",
+                               nt_errstr(nterr), line);
+                       return false;
+               }
+       }
+
+       return true;
+}
+
+
 /* check if the server produced the expected error code */
 static bool check_error(int line, struct cli_state *c, 
                        uint8 eclass, uint32 ecode, NTSTATUS nterr)