200f89602b688667e8c626328cbd125c4c4ca9ae
[ira/wip.git] / testprogs / win32 / spoolss / spoolss.c
1 /*
2    Unix SMB/CIFS implementation.
3    test suite for spoolss rpc operations
4
5    Copyright (C) Guenther Deschner 2009
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 /****************************************************************************
22 ****************************************************************************/
23
24 #include "spoolss.h"
25 #include "string.h"
26 #include "torture.h"
27
28 /****************************************************************************
29 ****************************************************************************/
30
31 static BOOL test_OpenPrinter(struct torture_context *tctx,
32                              LPSTR printername,
33                              HANDLE handle)
34 {
35         torture_comment(tctx, "Testing OpenPrinter(%s)", printername);
36
37         if (!OpenPrinter(printername, handle, NULL)) {
38                 char tmp[1024];
39                 sprintf(tmp, "failed to open printer %s, error was: 0x%08x\n",
40                         printername, GetLastError());
41                 torture_fail(tctx, tmp);
42         }
43
44         return TRUE;
45 }
46
47 /****************************************************************************
48 ****************************************************************************/
49
50 static BOOL test_ClosePrinter(struct torture_context *tctx,
51                               HANDLE handle)
52 {
53         torture_comment(tctx, "Testing ClosePrinter");
54
55         if (!ClosePrinter(handle)) {
56                 char tmp[1024];
57                 sprintf(tmp, "failed to close printer, error was: %s\n",
58                         errstr(GetLastError()));
59                 torture_fail(tctx, tmp);
60         }
61
62         return TRUE;
63 }
64
65
66 /****************************************************************************
67 ****************************************************************************/
68
69 static BOOL test_EnumPrinters(struct torture_context *tctx,
70                               LPSTR servername)
71 {
72         DWORD levels[]  = { 1, 2, 5 };
73         DWORD success[] = { 1, 1, 1 };
74         DWORD i;
75         DWORD flags = PRINTER_ENUM_NAME;
76         LPBYTE buffer = NULL;
77
78         for (i=0; i < ARRAY_SIZE(levels); i++) {
79
80                 DWORD needed = 0;
81                 DWORD returned = 0;
82                 DWORD err = 0;
83                 char tmp[1024];
84
85                 torture_comment(tctx, "Testing EnumPrinters level %d", levels[i]);
86
87                 EnumPrinters(flags, servername, levels[i], NULL, 0, &needed, &returned);
88                 err = GetLastError();
89                 if (err == ERROR_INSUFFICIENT_BUFFER) {
90                         err = 0;
91                         buffer = malloc(needed);
92                         torture_assert(tctx, buffer, "malloc failed");
93                         if (!EnumPrinters(flags, servername, levels[i], buffer, needed, &needed, &returned)) {
94                                 err = GetLastError();
95                         }
96                 }
97                 if (err) {
98                         sprintf(tmp, "EnumPrinters failed level %d on [%s] (buffer size = %d), error: %s\n",
99                                 levels[i], servername, needed, errstr(err));
100                         if (success[i]) {
101                                 torture_fail(tctx, tmp);
102                         } else {
103                                 torture_warning(tctx, tmp);
104                         }
105                 }
106
107                 free(buffer);
108                 buffer = NULL;
109         }
110
111         return TRUE;
112 }
113
114 /****************************************************************************
115 ****************************************************************************/
116
117 static BOOL test_EnumDrivers(struct torture_context *tctx,
118                              LPSTR servername)
119 {
120         DWORD levels[]  = { 1, 2, 3, 4, 5, 6, 8 };
121         DWORD success[] = { 1, 1, 1, 1, 1, 1, 1 };
122         DWORD i;
123         LPBYTE buffer = NULL;
124
125         for (i=0; i < ARRAY_SIZE(levels); i++) {
126
127                 DWORD needed = 0;
128                 DWORD returned = 0;
129                 DWORD err = 0;
130                 char tmp[1024];
131
132                 torture_comment(tctx, "Testing EnumPrinterDrivers level %d", levels[i]);
133
134                 EnumPrinterDrivers(servername, "Windows NT x86", levels[i], NULL, 0, &needed, &returned);
135                 err = GetLastError();
136                 if (err == ERROR_INSUFFICIENT_BUFFER) {
137                         err = 0;
138                         buffer = malloc(needed);
139                         torture_assert(tctx, buffer, "malloc failed");
140                         if (!EnumPrinterDrivers(servername, "Windows NT x86", levels[i], buffer, needed, &needed, &returned)) {
141                                 err = GetLastError();
142                         }
143                 }
144                 if (err) {
145                         sprintf(tmp, "EnumPrinterDrivers failed level %d on [%s] (buffer size = %d), error: %s\n",
146                                 levels[i], servername, needed, errstr(err));
147                         if (success[i]) {
148                                 torture_fail(tctx, tmp);
149                         } else {
150                                 torture_warning(tctx, tmp);
151                         }
152                 }
153
154                 free(buffer);
155                 buffer = NULL;
156         }
157
158         return TRUE;
159 }
160
161 /****************************************************************************
162 ****************************************************************************/
163
164 static BOOL test_EnumForms(struct torture_context *tctx,
165                            LPSTR servername,
166                            HANDLE handle)
167 {
168         DWORD levels[]  = { 1, 2 };
169         DWORD success[] = { 1, 0 };
170         DWORD i;
171         LPBYTE buffer = NULL;
172
173         for (i=0; i < ARRAY_SIZE(levels); i++) {
174
175                 DWORD needed = 0;
176                 DWORD returned = 0;
177                 DWORD err = 0;
178                 char tmp[1024];
179
180                 torture_comment(tctx, "Testing EnumForms level %d", levels[i]);
181
182                 EnumForms(handle, levels[i], NULL, 0, &needed, &returned);
183                 err = GetLastError();
184                 if (err == ERROR_INSUFFICIENT_BUFFER) {
185                         err = 0;
186                         buffer = malloc(needed);
187                         torture_assert(tctx, buffer, "malloc failed");
188                         if (!EnumForms(handle, levels[i], buffer, needed, &needed, &returned)) {
189                                 err = GetLastError();
190                         }
191                 }
192                 if (err) {
193                         sprintf(tmp, "EnumForms failed level %d on [%s] (buffer size = %d), error: %s\n",
194                                 levels[i], servername, needed, errstr(err));
195                         if (success[i]) {
196                                 torture_fail(tctx, tmp);
197                         } else {
198                                 torture_warning(tctx, tmp);
199                         }
200                 }
201
202                 free(buffer);
203                 buffer = NULL;
204         }
205
206         return TRUE;
207 }
208
209 /****************************************************************************
210 ****************************************************************************/
211
212 static BOOL test_EnumPorts(struct torture_context *tctx,
213                            LPSTR servername)
214 {
215         DWORD levels[]  = { 1, 2 };
216         DWORD success[] = { 1, 1 };
217         DWORD i;
218         LPBYTE buffer = NULL;
219
220         for (i=0; i < ARRAY_SIZE(levels); i++) {
221
222                 DWORD needed = 0;
223                 DWORD returned = 0;
224                 DWORD err = 0;
225                 char tmp[1024];
226
227                 torture_comment(tctx, "Testing EnumPorts level %d", levels[i]);
228
229                 EnumPorts(servername, levels[i], NULL, 0, &needed, &returned);
230                 err = GetLastError();
231                 if (err == ERROR_INSUFFICIENT_BUFFER) {
232                         err = 0;
233                         buffer = malloc(needed);
234                         torture_assert(tctx, buffer, "malloc failed");
235                         if (!EnumPorts(servername, levels[i], buffer, needed, &needed, &returned)) {
236                                 err = GetLastError();
237                         }
238                 }
239                 if (err) {
240                         sprintf(tmp, "EnumPorts failed level %d on [%s] (buffer size = %d), error: %s\n",
241                                 levels[i], servername, needed, errstr(err));
242                         if (success[i]) {
243                                 torture_fail(tctx, tmp);
244                         } else {
245                                 torture_warning(tctx, tmp);
246                         }
247                 }
248
249                 free(buffer);
250                 buffer = NULL;
251         }
252
253         return TRUE;
254 }
255
256 /****************************************************************************
257 ****************************************************************************/
258
259 static BOOL test_EnumMonitors(struct torture_context *tctx,
260                               LPSTR servername)
261 {
262         DWORD levels[]  = { 1, 2 };
263         DWORD success[] = { 1, 1 };
264         DWORD i;
265         LPBYTE buffer = NULL;
266
267         for (i=0; i < ARRAY_SIZE(levels); i++) {
268
269                 DWORD needed = 0;
270                 DWORD returned = 0;
271                 DWORD err = 0;
272                 char tmp[1024];
273
274                 torture_comment(tctx, "Testing EnumMonitors level %d", levels[i]);
275
276                 EnumMonitors(servername, levels[i], NULL, 0, &needed, &returned);
277                 err = GetLastError();
278                 if (err == ERROR_INSUFFICIENT_BUFFER) {
279                         err = 0;
280                         buffer = malloc(needed);
281                         torture_assert(tctx, buffer, "malloc failed");
282                         if (!EnumMonitors(servername, levels[i], buffer, needed, &needed, &returned)) {
283                                 err = GetLastError();
284                         }
285                 }
286                 if (err) {
287                         sprintf(tmp, "EnumMonitors failed level %d on [%s] (buffer size = %d), error: %s\n",
288                                 levels[i], servername, needed, errstr(err));
289                         if (success[i]) {
290                                 torture_fail(tctx, tmp);
291                         } else {
292                                 torture_warning(tctx, tmp);
293                         }
294                 }
295
296                 free(buffer);
297                 buffer = NULL;
298         }
299
300         return TRUE;
301 }
302
303 /****************************************************************************
304 ****************************************************************************/
305
306 static BOOL test_EnumPrintProcessors(struct torture_context *tctx,
307                                      LPSTR servername)
308 {
309         DWORD levels[]  = { 1 };
310         DWORD success[] = { 1 };
311         DWORD i;
312         LPBYTE buffer = NULL;
313
314         for (i=0; i < ARRAY_SIZE(levels); i++) {
315
316                 DWORD needed = 0;
317                 DWORD returned = 0;
318                 DWORD err = 0;
319                 char tmp[1024];
320
321                 torture_comment(tctx, "Testing EnumPrintProcessors level %d", levels[i]);
322
323                 EnumPrintProcessors(servername, "Windows NT x86", levels[i], NULL, 0, &needed, &returned);
324                 err = GetLastError();
325                 if (err == ERROR_INSUFFICIENT_BUFFER) {
326                         err = 0;
327                         buffer = malloc(needed);
328                         torture_assert(tctx, buffer, "malloc failed");
329                         if (!EnumPrintProcessors(servername, "Windows NT x86", levels[i], buffer, needed, &needed, &returned)) {
330                                 err = GetLastError();
331                         }
332                 }
333                 if (err) {
334                         sprintf(tmp, "EnumPrintProcessors failed level %d on [%s] (buffer size = %d), error: %s\n",
335                                 levels[i], servername, needed, errstr(err));
336                         if (success[i]) {
337                                 torture_fail(tctx, tmp);
338                         } else {
339                                 torture_warning(tctx, tmp);
340                         }
341                 }
342
343                 free(buffer);
344                 buffer = NULL;
345         }
346
347         return TRUE;
348 }
349
350 /****************************************************************************
351 ****************************************************************************/
352
353 static BOOL test_EnumPrintProcessorDatatypes(struct torture_context *tctx,
354                                              LPSTR servername)
355 {
356         DWORD levels[]  = { 1 };
357         DWORD success[] = { 1 };
358         DWORD i;
359         LPBYTE buffer = NULL;
360
361         for (i=0; i < ARRAY_SIZE(levels); i++) {
362
363                 DWORD needed = 0;
364                 DWORD returned = 0;
365                 DWORD err = 0;
366                 char tmp[1024];
367
368                 torture_comment(tctx, "Testing EnumPrintProcessorDatatypes level %d", levels[i]);
369
370                 EnumPrintProcessorDatatypes(servername, "Windows NT x86", levels[i], NULL, 0, &needed, &returned);
371                 err = GetLastError();
372                 if (err == ERROR_INSUFFICIENT_BUFFER) {
373                         err = 0;
374                         buffer = malloc(needed);
375                         torture_assert(tctx, buffer, "malloc failed");
376                         if (!EnumPrintProcessorDatatypes(servername, "Windows NT x86", levels[i], buffer, needed, &needed, &returned)) {
377                                 err = GetLastError();
378                         }
379                 }
380                 if (err) {
381                         sprintf(tmp, "EnumPrintProcessorDatatypes failed level %d on [%s] (buffer size = %d), error: %s\n",
382                                 levels[i], servername, needed, errstr(err));
383                         if (success[i]) {
384                                 torture_fail(tctx, tmp);
385                         } else {
386                                 torture_warning(tctx, tmp);
387                         }
388                 }
389
390                 free(buffer);
391                 buffer = NULL;
392         }
393
394         return TRUE;
395 }
396
397 /****************************************************************************
398 ****************************************************************************/
399
400 static BOOL test_GetPrinter(struct torture_context *tctx,
401                             LPSTR printername,
402                             HANDLE handle)
403 {
404         DWORD levels[]  = { 1, 2, 3, 4, 5, 6, 7, 8 };
405         DWORD success[] = { 1, 1, 1, 1, 1, 1, 1, 1 };
406         DWORD i;
407         LPBYTE buffer = NULL;
408
409         for (i=0; i < ARRAY_SIZE(levels); i++) {
410
411                 DWORD needed = 0;
412                 DWORD err = 0;
413                 char tmp[1024];
414
415                 torture_comment(tctx, "Testing GetPrinter level %d", levels[i]);
416
417                 GetPrinter(handle, levels[i], NULL, 0, &needed);
418                 err = GetLastError();
419                 if (err == ERROR_INSUFFICIENT_BUFFER) {
420                         err = 0;
421                         buffer = malloc(needed);
422                         torture_assert(tctx, buffer, "malloc failed");
423                         if (!GetPrinter(handle, levels[i], buffer, needed, &needed)) {
424                                 err = GetLastError();
425                         }
426                 }
427                 if (err) {
428                         sprintf(tmp, "GetPrinter failed level %d on [%s] (buffer size = %d), error: %s\n",
429                                 levels[i], printername, needed, errstr(err));
430                         if (success[i]) {
431                                 torture_fail(tctx, tmp);
432                         } else {
433                                 torture_warning(tctx, tmp);
434                         }
435                 }
436
437                 free(buffer);
438                 buffer = NULL;
439         }
440
441         return TRUE;
442 }
443
444 /****************************************************************************
445 ****************************************************************************/
446
447 static BOOL test_GetPrinterDriver(struct torture_context *tctx,
448                                   LPSTR printername,
449                                   HANDLE handle)
450 {
451         DWORD levels[]  = { 1, 2, 3, 4, 5, 6, 8, 101};
452         DWORD success[] = { 1, 1, 1, 1, 1, 1, 1, 1 };
453         DWORD i;
454         LPBYTE buffer = NULL;
455
456         for (i=0; i < ARRAY_SIZE(levels); i++) {
457
458                 DWORD needed = 0;
459                 DWORD err = 0;
460                 char tmp[1024];
461
462                 torture_comment(tctx, "Testing GetPrinterDriver level %d", levels[i]);
463
464                 GetPrinterDriver(handle, "Windows NT x86", levels[i], NULL, 0, &needed);
465                 err = GetLastError();
466                 if (err == ERROR_INSUFFICIENT_BUFFER) {
467                         err = 0;
468                         buffer = malloc(needed);
469                         torture_assert(tctx, buffer, "malloc failed");
470                         if (!GetPrinterDriver(handle, "Windows NT x86", levels[i], buffer, needed, &needed)) {
471                                 err = GetLastError();
472                         }
473                 }
474                 if (err) {
475                         sprintf(tmp, "GetPrinterDriver failed level %d on [%s] (buffer size = %d), error: %s\n",
476                                 levels[i], printername, needed, errstr(err));
477                         if (success[i]) {
478                                 torture_fail(tctx, tmp);
479                         } else {
480                                 torture_warning(tctx, tmp);
481                         }
482                 }
483
484                 free(buffer);
485                 buffer = NULL;
486         }
487
488         return TRUE;
489 }
490
491
492 /****************************************************************************
493 ****************************************************************************/
494
495 static BOOL test_EnumJobs(struct torture_context *tctx,
496                           LPSTR printername,
497                           HANDLE handle)
498 {
499         DWORD levels[]  = { 1, 2, 3, 4 };
500         DWORD success[] = { 1, 1, 1, 1 };
501         DWORD i;
502         LPBYTE buffer = NULL;
503
504         for (i=0; i < ARRAY_SIZE(levels); i++) {
505
506                 DWORD needed = 0;
507                 DWORD returned = 0;
508                 DWORD err = 0;
509                 char tmp[1024];
510
511                 torture_comment(tctx, "Testing EnumJobs level %d", levels[i]);
512
513                 EnumJobs(handle, 0, 100, levels[i], NULL, 0, &needed, &returned);
514                 err = GetLastError();
515                 if (err == ERROR_INSUFFICIENT_BUFFER) {
516                         err = 0;
517                         buffer = malloc(needed);
518                         torture_assert(tctx, buffer, "malloc failed");
519                         if (!EnumJobs(handle, 0, 100, levels[i], buffer, needed, &needed, &returned)) {
520                                 err = GetLastError();
521                         }
522                 }
523                 if (err) {
524                         sprintf(tmp, "EnumJobs failed level %d on [%s] (buffer size = %d), error: %s\n",
525                                 levels[i], printername, needed, errstr(err));
526                         if (success[i]) {
527                                 torture_fail(tctx, tmp);
528                         } else {
529                                 torture_warning(tctx, tmp);
530                         }
531                 }
532
533                 free(buffer);
534                 buffer = NULL;
535         }
536
537         return TRUE;
538 }
539
540 /****************************************************************************
541 ****************************************************************************/
542
543 static BOOL test_OnePrinter(struct torture_context *tctx,
544                             LPSTR printername)
545 {
546         HANDLE handle;
547         BOOL ret = TRUE;
548
549         torture_comment(tctx, "Testing Printer %s", printername);
550
551         ret &= test_OpenPrinter(tctx, printername, &handle);
552         ret &= test_GetPrinter(tctx, printername, handle);
553         ret &= test_GetPrinterDriver(tctx, printername, handle);
554         ret &= test_EnumForms(tctx, printername, handle);
555         ret &= test_EnumJobs(tctx, printername, handle);
556         ret &= test_ClosePrinter(tctx, handle);
557
558         return ret;
559 }
560
561 /****************************************************************************
562 ****************************************************************************/
563
564 static BOOL test_OneDriver(struct torture_context *tctx,
565                            LPSTR printername,
566                            LPSTR drivername)
567 {
568         return TRUE;
569 }
570
571 /****************************************************************************
572 ****************************************************************************/
573
574 static BOOL test_EachDriver(struct torture_context *tctx,
575                             LPSTR servername)
576 {
577         return TRUE;
578 }
579
580 /****************************************************************************
581 ****************************************************************************/
582
583 static BOOL test_EachPrinter(struct torture_context *tctx,
584                              LPSTR servername)
585 {
586         DWORD needed = 0;
587         DWORD returned = 0;
588         DWORD err = 0;
589         char tmp[1024];
590         DWORD i;
591         DWORD flags = PRINTER_ENUM_NAME;
592         PPRINTER_INFO_1 buffer = NULL;
593
594         torture_comment(tctx, "Testing EnumPrinters level %d", 1);
595
596         EnumPrinters(flags, servername, 1, NULL, 0, &needed, &returned);
597         err = GetLastError();
598         if (err == ERROR_INSUFFICIENT_BUFFER) {
599                 err = 0;
600                 buffer = (PPRINTER_INFO_1)malloc(needed);
601                 torture_assert(tctx, buffer, "malloc failed");
602                 if (!EnumPrinters(flags, servername, 1, (LPBYTE)buffer, needed, &needed, &returned)) {
603                         err = GetLastError();
604                 }
605         }
606         if (err) {
607                 sprintf(tmp, "EnumPrinters failed level %d on [%s] (buffer size = %d), error: %s\n",
608                         1, servername, needed, errstr(err));
609                 torture_fail(tctx, tmp);
610         }
611
612         for (i=0; i < returned; i++) {
613                 torture_assert(tctx, test_OnePrinter(tctx, buffer[i].pName),
614                         "failed to test one printer");
615         }
616
617         free(buffer);
618
619         return TRUE;
620 }
621
622 /****************************************************************************
623 ****************************************************************************/
624
625 static BOOL test_GetPrintProcessorDirectory(struct torture_context *tctx,
626                                             LPSTR servername)
627 {
628         DWORD levels[]  = { 1 };
629         DWORD success[] = { 1 };
630         DWORD i;
631         LPBYTE buffer = NULL;
632
633         for (i=0; i < ARRAY_SIZE(levels); i++) {
634
635                 DWORD needed = 0;
636                 DWORD err = 0;
637                 char tmp[1024];
638
639                 torture_comment(tctx, "Testing GetPrintProcessorDirectory level %d", levels[i]);
640
641                 GetPrintProcessorDirectory(servername, "Windows NT x86", levels[i], NULL, 0, &needed);
642                 err = GetLastError();
643                 if (err == ERROR_INSUFFICIENT_BUFFER) {
644                         err = 0;
645                         buffer = malloc(needed);
646                         torture_assert(tctx, buffer, "malloc failed");
647                         if (!GetPrintProcessorDirectory(servername, "Windows NT x86", levels[i], buffer, needed, &needed)) {
648                                 err = GetLastError();
649                         }
650                 }
651                 if (err) {
652                         sprintf(tmp, "GetPrintProcessorDirectory failed level %d on [%s] (buffer size = %d), error: %s\n",
653                                 levels[i], servername, needed, errstr(err));
654                         if (success[i]) {
655                                 torture_fail(tctx, tmp);
656                         } else {
657                                 torture_warning(tctx, tmp);
658                         }
659                 }
660
661                 free(buffer);
662                 buffer = NULL;
663         }
664
665         return TRUE;
666 }
667
668 /****************************************************************************
669 ****************************************************************************/
670
671 static BOOL test_GetPrinterDriverDirectory(struct torture_context *tctx,
672                                            LPSTR servername)
673 {
674         DWORD levels[]  = { 1 };
675         DWORD success[] = { 1 };
676         DWORD i;
677         LPBYTE buffer = NULL;
678
679         for (i=0; i < ARRAY_SIZE(levels); i++) {
680
681                 DWORD needed = 0;
682                 DWORD err = 0;
683                 char tmp[1024];
684
685                 torture_comment(tctx, "Testing GetPrinterDriverDirectory level %d", levels[i]);
686
687                 GetPrinterDriverDirectory(servername, "Windows NT x86", levels[i], NULL, 0, &needed);
688                 err = GetLastError();
689                 if (err == ERROR_INSUFFICIENT_BUFFER) {
690                         err = 0;
691                         buffer = malloc(needed);
692                         torture_assert(tctx, buffer, "malloc failed");
693                         if (!GetPrinterDriverDirectory(servername, "Windows NT x86", levels[i], buffer, needed, &needed)) {
694                                 err = GetLastError();
695                         }
696                 }
697                 if (err) {
698                         sprintf(tmp, "GetPrinterDriverDirectory failed level %d on [%s] (buffer size = %d), error: %s\n",
699                                 levels[i], servername, needed, errstr(err));
700                         if (success[i]) {
701                                 torture_fail(tctx, tmp);
702                         } else {
703                                 torture_warning(tctx, tmp);
704                         }
705                 }
706
707                 free(buffer);
708                 buffer = NULL;
709         }
710
711         return TRUE;
712 }
713
714
715 /****************************************************************************
716 ****************************************************************************/
717
718 int main(int argc, char *argv[])
719 {
720         BOOL ret = FALSE;
721         LPSTR servername;
722         HANDLE handle;
723         struct torture_context *tctx;
724
725         if (argc < 2) {
726                 fprintf(stderr, "usage: %s <servername> [print]\n", argv[0]);
727                 exit(-1);
728         }
729
730         tctx = malloc(sizeof(struct torture_context));
731         if (!tctx) {
732                 fprintf(stderr, "out of memory\n");
733                 exit(-1);
734         }
735         memset(tctx, '\0', sizeof(*tctx));
736
737         servername = argv[1];
738
739         if (argc >= 3) {
740                 if (strcmp(argv[2], "print") == 0) {
741                         tctx->print = TRUE;
742                 }
743         }
744
745         ret &= test_EnumPrinters(tctx, servername);
746         ret &= test_EnumDrivers(tctx, servername);
747         ret &= test_OpenPrinter(tctx, servername, &handle);
748         ret &= test_EnumForms(tctx, servername, handle);
749         ret &= test_ClosePrinter(tctx, handle);
750         ret &= test_EnumPorts(tctx, servername);
751         ret &= test_EnumMonitors(tctx, servername);
752         ret &= test_EnumPrintProcessors(tctx, servername);
753         ret &= test_EnumPrintProcessorDatatypes(tctx, servername);
754         ret &= test_GetPrintProcessorDirectory(tctx, servername);
755         ret &= test_GetPrinterDriverDirectory(tctx, servername);
756         ret &= test_EachPrinter(tctx, servername);
757         ret &= test_EachDriver(tctx, servername);
758
759         if (!ret) {
760                 if (tctx->last_reason) {
761                         fprintf(stderr, "failed: %s\n", tctx->last_reason);
762                 }
763                 free(tctx);
764                 return -1;
765         }
766
767         printf("%s run successfully\n", argv[0]);
768
769         free(tctx);
770         return 0;
771 }