>From 2f7c97a088fb1e3e3ae0ea575c22fe3cf0b5dc58 Mon Sep 17 00:00:00 2001 From: Douglas Bagnall Date: Wed, 24 Jun 2015 11:47:31 +1200 Subject: [PATCH 1/2] Avoid segfault in durable_open tests There are "goto done"s hiding in CHECK_STATUS in parts of the code where tree1 is unequivocally NULL. Signed-off-by: Douglas Bagnall Reviewed-by: Michael Adam --- source4/torture/smb2/durable_open.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/source4/torture/smb2/durable_open.c b/source4/torture/smb2/durable_open.c index fd6af33..bb32f96 100644 --- a/source4/torture/smb2/durable_open.c +++ b/source4/torture/smb2/durable_open.c @@ -2136,12 +2136,14 @@ static bool test_durable_open_open2_lease(struct torture_context *tctx, h1 = io1.out.file.handle; done: + if (tree1 != NULL){ + smb2_util_close(tree1, h1); + smb2_util_unlink(tree1, fname); + talloc_free(tree1); + } + smb2_util_close(tree2, h2); smb2_util_unlink(tree2, fname); - smb2_util_close(tree1, h1); - smb2_util_unlink(tree1, fname); - - talloc_free(tree1); talloc_free(tree2); return ret; -- 1.9.1 >From d48336f73ddcd15fb0258f1e39b9b56378aba456 Mon Sep 17 00:00:00 2001 From: Douglas Bagnall Date: Wed, 24 Jun 2015 12:41:51 +1200 Subject: [PATCH 2/2] replace CHECK_STATUS in durable_open.c CHECK_STATUS() hides a goto done in its heart and is not a standard part of the torture library. The standard torture library has torture_assert_ntstatus_equal_goto() which does the same thing, albeit more verbosely, and at least mentions goto in its name. Signed-off-by: Douglas Bagnall --- source4/torture/smb2/durable_open.c | 264 ++++++++++++++++++++++++------------ 1 file changed, 176 insertions(+), 88 deletions(-) diff --git a/source4/torture/smb2/durable_open.c b/source4/torture/smb2/durable_open.c index bb32f96..590ecb2 100644 --- a/source4/torture/smb2/durable_open.c +++ b/source4/torture/smb2/durable_open.c @@ -49,14 +49,6 @@ ret = false; \ }} while (0) -#define CHECK_STATUS(status, correct) do { \ - if (!NT_STATUS_EQUAL(status, correct)) { \ - torture_result(tctx, TORTURE_FAIL, __location__": Incorrect status %s - should be %s", \ - nt_errstr(status), nt_errstr(correct)); \ - ret = false; \ - goto done; \ - }} while (0) - #define CHECK_CREATED(__io, __created, __attribute) \ do { \ CHECK_VAL((__io)->out.create_action, NTCREATEX_ACTION_ ## __created); \ @@ -153,7 +145,8 @@ static bool test_one_durable_open_open_oplock(struct torture_context *tctx, io.in.durable_open = true; status = smb2_create(tree, mem_ctx, &io); - CHECK_STATUS(status, NT_STATUS_OK); + torture_assert_ntstatus_equal_goto(tctx, status, NT_STATUS_OK, ret, + done, "Status should be OK"); _h = io.out.file.handle; h = &_h; CHECK_CREATED(&io, CREATED, FILE_ATTRIBUTE_ARCHIVE); @@ -298,7 +291,8 @@ static bool test_one_durable_open_open_lease(struct torture_context *tctx, io.in.durable_open = true; status = smb2_create(tree, mem_ctx, &io); - CHECK_STATUS(status, NT_STATUS_OK); + torture_assert_ntstatus_equal_goto(tctx, status, NT_STATUS_OK, ret, + done, "Status should be OK"); _h = io.out.file.handle; h = &_h; CHECK_CREATED(&io, CREATED, FILE_ATTRIBUTE_ARCHIVE); @@ -386,7 +380,8 @@ static bool test_durable_open_reopen1(struct torture_context *tctx, io1.in.durable_open = true; status = smb2_create(tree, mem_ctx, &io1); - CHECK_STATUS(status, NT_STATUS_OK); + torture_assert_ntstatus_equal_goto(tctx, status, NT_STATUS_OK, ret, + done, "Status should be OK"); _h = io1.out.file.handle; h = &_h; CHECK_CREATED(&io1, CREATED, FILE_ATTRIBUTE_ARCHIVE); @@ -399,7 +394,9 @@ static bool test_durable_open_reopen1(struct torture_context *tctx, io2.in.durable_handle = h; status = smb2_create(tree, mem_ctx, &io2); - CHECK_STATUS(status, NT_STATUS_OBJECT_NAME_NOT_FOUND); + torture_assert_ntstatus_equal_goto(tctx, status, + NT_STATUS_OBJECT_NAME_NOT_FOUND, + ret, done, "Status is wrong"); done: if (h != NULL) { @@ -451,7 +448,8 @@ static bool test_durable_open_reopen1a(struct torture_context *tctx, io1.in.durable_open = true; status = smb2_create(tree, mem_ctx, &io1); - CHECK_STATUS(status, NT_STATUS_OK); + torture_assert_ntstatus_equal_goto(tctx, status, NT_STATUS_OK, ret, + done, "Status should be OK"); _h = io1.out.file.handle; h = &_h; CHECK_CREATED(&io1, CREATED, FILE_ATTRIBUTE_ARCHIVE); @@ -481,7 +479,9 @@ static bool test_durable_open_reopen1a(struct torture_context *tctx, io2.in.durable_handle = h; status = smb2_create(tree, mem_ctx, &io2); - CHECK_STATUS(status, NT_STATUS_USER_SESSION_DELETED); + torture_assert_ntstatus_equal_goto(tctx, status, + NT_STATUS_USER_SESSION_DELETED, + ret, done, "Status is wrong"); /* * but a durable reconnect on the new session succeeds: @@ -492,7 +492,8 @@ static bool test_durable_open_reopen1a(struct torture_context *tctx, io2.in.durable_handle = h; status = smb2_create(tree2, mem_ctx, &io2); - CHECK_STATUS(status, NT_STATUS_OK); + torture_assert_ntstatus_equal_goto(tctx, status, NT_STATUS_OK, ret, + done, "Status should be OK"); CHECK_CREATED(&io2, EXISTED, FILE_ATTRIBUTE_ARCHIVE); CHECK_VAL(io2.out.oplock_level, smb2_util_oplock_level("b")); _h = io2.out.file.handle; @@ -541,7 +542,8 @@ static bool test_durable_open_reopen2(struct torture_context *tctx, io.in.durable_open = true; status = smb2_create(tree, mem_ctx, &io); - CHECK_STATUS(status, NT_STATUS_OK); + torture_assert_ntstatus_equal_goto(tctx, status, NT_STATUS_OK, ret, + done, "Status should be OK"); _h = io.out.file.handle; h = &_h; CHECK_CREATED(&io, CREATED, FILE_ATTRIBUTE_ARCHIVE); @@ -564,7 +566,8 @@ static bool test_durable_open_reopen2(struct torture_context *tctx, h = NULL; status = smb2_create(tree, mem_ctx, &io); - CHECK_STATUS(status, NT_STATUS_OK); + torture_assert_ntstatus_equal_goto(tctx, status, NT_STATUS_OK, ret, + done, "Status should be OK"); CHECK_CREATED(&io, EXISTED, FILE_ATTRIBUTE_ARCHIVE); CHECK_VAL(io.out.oplock_level, smb2_util_oplock_level("b")); _h = io.out.file.handle; @@ -601,7 +604,8 @@ static bool test_durable_open_reopen2(struct torture_context *tctx, h = NULL; status = smb2_create(tree, mem_ctx, &io); - CHECK_STATUS(status, NT_STATUS_OK); + torture_assert_ntstatus_equal_goto(tctx, status, NT_STATUS_OK, ret, + done, "Status should be OK"); CHECK_CREATED(&io, EXISTED, FILE_ATTRIBUTE_ARCHIVE); CHECK_VAL(io.out.oplock_level, smb2_util_oplock_level("b")); _h = io.out.file.handle; @@ -630,7 +634,8 @@ static bool test_durable_open_reopen2(struct torture_context *tctx, h = NULL; status = smb2_create(tree, mem_ctx, &io); - CHECK_STATUS(status, NT_STATUS_OK); + torture_assert_ntstatus_equal_goto(tctx, status, NT_STATUS_OK, ret, + done, "Status should be OK"); CHECK_CREATED(&io, EXISTED, FILE_ATTRIBUTE_ARCHIVE); CHECK_VAL(io.out.oplock_level, smb2_util_oplock_level("b")); _h = io.out.file.handle; @@ -691,7 +696,8 @@ static bool test_durable_open_reopen2_lease(struct torture_context *tctx, io.in.durable_open = true; status = smb2_create(tree, mem_ctx, &io); - CHECK_STATUS(status, NT_STATUS_OK); + torture_assert_ntstatus_equal_goto(tctx, status, NT_STATUS_OK, ret, + done, "Status should be OK"); _h = io.out.file.handle; h = &_h; CHECK_CREATED(&io, CREATED, FILE_ATTRIBUTE_ARCHIVE); @@ -727,19 +733,25 @@ static bool test_durable_open_reopen2_lease(struct torture_context *tctx, io.in.fname = ""; io.in.durable_handle = h; status = smb2_create(tree, mem_ctx, &io); - CHECK_STATUS(status, NT_STATUS_OBJECT_NAME_NOT_FOUND); + torture_assert_ntstatus_equal_goto(tctx, status, + NT_STATUS_OBJECT_NAME_NOT_FOUND, + ret, done, "Status is wrong"); ZERO_STRUCT(io); io.in.fname = "__non_existing_fname__"; io.in.durable_handle = h; status = smb2_create(tree, mem_ctx, &io); - CHECK_STATUS(status, NT_STATUS_OBJECT_NAME_NOT_FOUND); + torture_assert_ntstatus_equal_goto(tctx, status, + NT_STATUS_OBJECT_NAME_NOT_FOUND, + ret, done, "Status is wrong"); ZERO_STRUCT(io); io.in.fname = fname; io.in.durable_handle = h; status = smb2_create(tree, mem_ctx, &io); - CHECK_STATUS(status, NT_STATUS_OBJECT_NAME_NOT_FOUND); + torture_assert_ntstatus_equal_goto(tctx, status, + NT_STATUS_OBJECT_NAME_NOT_FOUND, + ret, done, "Status is wrong"); /* * attempt with lease provided, but @@ -755,7 +767,9 @@ static bool test_durable_open_reopen2_lease(struct torture_context *tctx, ls.lease_key.data[0]++; status = smb2_create(tree, mem_ctx, &io); - CHECK_STATUS(status, NT_STATUS_OBJECT_NAME_NOT_FOUND); + torture_assert_ntstatus_equal_goto(tctx, status, + NT_STATUS_OBJECT_NAME_NOT_FOUND, + ret, done, "Status is wrong"); /* restore the correct lease key */ ls.lease_key.data[0]--; @@ -774,7 +788,9 @@ static bool test_durable_open_reopen2_lease(struct torture_context *tctx, io.in.oplock_level = SMB2_OPLOCK_LEVEL_LEASE; status = smb2_create(tree, mem_ctx, &io); - CHECK_STATUS(status, NT_STATUS_INVALID_PARAMETER); + torture_assert_ntstatus_equal_goto(tctx, status, + NT_STATUS_INVALID_PARAMETER, + ret, done, "Status is wrong"); /* * Now for a succeeding reconnect: @@ -793,7 +809,8 @@ static bool test_durable_open_reopen2_lease(struct torture_context *tctx, h = NULL; status = smb2_create(tree, mem_ctx, &io); - CHECK_STATUS(status, NT_STATUS_OK); + torture_assert_ntstatus_equal_goto(tctx, status, NT_STATUS_OK, ret, + done, "Status should be OK"); CHECK_CREATED(&io, EXISTED, FILE_ATTRIBUTE_ARCHIVE); CHECK_VAL(io.out.durable_open, false); @@ -856,7 +873,8 @@ static bool test_durable_open_reopen2_lease(struct torture_context *tctx, h = NULL; status = smb2_create(tree, mem_ctx, &io); - CHECK_STATUS(status, NT_STATUS_OK); + torture_assert_ntstatus_equal_goto(tctx, status, NT_STATUS_OK, ret, + done, "Status should be OK"); CHECK_CREATED(&io, EXISTED, FILE_ATTRIBUTE_ARCHIVE); CHECK_VAL(io.out.durable_open, false); @@ -929,7 +947,8 @@ static bool test_durable_open_reopen2_lease_v2(struct torture_context *tctx, io.in.durable_open = true; status = smb2_create(tree, mem_ctx, &io); - CHECK_STATUS(status, NT_STATUS_OK); + torture_assert_ntstatus_equal_goto(tctx, status, NT_STATUS_OK, ret, + done, "Status should be OK"); _h = io.out.file.handle; h = &_h; CHECK_CREATED(&io, CREATED, FILE_ATTRIBUTE_ARCHIVE); @@ -964,19 +983,25 @@ static bool test_durable_open_reopen2_lease_v2(struct torture_context *tctx, io.in.fname = ""; io.in.durable_handle = h; status = smb2_create(tree, mem_ctx, &io); - CHECK_STATUS(status, NT_STATUS_OBJECT_NAME_NOT_FOUND); + torture_assert_ntstatus_equal_goto(tctx, status, + NT_STATUS_OBJECT_NAME_NOT_FOUND, + ret, done, "Status is wrong"); ZERO_STRUCT(io); io.in.fname = "__non_existing_fname__"; io.in.durable_handle = h; status = smb2_create(tree, mem_ctx, &io); - CHECK_STATUS(status, NT_STATUS_OBJECT_NAME_NOT_FOUND); + torture_assert_ntstatus_equal_goto(tctx, status, + NT_STATUS_OBJECT_NAME_NOT_FOUND, + ret, done, "Status is wrong"); ZERO_STRUCT(io); io.in.fname = fname; io.in.durable_handle = h; status = smb2_create(tree, mem_ctx, &io); - CHECK_STATUS(status, NT_STATUS_OBJECT_NAME_NOT_FOUND); + torture_assert_ntstatus_equal_goto(tctx, status, + NT_STATUS_OBJECT_NAME_NOT_FOUND, + ret, done, "Status is wrong"); /* * attempt with lease provided, but @@ -992,7 +1017,9 @@ static bool test_durable_open_reopen2_lease_v2(struct torture_context *tctx, ls.lease_key.data[0]++; status = smb2_create(tree, mem_ctx, &io); - CHECK_STATUS(status, NT_STATUS_OBJECT_NAME_NOT_FOUND); + torture_assert_ntstatus_equal_goto(tctx, status, + NT_STATUS_OBJECT_NAME_NOT_FOUND, + ret, done, "Status is wrong"); /* restore the correct lease key */ ls.lease_key.data[0]--; @@ -1011,7 +1038,9 @@ static bool test_durable_open_reopen2_lease_v2(struct torture_context *tctx, io.in.oplock_level = SMB2_OPLOCK_LEVEL_LEASE; status = smb2_create(tree, mem_ctx, &io); - CHECK_STATUS(status, NT_STATUS_INVALID_PARAMETER); + torture_assert_ntstatus_equal_goto(tctx, status, + NT_STATUS_INVALID_PARAMETER, + ret, done, "Status is wrong"); /* * Now for a succeeding reconnect: @@ -1030,7 +1059,8 @@ static bool test_durable_open_reopen2_lease_v2(struct torture_context *tctx, h = NULL; status = smb2_create(tree, mem_ctx, &io); - CHECK_STATUS(status, NT_STATUS_OK); + torture_assert_ntstatus_equal_goto(tctx, status, NT_STATUS_OK, ret, + done, "Status should be OK"); CHECK_CREATED(&io, EXISTED, FILE_ATTRIBUTE_ARCHIVE); CHECK_VAL(io.out.durable_open, false); @@ -1093,7 +1123,8 @@ static bool test_durable_open_reopen2_lease_v2(struct torture_context *tctx, h = NULL; status = smb2_create(tree, mem_ctx, &io); - CHECK_STATUS(status, NT_STATUS_OK); + torture_assert_ntstatus_equal_goto(tctx, status, NT_STATUS_OK, ret, + done, "Status should be OK"); CHECK_CREATED(&io, EXISTED, FILE_ATTRIBUTE_ARCHIVE); CHECK_VAL(io.out.durable_open, false); @@ -1158,7 +1189,8 @@ static bool test_durable_open_reopen2a(struct torture_context *tctx, io1.in.durable_open = true; status = smb2_create(tree, mem_ctx, &io1); - CHECK_STATUS(status, NT_STATUS_OK); + torture_assert_ntstatus_equal_goto(tctx, status, NT_STATUS_OK, ret, + done, "Status should be OK"); _h = io1.out.file.handle; h = &_h; CHECK_CREATED(&io1, CREATED, FILE_ATTRIBUTE_ARCHIVE); @@ -1184,7 +1216,8 @@ static bool test_durable_open_reopen2a(struct torture_context *tctx, h = NULL; status = smb2_create(tree, mem_ctx, &io2); - CHECK_STATUS(status, NT_STATUS_OK); + torture_assert_ntstatus_equal_goto(tctx, status, NT_STATUS_OK, ret, + done, "Status should be OK"); CHECK_CREATED(&io2, EXISTED, FILE_ATTRIBUTE_ARCHIVE); CHECK_VAL(io2.out.oplock_level, smb2_util_oplock_level("b")); _h = io2.out.file.handle; @@ -1235,7 +1268,8 @@ static bool test_durable_open_reopen3(struct torture_context *tctx, io1.in.durable_open = true; status = smb2_create(tree, mem_ctx, &io1); - CHECK_STATUS(status, NT_STATUS_OK); + torture_assert_ntstatus_equal_goto(tctx, status, NT_STATUS_OK, ret, + done, "Status should be OK"); _h = io1.out.file.handle; h = &_h; CHECK_CREATED(&io1, CREATED, FILE_ATTRIBUTE_ARCHIVE); @@ -1244,7 +1278,8 @@ static bool test_durable_open_reopen3(struct torture_context *tctx, /* disconnect, reconnect and then do durable reopen */ status = smb2_tdis(tree); - CHECK_STATUS(status, NT_STATUS_OK); + torture_assert_ntstatus_equal_goto(tctx, status, NT_STATUS_OK, ret, + done, "Status should be OK"); if (!torture_smb2_tree_connect(tctx, tree->session, mem_ctx, &tree2)) { torture_warning(tctx, "couldn't reconnect to share, bailing\n"); @@ -1258,7 +1293,9 @@ static bool test_durable_open_reopen3(struct torture_context *tctx, io2.in.durable_handle = h; status = smb2_create(tree2, mem_ctx, &io2); - CHECK_STATUS(status, NT_STATUS_OBJECT_NAME_NOT_FOUND); + torture_assert_ntstatus_equal_goto(tctx, status, + NT_STATUS_OBJECT_NAME_NOT_FOUND, + ret, done, "Status is wrong"); done: if (tree != NULL) { @@ -1306,7 +1343,8 @@ static bool test_durable_open_reopen4(struct torture_context *tctx, io1.in.durable_open = true; status = smb2_create(tree, mem_ctx, &io1); - CHECK_STATUS(status, NT_STATUS_OK); + torture_assert_ntstatus_equal_goto(tctx, status, NT_STATUS_OK, ret, + done, "Status should be OK"); _h = io1.out.file.handle; h = &_h; CHECK_CREATED(&io1, CREATED, FILE_ATTRIBUTE_ARCHIVE); @@ -1319,7 +1357,8 @@ static bool test_durable_open_reopen4(struct torture_context *tctx, */ transport = tree->session->transport; status = smb2_logoff(tree->session); - CHECK_STATUS(status, NT_STATUS_OK); + torture_assert_ntstatus_equal_goto(tctx, status, NT_STATUS_OK, ret, + done, "Status should be OK"); if (!torture_smb2_session_setup(tctx, transport, 0, /* previous_session_id */ @@ -1348,7 +1387,8 @@ static bool test_durable_open_reopen4(struct torture_context *tctx, h = NULL; status = smb2_create(tree2, mem_ctx, &io2); - CHECK_STATUS(status, NT_STATUS_OK); + torture_assert_ntstatus_equal_goto(tctx, status, NT_STATUS_OK, ret, + done, "Status should be OK"); _h = io2.out.file.handle; h = &_h; @@ -1396,7 +1436,8 @@ static bool test_durable_open_delete_on_close1(struct torture_context *tctx, io1.in.create_options |= NTCREATEX_OPTIONS_DELETE_ON_CLOSE; status = smb2_create(tree, mem_ctx, &io1); - CHECK_STATUS(status, NT_STATUS_OK); + torture_assert_ntstatus_equal_goto(tctx, status, NT_STATUS_OK, ret, + done, "Status should be OK"); _h = io1.out.file.handle; h = &_h; CHECK_CREATED(&io1, CREATED, FILE_ATTRIBUTE_ARCHIVE); @@ -1404,7 +1445,8 @@ static bool test_durable_open_delete_on_close1(struct torture_context *tctx, CHECK_VAL(io1.out.oplock_level, smb2_util_oplock_level("b")); status = smb2_util_write(tree, *h, &b, 0, 1); - CHECK_STATUS(status, NT_STATUS_OK); + torture_assert_ntstatus_equal_goto(tctx, status, NT_STATUS_OK, ret, + done, "Status should be OK"); /* disconnect, leaving the durable handle in place */ TALLOC_FREE(tree); @@ -1428,7 +1470,8 @@ static bool test_durable_open_delete_on_close1(struct torture_context *tctx, io2.in.create_options |= NTCREATEX_OPTIONS_DELETE_ON_CLOSE; status = smb2_create(tree, mem_ctx, &io2); - CHECK_STATUS(status, NT_STATUS_OK); + torture_assert_ntstatus_equal_goto(tctx, status, NT_STATUS_OK, ret, + done, "Status should be OK"); _h = io2.out.file.handle; h = &_h; CHECK_CREATED_SIZE(&io2, CREATED, FILE_ATTRIBUTE_ARCHIVE, 0, 0); @@ -1482,7 +1525,8 @@ static bool test_durable_open_delete_on_close2(struct torture_context *tctx, io.in.create_options |= NTCREATEX_OPTIONS_DELETE_ON_CLOSE; status = smb2_create(tree, mem_ctx, &io); - CHECK_STATUS(status, NT_STATUS_OK); + torture_assert_ntstatus_equal_goto(tctx, status, NT_STATUS_OK, ret, + done, "Status should be OK"); _h = io.out.file.handle; h = &_h; CHECK_CREATED(&io, CREATED, FILE_ATTRIBUTE_ARCHIVE); @@ -1490,7 +1534,8 @@ static bool test_durable_open_delete_on_close2(struct torture_context *tctx, CHECK_VAL(io.out.oplock_level, smb2_util_oplock_level("b")); status = smb2_util_write(tree, *h, &b, 0, 1); - CHECK_STATUS(status, NT_STATUS_OK); + torture_assert_ntstatus_equal_goto(tctx, status, NT_STATUS_OK, ret, + done, "Status should be OK"); previous_session_id = smb2cli_session_current_id(tree->session->smbXcli); @@ -1510,7 +1555,8 @@ static bool test_durable_open_delete_on_close2(struct torture_context *tctx, io.in.durable_handle = h; status = smb2_create(tree, mem_ctx, &io); - CHECK_STATUS(status, NT_STATUS_OK); + torture_assert_ntstatus_equal_goto(tctx, status, NT_STATUS_OK, ret, + done, "Status should be OK"); _h = io.out.file.handle; h = &_h; alloc_size_step = io.out.alloc_size; @@ -1543,7 +1589,8 @@ static bool test_durable_open_delete_on_close2(struct torture_context *tctx, io.in.create_options |= NTCREATEX_OPTIONS_DELETE_ON_CLOSE; status = smb2_create(tree, mem_ctx, &io); - CHECK_STATUS(status, NT_STATUS_OK); + torture_assert_ntstatus_equal_goto(tctx, status, NT_STATUS_OK, ret, + done, "Status should be OK"); _h = io.out.file.handle; h = &_h; CHECK_CREATED_SIZE(&io, CREATED, FILE_ATTRIBUTE_ARCHIVE, 0, 0); @@ -1593,7 +1640,8 @@ static bool test_durable_open_file_position(struct torture_context *tctx, io.in.durable_open = true; status = smb2_create(tree, mem_ctx, &io); - CHECK_STATUS(status, NT_STATUS_OK); + torture_assert_ntstatus_equal_goto(tctx, status, NT_STATUS_OK, ret, + done, "Status should be OK"); h = io.out.file.handle; CHECK_CREATED(&io, CREATED, FILE_ATTRIBUTE_ARCHIVE); CHECK_VAL(io.out.durable_open, true); @@ -1605,7 +1653,8 @@ static bool test_durable_open_file_position(struct torture_context *tctx, qfinfo.generic.level = RAW_FILEINFO_POSITION_INFORMATION; qfinfo.generic.in.file.handle = h; status = smb2_getinfo_file(tree, mem_ctx, &qfinfo); - CHECK_STATUS(status, NT_STATUS_OK); + torture_assert_ntstatus_equal_goto(tctx, status, NT_STATUS_OK, ret, + done, "Status should be OK"); CHECK_VAL(qfinfo.position_information.out.position, 0); pos = qfinfo.position_information.out.position; torture_comment(tctx, "position: %llu\n", @@ -1616,13 +1665,15 @@ static bool test_durable_open_file_position(struct torture_context *tctx, sfinfo.generic.in.file.handle = h; sfinfo.position_information.in.position = 0x1000; status = smb2_setinfo_file(tree, &sfinfo); - CHECK_STATUS(status, NT_STATUS_OK); + torture_assert_ntstatus_equal_goto(tctx, status, NT_STATUS_OK, ret, + done, "Status should be OK"); ZERO_STRUCT(qfinfo); qfinfo.generic.level = RAW_FILEINFO_POSITION_INFORMATION; qfinfo.generic.in.file.handle = h; status = smb2_getinfo_file(tree, mem_ctx, &qfinfo); - CHECK_STATUS(status, NT_STATUS_OK); + torture_assert_ntstatus_equal_goto(tctx, status, NT_STATUS_OK, ret, + done, "Status should be OK"); CHECK_VAL(qfinfo.position_information.out.position, 0x1000); pos = qfinfo.position_information.out.position; torture_comment(tctx, "position: %llu\n", @@ -1647,14 +1698,16 @@ static bool test_durable_open_file_position(struct torture_context *tctx, qfinfo.generic.level = RAW_FILEINFO_POSITION_INFORMATION; qfinfo.generic.in.file.handle = h; status = smb2_getinfo_file(tree, mem_ctx, &qfinfo); - CHECK_STATUS(status, NT_STATUS_FILE_CLOSED); + torture_assert_ntstatus_equal_goto(tctx, status, NT_STATUS_FILE_CLOSED, + ret, done, "Status is wrong"); ZERO_STRUCT(io); io.in.fname = fname; io.in.durable_handle = &h; status = smb2_create(tree, mem_ctx, &io); - CHECK_STATUS(status, NT_STATUS_OK); + torture_assert_ntstatus_equal_goto(tctx, status, NT_STATUS_OK, ret, + done, "Status should be OK"); CHECK_VAL(io.out.oplock_level, SMB2_OPLOCK_LEVEL_BATCH); CHECK_VAL(io.out.reserved, 0x00); CHECK_VAL(io.out.create_action, NTCREATEX_ACTION_EXISTED); @@ -1669,7 +1722,8 @@ static bool test_durable_open_file_position(struct torture_context *tctx, qfinfo.generic.level = RAW_FILEINFO_POSITION_INFORMATION; qfinfo.generic.in.file.handle = h; status = smb2_getinfo_file(tree, mem_ctx, &qfinfo); - CHECK_STATUS(status, NT_STATUS_OK); + torture_assert_ntstatus_equal_goto(tctx, status, NT_STATUS_OK, ret, + done, "Status should be OK"); CHECK_VAL(qfinfo.position_information.out.position, 0x1000); pos = qfinfo.position_information.out.position; torture_comment(tctx, "position: %llu\n", @@ -1715,7 +1769,8 @@ static bool test_durable_open_oplock(struct torture_context *tctx, io2.in.create_disposition = NTCREATEX_DISP_OPEN; status = smb2_create(tree1, mem_ctx, &io1); - CHECK_STATUS(status, NT_STATUS_OK); + torture_assert_ntstatus_equal_goto(tctx, status, NT_STATUS_OK, ret, + done, "Status should be OK"); h1 = io1.out.file.handle; CHECK_CREATED(&io1, CREATED, FILE_ATTRIBUTE_ARCHIVE); CHECK_VAL(io1.out.durable_open, true); @@ -1731,7 +1786,8 @@ static bool test_durable_open_oplock(struct torture_context *tctx, * some time for the client to reconnect!) */ status = smb2_create(tree2, mem_ctx, &io2); - CHECK_STATUS(status, NT_STATUS_OK); + torture_assert_ntstatus_equal_goto(tctx, status, NT_STATUS_OK, ret, + done, "Status should be OK"); h2 = io2.out.file.handle; CHECK_CREATED(&io2, EXISTED, FILE_ATTRIBUTE_ARCHIVE); CHECK_VAL(io2.out.durable_open, true); @@ -1749,7 +1805,9 @@ static bool test_durable_open_oplock(struct torture_context *tctx, io1.in.durable_handle = &h1; status = smb2_create(tree1, mem_ctx, &io1); - CHECK_STATUS(status, NT_STATUS_OBJECT_NAME_NOT_FOUND); + torture_assert_ntstatus_equal_goto(tctx, status, + NT_STATUS_OBJECT_NAME_NOT_FOUND, + ret, done, "Status is wrong"); done: smb2_util_close(tree2, h2); @@ -1805,7 +1863,8 @@ static bool test_durable_open_lease(struct torture_context *tctx, io2.in.create_disposition = NTCREATEX_DISP_OPEN; status = smb2_create(tree1, mem_ctx, &io1); - CHECK_STATUS(status, NT_STATUS_OK); + torture_assert_ntstatus_equal_goto(tctx, status, NT_STATUS_OK, ret, + done, "Status should be OK"); h1 = io1.out.file.handle; CHECK_VAL(io1.out.durable_open, true); CHECK_CREATED(&io1, CREATED, FILE_ATTRIBUTE_ARCHIVE); @@ -1824,12 +1883,13 @@ static bool test_durable_open_lease(struct torture_context *tctx, * Windows7 (build 7000) will grant an RH lease immediate (not an RHW?) * even if the original client is gone. (ZML: This seems like a bug. It * should give some time for the client to reconnect! And why RH?) - * + * * obnox: Current windows 7 and w2k8r2 grant RHW instead of RH. * Test is adapted accordingly. */ status = smb2_create(tree2, mem_ctx, &io2); - CHECK_STATUS(status, NT_STATUS_OK); + torture_assert_ntstatus_equal_goto(tctx, status, NT_STATUS_OK, ret, + done, "Status should be OK"); h2 = io2.out.file.handle; CHECK_VAL(io2.out.durable_open, true); CHECK_CREATED(&io2, EXISTED, FILE_ATTRIBUTE_ARCHIVE); @@ -1853,7 +1913,9 @@ static bool test_durable_open_lease(struct torture_context *tctx, io1.in.lease_request = &ls1; status = smb2_create(tree1, mem_ctx, &io1); - CHECK_STATUS(status, NT_STATUS_OBJECT_NAME_NOT_FOUND); + torture_assert_ntstatus_equal_goto(tctx, status, + NT_STATUS_OBJECT_NAME_NOT_FOUND, + ret, done, "Status is wrong"); done: smb2_util_close(tree2, h2); @@ -1892,7 +1954,8 @@ static bool test_durable_open_lock_oplock(struct torture_context *tctx, io.in.durable_open = true; status = smb2_create(tree, mem_ctx, &io); - CHECK_STATUS(status, NT_STATUS_OK); + torture_assert_ntstatus_equal_goto(tctx, status, NT_STATUS_OK, ret, + done, "Status should be OK"); h = io.out.file.handle; CHECK_CREATED(&io, CREATED, FILE_ATTRIBUTE_ARCHIVE); @@ -1910,7 +1973,8 @@ static bool test_durable_open_lock_oplock(struct torture_context *tctx, el[0].reserved = 0x00000000; el[0].flags = SMB2_LOCK_FLAG_EXCLUSIVE; status = smb2_lock(tree, &lck); - CHECK_STATUS(status, NT_STATUS_OK); + torture_assert_ntstatus_equal_goto(tctx, status, NT_STATUS_OK, ret, + done, "Status should be OK"); /* Disconnect/Reconnect. */ talloc_free(tree); @@ -1927,13 +1991,15 @@ static bool test_durable_open_lock_oplock(struct torture_context *tctx, io.in.durable_handle = &h; status = smb2_create(tree, mem_ctx, &io); - CHECK_STATUS(status, NT_STATUS_OK); + torture_assert_ntstatus_equal_goto(tctx, status, NT_STATUS_OK, ret, + done, "Status should be OK"); h = io.out.file.handle; lck.in.file.handle = h; el[0].flags = SMB2_LOCK_FLAG_UNLOCK; status = smb2_lock(tree, &lck); - CHECK_STATUS(status, NT_STATUS_OK); + torture_assert_ntstatus_equal_goto(tctx, status, NT_STATUS_OK, ret, + done, "Status should be OK"); done: smb2_util_close(tree, h); @@ -1986,7 +2052,8 @@ static bool test_durable_open_lock_lease(struct torture_context *tctx, io.in.durable_open = true; status = smb2_create(tree, mem_ctx, &io); - CHECK_STATUS(status, NT_STATUS_OK); + torture_assert_ntstatus_equal_goto(tctx, status, NT_STATUS_OK, ret, + done, "Status should be OK"); h = io.out.file.handle; CHECK_CREATED(&io, CREATED, FILE_ATTRIBUTE_ARCHIVE); @@ -2008,7 +2075,8 @@ static bool test_durable_open_lock_lease(struct torture_context *tctx, el[0].reserved = 0x00000000; el[0].flags = SMB2_LOCK_FLAG_EXCLUSIVE; status = smb2_lock(tree, &lck); - CHECK_STATUS(status, NT_STATUS_OK); + torture_assert_ntstatus_equal_goto(tctx, status, NT_STATUS_OK, ret, + done, "Status should be OK"); /* Disconnect/Reconnect. */ talloc_free(tree); @@ -2026,13 +2094,15 @@ static bool test_durable_open_lock_lease(struct torture_context *tctx, io.in.lease_request = &ls; status = smb2_create(tree, mem_ctx, &io); - CHECK_STATUS(status, NT_STATUS_OK); + torture_assert_ntstatus_equal_goto(tctx, status, NT_STATUS_OK, ret, + done, "Status should be OK"); h = io.out.file.handle; lck.in.file.handle = h; el[0].flags = SMB2_LOCK_FLAG_UNLOCK; status = smb2_lock(tree, &lck); - CHECK_STATUS(status, NT_STATUS_OK); + torture_assert_ntstatus_equal_goto(tctx, status, NT_STATUS_OK, ret, + done, "Status should be OK"); done: smb2_util_close(tree, h); @@ -2091,7 +2161,8 @@ static bool test_durable_open_open2_lease(struct torture_context *tctx, io1.in.durable_open = true; status = smb2_create(tree1, mem_ctx, &io1); - CHECK_STATUS(status, NT_STATUS_OK); + torture_assert_ntstatus_equal_goto(tctx, status, NT_STATUS_OK, ret, + done, "Status should be OK"); h1 = io1.out.file.handle; CHECK_VAL(io1.out.durable_open, true); CHECK_CREATED(&io1, CREATED, FILE_ATTRIBUTE_ARCHIVE); @@ -2110,7 +2181,8 @@ static bool test_durable_open_open2_lease(struct torture_context *tctx, smb2_oplock_create(&io2, fname, SMB2_OPLOCK_LEVEL_NONE); status = smb2_create(tree2, mem_ctx, &io2); - CHECK_STATUS(status, NT_STATUS_OK); + torture_assert_ntstatus_equal_goto(tctx, status, NT_STATUS_OK, ret, + done, "Status should be OK"); h2 = io2.out.file.handle; CHECK_CREATED(&io1, CREATED, FILE_ATTRIBUTE_ARCHIVE); @@ -2132,7 +2204,9 @@ static bool test_durable_open_open2_lease(struct torture_context *tctx, * some time for the client to reconnect!) */ status = smb2_create(tree1, mem_ctx, &io1); - CHECK_STATUS(status, NT_STATUS_OBJECT_NAME_NOT_FOUND); + torture_assert_ntstatus_equal_goto(tctx, status, + NT_STATUS_OBJECT_NAME_NOT_FOUND, + ret, done, "Status is wrong"); h1 = io1.out.file.handle; done: @@ -2183,7 +2257,8 @@ static bool test_durable_open_open2_oplock(struct torture_context *tctx, io1.in.durable_open = true; status = smb2_create(tree1, mem_ctx, &io1); - CHECK_STATUS(status, NT_STATUS_OK); + torture_assert_ntstatus_equal_goto(tctx, status, NT_STATUS_OK, ret, + done, "Status should be OK"); h1 = io1.out.file.handle; CHECK_CREATED(&io1, CREATED, FILE_ATTRIBUTE_ARCHIVE); CHECK_VAL(io1.out.durable_open, true); @@ -2197,7 +2272,8 @@ static bool test_durable_open_open2_oplock(struct torture_context *tctx, smb2_oplock_create(&io2, fname, SMB2_OPLOCK_LEVEL_NONE); status = smb2_create(tree2, mem_ctx, &io2); - CHECK_STATUS(status, NT_STATUS_OK); + torture_assert_ntstatus_equal_goto(tctx, status, NT_STATUS_OK, ret, + done,"Status should be OK"); h2 = io2.out.file.handle; CHECK_CREATED(&io1, CREATED, FILE_ATTRIBUTE_ARCHIVE); @@ -2213,7 +2289,9 @@ static bool test_durable_open_open2_oplock(struct torture_context *tctx, io1.in.durable_handle = &h1; status = smb2_create(tree1, mem_ctx, &io1); - CHECK_STATUS(status, NT_STATUS_OBJECT_NAME_NOT_FOUND); + torture_assert_ntstatus_equal_goto(tctx, status, + NT_STATUS_OBJECT_NAME_NOT_FOUND, + ret, done, "Status is wrong"); h1 = io1.out.file.handle; done: @@ -2264,7 +2342,8 @@ static bool test_durable_open_alloc_size(struct torture_context *tctx, io.in.alloc_size = initial_alloc_size; status = smb2_create(tree, mem_ctx, &io); - CHECK_STATUS(status, NT_STATUS_OK); + torture_assert_ntstatus_equal_goto(tctx, status, NT_STATUS_OK, ret, + done,"Status should be OK"); _h = io.out.file.handle; h = &_h; CHECK_NOT_VAL(io.out.alloc_size, 0); @@ -2298,7 +2377,8 @@ static bool test_durable_open_alloc_size(struct torture_context *tctx, h = NULL; status = smb2_create(tree, mem_ctx, &io); - CHECK_STATUS(status, NT_STATUS_OK); + torture_assert_ntstatus_equal_goto(tctx, status, NT_STATUS_OK, ret, + done, "Status should be OK"); CHECK_CREATED_SIZE(&io, EXISTED, FILE_ATTRIBUTE_ARCHIVE, alloc_size_step, 0); CHECK_VAL(io.out.oplock_level, smb2_util_oplock_level("b")); @@ -2309,7 +2389,8 @@ static bool test_durable_open_alloc_size(struct torture_context *tctx, /* write one byte */ status = smb2_util_write(tree, *h, b, 0, 1); - CHECK_STATUS(status, NT_STATUS_OK); + torture_assert_ntstatus_equal_goto(tctx, status, NT_STATUS_OK, ret, + done, "Status should be OK"); /* disconnect, reconnect and then do durable reopen */ talloc_free(tree); @@ -2329,7 +2410,8 @@ static bool test_durable_open_alloc_size(struct torture_context *tctx, h = NULL; status = smb2_create(tree, mem_ctx, &io); - CHECK_STATUS(status, NT_STATUS_OK); + torture_assert_ntstatus_equal_goto(tctx, status, NT_STATUS_OK, ret, + done, "Status should be OK"); CHECK_CREATED_SIZE(&io, EXISTED, FILE_ATTRIBUTE_ARCHIVE, alloc_size_step, 1); CHECK_VAL(io.out.oplock_level, smb2_util_oplock_level("b")); @@ -2359,7 +2441,8 @@ static bool test_durable_open_alloc_size(struct torture_context *tctx, h = NULL; status = smb2_create(tree, mem_ctx, &io); - CHECK_STATUS(status, NT_STATUS_OK); + torture_assert_ntstatus_equal_goto(tctx, status, NT_STATUS_OK, ret, + done, "Status should be OK"); CHECK_CREATED_SIZE(&io, EXISTED, FILE_ATTRIBUTE_ARCHIVE, alloc_size_step * 2, alloc_size_step + 1); CHECK_VAL(io.out.oplock_level, smb2_util_oplock_level("b")); @@ -2413,7 +2496,8 @@ static bool test_durable_open_read_only(struct torture_context *tctx, io.in.file_attributes = FILE_ATTRIBUTE_READONLY; status = smb2_create(tree, mem_ctx, &io); - CHECK_STATUS(status, NT_STATUS_OK); + torture_assert_ntstatus_equal_goto(tctx, status, NT_STATUS_OK, ret, + done, "Status should be OK"); _h = io.out.file.handle; h = &_h; CHECK_CREATED(&io, CREATED, FILE_ATTRIBUTE_READONLY|FILE_ATTRIBUTE_ARCHIVE); @@ -2424,7 +2508,8 @@ static bool test_durable_open_read_only(struct torture_context *tctx, /* write one byte */ status = smb2_util_write(tree, *h, &b, 0, 1); - CHECK_STATUS(status, NT_STATUS_OK); + torture_assert_ntstatus_equal_goto(tctx, status, NT_STATUS_OK, ret, + done, "Status should be OK"); /* disconnect, reconnect and then do durable reopen */ talloc_free(tree); @@ -2444,7 +2529,8 @@ static bool test_durable_open_read_only(struct torture_context *tctx, h = NULL; status = smb2_create(tree, mem_ctx, &io); - CHECK_STATUS(status, NT_STATUS_OK); + torture_assert_ntstatus_equal_goto(tctx, status, NT_STATUS_OK, ret, + done, "Status should be OK"); alloc_size = io.out.alloc_size; CHECK_CREATED_SIZE(&io, EXISTED, FILE_ATTRIBUTE_READONLY|FILE_ATTRIBUTE_ARCHIVE, @@ -2455,7 +2541,8 @@ static bool test_durable_open_read_only(struct torture_context *tctx, /* write one byte */ status = smb2_util_write(tree, *h, &b, 1, 1); - CHECK_STATUS(status, NT_STATUS_OK); + torture_assert_ntstatus_equal_goto(tctx, status, NT_STATUS_OK, ret, + done, "Status should be OK"); done: if (h != NULL) { @@ -2502,7 +2589,8 @@ static bool test_durable_open_oplock_disconnect(struct torture_context *tctx, io.in.durable_open = true; status = smb2_create(tree, mem_ctx, &io); - CHECK_STATUS(status, NT_STATUS_OK); + torture_assert_ntstatus_equal_goto(tctx, status, NT_STATUS_OK, ret, + done, "Status should be OK"); _h = io.out.file.handle; h = &_h; -- 1.9.1