s4-smbtorture: allow to test returned type after specific error code in PrinterData...
authorGünther Deschner <gd@samba.org>
Wed, 10 Nov 2010 09:19:01 +0000 (10:19 +0100)
committerGünther Deschner <gd@samba.org>
Wed, 10 Nov 2010 14:23:21 +0000 (15:23 +0100)
Guenther

source4/torture/rpc/spoolss.c

index 8154cd2ba2c9d708356ee16a2ea03f7efea181fe..8b219777f35f58216848ca8cf97ba390023bc3e5 100644 (file)
@@ -3474,13 +3474,14 @@ static bool test_ResumePrinter(struct torture_context *tctx,
        return true;
 }
 
-static bool test_GetPrinterData(struct torture_context *tctx,
-                               struct dcerpc_binding_handle *b,
-                               struct policy_handle *handle,
-                               const char *value_name,
-                               enum winreg_Type *type_p,
-                               uint8_t **data_p,
-                               uint32_t *needed_p)
+static bool test_GetPrinterData_checktype(struct torture_context *tctx,
+                                         struct dcerpc_binding_handle *b,
+                                         struct policy_handle *handle,
+                                         const char *value_name,
+                                         enum winreg_Type *expected_type,
+                                         enum winreg_Type *type_p,
+                                         uint8_t **data_p,
+                                         uint32_t *needed_p)
 {
        NTSTATUS status;
        struct spoolss_GetPrinterData r;
@@ -3501,6 +3502,9 @@ static bool test_GetPrinterData(struct torture_context *tctx,
        torture_assert_ntstatus_ok(tctx, status, "GetPrinterData failed");
 
        if (W_ERROR_EQUAL(r.out.result, WERR_MORE_DATA)) {
+               if (expected_type) {
+                       torture_assert_int_equal(tctx, type, *expected_type, "unexpected type");
+               }
                r.in.offered = needed;
                r.out.data = talloc_zero_array(tctx, uint8_t, r.in.offered);
                status = dcerpc_spoolss_GetPrinterData_r(b, tctx, &r);
@@ -3527,14 +3531,27 @@ static bool test_GetPrinterData(struct torture_context *tctx,
        return true;
 }
 
-static bool test_GetPrinterDataEx(struct torture_context *tctx,
-                                 struct dcerpc_pipe *p,
-                                 struct policy_handle *handle,
-                                 const char *key_name,
-                                 const char *value_name,
-                                 enum winreg_Type *type_p,
-                                 uint8_t **data_p,
-                                 uint32_t *needed_p)
+static bool test_GetPrinterData(struct torture_context *tctx,
+                               struct dcerpc_binding_handle *b,
+                               struct policy_handle *handle,
+                               const char *value_name,
+                               enum winreg_Type *type_p,
+                               uint8_t **data_p,
+                               uint32_t *needed_p)
+{
+       return test_GetPrinterData_checktype(tctx, b, handle, value_name,
+                                            NULL, type_p, data_p, needed_p);
+}
+
+static bool test_GetPrinterDataEx_checktype(struct torture_context *tctx,
+                                           struct dcerpc_pipe *p,
+                                           struct policy_handle *handle,
+                                           const char *key_name,
+                                           const char *value_name,
+                                           enum winreg_Type *expected_type,
+                                           enum winreg_Type *type_p,
+                                           uint8_t **data_p,
+                                           uint32_t *needed_p)
 {
        NTSTATUS status;
        struct spoolss_GetPrinterDataEx r;
@@ -3563,6 +3580,9 @@ static bool test_GetPrinterDataEx(struct torture_context *tctx,
        }
 
        if (W_ERROR_EQUAL(r.out.result, WERR_MORE_DATA)) {
+               if (expected_type) {
+                       torture_assert_int_equal(tctx, type, *expected_type, "unexpected type");
+               }
                r.in.offered = needed;
                r.out.data = talloc_zero_array(tctx, uint8_t, r.in.offered);
                status = dcerpc_spoolss_GetPrinterDataEx_r(b, tctx, &r);
@@ -3589,6 +3609,19 @@ static bool test_GetPrinterDataEx(struct torture_context *tctx,
        return true;
 }
 
+static bool test_GetPrinterDataEx(struct torture_context *tctx,
+                                 struct dcerpc_pipe *p,
+                                 struct policy_handle *handle,
+                                 const char *key_name,
+                                 const char *value_name,
+                                 enum winreg_Type *type_p,
+                                 uint8_t **data_p,
+                                 uint32_t *needed_p)
+{
+       return test_GetPrinterDataEx_checktype(tctx, p, handle, key_name, value_name,
+                                              NULL, type_p, data_p, needed_p);
+}
+
 static bool test_get_environment(struct torture_context *tctx,
                                 struct dcerpc_binding_handle *b,
                                 struct policy_handle *handle,