diff options
author | Gregor Beck <gbeck@sernet.de> | 2012-02-29 11:02:20 +0100 |
---|---|---|
committer | Stefan Metzmacher <metze@samba.org> | 2012-03-06 23:53:06 +0100 |
commit | 10f266b6ed2553619da8bf028644b923988abb03 (patch) | |
tree | e39c0fc98d50a522818f8cfa38165404a41773e8 | |
parent | 01774d65c28facb0721978fd10391acd15b0dc1d (diff) | |
download | samba-10f266b6ed2553619da8bf028644b923988abb03.tar.gz samba-10f266b6ed2553619da8bf028644b923988abb03.tar.bz2 samba-10f266b6ed2553619da8bf028644b923988abb03.zip |
s4:torture: avoid reporting error on failure of smb2.ioctl tests
Signed-off-by: Stefan Metzmacher <metze@samba.org>
-rw-r--r-- | source4/torture/smb2/ioctl.c | 227 |
1 files changed, 79 insertions, 148 deletions
diff --git a/source4/torture/smb2/ioctl.c b/source4/torture/smb2/ioctl.c index cbef4d731e..ad300c028d 100644 --- a/source4/torture/smb2/ioctl.c +++ b/source4/torture/smb2/ioctl.c @@ -45,17 +45,11 @@ static bool test_ioctl_get_shadow_copy(struct torture_context *torture, smb2_util_unlink(tree, FNAME); status = torture_smb2_testfile(tree, FNAME, &h); - if (!NT_STATUS_IS_OK(status)) { - printf("create write\n"); - return false; - } + torture_assert_ntstatus_ok(torture, status, "create write"); ZERO_ARRAY(buf); status = smb2_util_write(tree, h, buf, 0, ARRAY_SIZE(buf)); - if (!NT_STATUS_IS_OK(status)) { - printf("failed write\n"); - return false; - } + torture_assert_ntstatus_ok(torture, status, "write"); ZERO_STRUCT(ioctl); ioctl.smb2.level = RAW_IOCTL_SMB2; @@ -65,10 +59,7 @@ static bool test_ioctl_get_shadow_copy(struct torture_context *torture, ioctl.smb2.in.flags = SMB2_IOCTL_FLAG_IS_FSCTL; status = smb2_ioctl(tree, tmp_ctx, &ioctl.smb2); - if (!NT_STATUS_IS_OK(status)) { - printf("FSCTL_SRV_ENUM_SNAPS failed\n"); - return false; - } + torture_assert_ntstatus_ok(torture, status, "FSCTL_SRV_ENUM_SNAPS"); return true; } @@ -90,17 +81,11 @@ static bool test_ioctl_req_resume_key(struct torture_context *torture, smb2_util_unlink(tree, FNAME); status = torture_smb2_testfile(tree, FNAME, &h); - if (!NT_STATUS_IS_OK(status)) { - printf("create write\n"); - return false; - } + torture_assert_ntstatus_ok(torture, status, "create write"); ZERO_ARRAY(buf); status = smb2_util_write(tree, h, buf, 0, ARRAY_SIZE(buf)); - if (!NT_STATUS_IS_OK(status)) { - printf("failed write\n"); - return false; - } + torture_assert_ntstatus_ok(torture, status, "write"); ZERO_STRUCT(ioctl); ioctl.smb2.level = RAW_IOCTL_SMB2; @@ -110,16 +95,12 @@ static bool test_ioctl_req_resume_key(struct torture_context *torture, ioctl.smb2.in.flags = SMB2_IOCTL_FLAG_IS_FSCTL; status = smb2_ioctl(tree, tmp_ctx, &ioctl.smb2); - if (!NT_STATUS_IS_OK(status)) { - printf("FSCTL_SRV_REQUEST_RESUME_KEY failed\n"); - return false; - } + torture_assert_ntstatus_ok(torture, status, "FSCTL_SRV_REQUEST_RESUME_KEY"); ndr_ret = ndr_pull_struct_blob(&ioctl.smb2.out.out, tmp_ctx, &res_key, (ndr_pull_flags_fn_t)ndr_pull_req_resume_key_rsp); - if (ndr_ret != NDR_ERR_SUCCESS) { - return false; - } + torture_assert_ndr_success(torture, ndr_ret, + "ndr_pull_req_resume_key_rsp"); ndr_print_debug((ndr_print_fn_t)ndr_print_req_resume_key_rsp, "yo", &res_key); @@ -132,7 +113,8 @@ static uint64_t patt_hash(uint64_t off) return off; } -static bool check_pattern(struct smb2_tree *tree, TALLOC_CTX *mem_ctx, +static bool check_pattern(struct torture_context *torture, + struct smb2_tree *tree, TALLOC_CTX *mem_ctx, struct smb2_handle h, uint64_t off, uint64_t len, uint64_t patt_off) { @@ -145,30 +127,25 @@ static bool check_pattern(struct smb2_tree *tree, TALLOC_CTX *mem_ctx, r.in.length = len; r.in.offset = off; status = smb2_read(tree, mem_ctx, &r); - if (!NT_STATUS_IS_OK(status)) { - printf("read failed - %s\n", nt_errstr(status)); - return false; - } else if (len != r.out.data.length) { - printf("read data len mismatch got %zu, expected %llu\n", - r.out.data.length, (unsigned long long)len); - return false; - } + torture_assert_ntstatus_ok(torture, status, "read"); + + torture_assert_u64_equal(torture, r.out.data.length, len, + "read data len mismatch"); for (i = 0; i <= len - 8; i += 8, patt_off += 8) { - if (BVAL(r.out.data.data, i) != patt_hash(patt_off)) { - printf("pattern bad at %llu, got %llx, expected %llx\n", - (unsigned long long)i, - (unsigned long long)BVAL(r.out.data.data, i), - (unsigned long long)patt_hash(patt_off)); - return false; - } + uint64_t data = BVAL(r.out.data.data, i); + torture_assert_u64_equal(torture, data, patt_hash(patt_off), + talloc_asprintf(torture, "read data " + "pattern bad at %llu\n", + (unsigned long long)i)); } talloc_free(r.out.data.data); return true; } -static bool test_setup_copy_chunk(struct smb2_tree *tree, TALLOC_CTX *mem_ctx, +static bool test_setup_copy_chunk(struct torture_context *torture, + struct smb2_tree *tree, TALLOC_CTX *mem_ctx, uint32_t nchunks, struct smb2_handle *src_h, uint64_t src_size, @@ -191,37 +168,25 @@ static bool test_setup_copy_chunk(struct smb2_tree *tree, TALLOC_CTX *mem_ctx, smb2_util_unlink(tree, FNAME2); status = torture_smb2_testfile(tree, FNAME, src_h); - if (!NT_STATUS_IS_OK(status)) { - printf("create write\n"); - return false; - } + torture_assert_ntstatus_ok(torture, status, "create write"); if (src_size > 0) { for (i = 0; i <= src_size - 8; i += 8) { SBVAL(buf, i, patt_hash(i)); } status = smb2_util_write(tree, *src_h, buf, 0, src_size); - if (!NT_STATUS_IS_OK(status)) { - printf("failed src write\n"); - return false; - } + torture_assert_ntstatus_ok(torture, status, "src write"); } status = torture_smb2_testfile(tree, FNAME2, dest_h); - if (!NT_STATUS_IS_OK(status)) { - printf("create write\n"); - return false; - } + torture_assert_ntstatus_ok(torture, status, "create write"); if (dest_size > 0) { for (i = 0; i <= src_size - 8; i += 8) { SBVAL(buf, i, patt_hash(i)); } status = smb2_util_write(tree, *dest_h, buf, 0, dest_size); - if (!NT_STATUS_IS_OK(status)) { - printf("failed dest write\n"); - return false; - } + torture_assert_ntstatus_ok(torture, status, "dest write"); } ZERO_STRUCTPN(ioctl); @@ -233,16 +198,15 @@ static bool test_setup_copy_chunk(struct smb2_tree *tree, TALLOC_CTX *mem_ctx, ioctl->smb2.in.flags = SMB2_IOCTL_FLAG_IS_FSCTL; status = smb2_ioctl(tree, mem_ctx, &ioctl->smb2); - if (!NT_STATUS_IS_OK(status)) { - printf("FSCTL_SRV_REQUEST_RESUME_KEY failed\n"); - return false; - } + torture_assert_ntstatus_ok(torture, status, + "FSCTL_SRV_REQUEST_RESUME_KEY"); + ndr_ret = ndr_pull_struct_blob(&ioctl->smb2.out.out, mem_ctx, &res_key, (ndr_pull_flags_fn_t)ndr_pull_req_resume_key_rsp); - if (ndr_ret != NDR_ERR_SUCCESS) { - return false; - } + + torture_assert_ndr_success(torture, ndr_ret, + "ndr_pull_req_resume_key_rsp"); ZERO_STRUCTPN(ioctl); ioctl->smb2.level = RAW_IOCTL_SMB2; @@ -264,26 +228,18 @@ static bool test_setup_copy_chunk(struct smb2_tree *tree, TALLOC_CTX *mem_ctx, } -static bool check_copy_chunk_rsp(struct srv_copychunk_rsp *cc_rsp, +static bool check_copy_chunk_rsp(struct torture_context *torture, + struct srv_copychunk_rsp *cc_rsp, uint32_t ex_chunks_written, uint32_t ex_chunk_bytes_written, uint32_t ex_total_bytes_written) { - if (cc_rsp->chunks_written != ex_chunks_written) { - printf("expected %u chunks, got %u\n", - ex_chunks_written, cc_rsp->chunks_written); - return false; - } - if (cc_rsp->chunk_bytes_written != ex_chunk_bytes_written) { - printf("expected %u chunk bytes remaining, got %u\n", - ex_chunk_bytes_written, cc_rsp->chunk_bytes_written); - return false; - } - if (cc_rsp->total_bytes_written != ex_total_bytes_written) { - printf("expected %u total bytes, got %u\n", - ex_total_bytes_written, cc_rsp->total_bytes_written); - return false; - } + torture_assert_int_equal(torture, cc_rsp->chunks_written, + ex_chunks_written, "num chunks"); + torture_assert_int_equal(torture, cc_rsp->chunk_bytes_written, + ex_chunk_bytes_written, "chunk bytes written"); + torture_assert_int_equal(torture, cc_rsp->total_bytes_written, + ex_total_bytes_written, "chunk total bytes"); return true; } @@ -300,7 +256,7 @@ static bool test_ioctl_copy_chunk_simple(struct torture_context *torture, enum ndr_err_code ndr_ret; bool ok; - ok = test_setup_copy_chunk(tree, tmp_ctx, + ok = test_setup_copy_chunk(torture, tree, tmp_ctx, 1, /* 1 chunk */ &src_h, 4096, /* fill 4096 byte src file */ &dest_h, 0, /* 0 byte dest file */ @@ -318,24 +274,19 @@ static bool test_ioctl_copy_chunk_simple(struct torture_context *torture, ndr_ret = ndr_push_struct_blob(&ioctl.smb2.in.out, tmp_ctx, &cc_copy, (ndr_push_flags_fn_t)ndr_push_srv_copychunk_copy); - if (ndr_ret != NDR_ERR_SUCCESS) { - return false; - } + torture_assert_ndr_success(torture, ndr_ret, + "ndr_push_srv_copychunk_copy"); status = smb2_ioctl(tree, tmp_ctx, &ioctl.smb2); - if (!NT_STATUS_IS_OK(status)) { - printf("FSCTL_SRV_COPYCHUNK failed\n"); - return false; - } + torture_assert_ntstatus_ok(torture, status, "FSCTL_SRV_COPYCHUNK"); ndr_ret = ndr_pull_struct_blob(&ioctl.smb2.out.out, tmp_ctx, &cc_rsp, (ndr_pull_flags_fn_t)ndr_pull_srv_copychunk_rsp); - if (ndr_ret != NDR_ERR_SUCCESS) { - return false; - } + torture_assert_ndr_success(torture, ndr_ret, + "ndr_pull_srv_copychunk_rsp"); - ok = check_copy_chunk_rsp(&cc_rsp, + ok = check_copy_chunk_rsp(torture, &cc_rsp, 1, /* chunks written */ 0, /* chunk bytes unsuccessfully written */ 4096); /* total bytes written */ @@ -343,7 +294,7 @@ static bool test_ioctl_copy_chunk_simple(struct torture_context *torture, return false; } - ok = check_pattern(tree, tmp_ctx, dest_h, 0, 4096, 0); + ok = check_pattern(torture, tree, tmp_ctx, dest_h, 0, 4096, 0); if (!ok) { return false; } @@ -367,7 +318,7 @@ static bool test_ioctl_copy_chunk_multi(struct torture_context *torture, enum ndr_err_code ndr_ret; bool ok; - ok = test_setup_copy_chunk(tree, tmp_ctx, + ok = test_setup_copy_chunk(torture, tree, tmp_ctx, 2, /* chunks */ &src_h, 8192, /* src file */ &dest_h, 0, /* dest file */ @@ -389,24 +340,19 @@ static bool test_ioctl_copy_chunk_multi(struct torture_context *torture, ndr_ret = ndr_push_struct_blob(&ioctl.smb2.in.out, tmp_ctx, &cc_copy, (ndr_push_flags_fn_t)ndr_push_srv_copychunk_copy); - if (ndr_ret != NDR_ERR_SUCCESS) { - return false; - } + torture_assert_ndr_success(torture, ndr_ret, + "ndr_push_srv_copychunk_copy"); status = smb2_ioctl(tree, tmp_ctx, &ioctl.smb2); - if (!NT_STATUS_IS_OK(status)) { - printf("FSCTL_SRV_COPYCHUNK failed\n"); - return false; - } + torture_assert_ntstatus_ok(torture, status, "FSCTL_SRV_COPYCHUNK"); ndr_ret = ndr_pull_struct_blob(&ioctl.smb2.out.out, tmp_ctx, &cc_rsp, (ndr_pull_flags_fn_t)ndr_pull_srv_copychunk_rsp); - if (ndr_ret != NDR_ERR_SUCCESS) { - return false; - } + torture_assert_ndr_success(torture, ndr_ret, + "ndr_pull_srv_copychunk_rsp"); - ok = check_copy_chunk_rsp(&cc_rsp, + ok = check_copy_chunk_rsp(torture, &cc_rsp, 2, /* chunks written */ 0, /* chunk bytes unsuccessfully written */ 8192); /* total bytes written */ @@ -433,7 +379,7 @@ static bool test_ioctl_copy_chunk_tiny(struct torture_context *torture, enum ndr_err_code ndr_ret; bool ok; - ok = test_setup_copy_chunk(tree, tmp_ctx, + ok = test_setup_copy_chunk(torture, tree, tmp_ctx, 2, /* chunks */ &src_h, 100, /* src file */ &dest_h, 0, /* dest file */ @@ -455,24 +401,19 @@ static bool test_ioctl_copy_chunk_tiny(struct torture_context *torture, ndr_ret = ndr_push_struct_blob(&ioctl.smb2.in.out, tmp_ctx, &cc_copy, (ndr_push_flags_fn_t)ndr_push_srv_copychunk_copy); - if (ndr_ret != NDR_ERR_SUCCESS) { - return false; - } + torture_assert_ndr_success(torture, ndr_ret, + "ndr_push_srv_copychunk_copy"); status = smb2_ioctl(tree, tmp_ctx, &ioctl.smb2); - if (!NT_STATUS_IS_OK(status)) { - printf("FSCTL_SRV_COPYCHUNK failed\n"); - return false; - } + torture_assert_ntstatus_ok(torture, status, "FSCTL_SRV_COPYCHUNK"); ndr_ret = ndr_pull_struct_blob(&ioctl.smb2.out.out, tmp_ctx, &cc_rsp, (ndr_pull_flags_fn_t)ndr_pull_srv_copychunk_rsp); - if (ndr_ret != NDR_ERR_SUCCESS) { - return false; - } + torture_assert_ndr_success(torture, ndr_ret, + "ndr_pull_srv_copychunk_rsp"); - ok = check_copy_chunk_rsp(&cc_rsp, + ok = check_copy_chunk_rsp(torture, &cc_rsp, 2, /* chunks written */ 0, /* chunk bytes unsuccessfully written */ 100); /* total bytes written */ @@ -480,7 +421,7 @@ static bool test_ioctl_copy_chunk_tiny(struct torture_context *torture, return false; } - ok = check_pattern(tree, tmp_ctx, dest_h, 0, 100, 0); + ok = check_pattern(torture, tree, tmp_ctx, dest_h, 0, 100, 0); if (!ok) { return false; } @@ -504,7 +445,7 @@ static bool test_ioctl_copy_chunk_over(struct torture_context *torture, enum ndr_err_code ndr_ret; bool ok; - ok = test_setup_copy_chunk(tree, tmp_ctx, + ok = test_setup_copy_chunk(torture, tree, tmp_ctx, 2, /* chunks */ &src_h, 8192, /* src file */ &dest_h, 4096, /* dest file */ @@ -527,24 +468,19 @@ static bool test_ioctl_copy_chunk_over(struct torture_context *torture, ndr_ret = ndr_push_struct_blob(&ioctl.smb2.in.out, tmp_ctx, &cc_copy, (ndr_push_flags_fn_t)ndr_push_srv_copychunk_copy); - if (ndr_ret != NDR_ERR_SUCCESS) { - return false; - } + torture_assert_ndr_success(torture, ndr_ret, + "ndr_push_srv_copychunk_copy"); status = smb2_ioctl(tree, tmp_ctx, &ioctl.smb2); - if (!NT_STATUS_IS_OK(status)) { - printf("FSCTL_SRV_COPYCHUNK failed\n"); - return false; - } + torture_assert_ntstatus_ok(torture, status, "FSCTL_SRV_COPYCHUNK"); ndr_ret = ndr_pull_struct_blob(&ioctl.smb2.out.out, tmp_ctx, &cc_rsp, (ndr_pull_flags_fn_t)ndr_pull_srv_copychunk_rsp); - if (ndr_ret != NDR_ERR_SUCCESS) { - return false; - } + torture_assert_ndr_success(torture, ndr_ret, + "ndr_pull_srv_copychunk_rsp"); - ok = check_copy_chunk_rsp(&cc_rsp, + ok = check_copy_chunk_rsp(torture, &cc_rsp, 2, /* chunks written */ 0, /* chunk bytes unsuccessfully written */ 8192); /* total bytes written */ @@ -552,7 +488,7 @@ static bool test_ioctl_copy_chunk_over(struct torture_context *torture, return false; } - ok = check_pattern(tree, tmp_ctx, dest_h, 0, 4096, 4096); + ok = check_pattern(torture, tree, tmp_ctx, dest_h, 0, 4096, 4096); if (!ok) { return false; } @@ -576,7 +512,7 @@ static bool test_ioctl_copy_chunk_append(struct torture_context *torture, enum ndr_err_code ndr_ret; bool ok; - ok = test_setup_copy_chunk(tree, tmp_ctx, + ok = test_setup_copy_chunk(torture, tree, tmp_ctx, 2, /* chunks */ &src_h, 4096, /* src file */ &dest_h, 0, /* dest file */ @@ -598,24 +534,19 @@ static bool test_ioctl_copy_chunk_append(struct torture_context *torture, ndr_ret = ndr_push_struct_blob(&ioctl.smb2.in.out, tmp_ctx, &cc_copy, (ndr_push_flags_fn_t)ndr_push_srv_copychunk_copy); - if (ndr_ret != NDR_ERR_SUCCESS) { - return false; - } + torture_assert_ndr_success(torture, ndr_ret, + "ndr_push_srv_copychunk_copy"); status = smb2_ioctl(tree, tmp_ctx, &ioctl.smb2); - if (!NT_STATUS_IS_OK(status)) { - printf("FSCTL_SRV_COPYCHUNK failed\n"); - return false; - } + torture_assert_ntstatus_ok(torture, status, "FSCTL_SRV_COPYCHUNK"); ndr_ret = ndr_pull_struct_blob(&ioctl.smb2.out.out, tmp_ctx, &cc_rsp, (ndr_pull_flags_fn_t)ndr_pull_srv_copychunk_rsp); - if (ndr_ret != NDR_ERR_SUCCESS) { - return false; - } + torture_assert_ndr_success(torture, ndr_ret, + "ndr_pull_srv_copychunk_rsp"); - ok = check_copy_chunk_rsp(&cc_rsp, + ok = check_copy_chunk_rsp(torture, &cc_rsp, 2, /* chunks written */ 0, /* chunk bytes unsuccessfully written */ 8192); /* total bytes written */ @@ -623,12 +554,12 @@ static bool test_ioctl_copy_chunk_append(struct torture_context *torture, return false; } - ok = check_pattern(tree, tmp_ctx, dest_h, 0, 4096, 0); + ok = check_pattern(torture, tree, tmp_ctx, dest_h, 0, 4096, 0); if (!ok) { return false; } - ok = check_pattern(tree, tmp_ctx, dest_h, 4096, 4096, 0); + ok = check_pattern(torture, tree, tmp_ctx, dest_h, 4096, 4096, 0); if (!ok) { return false; } |