r4700: first attempt at a composite async function, smb_composite_loadfile(),
[kai/samba.git] / source4 / torture / raw / composite.c
1 /* 
2    Unix SMB/CIFS implementation.
3
4    libcli composite function testing
5
6    Copyright (C) Andrew Tridgell 2005
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 2 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, write to the Free Software
20    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 */
22
23 #include "includes.h"
24 #include "libcli/raw/libcliraw.h"
25 #include "libcli/composite/composite.h"
26
27 #define BASEDIR "\\composite"
28
29 static BOOL test_loadfile(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
30 {
31         const char *fname = BASEDIR "\\test.txt";
32         int fnum;
33         NTSTATUS status;
34         struct smb_composite_loadfile io;
35         
36         fnum = create_complex_file(cli, mem_ctx, fname);
37         smbcli_close(cli->tree, fnum);
38
39         io.in.fname = fname;
40
41         status = smb_composite_loadfile(cli->tree, mem_ctx, &io);
42         if (!NT_STATUS_IS_OK(status)) {
43                 printf("Loadfile failed: %s\n", nt_errstr(status));
44                 return False;
45         }
46
47         return True;
48 }
49
50 /* 
51    basic testing of libcli composite calls
52 */
53 BOOL torture_raw_composite(void)
54 {
55         struct smbcli_state *cli;
56         BOOL ret = True;
57         TALLOC_CTX *mem_ctx;
58
59         if (!torture_open_connection(&cli)) {
60                 return False;
61         }
62
63         mem_ctx = talloc_init("torture_raw_composite");
64
65         if (!torture_setup_dir(cli, BASEDIR)) {
66                 return False;
67         }
68
69         ret &= test_loadfile(cli, mem_ctx);
70
71         smb_raw_exit(cli->session);
72         smbcli_deltree(cli->tree, BASEDIR);
73
74         torture_close_connection(cli);
75         talloc_destroy(mem_ctx);
76         return ret;
77 }