testprogs: better usage text.
[Samba/kamenim.git] / testprogs / win32 / spoolss / spoolss.c
blobacdbb13f47e4f01b498f01552bc5ae7c1d8caa7a
1 /*
2 Unix SMB/CIFS implementation.
3 test suite for spoolss rpc operations
5 Copyright (C) Guenther Deschner 2009-2010
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.
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.
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/>.
21 /****************************************************************************
22 ****************************************************************************/
24 #include "spoolss.h"
25 #include "string.h"
26 #include "torture.h"
28 /****************************************************************************
29 ****************************************************************************/
31 static BOOL test_OpenPrinter(struct torture_context *tctx,
32 LPSTR printername,
33 LPPRINTER_DEFAULTS defaults,
34 LPHANDLE handle)
36 torture_comment(tctx, "Testing OpenPrinter(%s)", printername);
38 if (!OpenPrinter(printername, handle, defaults)) {
39 char tmp[1024];
40 sprintf(tmp, "failed to open printer %s, error was: 0x%08x\n",
41 printername, GetLastError());
42 torture_fail(tctx, tmp);
45 return TRUE;
48 /****************************************************************************
49 ****************************************************************************/
51 static BOOL test_ClosePrinter(struct torture_context *tctx,
52 HANDLE handle)
54 torture_comment(tctx, "Testing ClosePrinter");
56 if (!ClosePrinter(handle)) {
57 char tmp[1024];
58 sprintf(tmp, "failed to close printer, error was: %s\n",
59 errstr(GetLastError()));
60 torture_fail(tctx, tmp);
63 return TRUE;
67 /****************************************************************************
68 ****************************************************************************/
70 static BOOL test_EnumPrinters(struct torture_context *tctx,
71 LPSTR servername)
73 DWORD levels[] = { 1, 2, 5 };
74 DWORD success[] = { 1, 1, 1 };
75 DWORD i;
76 DWORD flags = PRINTER_ENUM_NAME;
77 LPBYTE buffer = NULL;
79 for (i=0; i < ARRAY_SIZE(levels); i++) {
81 DWORD needed = 0;
82 DWORD returned = 0;
83 DWORD err = 0;
84 char tmp[1024];
86 torture_comment(tctx, "Testing EnumPrinters level %d", levels[i]);
88 EnumPrinters(flags, servername, levels[i], NULL, 0, &needed, &returned);
89 err = GetLastError();
90 if (err == ERROR_INSUFFICIENT_BUFFER) {
91 err = 0;
92 buffer = malloc(needed);
93 torture_assert(tctx, buffer, "malloc failed");
94 if (!EnumPrinters(flags, servername, levels[i], buffer, needed, &needed, &returned)) {
95 err = GetLastError();
98 if (err) {
99 sprintf(tmp, "EnumPrinters failed level %d on [%s] (buffer size = %d), error: %s\n",
100 levels[i], servername, needed, errstr(err));
101 if (success[i]) {
102 torture_fail(tctx, tmp);
103 } else {
104 torture_warning(tctx, tmp);
108 if (tctx->print) {
109 print_printer_info_bylevel(levels[i], buffer, returned);
112 free(buffer);
113 buffer = NULL;
116 return TRUE;
119 /****************************************************************************
120 ****************************************************************************/
122 static BOOL test_EnumDrivers(struct torture_context *tctx,
123 LPSTR servername,
124 LPSTR architecture)
126 DWORD levels[] = { 1, 2, 3, 4, 5, 6 };
127 DWORD success[] = { 1, 1, 1, 1, 1, 1 };
128 DWORD i;
129 LPBYTE buffer = NULL;
131 for (i=0; i < ARRAY_SIZE(levels); i++) {
133 DWORD needed = 0;
134 DWORD returned = 0;
135 DWORD err = 0;
136 char tmp[1024];
138 torture_comment(tctx, "Testing EnumPrinterDrivers level %d", levels[i]);
140 EnumPrinterDrivers(servername, architecture, levels[i], NULL, 0, &needed, &returned);
141 err = GetLastError();
142 if (err == ERROR_INSUFFICIENT_BUFFER) {
143 err = 0;
144 buffer = malloc(needed);
145 torture_assert(tctx, buffer, "malloc failed");
146 if (!EnumPrinterDrivers(servername, architecture, levels[i], buffer, needed, &needed, &returned)) {
147 err = GetLastError();
150 if (err) {
151 sprintf(tmp, "EnumPrinterDrivers failed level %d on [%s] (buffer size = %d), error: %s\n",
152 levels[i], servername, needed, errstr(err));
153 if (success[i]) {
154 torture_fail(tctx, tmp);
155 } else {
156 torture_warning(tctx, tmp);
160 if (tctx->print) {
161 print_driver_info_bylevel(levels[i], buffer, returned);
164 free(buffer);
165 buffer = NULL;
168 return TRUE;
171 /****************************************************************************
172 ****************************************************************************/
174 static BOOL test_GetForm(struct torture_context *tctx,
175 LPSTR servername,
176 HANDLE handle,
177 LPSTR formname)
179 DWORD levels[] = { 1, 2 };
180 DWORD success[] = { 1, 0 };
181 DWORD i;
182 LPBYTE buffer = NULL;
184 for (i=0; i < ARRAY_SIZE(levels); i++) {
186 DWORD needed = 0;
187 DWORD err = 0;
188 char tmp[1024];
190 torture_comment(tctx, "Testing GetForm(%s) level %d", formname, levels[i]);
192 GetForm(handle, formname, levels[i], NULL, 0, &needed);
193 err = GetLastError();
194 if (err == ERROR_INSUFFICIENT_BUFFER) {
195 err = 0;
196 buffer = malloc(needed);
197 torture_assert(tctx, buffer, "malloc failed");
198 if (!GetForm(handle, formname, levels[i], buffer, needed, &needed)) {
199 err = GetLastError();
202 if (err) {
203 sprintf(tmp, "GetForm failed level %d on [%s] (buffer size = %d), error: %s\n",
204 levels[i], servername, needed, errstr(err));
205 if (success[i]) {
206 torture_fail(tctx, tmp);
207 } else {
208 torture_warning(tctx, tmp);
212 if (tctx->print) {
213 print_form_info_bylevel(levels[i], buffer, 1);
216 free(buffer);
217 buffer = NULL;
220 return TRUE;
223 /****************************************************************************
224 ****************************************************************************/
226 static BOOL test_EnumForms(struct torture_context *tctx,
227 LPSTR servername,
228 HANDLE handle)
230 DWORD levels[] = { 1, 2 };
231 DWORD success[] = { 1, 1 };
232 DWORD i;
233 LPBYTE buffer = NULL;
235 for (i=0; i < ARRAY_SIZE(levels); i++) {
237 DWORD needed = 0;
238 DWORD returned = 0;
239 DWORD err = 0;
240 char tmp[1024];
242 torture_comment(tctx, "Testing EnumForms level %d", levels[i]);
244 if (tctx->samba3 && levels[i] == 2) {
245 torture_comment(tctx, "skipping level %d enum against samba\n", levels[i]);
246 continue;
249 EnumForms(handle, levels[i], NULL, 0, &needed, &returned);
250 err = GetLastError();
251 if (err == ERROR_INSUFFICIENT_BUFFER) {
252 err = 0;
253 buffer = malloc(needed);
254 torture_assert(tctx, buffer, "malloc failed");
255 if (!EnumForms(handle, levels[i], buffer, needed, &needed, &returned)) {
256 err = GetLastError();
259 if (err) {
260 sprintf(tmp, "EnumForms failed level %d on [%s] (buffer size = %d), error: %s\n",
261 levels[i], servername, needed, errstr(err));
262 if (success[i]) {
263 torture_fail(tctx, tmp);
264 } else {
265 torture_warning(tctx, tmp);
269 if (tctx->print) {
270 print_form_info_bylevel(levels[i], buffer, returned);
273 free(buffer);
274 buffer = NULL;
277 return TRUE;
280 /****************************************************************************
281 ****************************************************************************/
283 static BOOL test_EnumPorts(struct torture_context *tctx,
284 LPSTR servername)
286 DWORD levels[] = { 1, 2 };
287 DWORD success[] = { 1, 1 };
288 DWORD i;
289 LPBYTE buffer = NULL;
291 for (i=0; i < ARRAY_SIZE(levels); i++) {
293 DWORD needed = 0;
294 DWORD returned = 0;
295 DWORD err = 0;
296 char tmp[1024];
298 torture_comment(tctx, "Testing EnumPorts level %d", levels[i]);
300 EnumPorts(servername, levels[i], NULL, 0, &needed, &returned);
301 err = GetLastError();
302 if (err == ERROR_INSUFFICIENT_BUFFER) {
303 err = 0;
304 buffer = malloc(needed);
305 torture_assert(tctx, buffer, "malloc failed");
306 if (!EnumPorts(servername, levels[i], buffer, needed, &needed, &returned)) {
307 err = GetLastError();
310 if (err) {
311 sprintf(tmp, "EnumPorts failed level %d on [%s] (buffer size = %d), error: %s\n",
312 levels[i], servername, needed, errstr(err));
313 if (success[i]) {
314 torture_fail(tctx, tmp);
315 } else {
316 torture_warning(tctx, tmp);
320 if (tctx->print) {
321 print_port_info_bylevel(levels[i], buffer, returned);
324 free(buffer);
325 buffer = NULL;
328 return TRUE;
331 /****************************************************************************
332 ****************************************************************************/
334 static BOOL test_EnumMonitors(struct torture_context *tctx,
335 LPSTR servername)
337 DWORD levels[] = { 1, 2 };
338 DWORD success[] = { 1, 1 };
339 DWORD i;
340 LPBYTE buffer = NULL;
342 for (i=0; i < ARRAY_SIZE(levels); i++) {
344 DWORD needed = 0;
345 DWORD returned = 0;
346 DWORD err = 0;
347 char tmp[1024];
349 torture_comment(tctx, "Testing EnumMonitors level %d", levels[i]);
351 EnumMonitors(servername, levels[i], NULL, 0, &needed, &returned);
352 err = GetLastError();
353 if (err == ERROR_INSUFFICIENT_BUFFER) {
354 err = 0;
355 buffer = malloc(needed);
356 torture_assert(tctx, buffer, "malloc failed");
357 if (!EnumMonitors(servername, levels[i], buffer, needed, &needed, &returned)) {
358 err = GetLastError();
361 if (err) {
362 sprintf(tmp, "EnumMonitors failed level %d on [%s] (buffer size = %d), error: %s\n",
363 levels[i], servername, needed, errstr(err));
364 if (success[i]) {
365 torture_fail(tctx, tmp);
366 } else {
367 torture_warning(tctx, tmp);
371 if (tctx->print) {
372 print_monitor_info_bylevel(levels[i], buffer, returned);
375 free(buffer);
376 buffer = NULL;
379 return TRUE;
382 /****************************************************************************
383 ****************************************************************************/
385 static BOOL test_EnumPrintProcessors(struct torture_context *tctx,
386 LPSTR servername,
387 LPSTR architecture)
389 DWORD levels[] = { 1 };
390 DWORD success[] = { 1 };
391 DWORD i;
392 LPBYTE buffer = NULL;
394 for (i=0; i < ARRAY_SIZE(levels); i++) {
396 DWORD needed = 0;
397 DWORD returned = 0;
398 DWORD err = 0;
399 char tmp[1024];
401 torture_comment(tctx, "Testing EnumPrintProcessors level %d", levels[i]);
403 EnumPrintProcessors(servername, architecture, levels[i], NULL, 0, &needed, &returned);
404 err = GetLastError();
405 if (err == ERROR_INSUFFICIENT_BUFFER) {
406 err = 0;
407 buffer = malloc(needed);
408 torture_assert(tctx, buffer, "malloc failed");
409 if (!EnumPrintProcessors(servername, architecture, levels[i], buffer, needed, &needed, &returned)) {
410 err = GetLastError();
413 if (err) {
414 sprintf(tmp, "EnumPrintProcessors failed level %d on [%s] (buffer size = %d), error: %s\n",
415 levels[i], servername, needed, errstr(err));
416 if (success[i]) {
417 torture_fail(tctx, tmp);
418 } else {
419 torture_warning(tctx, tmp);
423 if (tctx->print) {
424 print_printprocessor_info_bylevel(levels[i], buffer, returned);
427 free(buffer);
428 buffer = NULL;
431 return TRUE;
434 /****************************************************************************
435 ****************************************************************************/
437 static BOOL test_EnumPrintProcessorDatatypes(struct torture_context *tctx,
438 LPSTR servername)
440 DWORD levels[] = { 1 };
441 DWORD success[] = { 1 };
442 DWORD i;
443 LPBYTE buffer = NULL;
445 for (i=0; i < ARRAY_SIZE(levels); i++) {
447 DWORD needed = 0;
448 DWORD returned = 0;
449 DWORD err = 0;
450 char tmp[1024];
452 torture_comment(tctx, "Testing EnumPrintProcessorDatatypes level %d", levels[i]);
454 EnumPrintProcessorDatatypes(servername, "winprint", levels[i], NULL, 0, &needed, &returned);
455 err = GetLastError();
456 if (err == ERROR_INSUFFICIENT_BUFFER) {
457 err = 0;
458 buffer = malloc(needed);
459 torture_assert(tctx, buffer, "malloc failed");
460 if (!EnumPrintProcessorDatatypes(servername, "winprint", levels[i], buffer, needed, &needed, &returned)) {
461 err = GetLastError();
464 if (err) {
465 sprintf(tmp, "EnumPrintProcessorDatatypes failed level %d on [%s] (buffer size = %d), error: %s\n",
466 levels[i], servername, needed, errstr(err));
467 if (success[i]) {
468 torture_fail(tctx, tmp);
469 } else {
470 torture_warning(tctx, tmp);
474 if (tctx->print) {
475 print_datatypes_info_bylevel(levels[i], buffer, returned);
478 free(buffer);
479 buffer = NULL;
482 return TRUE;
485 /****************************************************************************
486 ****************************************************************************/
488 static BOOL test_EnumPrinterKey(struct torture_context *tctx,
489 LPSTR servername,
490 HANDLE handle,
491 LPCSTR key)
493 LPSTR buffer = NULL;
494 DWORD needed = 0;
495 DWORD err = 0;
496 char tmp[1024];
498 torture_comment(tctx, "Testing EnumPrinterKey(%s)", key);
500 err = EnumPrinterKey(handle, key, NULL, 0, &needed);
501 if (err == ERROR_MORE_DATA) {
502 buffer = (LPTSTR)malloc(needed);
503 torture_assert(tctx, buffer, "malloc failed");
504 err = EnumPrinterKey(handle, key, buffer, needed, &needed);
506 if (err) {
507 sprintf(tmp, "EnumPrinterKey(%s) failed on [%s] (buffer size = %d), error: %s\n",
508 key, servername, needed, errstr(err));
509 torture_fail(tctx, tmp);
512 if (tctx->print) {
513 print_printer_keys(buffer);
516 free(buffer);
518 return TRUE;
521 /****************************************************************************
522 ****************************************************************************/
524 static BOOL test_GetPrinter(struct torture_context *tctx,
525 LPSTR printername,
526 HANDLE handle)
528 DWORD levels[] = { 1, 2, 3, 4, 5, 6, 7, 8 };
529 DWORD success[] = { 1, 1, 1, 1, 1, 1, 1, 1 };
530 DWORD i;
531 LPBYTE buffer = NULL;
533 for (i=0; i < ARRAY_SIZE(levels); i++) {
535 DWORD needed = 0;
536 DWORD err = 0;
537 char tmp[1024];
539 torture_comment(tctx, "Testing GetPrinter level %d", levels[i]);
541 GetPrinter(handle, levels[i], NULL, 0, &needed);
542 err = GetLastError();
543 if (err == ERROR_INSUFFICIENT_BUFFER) {
544 err = 0;
545 buffer = malloc(needed);
546 torture_assert(tctx, buffer, "malloc failed");
547 if (!GetPrinter(handle, levels[i], buffer, needed, &needed)) {
548 err = GetLastError();
551 if (err) {
552 sprintf(tmp, "GetPrinter failed level %d on [%s] (buffer size = %d), error: %s\n",
553 levels[i], printername, needed, errstr(err));
554 if (success[i]) {
555 torture_fail(tctx, tmp);
556 } else {
557 torture_warning(tctx, tmp);
561 if (tctx->print) {
562 print_printer_info_bylevel(levels[i], buffer, 1);
565 free(buffer);
566 buffer = NULL;
569 return TRUE;
572 /****************************************************************************
573 ****************************************************************************/
575 static BOOL test_GetPrinterDriver(struct torture_context *tctx,
576 LPSTR printername,
577 LPSTR architecture,
578 HANDLE handle)
580 DWORD levels[] = { 1, 2, 3, 4, 5, 6, 8 };
581 DWORD success[] = { 1, 1, 1, 1, 1, 1, 1 };
582 DWORD i;
583 LPBYTE buffer = NULL;
585 for (i=0; i < ARRAY_SIZE(levels); i++) {
587 DWORD needed = 0;
588 DWORD err = 0;
589 char tmp[1024];
591 torture_comment(tctx, "Testing GetPrinterDriver level %d", levels[i]);
593 GetPrinterDriver(handle, architecture, levels[i], NULL, 0, &needed);
594 err = GetLastError();
595 if (err == ERROR_INSUFFICIENT_BUFFER) {
596 err = 0;
597 buffer = malloc(needed);
598 torture_assert(tctx, buffer, "malloc failed");
599 if (!GetPrinterDriver(handle, architecture, levels[i], buffer, needed, &needed)) {
600 err = GetLastError();
603 if (err) {
604 sprintf(tmp, "GetPrinterDriver failed level %d on [%s] (buffer size = %d), error: %s\n",
605 levels[i], printername, needed, errstr(err));
606 if (success[i]) {
607 torture_fail(tctx, tmp);
608 } else {
609 torture_warning(tctx, tmp);
613 if (tctx->print) {
614 print_driver_info_bylevel(levels[i], buffer, 1);
617 free(buffer);
618 buffer = NULL;
621 return TRUE;
625 /****************************************************************************
626 ****************************************************************************/
628 static BOOL test_EnumJobs(struct torture_context *tctx,
629 LPSTR printername,
630 HANDLE handle)
632 DWORD levels[] = { 1, 2, 3, 4 };
633 DWORD success[] = { 1, 1, 1, 1 };
634 DWORD i;
635 LPBYTE buffer = NULL;
637 for (i=0; i < ARRAY_SIZE(levels); i++) {
639 DWORD needed = 0;
640 DWORD returned = 0;
641 DWORD err = 0;
642 char tmp[1024];
644 torture_comment(tctx, "Testing EnumJobs level %d", levels[i]);
646 if (tctx->samba3 && levels[i] == 4) {
647 torture_comment(tctx, "skipping level %d enum against samba\n", levels[i]);
648 continue;
651 EnumJobs(handle, 0, 100, levels[i], NULL, 0, &needed, &returned);
652 err = GetLastError();
653 if (err == ERROR_INSUFFICIENT_BUFFER) {
654 err = 0;
655 buffer = malloc(needed);
656 torture_assert(tctx, buffer, "malloc failed");
657 if (!EnumJobs(handle, 0, 100, levels[i], buffer, needed, &needed, &returned)) {
658 err = GetLastError();
661 if (err) {
662 sprintf(tmp, "EnumJobs failed level %d on [%s] (buffer size = %d), error: %s\n",
663 levels[i], printername, needed, errstr(err));
664 if (success[i]) {
665 torture_fail(tctx, tmp);
666 } else {
667 torture_warning(tctx, tmp);
671 if (tctx->print) {
672 print_job_info_bylevel(levels[i], buffer, returned);
675 free(buffer);
676 buffer = NULL;
679 return TRUE;
682 /****************************************************************************
683 ****************************************************************************/
685 static BOOL test_EnumPrinterDataEx(struct torture_context *tctx,
686 LPSTR servername,
687 LPSTR keyname,
688 HANDLE handle,
689 LPBYTE *buffer_p,
690 DWORD *returned_p)
692 LPBYTE buffer = NULL;
693 DWORD needed = 0;
694 DWORD returned = 0;
695 DWORD err = 0;
696 char tmp[1024];
698 torture_comment(tctx, "Testing EnumPrinterDataEx(%s)", keyname);
700 err = EnumPrinterDataEx(handle, keyname, NULL, 0, &needed, &returned);
701 if (err == ERROR_MORE_DATA) {
702 buffer = malloc(needed);
703 torture_assert(tctx, buffer, "malloc failed");
704 err = EnumPrinterDataEx(handle, keyname, buffer, needed, &needed, &returned);
706 if (err) {
707 sprintf(tmp, "EnumPrinterDataEx(%s) failed on [%s] (buffer size = %d), error: %s\n",
708 keyname, servername, needed, errstr(err));
709 torture_fail(tctx, tmp);
712 if (tctx->print) {
713 DWORD i;
714 LPPRINTER_ENUM_VALUES v = (LPPRINTER_ENUM_VALUES)buffer;
715 for (i=0; i < returned; i++) {
716 print_printer_enum_values(&v[i]);
720 if (returned_p) {
721 *returned_p = returned;
724 if (buffer_p) {
725 *buffer_p = buffer;
726 } else {
727 free(buffer);
730 return TRUE;
733 /****************************************************************************
734 ****************************************************************************/
736 static BOOL test_devicemode_equal(struct torture_context *tctx,
737 const DEVMODE *d1,
738 const DEVMODE *d2)
740 if (d1 == d2) {
741 return TRUE;
744 if (!d1 || !d2) {
745 torture_comment(tctx, "%s\n", __location__);
746 return FALSE;
749 torture_assert_str_equal(tctx, (const char *)d1->dmDeviceName, (const char *)d2->dmDeviceName, "dmDeviceName mismatch");
750 torture_assert_int_equal(tctx, d1->dmSpecVersion, d2->dmSpecVersion, "dmSpecVersion mismatch");
751 torture_assert_int_equal(tctx, d1->dmDriverVersion, d2->dmDriverVersion, "dmDriverVersion mismatch");
752 torture_assert_int_equal(tctx, d1->dmSize, d2->dmSize, "size mismatch");
753 torture_assert_int_equal(tctx, d1->dmDriverExtra, d2->dmDriverExtra, "dmDriverExtra mismatch");
754 torture_assert_int_equal(tctx, d1->dmFields, d2->dmFields, "dmFields mismatch");
756 torture_assert_int_equal(tctx, d1->dmOrientation, d2->dmOrientation, "dmOrientation mismatch");
757 torture_assert_int_equal(tctx, d1->dmPaperSize, d2->dmPaperSize, "dmPaperSize mismatch");
758 torture_assert_int_equal(tctx, d1->dmPaperLength, d2->dmPaperLength, "dmPaperLength mismatch");
759 torture_assert_int_equal(tctx, d1->dmPaperWidth, d2->dmPaperWidth, "dmPaperWidth mismatch");
760 torture_assert_int_equal(tctx, d1->dmScale, d2->dmScale, "dmScale mismatch");
761 torture_assert_int_equal(tctx, d1->dmCopies, d2->dmCopies, "dmCopies mismatch");
762 torture_assert_int_equal(tctx, d1->dmDefaultSource, d2->dmDefaultSource, "dmDefaultSource mismatch");
763 torture_assert_int_equal(tctx, d1->dmPrintQuality, d2->dmPrintQuality, "dmPrintQuality mismatch");
765 torture_assert_int_equal(tctx, d1->dmColor, d2->dmColor, "dmColor mismatch");
766 torture_assert_int_equal(tctx, d1->dmDuplex, d2->dmDuplex, "dmDuplex mismatch");
767 torture_assert_int_equal(tctx, d1->dmYResolution, d2->dmYResolution, "dmYResolution mismatch");
768 torture_assert_int_equal(tctx, d1->dmTTOption, d2->dmTTOption, "dmTTOption mismatch");
769 torture_assert_int_equal(tctx, d1->dmCollate, d2->dmCollate, "dmCollate mismatch");
770 torture_assert_str_equal(tctx, (const char *)d1->dmFormName, (const char *)d2->dmFormName, "dmFormName mismatch");
771 torture_assert_int_equal(tctx, d1->dmLogPixels, d2->dmLogPixels, "dmLogPixels mismatch");
772 torture_assert_int_equal(tctx, d1->dmBitsPerPel, d2->dmBitsPerPel, "dmBitsPerPel mismatch");
773 torture_assert_int_equal(tctx, d1->dmPelsWidth, d2->dmPelsWidth, "dmPelsWidth mismatch");
774 torture_assert_int_equal(tctx, d1->dmPelsHeight, d2->dmPelsHeight, "dmPelsHeight mismatch");
776 torture_assert_int_equal(tctx, d1->dmDisplayFlags, d2->dmDisplayFlags, "dmDisplayFlags mismatch");
777 /* or dmNup ? */
778 torture_assert_int_equal(tctx, d1->dmDisplayFrequency, d2->dmDisplayFrequency, "dmDisplayFrequency mismatch");
780 torture_assert_int_equal(tctx, d1->dmICMMethod, d2->dmICMMethod, "dmICMMethod mismatch");
781 torture_assert_int_equal(tctx, d1->dmICMIntent, d2->dmICMIntent, "dmICMIntent mismatch");
782 torture_assert_int_equal(tctx, d1->dmMediaType, d2->dmMediaType, "dmMediaType mismatch");
783 torture_assert_int_equal(tctx, d1->dmDitherType, d2->dmDitherType, "dmDitherType mismatch");
784 torture_assert_int_equal(tctx, d1->dmReserved1, d2->dmReserved1, "dmReserved1 mismatch");
785 torture_assert_int_equal(tctx, d1->dmReserved2, d2->dmReserved2, "reserved2 mismatch");
787 torture_assert_int_equal(tctx, d1->dmPanningWidth, d2->dmPanningWidth, "dmPanningWidth mismatch");
788 torture_assert_int_equal(tctx, d1->dmPanningHeight, d2->dmPanningHeight, "dmPanningHeight mismatch");
790 /* torture_assert_mem_equal(tctx, d1 + d1->dmSize, d2 + d2->dmSize, d1->dmDriverExtra, "private extra data mismatch"); */
792 return TRUE;
795 static BOOL test_DeviceModes(struct torture_context *tctx,
796 LPSTR printername,
797 HANDLE handle)
799 PPRINTER_INFO_2 info2 = NULL;
800 PPRINTER_INFO_8 info8 = NULL;
801 DWORD needed = 0;
802 DWORD err = 0;
803 char tmp[1024];
805 torture_comment(tctx, "Testing DeviceModes");
807 torture_comment(tctx, "Testing GetPrinter level %d", 2);
809 GetPrinter(handle, 2, NULL, 0, &needed);
810 err = GetLastError();
811 if (err == ERROR_INSUFFICIENT_BUFFER) {
812 err = 0;
813 info2 = (PPRINTER_INFO_2)malloc(needed);
814 torture_assert(tctx, (LPBYTE)info2, "malloc failed");
815 if (!GetPrinter(handle, 2, (LPBYTE)info2, needed, &needed)) {
816 err = GetLastError();
819 if (err) {
820 sprintf(tmp, "GetPrinter failed level %d on [%s] (buffer size = %d), error: %s\n",
821 2, printername, needed, errstr(err));
822 torture_fail(tctx, tmp);
825 if (tctx->print) {
826 print_printer_info_2(info2);
829 torture_comment(tctx, "Testing GetPrinter level %d", 8);
831 GetPrinter(handle, 8, NULL, 0, &needed);
832 err = GetLastError();
833 if (err == ERROR_INSUFFICIENT_BUFFER) {
834 err = 0;
835 info8 = (PPRINTER_INFO_8)malloc(needed);
836 torture_assert(tctx, (LPBYTE)info8, "malloc failed");
837 if (!GetPrinter(handle, 8, (LPBYTE)info8, needed, &needed)) {
838 err = GetLastError();
841 if (err) {
842 sprintf(tmp, "GetPrinter failed level %d on [%s] (buffer size = %d), error: %s\n",
843 8, printername, needed, errstr(err));
844 torture_fail(tctx, tmp);
847 if (tctx->print) {
848 print_printer_info_8(info8);
851 torture_assert(tctx, test_devicemode_equal(tctx, info2->pDevMode, info8->pDevMode), "");
853 free(info2);
854 free(info8);
856 return TRUE;
859 /****************************************************************************
860 ****************************************************************************/
862 static BOOL test_GetJob(struct torture_context *tctx,
863 LPSTR printername,
864 HANDLE handle,
865 DWORD job_id)
867 DWORD levels[] = { 1, 2, 3, 4 };
868 DWORD success[] = { 1, 1, 1, 1 };
869 DWORD i;
870 LPBYTE buffer = NULL;
872 for (i=0; i < ARRAY_SIZE(levels); i++) {
874 DWORD needed = 0;
875 DWORD err = 0;
876 char tmp[1024];
878 torture_comment(tctx, "Testing GetJob(%d) level %d", job_id, levels[i]);
880 if (tctx->samba3 && (levels[i] == 4) || (levels[i] == 3)) {
881 torture_comment(tctx, "skipping level %d getjob against samba\n", levels[i]);
882 continue;
885 GetJob(handle, job_id, levels[i], NULL, 0, &needed);
886 err = GetLastError();
887 if (err == ERROR_INSUFFICIENT_BUFFER) {
888 err = 0;
889 buffer = malloc(needed);
890 torture_assert(tctx, buffer, "malloc failed");
891 if (!GetJob(handle, job_id, levels[i], buffer, needed, &needed)) {
892 err = GetLastError();
895 if (err) {
896 sprintf(tmp, "GetJob failed level %d on [%s] (buffer size = %d), error: %s\n",
897 levels[i], printername, needed, errstr(err));
898 if (success[i]) {
899 torture_fail(tctx, tmp);
900 } else {
901 torture_warning(tctx, tmp);
905 if (tctx->print) {
906 print_job_info_bylevel(levels[i], buffer, 1);
909 free(buffer);
910 buffer = NULL;
913 return TRUE;
916 /****************************************************************************
917 ****************************************************************************/
919 static BOOL test_EachJob(struct torture_context *tctx,
920 LPSTR printername,
921 HANDLE handle)
923 DWORD i;
924 PJOB_INFO_1 buffer = NULL;
925 DWORD needed = 0;
926 DWORD returned = 0;
927 DWORD err = 0;
928 DWORD level = 1;
929 char tmp[1024];
930 BOOL ret = TRUE;
932 torture_comment(tctx, "Testing Each PrintJob %d");
934 EnumJobs(handle, 0, 100, level, NULL, 0, &needed, &returned);
935 err = GetLastError();
936 if (err == ERROR_INSUFFICIENT_BUFFER) {
937 err = 0;
938 buffer = (PJOB_INFO_1)malloc(needed);
939 torture_assert(tctx, buffer, "malloc failed");
940 if (!EnumJobs(handle, 0, 100, level, (LPBYTE)buffer, needed, &needed, &returned)) {
941 err = GetLastError();
944 if (err) {
945 sprintf(tmp, "EnumJobs failed level %d on [%s] (buffer size = %d), error: %s\n",
946 level, printername, needed, errstr(err));
947 torture_fail(tctx, tmp);
950 if (tctx->print) {
951 print_job_info_bylevel(level, (LPBYTE)buffer, returned);
954 for (i=0; i < returned; i++) {
955 ret = test_GetJob(tctx, printername, handle, buffer[i].JobId);
958 free(buffer);
960 return ret;
964 /****************************************************************************
965 ****************************************************************************/
967 static BOOL test_OnePrinter(struct torture_context *tctx,
968 LPSTR printername,
969 LPSTR architecture,
970 LPPRINTER_DEFAULTS defaults)
972 HANDLE handle;
973 BOOL ret = TRUE;
975 torture_comment(tctx, "Testing Printer %s", printername);
977 ret &= test_OpenPrinter(tctx, printername, defaults, &handle);
978 ret &= test_GetPrinter(tctx, printername, handle);
979 ret &= test_GetPrinterDriver(tctx, printername, architecture, handle);
980 ret &= test_EnumForms(tctx, printername, handle);
981 ret &= test_EnumJobs(tctx, printername, handle);
982 ret &= test_EachJob(tctx, printername, handle);
983 ret &= test_EnumPrinterKey(tctx, printername, handle, "");
984 ret &= test_EnumPrinterKey(tctx, printername, handle, "PrinterDriverData");
985 ret &= test_EnumPrinterDataEx(tctx, printername, "PrinterDriverData", handle, NULL, NULL);
986 ret &= test_DeviceModes(tctx, printername, handle);
987 ret &= test_PrinterData(tctx, printername, handle);
988 ret &= test_ClosePrinter(tctx, handle);
990 return ret;
993 /****************************************************************************
994 ****************************************************************************/
996 static BOOL test_EachPrinter(struct torture_context *tctx,
997 LPSTR servername,
998 LPSTR architecture,
999 LPPRINTER_DEFAULTS defaults)
1001 DWORD needed = 0;
1002 DWORD returned = 0;
1003 DWORD err = 0;
1004 char tmp[1024];
1005 DWORD i;
1006 DWORD flags = PRINTER_ENUM_NAME;
1007 PPRINTER_INFO_1 buffer = NULL;
1008 BOOL ret = TRUE;
1010 torture_comment(tctx, "Testing EnumPrinters level %d", 1);
1012 EnumPrinters(flags, servername, 1, NULL, 0, &needed, &returned);
1013 err = GetLastError();
1014 if (err == ERROR_INSUFFICIENT_BUFFER) {
1015 err = 0;
1016 buffer = (PPRINTER_INFO_1)malloc(needed);
1017 torture_assert(tctx, buffer, "malloc failed");
1018 if (!EnumPrinters(flags, servername, 1, (LPBYTE)buffer, needed, &needed, &returned)) {
1019 err = GetLastError();
1022 if (err) {
1023 sprintf(tmp, "EnumPrinters failed level %d on [%s] (buffer size = %d), error: %s\n",
1024 1, servername, needed, errstr(err));
1025 torture_fail(tctx, tmp);
1028 for (i=0; i < returned; i++) {
1029 ret &= test_OnePrinter(tctx, buffer[i].pName, architecture, defaults);
1032 free(buffer);
1034 return ret;
1037 /****************************************************************************
1038 ****************************************************************************/
1040 static BOOL test_GetPrintProcessorDirectory(struct torture_context *tctx,
1041 LPSTR servername,
1042 LPSTR architecture)
1044 DWORD levels[] = { 1 };
1045 DWORD success[] = { 1 };
1046 DWORD i;
1047 LPBYTE buffer = NULL;
1049 for (i=0; i < ARRAY_SIZE(levels); i++) {
1051 DWORD needed = 0;
1052 DWORD err = 0;
1053 char tmp[1024];
1055 torture_comment(tctx, "Testing GetPrintProcessorDirectory level %d", levels[i]);
1057 GetPrintProcessorDirectory(servername, architecture, levels[i], NULL, 0, &needed);
1058 err = GetLastError();
1059 if (err == ERROR_INSUFFICIENT_BUFFER) {
1060 err = 0;
1061 buffer = malloc(needed);
1062 torture_assert(tctx, buffer, "malloc failed");
1063 if (!GetPrintProcessorDirectory(servername, architecture, levels[i], buffer, needed, &needed)) {
1064 err = GetLastError();
1067 if (err) {
1068 sprintf(tmp, "GetPrintProcessorDirectory failed level %d on [%s] (buffer size = %d), error: %s\n",
1069 levels[i], servername, needed, errstr(err));
1070 if (success[i]) {
1071 torture_fail(tctx, tmp);
1072 } else {
1073 torture_warning(tctx, tmp);
1077 if (tctx->print) {
1078 printf("\tPrint Processor Directory\t= %s\n\n", (LPSTR)buffer);
1081 free(buffer);
1082 buffer = NULL;
1085 return TRUE;
1088 /****************************************************************************
1089 ****************************************************************************/
1091 static BOOL test_GetPrinterDriverDirectory(struct torture_context *tctx,
1092 LPSTR servername,
1093 LPSTR architecture)
1095 DWORD levels[] = { 1 };
1096 DWORD success[] = { 1 };
1097 DWORD i;
1098 LPBYTE buffer = NULL;
1100 for (i=0; i < ARRAY_SIZE(levels); i++) {
1102 DWORD needed = 0;
1103 DWORD err = 0;
1104 char tmp[1024];
1106 torture_comment(tctx, "Testing GetPrinterDriverDirectory level %d", levels[i]);
1108 GetPrinterDriverDirectory(servername, architecture, levels[i], NULL, 0, &needed);
1109 err = GetLastError();
1110 if (err == ERROR_INSUFFICIENT_BUFFER) {
1111 err = 0;
1112 buffer = malloc(needed);
1113 torture_assert(tctx, buffer, "malloc failed");
1114 if (!GetPrinterDriverDirectory(servername, architecture, levels[i], buffer, needed, &needed)) {
1115 err = GetLastError();
1118 if (err) {
1119 sprintf(tmp, "GetPrinterDriverDirectory failed level %d on [%s] (buffer size = %d), error: %s\n",
1120 levels[i], servername, needed, errstr(err));
1121 if (success[i]) {
1122 torture_fail(tctx, tmp);
1123 } else {
1124 torture_warning(tctx, tmp);
1128 if (tctx->print) {
1129 printf("\tPrinter Driver Directory\t= %s\n\n", (LPSTR)buffer);
1132 free(buffer);
1133 buffer = NULL;
1136 return TRUE;
1139 /****************************************************************************
1140 ****************************************************************************/
1142 static BOOL test_GetPrinterData(struct torture_context *tctx,
1143 LPSTR servername,
1144 LPSTR valuename,
1145 HANDLE handle,
1146 DWORD *type_p,
1147 LPBYTE *buffer_p,
1148 DWORD *size_p)
1150 LPBYTE buffer = NULL;
1151 DWORD needed = 0;
1152 DWORD type;
1153 DWORD err = 0;
1154 char tmp[1024];
1156 torture_comment(tctx, "Testing GetPrinterData(%s)", valuename);
1158 err = GetPrinterData(handle, valuename, &type, NULL, 0, &needed);
1159 if (err == ERROR_MORE_DATA) {
1160 buffer = (LPBYTE)malloc(needed);
1161 torture_assert(tctx, buffer, "malloc failed");
1162 err = GetPrinterData(handle, valuename, &type, buffer, needed, &needed);
1164 if (err) {
1165 sprintf(tmp, "GetPrinterData(%s) failed on [%s] (buffer size = %d), error: %s\n",
1166 valuename, servername, needed, errstr(err));
1167 torture_fail(tctx, tmp);
1170 if (tctx->print) {
1171 print_printer_data("PrinterDriverData", valuename, needed, buffer, type);
1174 if (type_p) {
1175 *type_p = type;
1178 if (size_p) {
1179 *size_p = needed;
1182 if (buffer_p) {
1183 *buffer_p = buffer;
1184 } else {
1185 free(buffer);
1188 return TRUE;
1191 /****************************************************************************
1192 ****************************************************************************/
1194 static BOOL test_GetPrinterDataEx(struct torture_context *tctx,
1195 LPSTR servername,
1196 LPSTR keyname,
1197 LPSTR valuename,
1198 HANDLE handle,
1199 DWORD *type_p,
1200 LPBYTE *buffer_p,
1201 DWORD *size_p)
1203 LPBYTE buffer = NULL;
1204 DWORD needed = 0;
1205 DWORD type;
1206 DWORD err = 0;
1207 char tmp[1024];
1209 torture_comment(tctx, "Testing GetPrinterDataEx(%s - %s)", keyname, valuename);
1211 err = GetPrinterDataEx(handle, keyname, valuename, &type, NULL, 0, &needed);
1212 if (err == ERROR_MORE_DATA) {
1213 buffer = (LPBYTE)malloc(needed);
1214 torture_assert(tctx, buffer, "malloc failed");
1215 err = GetPrinterDataEx(handle, keyname, valuename, &type, buffer, needed, &needed);
1217 if (err) {
1218 sprintf(tmp, "GetPrinterDataEx(%s) failed on [%s] (buffer size = %d), error: %s\n",
1219 valuename, servername, needed, errstr(err));
1220 torture_fail(tctx, tmp);
1223 if (tctx->print) {
1224 print_printer_data(keyname, valuename, needed, buffer, type);
1227 if (type_p) {
1228 *type_p = type;
1231 if (size_p) {
1232 *size_p = needed;
1235 if (buffer_p) {
1236 *buffer_p = buffer;
1237 } else {
1238 free(buffer);
1241 return TRUE;
1244 /****************************************************************************
1245 ****************************************************************************/
1247 static BOOL test_DeletePrinterDataEx(struct torture_context *tctx,
1248 LPSTR servername,
1249 LPSTR keyname,
1250 LPSTR valuename,
1251 HANDLE handle)
1253 DWORD err = 0;
1254 char tmp[1024];
1256 torture_comment(tctx, "Testing DeletePrinterDataEx(%s - %s)", keyname, valuename);
1258 err = DeletePrinterDataEx(handle, keyname, valuename);
1259 if (err) {
1260 sprintf(tmp, "DeletePrinterDataEx(%s - %s) failed on [%s], error: %s\n",
1261 keyname, valuename, servername, errstr(err));
1262 torture_fail(tctx, tmp);
1265 return TRUE;
1268 /****************************************************************************
1269 ****************************************************************************/
1271 static BOOL test_DeletePrinterKey(struct torture_context *tctx,
1272 LPSTR servername,
1273 LPSTR keyname,
1274 HANDLE handle)
1276 DWORD err = 0;
1277 char tmp[1024];
1279 torture_comment(tctx, "Testing DeletePrinterKey(%s)", keyname);
1281 err = DeletePrinterKey(handle, keyname);
1282 if (err) {
1283 sprintf(tmp, "DeletePrinterKey(%s) failed on [%s], error: %s\n",
1284 keyname, servername, errstr(err));
1285 torture_fail(tctx, tmp);
1288 return TRUE;
1291 /****************************************************************************
1292 ****************************************************************************/
1294 static BOOL test_SetPrinterDataEx(struct torture_context *tctx,
1295 LPSTR servername,
1296 LPSTR keyname,
1297 LPSTR valuename,
1298 HANDLE handle,
1299 DWORD type,
1300 LPBYTE buffer,
1301 DWORD offered)
1303 DWORD err = 0;
1304 char tmp[1024];
1306 torture_comment(tctx, "Testing SetPrinterDataEx(%s - %s)", keyname, valuename);
1308 err = SetPrinterDataEx(handle, keyname, valuename, type, buffer, offered);
1309 if (err) {
1310 sprintf(tmp, "SetPrinterDataEx(%s) failed on [%s] (buffer size = %d), error: %s\n",
1311 valuename, servername, offered, errstr(err));
1312 torture_fail(tctx, tmp);
1315 return TRUE;
1318 /****************************************************************************
1319 ****************************************************************************/
1321 static BOOL test_PrinterData_Server(struct torture_context *tctx,
1322 LPSTR servername,
1323 HANDLE handle)
1325 BOOL ret = TRUE;
1326 DWORD i;
1327 DWORD type, type_ex;
1328 LPBYTE buffer, buffer_ex;
1329 DWORD size, size_ex;
1330 LPSTR valuenames[] = {
1331 SPLREG_DEFAULT_SPOOL_DIRECTORY,
1332 SPLREG_MAJOR_VERSION,
1333 SPLREG_MINOR_VERSION,
1334 SPLREG_DS_PRESENT,
1335 SPLREG_DNS_MACHINE_NAME,
1336 SPLREG_ARCHITECTURE,
1337 SPLREG_OS_VERSION
1340 for (i=0; i < ARRAY_SIZE(valuenames); i++) {
1341 ret &= test_GetPrinterData(tctx, servername, valuenames[i], handle, &type, &buffer, &size);
1342 ret &= test_GetPrinterDataEx(tctx, servername, "random", valuenames[i], handle, &type_ex, &buffer_ex, &size_ex);
1343 torture_assert_int_equal(tctx, type, type_ex, "type mismatch");
1344 torture_assert_int_equal(tctx, size, size_ex, "size mismatch");
1345 torture_assert_mem_equal(tctx, buffer, buffer_ex, size, "buffer mismatch");
1346 free(buffer);
1347 free(buffer_ex);
1350 return ret;
1353 /****************************************************************************
1354 ****************************************************************************/
1356 static BOOL test_PrinterData(struct torture_context *tctx,
1357 LPSTR printername,
1358 HANDLE handle)
1360 LPSTR keyname = "torture_key";
1361 LPSTR valuename = "torture_value";
1362 DWORD type = REG_NONE;
1363 LPBYTE buffer = NULL;
1364 DWORD offered = 0;
1365 BOOL ret = TRUE;
1367 torture_comment(tctx, "Testing PrinterData");
1369 type = REG_SZ;
1370 offered = 4;
1371 buffer = malloc(offered);
1372 if (!buffer) {
1373 return FALSE;
1375 buffer[0] = 'c';
1376 buffer[1] = 'r';
1377 buffer[2] = 'a';
1378 buffer[3] = 'p';
1380 ret &= test_SetPrinterDataEx(tctx, printername, keyname, valuename, handle, type, buffer, offered);
1381 ret &= test_GetPrinterDataEx(tctx, printername, keyname, valuename, handle, NULL, NULL, NULL);
1382 ret &= test_DeletePrinterDataEx(tctx, printername, keyname, valuename, handle);
1383 ret &= test_DeletePrinterKey(tctx, printername, keyname, handle);
1385 free(buffer);
1387 return TRUE;
1390 /****************************************************************************
1391 ****************************************************************************/
1393 const char *get_string_param(const char *str)
1395 const char *p;
1397 p = strchr(str, '=');
1398 if (!p) {
1399 return NULL;
1402 return (p+1);
1405 /****************************************************************************
1406 ****************************************************************************/
1408 int main(int argc, char *argv[])
1410 BOOL ret = FALSE;
1411 LPSTR servername;
1412 LPSTR architecture = "Windows NT x86";
1413 HANDLE server_handle;
1414 PRINTER_DEFAULTS defaults_admin, defaults_use;
1415 struct torture_context *tctx;
1416 int i;
1418 if (argc < 2) {
1419 fprintf(stderr, "usage: %s <name> [print] [samba3] [architecture=ARCHITECTURE]\n\n", argv[0]);
1420 fprintf(stderr, "\t<name> can be a server or printer name URI\n");
1421 fprintf(stderr, "\t[print] will print all data that has been retrieved\n");
1422 fprintf(stderr, "\t from the printserver\n");
1423 fprintf(stderr, "\t[samba3] will skip some tests samba servers are known\n");
1424 fprintf(stderr, "\t not to have implemented\n");
1425 fprintf(stderr, "\t[architecture=X] allows to define a specific\n");
1426 fprintf(stderr, "\t architecture to test with. choose between:\n");
1427 fprintf(stderr, "\t \"Windows NT x86\" or \"Windows x64\"\n");
1428 exit(-1);
1431 tctx = malloc(sizeof(struct torture_context));
1432 if (!tctx) {
1433 fprintf(stderr, "out of memory\n");
1434 exit(-1);
1436 memset(tctx, '\0', sizeof(*tctx));
1438 servername = argv[1];
1440 for (i=1; i < argc; i++) {
1441 if (strcmp(argv[i], "print") == 0) {
1442 tctx->print = TRUE;
1444 if (strcmp(argv[i], "samba3") == 0) {
1445 tctx->samba3 = TRUE;
1447 if (strncmp(argv[i], "architecture", strlen("architecture")) == 0) {
1448 architecture = get_string_param(argv[i]);
1452 printf("Running testsuite with architecture: %s\n", architecture);
1454 defaults_admin.pDatatype = NULL;
1455 defaults_admin.pDevMode = NULL;
1456 defaults_admin.DesiredAccess = PRINTER_ACCESS_ADMINISTER;
1458 defaults_use.pDatatype = NULL;
1459 defaults_use.pDevMode = NULL;
1460 defaults_use.DesiredAccess = PRINTER_ACCESS_USE;
1462 if ((servername[0] == '\\') && (servername[1] == '\\')) {
1463 LPSTR p = servername+2;
1464 LPSTR p2;
1465 if ((p2 = strchr(p, '\\')) != NULL) {
1466 ret = test_OnePrinter(tctx, servername, architecture, &defaults_admin);
1467 goto done;
1471 ret &= test_EnumPrinters(tctx, servername);
1472 ret &= test_EnumDrivers(tctx, servername, architecture);
1473 ret &= test_OpenPrinter(tctx, servername, NULL, &server_handle);
1474 /* ret &= test_EnumPrinterKey(tctx, servername, server_handle, ""); */
1475 ret &= test_PrinterData_Server(tctx, servername, server_handle);
1476 ret &= test_EnumForms(tctx, servername, server_handle);
1477 ret &= test_ClosePrinter(tctx, server_handle);
1478 ret &= test_EnumPorts(tctx, servername);
1479 ret &= test_EnumMonitors(tctx, servername);
1480 ret &= test_EnumPrintProcessors(tctx, servername, architecture);
1481 ret &= test_EnumPrintProcessorDatatypes(tctx, servername);
1482 ret &= test_GetPrintProcessorDirectory(tctx, servername, architecture);
1483 ret &= test_GetPrinterDriverDirectory(tctx, servername, architecture);
1484 ret &= test_EachPrinter(tctx, servername, architecture, &defaults_admin);
1486 done:
1487 if (!ret) {
1488 if (tctx->last_reason) {
1489 fprintf(stderr, "failed: %s\n", tctx->last_reason);
1491 free(tctx);
1492 return -1;
1495 printf("%s run successfully\n", argv[0]);
1497 free(tctx);
1498 return 0;