From 287515fd3db1932f06d56da3bb388a7efc1120eb Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 12 Jan 2005 11:43:18 +0000 Subject: r4710: added a smb_composite_savefile() function, and expanded the test suite a little (This used to be commit ef4dbc443dbdebc4160209ed3f23cbb97109c414) --- source4/torture/raw/composite.c | 47 +++++++++++++++++++++++++++++++++++------ 1 file changed, 40 insertions(+), 7 deletions(-) (limited to 'source4/torture') 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; } -- cgit