summaryrefslogtreecommitdiff
path: root/source4/torture
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2005-01-12 11:43:18 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:08:46 -0500
commit287515fd3db1932f06d56da3bb388a7efc1120eb (patch)
treeaa22ff31a537d30af6bc1086b014207993275883 /source4/torture
parent09c34de35a472acfe92ef489409646086a564326 (diff)
downloadsamba-287515fd3db1932f06d56da3bb388a7efc1120eb.tar.gz
samba-287515fd3db1932f06d56da3bb388a7efc1120eb.tar.bz2
samba-287515fd3db1932f06d56da3bb388a7efc1120eb.zip
r4710: added a smb_composite_savefile() function, and expanded the test suite a little
(This used to be commit ef4dbc443dbdebc4160209ed3f23cbb97109c414)
Diffstat (limited to 'source4/torture')
-rw-r--r--source4/torture/raw/composite.c47
1 files changed, 40 insertions, 7 deletions
diff --git a/source4/torture/raw/composite.c b/source4/torture/raw/composite.c
index 97f820c9e5..563705740d 100644
--- a/source4/torture/raw/composite.c
+++ b/source4/torture/raw/composite.c
@@ -26,24 +26,57 @@
#define BASEDIR "\\composite"
+/*
+ test a simple savefile/loadfile combination
+*/
static BOOL test_loadfile(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
{
const char *fname = BASEDIR "\\test.txt";
- int fnum;
NTSTATUS status;
- struct smb_composite_loadfile io;
-
- fnum = create_complex_file(cli, mem_ctx, fname);
- smbcli_close(cli->tree, fnum);
+ struct smb_composite_savefile io1;
+ struct smb_composite_loadfile io2;
+ char *data;
+ size_t len = random() % 100000;
+
+ data = talloc_array(mem_ctx, uint8_t, len);
+
+ generate_random_buffer(data, len);
- io.in.fname = fname;
+ io1.in.fname = fname;
+ io1.in.data = data;
+ io1.in.size = len;
- status = smb_composite_loadfile(cli->tree, mem_ctx, &io);
+ printf("testing savefile\n");
+
+ status = smb_composite_savefile(cli->tree, &io1);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("savefile failed: %s\n", nt_errstr(status));
+ return False;
+ }
+
+ io2.in.fname = fname;
+
+ printf("testing loadfile\n");
+
+ status = smb_composite_loadfile(cli->tree, mem_ctx, &io2);
if (!NT_STATUS_IS_OK(status)) {
printf("Loadfile failed: %s\n", nt_errstr(status));
return False;
}
+ if (io2.out.size != len) {
+ printf("wrong length in returned data - %d should be %d\n",
+ io2.out.size, len);
+ return False;
+ }
+
+ if (memcmp(io2.out.data, data, len) != 0) {
+ printf("wrong data in loadfile!\n");
+ return False;
+ }
+
+ talloc_free(data);
+
return True;
}