From 2a5b0d5bb9bc354cede9657378a2af4c79614772 Mon Sep 17 00:00:00 2001 From: Sachin Prabhu Date: Mon, 11 Mar 2019 17:14:44 +0000 Subject: [PATCH] s4-torture: Add #defines required by the new tests New macros used by our tests. Signed-off-by: Guenther Deschner Signed-off-by: Sachin Prabhu Reviewed-by: Jeremy Allison --- source4/torture/smb2/multichannel.c | 73 +++++++++++++++++++++++++++-- 1 file changed, 68 insertions(+), 5 deletions(-) diff --git a/source4/torture/smb2/multichannel.c b/source4/torture/smb2/multichannel.c index 0a4203aa5fb..9aba784a980 100644 --- a/source4/torture/smb2/multichannel.c +++ b/source4/torture/smb2/multichannel.c @@ -30,14 +30,77 @@ #include "librpc/gen_ndr/ndr_ioctl.h" #include "../libcli/smb/smbXcli_base.h" -#define CHECK_STATUS(status, correct) do { \ - if (!NT_STATUS_EQUAL(status, correct)) { \ +#define BASEDIR "multichanneltestdir" + +#define CHECK_STATUS(status, correct) \ + torture_assert_ntstatus_equal_goto(tctx, status, correct,\ + ret, done, "") + +#define CHECK_VAL(v, correct) do { \ + if ((v) != (correct)) { \ + torture_result(tctx, TORTURE_FAIL, "(%s): wrong value for %s" \ + " got 0x%x - should be 0x%x\n", \ + __location__, #v, (int)v, (int)correct); \ + ret = false; \ + goto done; \ + } } while (0) + +#define CHECK_VAL_GREATER_THAN(v, gt_val) do { \ + if ((v) <= (gt_val)) { \ torture_result(tctx, TORTURE_FAIL, \ - "(%s) Incorrect status %s - should be %s\n", \ - __location__, nt_errstr(status), nt_errstr(correct)); \ - return false; \ + "(%s): wrong value for %s got 0x%x - " \ + "should be greater than 0x%x\n", \ + __location__, #v, (int)v, (int)gt_val); \ + ret = false; \ + goto done; \ } } while (0) +#define CHECK_CREATED(__io, __created, __attribute) \ + do { \ + CHECK_VAL((__io)->out.create_action, \ + NTCREATEX_ACTION_ ## __created); \ + CHECK_VAL((__io)->out.alloc_size, 0); \ + CHECK_VAL((__io)->out.size, 0); \ + CHECK_VAL((__io)->out.file_attr, (__attribute)); \ + CHECK_VAL((__io)->out.reserved2, 0); \ + } while (0) + +#define CHECK_PTR(ptr, correct) do { \ + if ((ptr) != (correct)) { \ + torture_result(tctx, TORTURE_FAIL, "(%s): wrong value for %s " \ + "got 0x%p - should be 0x%p\n", \ + __location__, #ptr, ptr, correct); \ + ret = false; \ + goto done; \ + } } while (0) + +#define CHECK_LEASE(__io, __state, __oplevel, __key, __flags) \ + do { \ + CHECK_VAL((__io)->out.lease_response.lease_version, 1); \ + if (__oplevel) { \ + CHECK_VAL((__io)->out.oplock_level, \ + SMB2_OPLOCK_LEVEL_LEASE); \ + CHECK_VAL((__io)->out.lease_response.lease_key.data[0],\ + (__key)); \ + CHECK_VAL((__io)->out.lease_response.lease_key.data[1],\ + ~(__key)); \ + CHECK_VAL((__io)->out.lease_response.lease_state,\ + smb2_util_lease_state(__state)); \ + } else { \ + CHECK_VAL((__io)->out.oplock_level,\ + SMB2_OPLOCK_LEVEL_NONE); \ + CHECK_VAL((__io)->out.lease_response.lease_key.data[0],\ + 0); \ + CHECK_VAL((__io)->out.lease_response.lease_key.data[1],\ + 0); \ + CHECK_VAL((__io)->out.lease_response.lease_state, 0); \ + } \ + \ + CHECK_VAL((__io)->out.lease_response.lease_flags, (__flags)); \ + CHECK_VAL((__io)->out.lease_response.lease_duration, 0); \ + CHECK_VAL((__io)->out.lease_response.lease_epoch, 0); \ + } while (0) + static bool test_ioctl_network_interface_info(struct torture_context *tctx, struct smb2_tree *tree, struct fsctl_net_iface_info *info) -- 2.34.1