s4-smbtorture: test all levels in test_GetJob().
authorGünther Deschner <gd@samba.org>
Mon, 13 Apr 2009 21:56:59 +0000 (23:56 +0200)
committerGünther Deschner <gd@samba.org>
Sun, 19 Apr 2009 22:59:36 +0000 (00:59 +0200)
Guenther

source4/torture/rpc/spoolss.c

index bc89eabfe17e388041f6dc9387f07a38cbdc330a..bfe667240cde51935f2d1985109bc9069109c597 100644 (file)
@@ -1064,28 +1064,43 @@ static bool test_GetJob(struct torture_context *tctx,
        NTSTATUS status;
        struct spoolss_GetJob r;
        uint32_t needed;
+       uint32_t levels[] = {1, 2 /* 3, 4 */};
+       uint32_t i;
 
        r.in.handle = handle;
        r.in.job_id = job_id;
-       r.in.level = 1;
+       r.in.level = 0;
        r.in.buffer = NULL;
        r.in.offered = 0;
        r.out.needed = &needed;
 
-       torture_comment(tctx, "Testing GetJob\n");
+       torture_comment(tctx, "Testing GetJob level %d\n", r.in.level);
 
        status = dcerpc_spoolss_GetJob(p, tctx, &r);
-       torture_assert_ntstatus_ok(tctx, status, "GetJob failed");
+       torture_assert_werr_equal(tctx, r.out.result, WERR_UNKNOWN_LEVEL, "Unexpected return code");
 
-       if (W_ERROR_EQUAL(r.out.result, WERR_INSUFFICIENT_BUFFER)) {
-               DATA_BLOB blob = data_blob_talloc(tctx, NULL, needed);
-               data_blob_clear(&blob);
-               r.in.buffer = &blob;
-               r.in.offered = needed;
+       for (i = 0; i < ARRAY_SIZE(levels); i++) {
+
+               torture_comment(tctx, "Testing GetJob level %d\n", r.in.level);
+
+               r.in.level = levels[i];
+               r.in.offered = 0;
 
                status = dcerpc_spoolss_GetJob(p, tctx, &r);
+               torture_assert_ntstatus_ok(tctx, status, "GetJob failed");
 
+               if (W_ERROR_EQUAL(r.out.result, WERR_INSUFFICIENT_BUFFER)) {
+                       DATA_BLOB blob = data_blob_talloc(tctx, NULL, needed);
+                       data_blob_clear(&blob);
+                       r.in.buffer = &blob;
+                       r.in.offered = needed;
+
+                       status = dcerpc_spoolss_GetJob(p, tctx, &r);
+                       torture_assert_ntstatus_ok(tctx, status, "GetJob failed");
+
+               }
                torture_assert(tctx, r.out.info, "No job info returned");
+               torture_assert_werr_ok(tctx, r.out.result, "GetJob failed");
        }
 
        return true;