2
2
Unix SMB/CIFS implementation.
3
3
test suite for various write operations
5
5
Copyright (C) Andrew Tridgell 2003
7
7
This program is free software; you can redistribute it and/or modify
8
8
it under the terms of the GNU General Public License as published by
9
9
the Free Software Foundation; either version 3 of the License, or
10
10
(at your option) any later version.
12
12
This program is distributed in the hope that it will be useful,
13
13
but WITHOUT ANY WARRANTY; without even the implied warranty of
14
14
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
15
GNU General Public License for more details.
17
17
You should have received a copy of the GNU General Public License
18
18
along with this program. If not, see <http://www.gnu.org/licenses/>.
21
21
#include "includes.h"
22
#include "torture/torture.h"
23
22
#include "libcli/raw/libcliraw.h"
24
#include "libcli/raw/raw_proto.h"
25
23
#include "system/time.h"
26
24
#include "system/filesys.h"
27
25
#include "libcli/libcli.h"
30
28
#define CHECK_STATUS(status, correct) do { \
31
29
if (!NT_STATUS_EQUAL(status, correct)) { \
32
printf("(%s) Incorrect status %s - should be %s\n", \
33
__location__, nt_errstr(status), nt_errstr(correct)); \
30
torture_fail(tctx, talloc_asprintf(tctx, "(%s) Incorrect status %s - should be %s\n", \
31
__location__, nt_errstr(status), nt_errstr(correct))); \
38
36
#define CHECK_VALUE(v, correct) do { \
39
37
if ((v) != (correct)) { \
40
printf("(%s) Incorrect value %s=%d - should be %d\n", \
41
__location__, #v, v, correct); \
38
torture_fail(tctx, talloc_asprintf(tctx, "(%s) Incorrect value %s=%d - should be %d\n", \
39
__location__, #v, v, correct)); \
46
44
#define CHECK_BUFFER(buf, seed, len) do { \
47
if (!check_buffer(buf, seed, len, __location__)) { \
45
if (!check_buffer(tctx, buf, seed, len, __location__)) { \
55
53
status = smb_raw_pathinfo(cli->tree, tctx, &finfo); \
56
54
CHECK_STATUS(status, NT_STATUS_OK); \
57
55
if ((v) != finfo.all_info.out.field) { \
58
printf("(%s) wrong value for field %s %.0f - %.0f\n", \
56
torture_comment(tctx, "(%s) wrong value for field %s %.0f - %.0f\n", \
59
57
__location__, #field, (double)v, (double)finfo.all_info.out.field); \
60
58
dump_all_info(tctx, &finfo); \
69
67
setup a random buffer based on a seed
71
static void setup_buffer(uint8_t *buf, uint_t seed, int len)
69
static void setup_buffer(uint8_t *buf, unsigned int seed, int len)
79
77
check a random buffer based on a seed
81
static bool check_buffer(uint8_t *buf, uint_t seed, int len, const char *location)
79
static bool check_buffer(struct torture_context *tctx,
80
uint8_t *buf, unsigned int seed, int len, const char *location)
85
84
for (i=0;i<len;i++) {
86
85
uint8_t v = random();
88
printf("Buffer incorrect at %s! ofs=%d buf=0x%x correct=0x%x\n",
89
location, i, buf[i], v);
87
torture_fail(tctx, talloc_asprintf(tctx, "Buffer incorrect at %s! ofs=%d buf=0x%x correct=0x%x\n",
88
location, i, buf[i], v));
99
static bool test_write(struct torture_context *tctx,
100
struct smbcli_state *cli)
98
static bool test_write(struct torture_context *tctx,
99
struct smbcli_state *cli)
102
101
union smb_write io;
107
106
const int maxsize = 90000;
108
107
const char *fname = BASEDIR "\\test.txt";
109
uint_t seed = time(NULL);
108
unsigned int seed = time(NULL);
110
109
union smb_fileinfo finfo;
112
111
buf = talloc_zero_array(tctx, uint8_t, maxsize);
114
113
if (!torture_setup_dir(cli, BASEDIR)) {
114
torture_fail(tctx, "failed to setup basedir");
118
printf("Testing RAW_WRITE_WRITE\n");
117
torture_comment(tctx, "Testing RAW_WRITE_WRITE\n");
119
118
io.generic.level = RAW_WRITE_WRITE;
121
120
fnum = smbcli_open(cli->tree, fname, O_RDWR|O_CREAT, DENY_NONE);
122
121
if (fnum == -1) {
123
printf("Failed to create %s - %s\n", fname, smbcli_errstr(cli->tree));
123
torture_fail_goto(tctx, done,
124
talloc_asprintf(tctx, "Failed to create %s - %s\n", fname, smbcli_errstr(cli->tree)));
128
printf("Trying zero write\n");
127
torture_comment(tctx, "Trying zero write\n");
129
128
io.write.in.file.fnum = fnum;
130
129
io.write.in.count = 0;
131
130
io.write.in.offset = 0;
138
137
setup_buffer(buf, seed, maxsize);
140
printf("Trying small write\n");
139
torture_comment(tctx, "Trying small write\n");
141
140
io.write.in.count = 9;
142
141
io.write.in.offset = 4;
143
142
io.write.in.data = buf;
148
147
memset(buf, 0, maxsize);
149
148
if (smbcli_read(cli->tree, fnum, buf, 0, 13) != 13) {
150
printf("read failed at %s\n", __location__);
150
torture_fail_goto(tctx, done, talloc_asprintf(tctx, "read failed at %s\n", __location__));
154
152
CHECK_BUFFER(buf+4, seed, 9);
155
153
CHECK_VALUE(IVAL(buf,0), 0);
157
155
setup_buffer(buf, seed, maxsize);
159
printf("Trying large write\n");
157
torture_comment(tctx, "Trying large write\n");
160
158
io.write.in.count = 4000;
161
159
io.write.in.offset = 0;
162
160
io.write.in.data = buf;
167
165
memset(buf, 0, maxsize);
168
166
if (smbcli_read(cli->tree, fnum, buf, 0, 4000) != 4000) {
169
printf("read failed at %s\n", __location__);
168
torture_fail_goto(tctx, done, talloc_asprintf(tctx, "read failed at %s\n", __location__));
173
170
CHECK_BUFFER(buf, seed, 4000);
175
printf("Trying bad fnum\n");
172
torture_comment(tctx, "Trying bad fnum\n");
176
173
io.write.in.file.fnum = fnum+1;
177
174
io.write.in.count = 4000;
178
175
io.write.in.offset = 0;
180
177
status = smb_raw_write(cli->tree, &io);
181
178
CHECK_STATUS(status, NT_STATUS_INVALID_HANDLE);
183
printf("Setting file as sparse\n");
180
torture_comment(tctx, "Setting file as sparse\n");
184
181
status = torture_set_sparse(cli->tree, fnum);
185
182
CHECK_STATUS(status, NT_STATUS_OK);
187
184
if (!(cli->transport->negotiate.capabilities & CAP_LARGE_FILES)) {
188
printf("skipping large file tests - CAP_LARGE_FILES not set\n");
192
if (!(cli->transport->negotiate.capabilities & CAP_LARGE_FILES)) {
193
printf("skipping large file tests - CAP_LARGE_FILES not set\n");
185
torture_comment(tctx, "skipping large file tests - CAP_LARGE_FILES not set\n");
197
printf("Trying 2^32 offset\n");
189
torture_comment(tctx, "Trying 2^32 offset\n");
198
190
setup_buffer(buf, seed, maxsize);
199
191
io.write.in.file.fnum = fnum;
200
192
io.write.in.count = 4000;
204
196
CHECK_STATUS(status, NT_STATUS_OK);
205
197
CHECK_VALUE(io.write.out.nwritten, 4000);
206
198
CHECK_ALL_INFO(io.write.in.count + (uint64_t)io.write.in.offset, size);
208
200
memset(buf, 0, maxsize);
209
201
if (smbcli_read(cli->tree, fnum, buf, io.write.in.offset, 4000) != 4000) {
210
printf("read failed at %s\n", __location__);
203
torture_fail_goto(tctx, done, talloc_asprintf(tctx, "read failed at %s\n", __location__));
214
205
CHECK_BUFFER(buf, seed, 4000);
227
static bool test_writex(struct torture_context *tctx,
228
struct smbcli_state *cli)
218
static bool test_writex(struct torture_context *tctx,
219
struct smbcli_state *cli)
230
221
union smb_write io;
235
226
const int maxsize = 90000;
236
227
const char *fname = BASEDIR "\\test.txt";
237
uint_t seed = time(NULL);
228
unsigned int seed = time(NULL);
238
229
union smb_fileinfo finfo;
246
237
buf = talloc_zero_array(tctx, uint8_t, maxsize);
239
if (!cli->transport->negotiate.lockread_supported) {
240
torture_comment(tctx, "Server does not support writeunlock - skipping\n");
248
244
if (!torture_setup_dir(cli, BASEDIR)) {
245
torture_fail(tctx, "failed to setup basedir");
252
printf("Testing RAW_WRITE_WRITEX\n");
248
torture_comment(tctx, "Testing RAW_WRITE_WRITEX\n");
253
249
io.generic.level = RAW_WRITE_WRITEX;
255
251
fnum = smbcli_open(cli->tree, fname, O_RDWR|O_CREAT, DENY_NONE);
256
252
if (fnum == -1) {
257
printf("Failed to create %s - %s\n", fname, smbcli_errstr(cli->tree));
254
torture_fail_goto(tctx, done, talloc_asprintf(tctx, "Failed to create %s - %s\n", fname, smbcli_errstr(cli->tree)));
262
printf("Trying zero write\n");
257
torture_comment(tctx, "Trying zero write\n");
263
258
io.writex.in.file.fnum = fnum;
264
259
io.writex.in.offset = 0;
265
260
io.writex.in.wmode = 0;
273
268
setup_buffer(buf, seed, maxsize);
275
printf("Trying small write\n");
270
torture_comment(tctx, "Trying small write\n");
276
271
io.writex.in.count = 9;
277
272
io.writex.in.offset = 4;
278
273
io.writex.in.data = buf;
283
278
memset(buf, 0, maxsize);
284
279
if (smbcli_read(cli->tree, fnum, buf, 0, 13) != 13) {
285
printf("read failed at %s\n", __location__);
281
torture_fail_goto(tctx, done, talloc_asprintf(tctx, "read failed at %s\n", __location__));
289
283
CHECK_BUFFER(buf+4, seed, 9);
290
284
CHECK_VALUE(IVAL(buf,0), 0);
292
286
setup_buffer(buf, seed, maxsize);
294
printf("Trying large write\n");
288
torture_comment(tctx, "Trying large write\n");
295
289
io.writex.in.count = 4000;
296
290
io.writex.in.offset = 0;
297
291
io.writex.in.data = buf;
302
296
memset(buf, 0, maxsize);
303
297
if (smbcli_read(cli->tree, fnum, buf, 0, 4000) != 4000) {
304
printf("read failed at %s\n", __location__);
299
torture_fail_goto(tctx, done, talloc_asprintf(tctx, "read failed at %s\n", __location__));
308
301
CHECK_BUFFER(buf, seed, 4000);
310
printf("Trying bad fnum\n");
303
torture_comment(tctx, "Trying bad fnum\n");
311
304
io.writex.in.file.fnum = fnum+1;
312
305
io.writex.in.count = 4000;
313
306
io.writex.in.offset = 0;
315
308
status = smb_raw_write(cli->tree, &io);
316
309
CHECK_STATUS(status, NT_STATUS_INVALID_HANDLE);
318
printf("Testing wmode\n");
311
torture_comment(tctx, "Testing wmode\n");
319
312
io.writex.in.file.fnum = fnum;
320
313
io.writex.in.count = 1;
321
314
io.writex.in.offset = 0;
331
324
CHECK_VALUE(io.writex.out.nwritten, io.writex.in.count);
334
printf("Trying locked region\n");
327
torture_comment(tctx, "Trying locked region\n");
335
328
cli->session->pid++;
336
329
if (NT_STATUS_IS_ERR(smbcli_lock(cli->tree, fnum, 3, 1, 0, WRITE_LOCK))) {
337
printf("Failed to lock file at %s\n", __location__);
331
torture_fail_goto(tctx, done, talloc_asprintf(tctx, "Failed to lock file at %s\n", __location__));
341
333
cli->session->pid--;
342
334
io.writex.in.wmode = 0;
345
337
status = smb_raw_write(cli->tree, &io);
346
338
CHECK_STATUS(status, NT_STATUS_FILE_LOCK_CONFLICT);
348
printf("Setting file as sparse\n");
340
torture_comment(tctx, "Setting file as sparse\n");
349
341
status = torture_set_sparse(cli->tree, fnum);
350
342
CHECK_STATUS(status, NT_STATUS_OK);
352
344
if (!(cli->transport->negotiate.capabilities & CAP_LARGE_FILES)) {
353
printf("skipping large file tests - CAP_LARGE_FILES not set\n");
345
torture_skip(tctx, "skipping large file tests - CAP_LARGE_FILES not set\n");
357
printf("Trying 2^32 offset\n");
348
torture_comment(tctx, "Trying 2^32 offset\n");
358
349
setup_buffer(buf, seed, maxsize);
359
350
io.writex.in.file.fnum = fnum;
360
351
io.writex.in.count = 4000;
368
359
memset(buf, 0, maxsize);
369
360
if (smbcli_read(cli->tree, fnum, buf, io.writex.in.offset, 4000) != 4000) {
370
printf("read failed at %s\n", __location__);
362
torture_fail_goto(tctx, done, talloc_asprintf(tctx, "read failed at %s\n", __location__));
374
364
CHECK_BUFFER(buf, seed, 4000);
376
366
for (i=33;i<max_bits;i++) {
377
printf("Trying 2^%d offset\n", i);
367
torture_comment(tctx, "Trying 2^%d offset\n", i);
378
368
setup_buffer(buf, seed+1, maxsize);
379
369
io.writex.in.file.fnum = fnum;
380
370
io.writex.in.count = 4000;
392
382
memset(buf, 0, maxsize);
393
383
if (smbcli_read(cli->tree, fnum, buf, io.writex.in.offset, 4000) != 4000) {
394
printf("read failed at %s\n", __location__);
385
torture_fail_goto(tctx, done, talloc_asprintf(tctx, "read failed at %s\n", __location__));
398
387
CHECK_BUFFER(buf, seed+1, 4000);
400
printf("limit is 2^%d\n", i);
389
torture_comment(tctx, "limit is 2^%d\n", i);
402
391
setup_buffer(buf, seed, maxsize);
413
402
test write unlock ops
415
static bool test_writeunlock(struct torture_context *tctx,
416
struct smbcli_state *cli)
404
static bool test_writeunlock(struct torture_context *tctx,
405
struct smbcli_state *cli)
418
407
union smb_write io;
423
412
const int maxsize = 90000;
424
413
const char *fname = BASEDIR "\\test.txt";
425
uint_t seed = time(NULL);
414
unsigned int seed = time(NULL);
426
415
union smb_fileinfo finfo;
428
417
buf = talloc_zero_array(tctx, uint8_t, maxsize);
419
if (!cli->transport->negotiate.lockread_supported) {
420
torture_skip(tctx, "Server does not support writeunlock - skipping\n");
430
423
if (!torture_setup_dir(cli, BASEDIR)) {
424
torture_fail(tctx, "failed to setup basedir");
434
printf("Testing RAW_WRITE_WRITEUNLOCK\n");
427
torture_comment(tctx, "Testing RAW_WRITE_WRITEUNLOCK\n");
435
428
io.generic.level = RAW_WRITE_WRITEUNLOCK;
437
430
fnum = smbcli_open(cli->tree, fname, O_RDWR|O_CREAT, DENY_NONE);
438
431
if (fnum == -1) {
439
printf("Failed to create %s - %s\n", fname, smbcli_errstr(cli->tree));
433
torture_fail_goto(tctx, done, talloc_asprintf(tctx, "Failed to create %s - %s\n", fname, smbcli_errstr(cli->tree)));
444
printf("Trying zero write\n");
436
torture_comment(tctx, "Trying zero write\n");
445
437
io.writeunlock.in.file.fnum = fnum;
446
438
io.writeunlock.in.count = 0;
447
439
io.writeunlock.in.offset = 0;
454
446
setup_buffer(buf, seed, maxsize);
456
printf("Trying small write\n");
448
torture_comment(tctx, "Trying small write\n");
457
449
io.writeunlock.in.count = 9;
458
450
io.writeunlock.in.offset = 4;
459
451
io.writeunlock.in.data = buf;
460
452
status = smb_raw_write(cli->tree, &io);
461
453
CHECK_STATUS(status, NT_STATUS_RANGE_NOT_LOCKED);
462
454
if (smbcli_read(cli->tree, fnum, buf, 0, 13) != 13) {
463
printf("read failed at %s\n", __location__);
456
torture_fail_goto(tctx, done, talloc_asprintf(tctx, "read failed at %s\n", __location__));
467
458
CHECK_BUFFER(buf+4, seed, 9);
468
459
CHECK_VALUE(IVAL(buf,0), 0);
470
461
setup_buffer(buf, seed, maxsize);
471
smbcli_lock(cli->tree, fnum, io.writeunlock.in.offset, io.writeunlock.in.count,
462
smbcli_lock(cli->tree, fnum, io.writeunlock.in.offset, io.writeunlock.in.count,
473
464
status = smb_raw_write(cli->tree, &io);
474
465
CHECK_STATUS(status, NT_STATUS_OK);
477
468
memset(buf, 0, maxsize);
478
469
if (smbcli_read(cli->tree, fnum, buf, 0, 13) != 13) {
479
printf("read failed at %s\n", __location__);
471
torture_fail_goto(tctx, done, talloc_asprintf(tctx, "read failed at %s\n", __location__));
483
473
CHECK_BUFFER(buf+4, seed, 9);
484
474
CHECK_VALUE(IVAL(buf,0), 0);
486
476
setup_buffer(buf, seed, maxsize);
488
printf("Trying large write\n");
478
torture_comment(tctx, "Trying large write\n");
489
479
io.writeunlock.in.count = 4000;
490
480
io.writeunlock.in.offset = 0;
491
481
io.writeunlock.in.data = buf;
492
smbcli_lock(cli->tree, fnum, io.writeunlock.in.offset, io.writeunlock.in.count,
482
smbcli_lock(cli->tree, fnum, io.writeunlock.in.offset, io.writeunlock.in.count,
494
484
status = smb_raw_write(cli->tree, &io);
495
485
CHECK_STATUS(status, NT_STATUS_OK);
501
491
memset(buf, 0, maxsize);
502
492
if (smbcli_read(cli->tree, fnum, buf, 0, 4000) != 4000) {
503
printf("read failed at %s\n", __location__);
494
torture_fail_goto(tctx, done, talloc_asprintf(tctx, "read failed at %s\n", __location__));
507
496
CHECK_BUFFER(buf, seed, 4000);
509
printf("Trying bad fnum\n");
498
torture_comment(tctx, "Trying bad fnum\n");
510
499
io.writeunlock.in.file.fnum = fnum+1;
511
500
io.writeunlock.in.count = 4000;
512
501
io.writeunlock.in.offset = 0;
514
503
status = smb_raw_write(cli->tree, &io);
515
504
CHECK_STATUS(status, NT_STATUS_INVALID_HANDLE);
517
printf("Setting file as sparse\n");
506
torture_comment(tctx, "Setting file as sparse\n");
518
507
status = torture_set_sparse(cli->tree, fnum);
519
508
CHECK_STATUS(status, NT_STATUS_OK);
521
510
if (!(cli->transport->negotiate.capabilities & CAP_LARGE_FILES)) {
522
printf("skipping large file tests - CAP_LARGE_FILES not set\n");
511
torture_skip(tctx, "skipping large file tests - CAP_LARGE_FILES not set\n");
526
printf("Trying 2^32 offset\n");
514
torture_comment(tctx, "Trying 2^32 offset\n");
527
515
setup_buffer(buf, seed, maxsize);
528
516
io.writeunlock.in.file.fnum = fnum;
529
517
io.writeunlock.in.count = 4000;
530
518
io.writeunlock.in.offset = 0xFFFFFFFF - 2000;
531
519
io.writeunlock.in.data = buf;
532
smbcli_lock(cli->tree, fnum, io.writeunlock.in.offset, io.writeunlock.in.count,
520
smbcli_lock(cli->tree, fnum, io.writeunlock.in.offset, io.writeunlock.in.count,
534
522
status = smb_raw_write(cli->tree, &io);
535
523
CHECK_STATUS(status, NT_STATUS_OK);
539
527
memset(buf, 0, maxsize);
540
528
if (smbcli_read(cli->tree, fnum, buf, io.writeunlock.in.offset, 4000) != 4000) {
541
printf("read failed at %s\n", __location__);
530
torture_fail_goto(tctx, done, talloc_asprintf(tctx, "read failed at %s\n", __location__));
545
532
CHECK_BUFFER(buf, seed, 4000);
556
543
test write close ops
558
static bool test_writeclose(struct torture_context *tctx,
559
struct smbcli_state *cli)
545
static bool test_writeclose(struct torture_context *tctx,
546
struct smbcli_state *cli)
561
548
union smb_write io;
566
553
const int maxsize = 90000;
567
554
const char *fname = BASEDIR "\\test.txt";
568
uint_t seed = time(NULL);
555
unsigned int seed = time(NULL);
569
556
union smb_fileinfo finfo;
571
558
buf = talloc_zero_array(tctx, uint8_t, maxsize);
560
if (!torture_setting_bool(tctx, "writeclose_support", true)) {
561
torture_skip(tctx, "Server does not support writeclose - skipping\n");
573
564
if (!torture_setup_dir(cli, BASEDIR)) {
565
torture_fail(tctx, "failed to setup basedir");
577
printf("Testing RAW_WRITE_WRITECLOSE\n");
568
torture_comment(tctx, "Testing RAW_WRITE_WRITECLOSE\n");
578
569
io.generic.level = RAW_WRITE_WRITECLOSE;
580
571
fnum = smbcli_open(cli->tree, fname, O_RDWR|O_CREAT, DENY_NONE);
581
572
if (fnum == -1) {
582
printf("Failed to create %s - %s\n", fname, smbcli_errstr(cli->tree));
574
torture_fail_goto(tctx, done, talloc_asprintf(tctx, "Failed to create %s - %s\n", fname, smbcli_errstr(cli->tree)));
587
printf("Trying zero write\n");
577
torture_comment(tctx, "Trying zero write\n");
588
578
io.writeclose.in.file.fnum = fnum;
589
579
io.writeclose.in.count = 0;
590
580
io.writeclose.in.offset = 0;
601
591
setup_buffer(buf, seed, maxsize);
603
printf("Trying small write\n");
593
torture_comment(tctx, "Trying small write\n");
604
594
io.writeclose.in.count = 9;
605
595
io.writeclose.in.offset = 4;
606
596
io.writeclose.in.data = buf;
614
604
io.writeclose.in.file.fnum = fnum;
616
606
if (smbcli_read(cli->tree, fnum, buf, 0, 13) != 13) {
617
printf("read failed at %s\n", __location__);
608
torture_fail_goto(tctx, done, talloc_asprintf(tctx, "read failed at %s\n", __location__));
621
610
CHECK_BUFFER(buf+4, seed, 9);
622
611
CHECK_VALUE(IVAL(buf,0), 0);
632
621
memset(buf, 0, maxsize);
633
622
if (smbcli_read(cli->tree, fnum, buf, 0, 13) != 13) {
634
printf("read failed at %s\n", __location__);
624
torture_fail_goto(tctx, done, talloc_asprintf(tctx, "read failed at %s\n", __location__));
638
626
CHECK_BUFFER(buf+4, seed, 9);
639
627
CHECK_VALUE(IVAL(buf,0), 0);
641
629
setup_buffer(buf, seed, maxsize);
643
printf("Trying large write\n");
631
torture_comment(tctx, "Trying large write\n");
644
632
io.writeclose.in.count = 4000;
645
633
io.writeclose.in.offset = 0;
646
634
io.writeclose.in.data = buf;
657
645
memset(buf, 0, maxsize);
658
646
if (smbcli_read(cli->tree, fnum, buf, 0, 4000) != 4000) {
659
printf("read failed at %s\n", __location__);
648
torture_fail_goto(tctx, done, talloc_asprintf(tctx, "read failed at %s\n", __location__));
663
650
CHECK_BUFFER(buf, seed, 4000);
665
printf("Trying bad fnum\n");
652
torture_comment(tctx, "Trying bad fnum\n");
666
653
io.writeclose.in.file.fnum = fnum+1;
667
654
io.writeclose.in.count = 4000;
668
655
io.writeclose.in.offset = 0;
670
657
status = smb_raw_write(cli->tree, &io);
671
658
CHECK_STATUS(status, NT_STATUS_INVALID_HANDLE);
673
printf("Setting file as sparse\n");
660
torture_comment(tctx, "Setting file as sparse\n");
674
661
status = torture_set_sparse(cli->tree, fnum);
675
662
CHECK_STATUS(status, NT_STATUS_OK);
677
664
if (!(cli->transport->negotiate.capabilities & CAP_LARGE_FILES)) {
678
printf("skipping large file tests - CAP_LARGE_FILES not set\n");
665
torture_skip(tctx, "skipping large file tests - CAP_LARGE_FILES not set\n");
682
printf("Trying 2^32 offset\n");
668
torture_comment(tctx, "Trying 2^32 offset\n");
683
669
setup_buffer(buf, seed, maxsize);
684
670
io.writeclose.in.file.fnum = fnum;
685
671
io.writeclose.in.count = 4000;
696
682
memset(buf, 0, maxsize);
697
683
if (smbcli_read(cli->tree, fnum, buf, io.writeclose.in.offset, 4000) != 4000) {
698
printf("read failed at %s\n", __location__);
685
torture_fail_goto(tctx, done, talloc_asprintf(tctx, "read failed at %s\n", __location__));
702
687
CHECK_BUFFER(buf, seed, 4000);
712
697
basic testing of write calls
714
699
struct torture_suite *torture_raw_write(TALLOC_CTX *mem_ctx)
716
struct torture_suite *suite = torture_suite_create(mem_ctx, "WRITE");
701
struct torture_suite *suite = torture_suite_create(mem_ctx, "write");
718
703
torture_suite_add_1smb_test(suite, "write", test_write);
719
704
torture_suite_add_1smb_test(suite, "write unlock", test_writeunlock);