LCOV - code coverage report
Current view: top level - source4/torture/smb2 - read.c (source / functions) Hit Total Coverage
Test: coverage report for master 2b515b7d Lines: 268 299 89.6 %
Date: 2024-02-28 12:06:22 Functions: 8 8 100.0 %

          Line data    Source code
       1             : /* 
       2             :    Unix SMB/CIFS implementation.
       3             : 
       4             :    SMB2 read test suite
       5             : 
       6             :    Copyright (C) Andrew Tridgell 2008
       7             :    
       8             :    This program is free software; you can redistribute it and/or modify
       9             :    it under the terms of the GNU General Public License as published by
      10             :    the Free Software Foundation; either version 3 of the License, or
      11             :    (at your option) any later version.
      12             :    
      13             :    This program is distributed in the hope that it will be useful,
      14             :    but WITHOUT ANY WARRANTY; without even the implied warranty of
      15             :    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      16             :    GNU General Public License for more details.
      17             :    
      18             :    You should have received a copy of the GNU General Public License
      19             :    along with this program.  If not, see <http://www.gnu.org/licenses/>.
      20             : */
      21             : 
      22             : #include "includes.h"
      23             : #include "libcli/smb2/smb2.h"
      24             : #include "libcli/smb2/smb2_calls.h"
      25             : #include <tevent.h>
      26             : 
      27             : #include "torture/torture.h"
      28             : #include "torture/smb2/proto.h"
      29             : #include "../libcli/smb/smbXcli_base.h"
      30             : #include "librpc/gen_ndr/ndr_ioctl.h"
      31             : 
      32             : 
      33             : #define CHECK_STATUS(_status, _expected) \
      34             :         torture_assert_ntstatus_equal_goto(torture, _status, _expected, \
      35             :                  ret, done, "Incorrect status")
      36             : 
      37             : #define CHECK_VALUE(v, correct) \
      38             :         torture_assert_int_equal_goto(torture, v, correct, \
      39             :                  ret, done, "Incorrect value")
      40             : 
      41             : #define FNAME "smb2_readtest.dat"
      42             : #define DNAME "smb2_readtest.dir"
      43             : 
      44           5 : static bool test_read_eof(struct torture_context *torture, struct smb2_tree *tree)
      45             : {
      46           5 :         bool ret = true;
      47           0 :         NTSTATUS status;
      48           0 :         struct smb2_handle h;
      49           0 :         uint8_t buf[64*1024];
      50           0 :         struct smb2_read rd;
      51           5 :         TALLOC_CTX *tmp_ctx = talloc_new(tree);
      52             : 
      53           5 :         ZERO_STRUCT(buf);
      54             : 
      55           5 :         smb2_util_unlink(tree, FNAME);
      56             : 
      57           5 :         status = torture_smb2_testfile(tree, FNAME, &h);
      58           5 :         CHECK_STATUS(status, NT_STATUS_OK);
      59             : 
      60           5 :         ZERO_STRUCT(rd);
      61           5 :         rd.in.file.handle = h;
      62           5 :         rd.in.length      = 5;
      63           5 :         rd.in.offset      = 0;
      64           5 :         status = smb2_read(tree, tree, &rd);
      65           5 :         CHECK_STATUS(status, NT_STATUS_END_OF_FILE);
      66             : 
      67           5 :         status = smb2_util_write(tree, h, buf, 0, ARRAY_SIZE(buf));
      68           5 :         CHECK_STATUS(status, NT_STATUS_OK);
      69             : 
      70           5 :         ZERO_STRUCT(rd);
      71           5 :         rd.in.file.handle = h;
      72           5 :         rd.in.length = 10;
      73           5 :         rd.in.offset = 0;
      74           5 :         rd.in.min_count = 1;
      75             : 
      76           5 :         status = smb2_read(tree, tmp_ctx, &rd);
      77           5 :         CHECK_STATUS(status, NT_STATUS_OK);
      78           5 :         CHECK_VALUE(rd.out.data.length, 10);
      79             : 
      80           5 :         rd.in.min_count = 0;
      81           5 :         rd.in.length = 10;
      82           5 :         rd.in.offset = sizeof(buf);
      83           5 :         status = smb2_read(tree, tmp_ctx, &rd);
      84           5 :         CHECK_STATUS(status, NT_STATUS_END_OF_FILE);
      85             : 
      86           5 :         rd.in.min_count = 0;
      87           5 :         rd.in.length = 0;
      88           5 :         rd.in.offset = sizeof(buf);
      89           5 :         status = smb2_read(tree, tmp_ctx, &rd);
      90           5 :         CHECK_STATUS(status, NT_STATUS_OK);
      91           5 :         CHECK_VALUE(rd.out.data.length, 0);
      92             : 
      93           5 :         rd.in.min_count = 1;
      94           5 :         rd.in.length = 0;
      95           5 :         rd.in.offset = sizeof(buf);
      96           5 :         status = smb2_read(tree, tmp_ctx, &rd);
      97           5 :         CHECK_STATUS(status, NT_STATUS_END_OF_FILE);
      98             : 
      99           5 :         rd.in.min_count = 0;
     100           5 :         rd.in.length = 2;
     101           5 :         rd.in.offset = sizeof(buf) - 1;
     102           5 :         status = smb2_read(tree, tmp_ctx, &rd);
     103           5 :         CHECK_STATUS(status, NT_STATUS_OK);
     104           5 :         CHECK_VALUE(rd.out.data.length, 1);
     105             : 
     106           5 :         rd.in.min_count = 2;
     107           5 :         rd.in.length = 1;
     108           5 :         rd.in.offset = sizeof(buf) - 1;
     109           5 :         status = smb2_read(tree, tmp_ctx, &rd);
     110           5 :         CHECK_STATUS(status, NT_STATUS_END_OF_FILE);
     111             : 
     112           5 :         rd.in.min_count = 0x10000;
     113           5 :         rd.in.length = 1;
     114           5 :         rd.in.offset = 0;
     115           5 :         status = smb2_read(tree, tmp_ctx, &rd);
     116           5 :         CHECK_STATUS(status, NT_STATUS_END_OF_FILE);
     117             : 
     118           5 :         rd.in.min_count = 0x10000 - 2;
     119           5 :         rd.in.length = 1;
     120           5 :         rd.in.offset = 0;
     121           5 :         status = smb2_read(tree, tmp_ctx, &rd);
     122           5 :         CHECK_STATUS(status, NT_STATUS_END_OF_FILE);
     123             : 
     124           5 :         rd.in.min_count = 10;
     125           5 :         rd.in.length = 5;
     126           5 :         rd.in.offset = 0;
     127           5 :         status = smb2_read(tree, tmp_ctx, &rd);
     128           5 :         CHECK_STATUS(status, NT_STATUS_END_OF_FILE);
     129             : 
     130           5 : done:
     131           5 :         talloc_free(tmp_ctx);
     132           5 :         return ret;
     133             : }
     134             : 
     135             : 
     136           5 : static bool test_read_position(struct torture_context *torture, struct smb2_tree *tree)
     137             : {
     138           5 :         bool ret = true;
     139           0 :         NTSTATUS status;
     140           0 :         struct smb2_handle h;
     141           0 :         uint8_t buf[64*1024];
     142           0 :         struct smb2_read rd;
     143           5 :         TALLOC_CTX *tmp_ctx = talloc_new(tree);
     144           0 :         union smb_fileinfo info;
     145             : 
     146           5 :         ZERO_STRUCT(buf);
     147             : 
     148           5 :         smb2_util_unlink(tree, FNAME);
     149             : 
     150           5 :         status = torture_smb2_testfile(tree, FNAME, &h);
     151           5 :         CHECK_STATUS(status, NT_STATUS_OK);
     152             : 
     153           5 :         status = smb2_util_write(tree, h, buf, 0, ARRAY_SIZE(buf));
     154           5 :         CHECK_STATUS(status, NT_STATUS_OK);
     155             : 
     156           5 :         ZERO_STRUCT(rd);
     157           5 :         rd.in.file.handle = h;
     158           5 :         rd.in.length = 10;
     159           5 :         rd.in.offset = 0;
     160           5 :         rd.in.min_count = 1;
     161             : 
     162           5 :         status = smb2_read(tree, tmp_ctx, &rd);
     163           5 :         CHECK_STATUS(status, NT_STATUS_OK);
     164           5 :         CHECK_VALUE(rd.out.data.length, 10);
     165             : 
     166           5 :         info.generic.level = RAW_FILEINFO_SMB2_ALL_INFORMATION;
     167           5 :         info.generic.in.file.handle = h;
     168             : 
     169           5 :         status = smb2_getinfo_file(tree, tmp_ctx, &info);
     170           5 :         CHECK_STATUS(status, NT_STATUS_OK);
     171           5 :         if (torture_setting_bool(torture, "windows", false)) {
     172           0 :                 CHECK_VALUE(info.all_info2.out.position, 0);
     173             :         } else {
     174           5 :                 CHECK_VALUE(info.all_info2.out.position, 10);
     175             :         }
     176             : 
     177             :         
     178           5 : done:
     179           5 :         talloc_free(tmp_ctx);
     180           5 :         return ret;
     181             : }
     182             : 
     183           5 : static bool test_read_dir(struct torture_context *torture, struct smb2_tree *tree)
     184             : {
     185           5 :         bool ret = true;
     186           0 :         NTSTATUS status;
     187           0 :         struct smb2_handle h;
     188           0 :         struct smb2_read rd;
     189           5 :         TALLOC_CTX *tmp_ctx = talloc_new(tree);
     190             : 
     191           5 :         status = torture_smb2_testdir(tree, DNAME, &h);
     192           5 :         if (!NT_STATUS_IS_OK(status)) {
     193           0 :                 printf(__location__ " Unable to create test directory '%s' - %s\n", DNAME, nt_errstr(status));
     194           0 :                 return false;
     195             :         }
     196             : 
     197           5 :         ZERO_STRUCT(rd);
     198           5 :         rd.in.file.handle = h;
     199           5 :         rd.in.length = 10;
     200           5 :         rd.in.offset = 0;
     201           5 :         rd.in.min_count = 1;
     202             : 
     203           5 :         status = smb2_read(tree, tmp_ctx, &rd);
     204           5 :         CHECK_STATUS(status, NT_STATUS_INVALID_DEVICE_REQUEST);
     205             :         
     206           5 :         rd.in.min_count = 11;
     207           5 :         status = smb2_read(tree, tmp_ctx, &rd);
     208           5 :         CHECK_STATUS(status, NT_STATUS_INVALID_DEVICE_REQUEST);
     209             : 
     210           5 :         rd.in.length = 0;
     211           5 :         rd.in.min_count = 2592;
     212           5 :         status = smb2_read(tree, tmp_ctx, &rd);
     213           5 :         if (torture_setting_bool(torture, "windows", false)) {
     214           0 :                 CHECK_STATUS(status, NT_STATUS_END_OF_FILE);
     215             :         } else {
     216           5 :                 CHECK_STATUS(status, NT_STATUS_INVALID_DEVICE_REQUEST);
     217             :         }
     218             : 
     219           5 :         rd.in.length = 0;
     220           5 :         rd.in.min_count = 0;
     221           5 :         rd.in.channel = 0;
     222           5 :         status = smb2_read(tree, tmp_ctx, &rd);
     223           5 :         if (torture_setting_bool(torture, "windows", false)) {
     224           0 :                 CHECK_STATUS(status, NT_STATUS_OK);
     225             :         } else {
     226           5 :                 CHECK_STATUS(status, NT_STATUS_INVALID_DEVICE_REQUEST);
     227             :         }
     228             :         
     229           5 : done:
     230           5 :         talloc_free(tmp_ctx);
     231           5 :         return ret;
     232             : }
     233             : 
     234           5 : static bool test_read_access(struct torture_context *torture,
     235             :                              struct smb2_tree *tree)
     236             : {
     237           5 :         bool ret = true;
     238           0 :         NTSTATUS status;
     239           0 :         struct smb2_handle h;
     240           0 :         uint8_t buf[64 * 1024];
     241           0 :         struct smb2_read rd;
     242           5 :         TALLOC_CTX *tmp_ctx = talloc_new(tree);
     243             : 
     244           5 :         ZERO_STRUCT(buf);
     245             : 
     246             :         /* create a file */
     247           5 :         smb2_util_unlink(tree, FNAME);
     248             : 
     249           5 :         status = torture_smb2_testfile(tree, FNAME, &h);
     250           5 :         CHECK_STATUS(status, NT_STATUS_OK);
     251             : 
     252           5 :         status = smb2_util_write(tree, h, buf, 0, ARRAY_SIZE(buf));
     253           5 :         CHECK_STATUS(status, NT_STATUS_OK);
     254             : 
     255           5 :         status = smb2_util_close(tree, h);
     256           5 :         CHECK_STATUS(status, NT_STATUS_OK);
     257             : 
     258             :         /* open w/ READ access - success */
     259           5 :         status = torture_smb2_testfile_access(
     260             :             tree, FNAME, &h, SEC_FILE_READ_ATTRIBUTE | SEC_FILE_READ_DATA);
     261           5 :         CHECK_STATUS(status, NT_STATUS_OK);
     262             : 
     263           5 :         ZERO_STRUCT(rd);
     264           5 :         rd.in.file.handle = h;
     265           5 :         rd.in.length = 5;
     266           5 :         rd.in.offset = 0;
     267           5 :         status = smb2_read(tree, tree, &rd);
     268           5 :         CHECK_STATUS(status, NT_STATUS_OK);
     269             : 
     270           5 :         status = smb2_util_close(tree, h);
     271           5 :         CHECK_STATUS(status, NT_STATUS_OK);
     272             : 
     273             :         /* open w/ EXECUTE access - success */
     274           5 :         status = torture_smb2_testfile_access(
     275             :             tree, FNAME, &h, SEC_FILE_READ_ATTRIBUTE | SEC_FILE_EXECUTE);
     276           5 :         CHECK_STATUS(status, NT_STATUS_OK);
     277             : 
     278           5 :         ZERO_STRUCT(rd);
     279           5 :         rd.in.file.handle = h;
     280           5 :         rd.in.length = 5;
     281           5 :         rd.in.offset = 0;
     282           5 :         status = smb2_read(tree, tree, &rd);
     283           5 :         CHECK_STATUS(status, NT_STATUS_OK);
     284             : 
     285           4 :         status = smb2_util_close(tree, h);
     286           4 :         CHECK_STATUS(status, NT_STATUS_OK);
     287             : 
     288             :         /* open without READ or EXECUTE access - access denied */
     289           4 :         status = torture_smb2_testfile_access(tree, FNAME, &h,
     290             :                                               SEC_FILE_READ_ATTRIBUTE);
     291           4 :         CHECK_STATUS(status, NT_STATUS_OK);
     292             : 
     293           4 :         ZERO_STRUCT(rd);
     294           4 :         rd.in.file.handle = h;
     295           4 :         rd.in.length = 5;
     296           4 :         rd.in.offset = 0;
     297           4 :         status = smb2_read(tree, tree, &rd);
     298           4 :         CHECK_STATUS(status, NT_STATUS_ACCESS_DENIED);
     299             : 
     300           4 :         status = smb2_util_close(tree, h);
     301           4 :         CHECK_STATUS(status, NT_STATUS_OK);
     302             : 
     303           5 : done:
     304           5 :         talloc_free(tmp_ctx);
     305           5 :         return ret;
     306             : }
     307             : 
     308             : /*
     309             :    basic regression test for BUG 14607
     310             :    https://bugzilla.samba.org/show_bug.cgi?id=14607
     311             : */
     312           5 : static bool test_read_bug14607(struct torture_context *torture,
     313             :                                 struct smb2_tree *tree)
     314             : {
     315           5 :         bool ret = true;
     316           0 :         NTSTATUS status;
     317           0 :         struct smb2_handle h;
     318           0 :         uint8_t buf[64 * 1024];
     319           0 :         struct smb2_read rd;
     320           0 :         uint32_t timeout_msec;
     321           5 :         DATA_BLOB out_input_buffer = data_blob_null;
     322           5 :         DATA_BLOB out_output_buffer = data_blob_null;
     323           5 :         TALLOC_CTX *tmp_ctx = talloc_new(tree);
     324           5 :         uint8_t *data = NULL;
     325           5 :         uint32_t data_length = 0;
     326             : 
     327           5 :         memset(buf, 0x1f, ARRAY_SIZE(buf));
     328             : 
     329             :         /* create a file */
     330           5 :         smb2_util_unlink(tree, FNAME);
     331             : 
     332           5 :         status = torture_smb2_testfile(tree, FNAME, &h);
     333           5 :         CHECK_STATUS(status, NT_STATUS_OK);
     334             : 
     335           5 :         status = smb2_util_write(tree, h, buf, 0, ARRAY_SIZE(buf));
     336           5 :         CHECK_STATUS(status, NT_STATUS_OK);
     337             : 
     338           5 :         ZERO_STRUCT(rd);
     339           5 :         rd.in.file.handle = h;
     340           5 :         rd.in.length = ARRAY_SIZE(buf);
     341           5 :         rd.in.offset = 0;
     342           5 :         status = smb2_read(tree, tree, &rd);
     343           5 :         CHECK_STATUS(status, NT_STATUS_OK);
     344           5 :         CHECK_VALUE(rd.out.data.length, ARRAY_SIZE(buf));
     345           5 :         torture_assert_mem_equal_goto(torture, rd.out.data.data,
     346             :                                       buf, ARRAY_SIZE(buf),
     347             :                                       ret, done,
     348             :                                       "Invalid content smb2_read");
     349             : 
     350           5 :         timeout_msec = tree->session->transport->options.request_timeout * 1000;
     351             : 
     352           5 :         status = smb2cli_read(tree->session->transport->conn,
     353             :                               timeout_msec,
     354           5 :                               tree->session->smbXcli,
     355             :                               tree->smbXcli,
     356             :                               rd.in.length,
     357             :                               rd.in.offset,
     358             :                               h.data[0],
     359             :                               h.data[1],
     360           5 :                               rd.in.min_count,
     361           5 :                               rd.in.remaining,
     362             :                               tmp_ctx,
     363             :                               &data, &data_length);
     364           5 :         CHECK_STATUS(status, NT_STATUS_OK);
     365           5 :         CHECK_VALUE(data_length, ARRAY_SIZE(buf));
     366           5 :         torture_assert_mem_equal_goto(torture, data,
     367             :                                       buf, ARRAY_SIZE(buf),
     368             :                                       ret, done,
     369             :                                       "Invalid content smb2cli_read");
     370             : 
     371           5 :         status = smb2cli_ioctl(tree->session->transport->conn,
     372             :                                timeout_msec,
     373           5 :                                tree->session->smbXcli,
     374             :                                tree->smbXcli,
     375             :                                UINT64_MAX, /* in_fid_persistent */
     376             :                                UINT64_MAX, /* in_fid_volatile */
     377             :                                FSCTL_SMBTORTURE_GLOBAL_READ_RESPONSE_BODY_PADDING8,
     378             :                                0, /* in_max_input_length */
     379             :                                NULL, /* in_input_buffer */
     380             :                                1, /* in_max_output_length */
     381             :                                NULL, /* in_output_buffer */
     382             :                                SMB2_IOCTL_FLAG_IS_FSCTL,
     383             :                                tmp_ctx,
     384             :                                &out_input_buffer,
     385             :                                &out_output_buffer);
     386           5 :         if (NT_STATUS_EQUAL(status, NT_STATUS_NOT_SUPPORTED) ||
     387           5 :             NT_STATUS_EQUAL(status, NT_STATUS_FILE_CLOSED) ||
     388           5 :             NT_STATUS_EQUAL(status, NT_STATUS_FS_DRIVER_REQUIRED) ||
     389           5 :             NT_STATUS_EQUAL(status, NT_STATUS_INVALID_DEVICE_REQUEST))
     390             :         {
     391           1 :                 torture_comment(torture,
     392             :                                 "FSCTL_SMBTORTURE_GLOBAL_READ_RESPONSE_BODY_PADDING8: %s\n",
     393             :                                 nt_errstr(status));
     394           1 :                 torture_skip(torture, "server doesn't support FSCTL_SMBTORTURE_GLOBAL_READ_RESPONSE_BODY_PADDING8\n");
     395             :         }
     396           4 :         torture_assert_ntstatus_ok(torture, status, "FSCTL_SMBTORTURE_GLOBAL_READ_RESPONSE_BODY_PADDING8");
     397             : 
     398           4 :         torture_assert_int_equal(torture, out_output_buffer.length, 0,
     399             :                                  "output length");
     400             : 
     401           4 :         ZERO_STRUCT(rd);
     402           4 :         rd.in.file.handle = h;
     403           4 :         rd.in.length = ARRAY_SIZE(buf);
     404           4 :         rd.in.offset = 0;
     405           4 :         status = smb2_read(tree, tree, &rd);
     406           4 :         CHECK_STATUS(status, NT_STATUS_OK);
     407           4 :         CHECK_VALUE(rd.out.data.length, ARRAY_SIZE(buf));
     408           4 :         torture_assert_mem_equal_goto(torture, rd.out.data.data,
     409             :                                       buf, ARRAY_SIZE(buf),
     410             :                                       ret, done,
     411             :                                       "Invalid content after padding smb2_read");
     412             : 
     413           4 :         status = smb2cli_read(tree->session->transport->conn,
     414             :                               timeout_msec,
     415           4 :                               tree->session->smbXcli,
     416             :                               tree->smbXcli,
     417             :                               rd.in.length,
     418             :                               rd.in.offset,
     419             :                               h.data[0],
     420             :                               h.data[1],
     421           4 :                               rd.in.min_count,
     422           4 :                               rd.in.remaining,
     423             :                               tmp_ctx,
     424             :                               &data, &data_length);
     425           4 :         CHECK_STATUS(status, NT_STATUS_OK);
     426           4 :         CHECK_VALUE(data_length, ARRAY_SIZE(buf));
     427           4 :         torture_assert_mem_equal_goto(torture, data,
     428             :                                       buf, ARRAY_SIZE(buf),
     429             :                                       ret, done,
     430             :                                       "Invalid content after padding smb2cli_read");
     431             : 
     432           4 :         status = smb2_util_close(tree, h);
     433           4 :         CHECK_STATUS(status, NT_STATUS_OK);
     434             : 
     435           4 : done:
     436           4 :         talloc_free(tmp_ctx);
     437           4 :         return ret;
     438             : }
     439             : 
     440             : /* 
     441             :    basic testing of SMB2 read
     442             : */
     443        2379 : struct torture_suite *torture_smb2_read_init(TALLOC_CTX *ctx)
     444             : {
     445        2379 :         struct torture_suite *suite = torture_suite_create(ctx, "read");
     446             : 
     447        2379 :         torture_suite_add_1smb2_test(suite, "eof", test_read_eof);
     448        2379 :         torture_suite_add_1smb2_test(suite, "position", test_read_position);
     449        2379 :         torture_suite_add_1smb2_test(suite, "dir", test_read_dir);
     450        2379 :         torture_suite_add_1smb2_test(suite, "access", test_read_access);
     451        2379 :         torture_suite_add_1smb2_test(suite, "bug14607",
     452             :                                      test_read_bug14607);
     453             : 
     454        2379 :         suite->description = talloc_strdup(suite, "SMB2-READ tests");
     455             : 
     456        2379 :         return suite;
     457             : }
     458             : 
     459           2 : static bool test_aio_cancel(struct torture_context *tctx,
     460             :                             struct smb2_tree *tree)
     461             : {
     462           0 :         struct smb2_handle h;
     463           0 :         uint8_t buf[64 * 1024];
     464           0 :         struct smb2_read r;
     465           2 :         struct smb2_request *req = NULL;
     466           0 :         int rc;
     467           0 :         NTSTATUS status;
     468           2 :         bool ret = true;
     469             : 
     470           2 :         ZERO_STRUCT(buf);
     471             : 
     472           2 :         smb2_util_unlink(tree, FNAME);
     473             : 
     474           2 :         status = torture_smb2_testfile(tree, FNAME, &h);
     475           2 :         torture_assert_ntstatus_ok_goto(
     476             :                 tctx,
     477             :                 status,
     478             :                 ret,
     479             :                 done,
     480             :                 "torture_smb2_testfile failed\n");
     481             : 
     482           2 :         status = smb2_util_write(tree, h, buf, 0, ARRAY_SIZE(buf));
     483           2 :         torture_assert_ntstatus_ok_goto(
     484             :                 tctx,
     485             :                 status,
     486             :                 ret,
     487             :                 done,
     488             :                 "smb2_util_write failed\n");
     489             : 
     490           2 :         status = smb2_util_close(tree, h);
     491           2 :         torture_assert_ntstatus_ok_goto(
     492             :                 tctx,
     493             :                 status,
     494             :                 ret,
     495             :                 done,
     496             :                 "smb2_util_close failed\n");
     497             : 
     498           2 :         status = torture_smb2_testfile_access(
     499             :                 tree, FNAME, &h, SEC_RIGHTS_FILE_ALL);
     500           2 :         torture_assert_ntstatus_ok_goto(
     501             :                 tctx,
     502             :                 status,
     503             :                 ret,
     504             :                 done,
     505             :                 "torture_smb2_testfile_access failed\n");
     506             : 
     507           2 :         r = (struct smb2_read) {
     508             :                 .in.file.handle = h,
     509             :                 .in.length      = 1,
     510             :                 .in.offset      = 0,
     511             :                 .in.min_count   = 1,
     512             :         };
     513             : 
     514           2 :         req = smb2_read_send(tree, &r);
     515           2 :         torture_assert_goto(
     516             :                 tctx,
     517             :                 req != NULL,
     518             :                 ret,
     519             :                 done,
     520             :                 "smb2_read_send failed\n");
     521             : 
     522          10 :         while (!req->cancel.can_cancel) {
     523           8 :                 rc = tevent_loop_once(tctx->ev);
     524           8 :                 torture_assert_goto(
     525             :                         tctx,
     526             :                         rc == 0,
     527             :                         ret,
     528             :                         done,
     529             :                         "tevent_loop_once failed\n");
     530             :         }
     531             : 
     532           2 :         status = smb2_cancel(req);
     533           2 :         torture_assert_ntstatus_ok_goto(
     534             :                 tctx,
     535             :                 status,
     536             :                 ret,
     537             :                 done,
     538             :                 "smb2_cancel failed\n");
     539             : 
     540           2 :         status = smb2_read_recv(req, tree, &r);
     541           2 :         torture_assert_ntstatus_ok_goto(
     542             :                 tctx,
     543             :                 status,
     544             :                 ret,
     545             :                 done,
     546             :                 "smb2_read_recv failed\n");
     547             : 
     548           2 :         status = smb2_util_close(tree, h);
     549           2 :         torture_assert_ntstatus_ok_goto(
     550             :                 tctx,
     551             :                 status,
     552             :                 ret,
     553             :                 done,
     554             :                 "smb2_util_close failed\n");
     555             : 
     556           2 : done:
     557           2 :         smb2_util_unlink(tree, FNAME);
     558           2 :         return ret;
     559             : }
     560             : 
     561             : /*
     562             :  * aio testing against share with VFS module "delay_inject"
     563             :  */
     564        2379 : struct torture_suite *torture_smb2_aio_delay_init(TALLOC_CTX *ctx)
     565             : {
     566        2379 :         struct torture_suite *suite = torture_suite_create(ctx, "aio_delay");
     567             : 
     568        2379 :         torture_suite_add_1smb2_test(suite, "aio_cancel", test_aio_cancel);
     569             : 
     570        2379 :         suite->description = talloc_strdup(suite, "SMB2 delayed aio tests");
     571             : 
     572        2379 :         return suite;
     573             : }

Generated by: LCOV version 1.14