mirror of
https://github.com/samba-team/samba.git
synced 2025-01-22 22:04:08 +03:00
smbtorture: Add smb2.ioctl.zero_data
Allow to manually issue the FSCTL_ZERO_DATA call and verify the state of the file in the file system. Signed-off-by: Christof Schmitt <cs@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
This commit is contained in:
parent
aa199696b9
commit
e1bb3d34d9
@ -71,6 +71,7 @@
|
||||
^samba3.smb2.hold-sharemode # Not a test, but a way to block other clients for a test
|
||||
^samba3.smb2.check-sharemode # Not a test, but a way to test sharemodes outside of Samba
|
||||
^samba3.smb2.set-sparse-ioctl # For manual testing, needs additional parameters.
|
||||
^samba3.smb2.zero-data-ioctl # For manual testing, needs additional parameters.
|
||||
^samba3.smb2.durable-open-disconnect # Not a test, but a way to create a disconnected durable
|
||||
^samba3.smb2.scan # No tests
|
||||
^samba3.smb2.oplock.levelii501 # No test yet
|
||||
@ -85,6 +86,7 @@
|
||||
^samba4.smb2.hold-sharemode # Not a test, but a way to block other clients for a test
|
||||
^samba4.smb2.check-sharemode # Not a test, but a way to test sharemodes outside of Samba
|
||||
^samba4.smb2.set-sparse-ioctl # For manual testing, needs additional parameters.
|
||||
^samba4.smb2.zero-data-ioctl # For manual testing, needs additional parameters.
|
||||
^samba4.raw.ping.pong # Needs second server to test
|
||||
^samba4.rpc.samr.accessmask
|
||||
^samba4.rpc.samr.passwords.*ncacn_np\(ad_dc_ntvfs\) # currently fails, possibly config issue
|
||||
|
@ -3894,6 +3894,67 @@ err_out:
|
||||
return status;
|
||||
}
|
||||
|
||||
bool test_ioctl_zero_data(struct torture_context *tctx)
|
||||
{
|
||||
bool ret = true;
|
||||
int offset, beyond_final_zero;
|
||||
const char *filename;
|
||||
NTSTATUS status;
|
||||
struct smb2_create create = { };
|
||||
struct smb2_tree *tree = NULL;
|
||||
|
||||
offset = torture_setting_int(tctx, "offset", -1);
|
||||
|
||||
if (offset < 0) {
|
||||
torture_fail(tctx, "Need to provide non-negative offset "
|
||||
"through --option=torture:offset=NNN\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
beyond_final_zero = torture_setting_int(tctx, "beyond_final_zero",
|
||||
-1);
|
||||
if (beyond_final_zero < 0) {
|
||||
torture_fail(tctx, "Need to provide non-negative "
|
||||
"'beyond final zero' through "
|
||||
"--option=torture:beyond_final_zero=NNN\n");
|
||||
return false;
|
||||
}
|
||||
filename = torture_setting_string(tctx, "filename", NULL);
|
||||
if (filename == NULL) {
|
||||
torture_fail(tctx, "Need to provide filename through "
|
||||
"--option=torture:filename=testfile\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!torture_smb2_connection(tctx, &tree)) {
|
||||
torture_comment(tctx, "Initializing smb2 connection failed.\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
create.in.desired_access = SEC_RIGHTS_DIR_ALL;
|
||||
create.in.create_options = 0;
|
||||
create.in.file_attributes = FILE_ATTRIBUTE_NORMAL;
|
||||
create.in.share_access = NTCREATEX_SHARE_ACCESS_READ |
|
||||
NTCREATEX_SHARE_ACCESS_WRITE |
|
||||
NTCREATEX_SHARE_ACCESS_DELETE;
|
||||
create.in.create_disposition = NTCREATEX_DISP_OPEN;
|
||||
create.in.fname = filename;
|
||||
|
||||
status = smb2_create(tree, tctx, &create);
|
||||
torture_assert_ntstatus_ok_goto(tctx, status, ret, done,
|
||||
"CREATE failed.\n");
|
||||
|
||||
status = test_ioctl_zdata_req(tctx, tctx, tree,
|
||||
create.out.file.handle,
|
||||
offset,
|
||||
beyond_final_zero);
|
||||
torture_assert_ntstatus_ok_goto(tctx, status, ret, done,
|
||||
"FSCTL_ZERO_DATA failed.\n");
|
||||
|
||||
done:
|
||||
return ret;
|
||||
}
|
||||
|
||||
static bool test_ioctl_sparse_punch(struct torture_context *torture,
|
||||
struct smb2_tree *tree)
|
||||
{
|
||||
|
@ -177,6 +177,8 @@ NTSTATUS torture_smb2_init(TALLOC_CTX *ctx)
|
||||
torture_suite_add_suite(suite, torture_smb2_ioctl_init(suite));
|
||||
torture_suite_add_simple_test(suite, "set-sparse-ioctl",
|
||||
test_ioctl_set_sparse);
|
||||
torture_suite_add_simple_test(suite, "zero-data-ioctl",
|
||||
test_ioctl_zero_data);
|
||||
torture_suite_add_suite(suite, torture_smb2_rename_init(suite));
|
||||
torture_suite_add_1smb2_test(suite, "bench-oplock", test_smb2_bench_oplock);
|
||||
torture_suite_add_suite(suite, torture_smb2_sharemode_init(suite));
|
||||
|
Loading…
x
Reference in New Issue
Block a user