2 Unix SMB/CIFS implementation.
4 libcli composite function testing
6 Copyright (C) Andrew Tridgell 2005
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 2 of the License, or
11 (at your option) any later version.
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.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 #include "libcli/raw/libcliraw.h"
25 #include "libcli/composite/composite.h"
27 #define BASEDIR "\\composite"
30 test a simple savefile/loadfile combination
32 static BOOL test_loadfile(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
34 const char *fname = BASEDIR "\\test.txt";
36 struct smb_composite_savefile io1;
37 struct smb_composite_loadfile io2;
39 size_t len = random() % 100000;
41 data = talloc_array(mem_ctx, uint8_t, len);
43 generate_random_buffer(data, len);
49 printf("testing savefile\n");
51 status = smb_composite_savefile(cli->tree, &io1);
52 if (!NT_STATUS_IS_OK(status)) {
53 printf("savefile failed: %s\n", nt_errstr(status));
59 printf("testing loadfile\n");
61 status = smb_composite_loadfile(cli->tree, mem_ctx, &io2);
62 if (!NT_STATUS_IS_OK(status)) {
63 printf("Loadfile failed: %s\n", nt_errstr(status));
67 if (io2.out.size != len) {
68 printf("wrong length in returned data - %d should be %d\n",
73 if (memcmp(io2.out.data, data, len) != 0) {
74 printf("wrong data in loadfile!\n");
84 basic testing of libcli composite calls
86 BOOL torture_raw_composite(void)
88 struct smbcli_state *cli;
92 if (!torture_open_connection(&cli)) {
96 mem_ctx = talloc_init("torture_raw_composite");
98 if (!torture_setup_dir(cli, BASEDIR)) {
102 ret &= test_loadfile(cli, mem_ctx);
104 smb_raw_exit(cli->session);
105 smbcli_deltree(cli->tree, BASEDIR);
107 torture_close_connection(cli);
108 talloc_destroy(mem_ctx);