ab32dbb1d74cba464770313cc2e0fac9391627c7
[amitay/samba.git] / source4 / torture / rap / printing.c
1 /*
2    Unix SMB/CIFS implementation.
3    test suite for SMB printing operations
4
5    Copyright (C) Guenther Deschner 2010
6
7    This program is free software; you can redistribute it and/or modify
8    it under the terms of the GNU General Public License as published by
9    the Free Software Foundation; either version 3 of the License, or
10    (at your option) any later version.
11
12    This program is distributed in the hope that it will be useful,
13    but WITHOUT ANY WARRANTY; without even the implied warranty of
14    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15    GNU General Public License for more details.
16
17    You should have received a copy of the GNU General Public License
18    along with this program.  If not, see <http://www.gnu.org/licenses/>.
19 */
20
21 #include "includes.h"
22 #include "libcli/raw/libcliraw.h"
23 #include "libcli/libcli.h"
24 #include "torture/torture.h"
25 #include "torture/util.h"
26 #include "system/filesys.h"
27
28 #include "torture/smbtorture.h"
29 #include "torture/util.h"
30 #include "../librpc/gen_ndr/rap.h"
31 #include "torture/rap/proto.h"
32 #include "param/param.h"
33
34
35 #define TORTURE_PRINT_FILE "torture_print_file"
36
37 static bool test_raw_print(struct torture_context *tctx,
38                            struct smbcli_state *cli)
39 {
40         int fnum;
41         DATA_BLOB data;
42         ssize_t size_written;
43         const char *str;
44
45         fnum = smbcli_open(cli->tree, TORTURE_PRINT_FILE, O_RDWR|O_CREAT|O_TRUNC, DENY_NONE);
46         if (fnum == -1) {
47                 torture_fail(tctx, "failed to open file");
48         }
49
50         str = talloc_asprintf(tctx, "TortureTestPage: %d\nData\n",0);
51
52         data = data_blob_string_const(str);
53
54         size_written = smbcli_write(cli->tree, fnum, 0, data.data, 0, data.length);
55         if (size_written != data.length) {
56                 torture_fail(tctx, "failed to write file");
57         }
58
59         torture_assert_ntstatus_ok(tctx,
60                 smbcli_close(cli->tree, fnum),
61                 "failed to close file");
62
63         return true;
64 }
65
66 static bool test_rap_print(struct torture_context *tctx,
67                            struct smbcli_state *cli)
68 {
69         /*
70         pause printer
71         print printfile
72         enumjobs printer
73         delete job
74         start printer
75         */
76
77         return true;
78 }
79
80 struct torture_suite *torture_rap_printing(TALLOC_CTX *mem_ctx)
81 {
82         struct torture_suite *suite = torture_suite_create(mem_ctx, "PRINTING");
83
84         torture_suite_add_1smb_test(suite, "raw_print", test_raw_print);
85         torture_suite_add_1smb_test(suite, "rap_print", test_rap_print);
86
87         return suite;
88 }