From 030ae6a14e49fda8ca30a2c0e065600c3984081a Mon Sep 17 00:00:00 2001 From: msweet Date: Mon, 9 Aug 2010 22:14:41 +0000 Subject: [PATCH] Merge changes from CUPS 1.5svn-r9229. git-svn-id: svn+ssh://src.apple.com/svn/cups/easysw/current@2468 a1ca3aef-8c08-0410-bb20-df032aa958be --- cups/pwg-file.c | 2 +- cups/testppd.c | 5 + man/ipptool.man | 7 +- man/ipptoolfile.man | 48 +++- man/mantohtml.c | 10 +- scheduler/job.c | 7 +- test/ipptool.c | 545 +++++++++++++++++++++++++++++++++++--------- test/print-job.test | 14 +- 8 files changed, 517 insertions(+), 121 deletions(-) diff --git a/cups/pwg-file.c b/cups/pwg-file.c index a6552e11a..52bac4d3e 100644 --- a/cups/pwg-file.c +++ b/cups/pwg-file.c @@ -598,7 +598,7 @@ _pwgWriteFile(_pwg_t *pwg, /* I - PWG mapping data */ */ for (i = _PWG_OUTPUT_MODE_MONOCHROME; i < _PWG_OUTPUT_MODE_MAX; i ++) - for (j = _PWG_PRINT_QUALITY_DRAFT; i < _PWG_PRINT_QUALITY_MAX; i ++) + for (j = _PWG_PRINT_QUALITY_DRAFT; j < _PWG_PRINT_QUALITY_MAX; j ++) if (pwg->num_presets[i][j]) { cupsFilePrintf(fp, "Preset %d %d", i, j); diff --git a/cups/testppd.c b/cups/testppd.c index 9fe4d562b..bb5567e0f 100644 --- a/cups/testppd.c +++ b/cups/testppd.c @@ -997,6 +997,11 @@ main(int argc, /* I - Number of command-line arguments */ } } + puts("\nSizes:"); + for (i = ppd->num_sizes, size = ppd->sizes; i > 0; i --, size ++) + printf(" %s = %gx%g, [%g %g %g %g]\n", size->name, size->width, + size->length, size->left, size->bottom, size->right, size->top); + puts("\nConstraints:"); for (i = ppd->num_consts, c = ppd->consts; i > 0; i --, c ++) diff --git a/man/ipptool.man b/man/ipptool.man index 89dbf3d52..1e9f59b3c 100644 --- a/man/ipptool.man +++ b/man/ipptool.man @@ -11,12 +11,12 @@ .\" which should have been included with this file. If this file is .\" file is missing or damaged, see the license at "http://www.cups.org/". .\" -.TH ipptool 1 "CUPS" "6 April 2010" "Apple Inc." +.TH ipptool 1 "CUPS" "2 August 2010" "Apple Inc." .SH NAME ipptool - perform internet printing protocol requests .SH SYNOPSIS .B ipptool -[ -C ] [ -E ] [ -L ] [ -S ] [ -V +[ -C ] [ -E ] [ -I ] [ -L ] [ -S ] [ -V .I version ] [ -X ] [ -c ] [ -d .I name=value @@ -43,6 +43,9 @@ Specifies that requests should be sent using the HTTP/1.1 "Transfer-Encoding: ch -E Forces TLS encryption when connecting to the server using the HTTP "Upgrade" header. .TP 5 +-I +Specifies that \fIipptool\fR will continue past errors. +.TP 5 -L Specifies that requests should be sent using the HTTP/1.0 "Content-Length:" header, which is required for conformance by all versions of IPP. The default is to use "Transfer-Encoding: chunked" for requests with attached files and "Content-Length:" for requests without attached files. .TP 5 diff --git a/man/ipptoolfile.man b/man/ipptoolfile.man index 0f59b67ce..3eb02f3dc 100644 --- a/man/ipptoolfile.man +++ b/man/ipptoolfile.man @@ -11,7 +11,7 @@ .\" which should have been included with this file. If this file is .\" file is missing or damaged, see the license at "http://www.cups.org/". .\" -.TH ipptoolfile 5 "CUPS" "6 April 2010" "Apple Inc." +.TH ipptoolfile 5 "CUPS" "6 August 2010" "Apple Inc." .SH NAME ipptoolfile \- ipptool file format @@ -74,6 +74,12 @@ DEFINE variable-name value Defines the named variable to the given value. This is equivalent to specifying "-d variable-name=value" on the \fIipptool\fR command-line. .TP 5 +IGNORE-ERRORS yes +.TP 5 +IGNORE-ERRORS no +Specifies whether, by default, \fIipptool\fR will ignore errors and continue with +subsequent tests. +.TP 5 INCLUDE "filename" .TP 5 INCLUDE @@ -81,6 +87,12 @@ Includes another test file. The first form includes a file relative to the current test file, while the second form includes a file from the \fIipptool\fR include directory. .TP 5 +SKIP-IF-DEFINED variable-name +.TP 5 +SKIP-IF-NOT-DEFINED variable-name +Specifies that the remainder of the test file should be skipped when the +variable is or is not defined. +.TP 5 TRANSFER auto Specifies that tests will, by default, use "Transfer-Encoding: chunked" for requests with attached files and "Content-Length:" for requests without attached @@ -144,6 +156,12 @@ when sending a test print file. GROUP tag Specifies the group tag for subsequent attributes in the request. .TP 5 +IGNORE-ERRORS yes +.TP 5 +IGNORE-ERRORS no +Specifies whether \fIipptool\fR will ignore errors and continue with subsequent +tests. +.TP 5 NAME "literal string" Specifies the human-readable name of the test. .TP 5 @@ -160,6 +178,18 @@ RESOURCE path Specifies an alternate resource path that is used for the HTTP POST request. The default is the resource from the URI provided to the \fIipptool\fR program. .TP 5 +SKIP-IF-DEFINED variable-name +.TP 5 +SKIP-IF-NOT-DEFINED variable-name +Specifies that the current test should be skipped when the variable is or is not +defined. +.TP 5 +SKIP-PREVIOUS-ERROR yes +.TP 5 +SKIP-PREVIOUS-ERROR no +Specifies whether \fIipptool\fR will skip the current test if the previous test +resulted in an error/failure. +.TP 5 STATUS status-code [ predicate ] Specifies an expected response status-code value. Additional requirements can be added as predicates - see the "STATUS PREDICATES" section for more information @@ -193,6 +223,18 @@ The following predicates are understood following the EXPECT test directive: COUNT number Requires the EXPECT attribute to have the specified number of values. .TP 5 +DEFINE-MATCH variable-name +Defines the variable to "1" when the EXPECT condition matches. A side-effect of +this predicate is that this EXPECT will never fail a test. +.TP 5 +DEFINE-NO-MATCH variable-name +Defines the variable to "1" when the EXPECT condition does not match. A side- +effect of this predicate is that this EXPECT will never fail a test. +.TP 5 +DEFINE-VALUE variable-name +Defines the variable to the value of the attribute when the EXPECT condition +matches. +.TP 5 IF-DEFINED variable-name Makes the EXPECT conditions apply only if the specified variable is defined. .TP 5 @@ -299,8 +341,8 @@ RFC 2911 and other IPP extension specifications. Here is a complete list: .fi .SH STATUS CODES -Status codes correspond to the names from RFC 2911 and other IPP extension -specifications. Here is a complete list: +Status codes correspond to the hexadecimal numbers (0xHHHH) and names from RFC +2911 and other IPP extension specifications. Here is a complete list: .nf client-error-attributes-not-settable client-error-attributes-or-values-not-supported diff --git a/man/mantohtml.c b/man/mantohtml.c index b59ddac3e..3c18e82a5 100644 --- a/man/mantohtml.c +++ b/man/mantohtml.c @@ -281,7 +281,7 @@ main(int argc, /* I - Number of command-line args */ * Grab line break... */ - if (list == 1) + if (list == 1) { fputs("\n
", outfile); list = 2; @@ -402,7 +402,7 @@ main(int argc, /* I - Number of command-line args */ * Process the text as if it was in-line... */ - post = "\n
\n
"; + post = "\n
\n
"; goto process_text; } else if (!strncmp(line, ".\\}", 3)) @@ -636,6 +636,12 @@ process_text: fputs(post, outfile); post = NULL; } + + if (list == 1) + { + fputs("\n
", outfile); + list = 2; + } } } diff --git a/scheduler/job.c b/scheduler/job.c index 2d930302b..62b634540 100644 --- a/scheduler/job.c +++ b/scheduler/job.c @@ -3064,7 +3064,7 @@ get_options(cupsd_job_t *job, /* I - Job */ attr->values[0].integer <= IPP_QUALITY_HIGH) print_quality = attr->values[0].integer - IPP_QUALITY_DRAFT; else - print_quality = IPP_QUALITY_NORMAL; + print_quality = _PWG_PRINT_QUALITY_NORMAL; if (pwg->num_presets[output_mode][print_quality] == 0) { @@ -3139,8 +3139,13 @@ get_options(cupsd_job_t *job, /* I - Job */ if (!ippFindAttribute(job->attrs, "PageRegion", IPP_TAG_ZERO) && !ippFindAttribute(job->attrs, "PageSize", IPP_TAG_ZERO) && (ppd = _pwgGetPageSize(pwg, job->attrs, NULL, &exact)) != NULL) + { num_pwgppds = cupsAddOption("PageSize", ppd, num_pwgppds, &pwgppds); + if (!ippFindAttribute(job->attrs, "media", IPP_TAG_ZERO)) + num_pwgppds = cupsAddOption("media", ppd, num_pwgppds, &pwgppds); + } + if (!ippFindAttribute(job->attrs, "OutputBin", IPP_TAG_ZERO) && (attr = ippFindAttribute(job->attrs, "output-bin", IPP_TAG_ZERO)) != NULL && diff --git a/test/ipptool.c b/test/ipptool.c index 689da2416..ac8ee8864 100644 --- a/test/ipptool.c +++ b/test/ipptool.c @@ -82,7 +82,10 @@ typedef struct _cups_expect_s /**** Expected attribute info ****/ *same_count_as, /* Parallel attribute name */ *if_defined, /* Only required if variable defined */ *if_undefined, /* Only required if variable is not defined */ - *with_value; /* Attribute must include this value */ + *with_value, /* Attribute must include this value */ + *define_match, /* Variable to define on match */ + *define_no_match, /* Variable to define on no-match */ + *define_value; /* Variable to define with value */ int with_regex, /* WITH-VALUE is a regular expression */ count; /* Expected count if > 0 */ ipp_tag_t in_group; /* IN-GROUP value */ @@ -123,7 +126,8 @@ _cups_transfer_t Transfer = _CUPS_TRANSFER_AUTO; /* How to transfer requests */ _cups_output_t Output = _CUPS_OUTPUT_LIST; /* Output mode */ -int Verbosity = 0, /* Show all attributes? */ +int IgnoreErrors = 0, /* Ignore errors? */ + Verbosity = 0, /* Show all attributes? */ Version = 11, /* Default IPP version */ XMLHeader = 0; /* 1 if header is written */ const char * const URIStatusStrings[] = /* URI status strings */ @@ -256,6 +260,10 @@ main(int argc, /* I - Number of command-line args */ #endif /* HAVE_SSL */ break; + case 'I' : /* Ignore errors */ + IgnoreErrors = 1; + break; + case 'L' : /* Disable HTTP chunking */ Transfer = _CUPS_TRANSFER_LENGTH; break; @@ -544,8 +552,11 @@ do_tests(_cups_vars_t *vars, /* I - Variables */ int i, /* Looping var */ linenum, /* Current line number */ pass, /* Did we pass the test? */ + prev_pass = 1, /* Did we pass the previous test? */ request_id, /* Current request ID */ - show_header = 1; /* Show the test header? */ + show_header = 1, /* Show the test header? */ + ignore_errors, /* Ignore test failures? */ + skip_previous = 0; /* Skip on previous test failure? */ http_t *http = NULL; /* HTTP connection to server */ FILE *fp = NULL; /* Test file */ char resource[512], /* Resource for request */ @@ -564,7 +575,8 @@ do_tests(_cups_vars_t *vars, /* I - Variables */ char name[1024]; /* Name of test */ char filename[1024]; /* Filename */ _cups_transfer_t transfer; /* To chunk or not to chunk */ - int version; /* IPP version number to use */ + int version, /* IPP version number to use */ + skip_test; /* Skip this test? */ int num_statuses = 0; /* Number of valid status codes */ _cups_status_t statuses[100], /* Valid status codes */ *last_status; /* Last STATUS (for predicates) */ @@ -585,7 +597,8 @@ do_tests(_cups_vars_t *vars, /* I - Variables */ { print_fatal_error("Unable to open test file %s - %s", testfile, strerror(errno)); - goto test_error; + pass = 0; + goto test_exit; } /* @@ -597,7 +610,8 @@ do_tests(_cups_vars_t *vars, /* I - Variables */ { print_fatal_error("Unable to connect to %s on port %d - %s", vars->hostname, vars->port, strerror(errno)); - goto test_error; + pass = 0; + goto test_exit; } /* @@ -632,7 +646,29 @@ do_tests(_cups_vars_t *vars, /* I - Variables */ { print_fatal_error("Missing DEFINE name and/or value on line %d.", linenum); - goto test_error; + pass = 0; + goto test_exit; + } + + continue; + } + else if (!strcmp(token, "IGNORE-ERRORS")) + { + /* + * IGNORE-ERRORS yes + * IGNORE-ERRORS no + */ + + if (get_token(fp, temp, sizeof(temp), &linenum) && + (!strcasecmp(temp, "yes") || !strcasecmp(temp, "no"))) + { + IgnoreErrors = !strcasecmp(temp, "yes"); + } + else + { + print_fatal_error("Missing IGNORE-ERRORS value on line %d.", linenum); + pass = 0; + goto test_exit; } continue; @@ -652,17 +688,60 @@ do_tests(_cups_vars_t *vars, /* I - Variables */ if (!do_tests(vars, get_filename(testfile, filename, temp, sizeof(filename)))) - goto test_error; + { + pass = 0; + + if (!IgnoreErrors) + goto test_exit; + } } else { print_fatal_error("Missing INCLUDE filename on line %d.", linenum); - goto test_error; + pass = 0; + goto test_exit; } show_header = 1; continue; } + else if (!strcmp(token, "SKIP-IF-DEFINED")) + { + /* + * SKIP-IF-DEFINED variable + */ + + if (get_token(fp, temp, sizeof(temp), &linenum)) + { + if (get_variable(vars, temp)) + goto test_exit; + } + else + { + print_fatal_error("Missing SKIP-IF-DEFINED value on line %d.", linenum); + pass = 0; + goto test_exit; + } + } + else if (!strcmp(token, "SKIP-IF-NOT-DEFINED")) + { + /* + * SKIP-IF-NOT-DEFINED variable + */ + + if (get_token(fp, temp, sizeof(temp), &linenum)) + { + if (!get_variable(vars, temp)) + goto test_exit; + } + else + { + print_fatal_error("Missing SKIP-IF-NOT-DEFINED value on line %d.", + linenum); + pass = 0; + goto test_exit; + } + } else if (!strcmp(token, "TRANSFER")) { /* @@ -683,13 +762,15 @@ do_tests(_cups_vars_t *vars, /* I - Variables */ { print_fatal_error("Bad TRANSFER value \"%s\" on line %d.", temp, linenum); - goto test_error; + pass = 0; + goto test_exit; } } else { print_fatal_error("Missing TRANSFER value on line %d.", linenum); - goto test_error; + pass = 0; + goto test_exit; } continue; @@ -711,13 +792,15 @@ do_tests(_cups_vars_t *vars, /* I - Variables */ else { print_fatal_error("Bad VERSION \"%s\" on line %d.", temp, linenum); - goto test_error; + pass = 0; + goto test_exit; } } else { print_fatal_error("Missing VERSION number on line %d.", linenum); - goto test_error; + pass = 0; + goto test_exit; } continue; @@ -725,7 +808,8 @@ do_tests(_cups_vars_t *vars, /* I - Variables */ else if (strcmp(token, "{")) { print_fatal_error("Unexpected token %s seen on line %d.", token, linenum); - goto test_error; + pass = 0; + goto test_exit; } /* @@ -748,9 +832,11 @@ do_tests(_cups_vars_t *vars, /* I - Variables */ request = ippNew(); op = (ipp_op_t)0; group = IPP_TAG_ZERO; + ignore_errors = IgnoreErrors; last_expect = NULL; last_status = NULL; filename[0] = '\0'; + skip_test = 0; version = Version; transfer = Transfer; @@ -765,6 +851,9 @@ do_tests(_cups_vars_t *vars, /* I - Variables */ while (get_token(fp, token, sizeof(token), &linenum) != NULL) { if (strcasecmp(token, "COUNT") && + strcasecmp(token, "DEFINE-MATCH") && + strcasecmp(token, "DEFINE-NO-MATCH") && + strcasecmp(token, "DEFINE-VALUE") && strcasecmp(token, "IF-DEFINED") && strcasecmp(token, "IF-UNDEFINED") && strcasecmp(token, "IN-GROUP") && @@ -802,7 +891,8 @@ do_tests(_cups_vars_t *vars, /* I - Variables */ sizeof(ipp_value_t))) == NULL) { print_fatal_error("Unable to allocate memory on line %d.", linenum); - goto test_error; + pass = 0; + goto test_exit; } if (tempcol != lastcol) @@ -823,7 +913,10 @@ do_tests(_cups_vars_t *vars, /* I - Variables */ lastcol->num_values ++; } else - goto test_error; + { + pass = 0; + goto test_exit; + } } else if (!strcmp(token, "DEFINE")) { @@ -841,9 +934,31 @@ do_tests(_cups_vars_t *vars, /* I - Variables */ { print_fatal_error("Missing DEFINE name and/or value on line %d.", linenum); - goto test_error; + pass = 0; + goto test_exit; } } + else if (!strcmp(token, "IGNORE-ERRORS")) + { + /* + * IGNORE-ERRORS yes + * IGNORE-ERRORS no + */ + + if (get_token(fp, temp, sizeof(temp), &linenum) && + (!strcasecmp(temp, "yes") || !strcasecmp(temp, "no"))) + { + ignore_errors = !strcasecmp(temp, "yes"); + } + else + { + print_fatal_error("Missing IGNORE-ERRORS value on line %d.", linenum); + pass = 0; + goto test_exit; + } + + continue; + } else if (!strcasecmp(token, "NAME")) { /* @@ -869,14 +984,75 @@ do_tests(_cups_vars_t *vars, /* I - Variables */ { print_fatal_error("Bad REQUEST-ID value \"%s\" on line %d.", temp, linenum); - goto test_error; + pass = 0; + goto test_exit; } } else { print_fatal_error("Missing REQUEST-ID value on line %d.", linenum); - goto test_error; + pass = 0; + goto test_exit; + } + } + else if (!strcmp(token, "SKIP-IF-DEFINED")) + { + /* + * SKIP-IF-DEFINED variable + */ + + if (get_token(fp, temp, sizeof(temp), &linenum)) + { + if (get_variable(vars, temp)) + skip_test = 1; + } + else + { + print_fatal_error("Missing SKIP-IF-DEFINED value on line %d.", + linenum); + pass = 0; + goto test_exit; + } + } + else if (!strcmp(token, "SKIP-IF-NOT-DEFINED")) + { + /* + * SKIP-IF-NOT-DEFINED variable + */ + + if (get_token(fp, temp, sizeof(temp), &linenum)) + { + if (!get_variable(vars, temp)) + skip_test = 1; + } + else + { + print_fatal_error("Missing SKIP-IF-NOT-DEFINED value on line %d.", + linenum); + pass = 0; + goto test_exit; + } + } + else if (!strcmp(token, "SKIP-PREVIOUS-ERROR")) + { + /* + * SKIP-PREVIOUS-ERROR yes + * SKIP-PREVIOUS-ERROR no + */ + + if (get_token(fp, temp, sizeof(temp), &linenum) && + (!strcasecmp(temp, "yes") || !strcasecmp(temp, "no"))) + { + skip_previous = !strcasecmp(temp, "yes"); } + else + { + print_fatal_error("Missing SKIP-PREVIOUS-ERROR value on line %d.", linenum); + pass = 0; + goto test_exit; + } + + continue; } else if (!strcmp(token, "TRANSFER")) { @@ -898,13 +1074,15 @@ do_tests(_cups_vars_t *vars, /* I - Variables */ { print_fatal_error("Bad TRANSFER value \"%s\" on line %d.", temp, linenum); - goto test_error; + pass = 0; + goto test_exit; } } else { print_fatal_error("Missing TRANSFER value on line %d.", linenum); - goto test_error; + pass = 0; + goto test_exit; } } else if (!strcasecmp(token, "VERSION")) @@ -926,13 +1104,15 @@ do_tests(_cups_vars_t *vars, /* I - Variables */ else { print_fatal_error("Bad VERSION \"%s\" on line %d.", temp, linenum); - goto test_error; + pass = 0; + goto test_exit; } } else { print_fatal_error("Missing VERSION number on line %d.", linenum); - goto test_error; + pass = 0; + goto test_exit; } } else if (!strcasecmp(token, "RESOURCE")) @@ -944,7 +1124,8 @@ do_tests(_cups_vars_t *vars, /* I - Variables */ if (!get_token(fp, resource, sizeof(resource), &linenum)) { print_fatal_error("Missing RESOURCE path on line %d.", linenum); - goto test_error; + pass = 0; + goto test_exit; } } else if (!strcasecmp(token, "OPERATION")) @@ -956,14 +1137,16 @@ do_tests(_cups_vars_t *vars, /* I - Variables */ if (!get_token(fp, token, sizeof(token), &linenum)) { print_fatal_error("Missing OPERATION code on line %d.", linenum); - goto test_error; + pass = 0; + goto test_exit; } if ((op = ippOpValue(token)) < 0 && (op = strtol(token, NULL, 0)) == 0) { print_fatal_error("Bad OPERATION code \"%s\" on line %d.", token, linenum); - goto test_error; + pass = 0; + goto test_exit; } } else if (!strcasecmp(token, "GROUP")) @@ -975,13 +1158,15 @@ do_tests(_cups_vars_t *vars, /* I - Variables */ if (!get_token(fp, token, sizeof(token), &linenum)) { print_fatal_error("Missing GROUP tag on line %d.", linenum); - goto test_error; + pass = 0; + goto test_exit; } if ((value = ippTagValue(token)) < 0) { print_fatal_error("Bad GROUP tag \"%s\" on line %d.", token, linenum); - goto test_error; + pass = 0; + goto test_exit; } if (value == group) @@ -1000,14 +1185,16 @@ do_tests(_cups_vars_t *vars, /* I - Variables */ if (!get_token(fp, token, sizeof(token), &linenum)) { print_fatal_error("Missing DELAY value on line %d.", linenum); - goto test_error; + pass = 0; + goto test_exit; } if ((delay = atoi(token)) <= 0) { print_fatal_error("Bad DELAY value \"%s\" on line %d.", token, linenum); - goto test_error; + pass = 0; + goto test_exit; } else sleep(delay); @@ -1021,26 +1208,30 @@ do_tests(_cups_vars_t *vars, /* I - Variables */ if (!get_token(fp, token, sizeof(token), &linenum)) { print_fatal_error("Missing ATTR value tag on line %d.", linenum); - goto test_error; + pass = 0; + goto test_exit; } if ((value = ippTagValue(token)) == IPP_TAG_ZERO) { print_fatal_error("Bad ATTR value tag \"%s\" on line %d.", token, linenum); - goto test_error; + pass = 0; + goto test_exit; } if (!get_token(fp, attr, sizeof(attr), &linenum)) { print_fatal_error("Missing ATTR name on line %d.", linenum); - goto test_error; + pass = 0; + goto test_exit; } if (!get_token(fp, temp, sizeof(temp), &linenum)) { print_fatal_error("Missing ATTR value on line %d.", linenum); - goto test_error; + pass = 0; + goto test_exit; } expand_variables(vars, token, temp, sizeof(token)); @@ -1062,8 +1253,8 @@ do_tests(_cups_vars_t *vars, /* I - Variables */ case IPP_TAG_RESOLUTION : { int xres, /* X resolution */ - yres; /* Y resolution */ - char *ptr; /* Pointer into value */ + yres; /* Y resolution */ + char *ptr; /* Pointer into value */ xres = yres = strtol(token, (char **)&ptr, 10); if (ptr > token && xres > 0) @@ -1078,7 +1269,8 @@ do_tests(_cups_vars_t *vars, /* I - Variables */ { print_fatal_error("Bad resolution value \"%s\" on line %d.", token, linenum); - goto test_error; + pass = 0; + goto test_exit; } if (!strcasecmp(ptr, "dpi")) @@ -1110,7 +1302,8 @@ do_tests(_cups_vars_t *vars, /* I - Variables */ { print_fatal_error("Bad rangeOfInteger value \"%s\" on line " "%d.", token, linenum); - goto test_error; + pass = 0; + goto test_exit; } ippAddRanges(request, group, attr, num_vals / 2, lowers, @@ -1130,20 +1323,25 @@ do_tests(_cups_vars_t *vars, /* I - Variables */ ippDelete(col); } else - goto test_error; + { + pass = 0; + goto test_exit; + } } else { print_fatal_error("Bad ATTR collection value on line %d.", linenum); - goto test_error; + pass = 0; + goto test_exit; } break; default : print_fatal_error("Unsupported ATTR value tag %s on line %d.", ippTagString(value), linenum); - goto test_error; + pass = 0; + goto test_exit; case IPP_TAG_TEXTLANG : case IPP_TAG_NAMELANG : @@ -1193,7 +1391,8 @@ do_tests(_cups_vars_t *vars, /* I - Variables */ if (!get_token(fp, temp, sizeof(temp), &linenum)) { print_fatal_error("Missing FILE filename on line %d.", linenum); - goto test_error; + pass = 0; + goto test_exit; } expand_variables(vars, token, temp, sizeof(token)); @@ -1208,20 +1407,24 @@ do_tests(_cups_vars_t *vars, /* I - Variables */ if (num_statuses >= (int)(sizeof(statuses) / sizeof(statuses[0]))) { print_fatal_error("Too many STATUS's on line %d.", linenum); - goto test_error; + pass = 0; + goto test_exit; } if (!get_token(fp, token, sizeof(token), &linenum)) { print_fatal_error("Missing STATUS code on line %d.", linenum); - goto test_error; + pass = 0; + goto test_exit; } - if ((statuses[num_statuses].status = ippErrorValue(token)) < 0) + if ((statuses[num_statuses].status = ippErrorValue(token)) < 0 && + (statuses[num_statuses].status = strtol(token, NULL, 0)) == 0) { print_fatal_error("Bad STATUS code \"%s\" on line %d.", token, linenum); - goto test_error; + pass = 0; + goto test_exit; } last_status = statuses + num_statuses; @@ -1239,13 +1442,15 @@ do_tests(_cups_vars_t *vars, /* I - Variables */ if (num_expects >= (int)(sizeof(expects) / sizeof(expects[0]))) { print_fatal_error("Too many EXPECT's on line %d.", linenum); - goto test_error; + pass = 0; + goto test_exit; } if (!get_token(fp, token, sizeof(token), &linenum)) { print_fatal_error("Missing EXPECT name on line %d.", linenum); - goto test_error; + pass = 0; + goto test_exit; } last_expect = expects + num_expects; @@ -1271,13 +1476,15 @@ do_tests(_cups_vars_t *vars, /* I - Variables */ if (!get_token(fp, token, sizeof(token), &linenum)) { print_fatal_error("Missing COUNT number on line %d.", linenum); - goto test_error; + pass = 0; + goto test_exit; } if ((i = atoi(token)) <= 0) { print_fatal_error("Bad COUNT \"%s\" on line %d.", token, linenum); - goto test_error; + pass = 0; + goto test_exit; } if (last_expect) @@ -1286,7 +1493,68 @@ do_tests(_cups_vars_t *vars, /* I - Variables */ { print_fatal_error("COUNT without a preceding EXPECT on line %d.", linenum); - goto test_error; + pass = 0; + goto test_exit; + } + } + else if (!strcasecmp(token, "DEFINE-MATCH")) + { + if (!get_token(fp, token, sizeof(token), &linenum)) + { + print_fatal_error("Missing DEFINE-MATCH variable on line %d.", + linenum); + pass = 0; + goto test_exit; + } + + if (last_expect) + last_expect->define_match = strdup(token); + else + { + print_fatal_error("DEFINE-MATCH without a preceding EXPECT on line " + "%d.", linenum); + pass = 0; + goto test_exit; + } + } + else if (!strcasecmp(token, "DEFINE-NO-MATCH")) + { + if (!get_token(fp, token, sizeof(token), &linenum)) + { + print_fatal_error("Missing DEFINE-NO-MATCH variable on line %d.", + linenum); + pass = 0; + goto test_exit; + } + + if (last_expect) + last_expect->define_no_match = strdup(token); + else + { + print_fatal_error("DEFINE-NO-MATCH without a preceding EXPECT on " + "line %d.", linenum); + pass = 0; + goto test_exit; + } + } + else if (!strcasecmp(token, "DEFINE-VALUE")) + { + if (!get_token(fp, token, sizeof(token), &linenum)) + { + print_fatal_error("Missing DEFINE-VALUE variable on line %d.", + linenum); + pass = 0; + goto test_exit; + } + + if (last_expect) + last_expect->define_value = strdup(token); + else + { + print_fatal_error("DEFINE-VALUE without a preceding EXPECT on line " + "%d.", linenum); + pass = 0; + goto test_exit; } } else if (!strcasecmp(token, "OF-TYPE")) @@ -1295,7 +1563,8 @@ do_tests(_cups_vars_t *vars, /* I - Variables */ { print_fatal_error("Missing OF-TYPE value tag(s) on line %d.", linenum); - goto test_error; + pass = 0; + goto test_exit; } if (last_expect) @@ -1304,7 +1573,8 @@ do_tests(_cups_vars_t *vars, /* I - Variables */ { print_fatal_error("OF-TYPE without a preceding EXPECT on line %d.", linenum); - goto test_error; + pass = 0; + goto test_exit; } } else if (!strcasecmp(token, "IN-GROUP")) @@ -1315,7 +1585,8 @@ do_tests(_cups_vars_t *vars, /* I - Variables */ if (!get_token(fp, token, sizeof(token), &linenum)) { print_fatal_error("Missing IN-GROUP group tag on line %d.", linenum); - goto test_error; + pass = 0; + goto test_exit; } if ((in_group = ippTagValue(token)) == (ipp_tag_t)-1) @@ -1327,7 +1598,8 @@ do_tests(_cups_vars_t *vars, /* I - Variables */ { print_fatal_error("IN-GROUP without a preceding EXPECT on line %d.", linenum); - goto test_error; + pass = 0; + goto test_exit; } } else if (!strcasecmp(token, "SAME-COUNT-AS")) @@ -1335,7 +1607,8 @@ do_tests(_cups_vars_t *vars, /* I - Variables */ if (!get_token(fp, token, sizeof(token), &linenum)) { print_fatal_error("Missing SAME-COUNT-AS name on line %d.", linenum); - goto test_error; + pass = 0; + goto test_exit; } if (last_expect) @@ -1344,7 +1617,8 @@ do_tests(_cups_vars_t *vars, /* I - Variables */ { print_fatal_error("SAME-COUNT-AS without a preceding EXPECT on line " "%d.", linenum); - goto test_error; + pass = 0; + goto test_exit; } } else if (!strcasecmp(token, "IF-DEFINED")) @@ -1352,7 +1626,8 @@ do_tests(_cups_vars_t *vars, /* I - Variables */ if (!get_token(fp, token, sizeof(token), &linenum)) { print_fatal_error("Missing IF-DEFINED name on line %d.", linenum); - goto test_error; + pass = 0; + goto test_exit; } if (last_expect) @@ -1363,7 +1638,8 @@ do_tests(_cups_vars_t *vars, /* I - Variables */ { print_fatal_error("IF-DEFINED without a preceding EXPECT or STATUS " "on line %d.", linenum); - goto test_error; + pass = 0; + goto test_exit; } } else if (!strcasecmp(token, "IF-UNDEFINED")) @@ -1371,7 +1647,8 @@ do_tests(_cups_vars_t *vars, /* I - Variables */ if (!get_token(fp, token, sizeof(token), &linenum)) { print_fatal_error("Missing IF-UNDEFINED name on line %d.", linenum); - goto test_error; + pass = 0; + goto test_exit; } if (last_expect) @@ -1382,7 +1659,8 @@ do_tests(_cups_vars_t *vars, /* I - Variables */ { print_fatal_error("IF-UNDEFINED without a preceding EXPECT or STATUS " "on line %d.", linenum); - goto test_error; + pass = 0; + goto test_exit; } } else if (!strcasecmp(token, "WITH-VALUE")) @@ -1390,7 +1668,8 @@ do_tests(_cups_vars_t *vars, /* I - Variables */ if (!get_token(fp, token, sizeof(token), &linenum)) { print_fatal_error("Missing WITH-VALUE value on line %d.", linenum); - goto test_error; + pass = 0; + goto test_exit; } if (last_expect) @@ -1421,7 +1700,8 @@ do_tests(_cups_vars_t *vars, /* I - Variables */ { print_fatal_error("WITH-VALUE without a preceding EXPECT on line %d.", linenum); - goto test_error; + pass = 0; + goto test_exit; } } else if (!strcasecmp(token, "DISPLAY")) @@ -1433,13 +1713,15 @@ do_tests(_cups_vars_t *vars, /* I - Variables */ if (num_displayed >= (int)(sizeof(displayed) / sizeof(displayed[0]))) { print_fatal_error("Too many DISPLAY's on line %d", linenum); - goto test_error; + pass = 0; + goto test_exit; } if (!get_token(fp, token, sizeof(token), &linenum)) { print_fatal_error("Missing DISPLAY name on line %d.", linenum); - goto test_error; + pass = 0; + goto test_exit; } displayed[num_displayed] = strdup(token); @@ -1449,7 +1731,8 @@ do_tests(_cups_vars_t *vars, /* I - Variables */ { print_fatal_error("Unexpected token %s seen on line %d.", token, linenum); - goto test_error; + pass = 0; + goto test_exit; } } @@ -1489,6 +1772,27 @@ do_tests(_cups_vars_t *vars, /* I - Variables */ fflush(stdout); } + if ((skip_previous && !prev_pass) || skip_test) + { + ippDelete(request); + request = NULL; + + if (Output == _CUPS_OUTPUT_PLIST) + { + puts("Successful"); + puts(""); + puts("StatusCode"); + print_xml_string("string", "skipped"); + puts("ResponseAttributes"); + puts(""); + puts(""); + } + else if (Output == _CUPS_OUTPUT_TEST) + puts("SKIPPED]"); + + goto skip_error; + } + if (transfer == _CUPS_TRANSFER_CHUNKED || (transfer == _CUPS_TRANSFER_AUTO && filename[0])) { @@ -1532,19 +1836,20 @@ do_tests(_cups_vars_t *vars, /* I - Variables */ else response = cupsDoRequest(http, request, resource); - request = NULL; + request = NULL; + prev_pass = 1; if (!response) - pass = 0; + prev_pass = pass = 0; else { if (http->version != HTTP_1_1) - pass = 0; + prev_pass = pass = 0; if (response->request.status.version[0] != (version / 10) || response->request.status.version[1] != (version % 10) || response->request.status.request_id != request_id) - pass = 0; + prev_pass = pass = 0; if ((attrptr = ippFindAttribute(response, "job-id", IPP_TAG_INTEGER)) != NULL) @@ -1570,7 +1875,7 @@ do_tests(_cups_vars_t *vars, /* I - Variables */ attrptr->group_tag != IPP_TAG_OPERATION || attrptr->num_values != 1 || strcmp(attrptr->name, "attributes-charset")) - pass = 0; + prev_pass = pass = 0; if (attrptr) { @@ -1580,7 +1885,7 @@ do_tests(_cups_vars_t *vars, /* I - Variables */ attrptr->group_tag != IPP_TAG_OPERATION || attrptr->num_values != 1 || strcmp(attrptr->name, "attributes-natural-language")) - pass = 0; + prev_pass = pass = 0; } if ((attrptr = ippFindAttribute(response, "status-message", @@ -1590,7 +1895,7 @@ do_tests(_cups_vars_t *vars, /* I - Variables */ attrptr->num_values != 1 || (attrptr->value_tag == IPP_TAG_TEXT && strlen(attrptr->values[0].string.text) > 255))) - pass = 0; + prev_pass = pass = 0; if ((attrptr = ippFindAttribute(response, "detailed-status-message", IPP_TAG_ZERO)) != NULL && @@ -1599,7 +1904,7 @@ do_tests(_cups_vars_t *vars, /* I - Variables */ attrptr->num_values != 1 || (attrptr->value_tag == IPP_TAG_TEXT && strlen(attrptr->values[0].string.text) > 1023))) - pass = 0; + prev_pass = pass = 0; for (attrptr = response->attrs, group = attrptr->group_tag; attrptr; @@ -1607,13 +1912,13 @@ do_tests(_cups_vars_t *vars, /* I - Variables */ { if (attrptr->group_tag < group && attrptr->group_tag != IPP_TAG_ZERO) { - pass = 0; + prev_pass = pass = 0; break; } if (!validate_attr(attrptr, 0)) { - pass = 0; + prev_pass = pass = 0; break; } } @@ -1633,7 +1938,7 @@ do_tests(_cups_vars_t *vars, /* I - Variables */ } if (i == num_statuses && num_statuses > 0) - pass = 0; + prev_pass = pass = 0; else { for (i = num_expects, expect = expects; i > 0; i --, expect ++) @@ -1652,21 +1957,33 @@ do_tests(_cups_vars_t *vars, /* I - Variables */ (found && expect->in_group && found->group_tag != expect->in_group)) { - pass = 0; - break; + if (expect->define_no_match) + set_variable(vars, expect->define_no_match, "1"); + else if (!expect->define_match) + prev_pass = pass = 0; + + continue; } if (found && !with_value(expect->with_value, expect->with_regex, found)) { - pass = 0; - break; + if (expect->define_no_match) + set_variable(vars, expect->define_no_match, "1"); + else if (!expect->define_match) + prev_pass = pass = 0; + + continue; } if (found && expect->count > 0 && found->num_values != expect->count) { - pass = 0; - break; + if (expect->define_no_match) + set_variable(vars, expect->define_no_match, "1"); + else if (!expect->define_match) + prev_pass = pass = 0; + + continue; } if (found && expect->same_count_as) @@ -1676,10 +1993,23 @@ do_tests(_cups_vars_t *vars, /* I - Variables */ if (!attrptr || attrptr->num_values != found->num_values) { - pass = 0; - break; + if (expect->define_no_match) + set_variable(vars, expect->define_no_match, "1"); + else if (!expect->define_match) + prev_pass = pass = 0; + + continue; } } + + if (found && expect->define_match) + set_variable(vars, expect->define_match, "1"); + + if (found && expect->define_value) + { + _ippAttrString(found, token, sizeof(token)); + set_variable(vars, expect->define_value, token); + } } } } @@ -1687,7 +2017,7 @@ do_tests(_cups_vars_t *vars, /* I - Variables */ if (Output == _CUPS_OUTPUT_PLIST) { puts("Successful"); - puts(pass ? "" : ""); + puts(prev_pass ? "" : ""); puts("StatusCode"); print_xml_string("string", ippErrorString(cupsLastError())); puts("ResponseAttributes"); @@ -1700,7 +2030,7 @@ do_tests(_cups_vars_t *vars, /* I - Variables */ } else if (Output == _CUPS_OUTPUT_TEST) { - puts(pass ? "PASS]" : "FAIL]"); + puts(prev_pass ? "PASS]" : "FAIL]"); if (Verbosity && response) { @@ -1717,11 +2047,11 @@ do_tests(_cups_vars_t *vars, /* I - Variables */ } } } - else if (!pass) + else if (!prev_pass) fprintf(stderr, "%s\n", cupsLastErrorString()); - if (pass && Output != _CUPS_OUTPUT_PLIST && Output != _CUPS_OUTPUT_QUIET && - !Verbosity && num_displayed > 0) + if (prev_pass && Output != _CUPS_OUTPUT_PLIST && + Output != _CUPS_OUTPUT_QUIET && !Verbosity && num_displayed > 0) { if (Output >= _CUPS_OUTPUT_LIST) { @@ -1787,7 +2117,7 @@ do_tests(_cups_vars_t *vars, /* I - Variables */ } } } - else if (!pass) + else if (!prev_pass) { if (Output == _CUPS_OUTPUT_PLIST) { @@ -1940,6 +2270,9 @@ do_tests(_cups_vars_t *vars, /* I - Variables */ for (i = num_expects, expect = expects; i > 0; i --, expect ++) { + if (expect->define_match || expect->define_no_match) + continue; + if (expect->if_defined && !get_variable(vars, expect->if_defined)) continue; @@ -2005,6 +2338,8 @@ do_tests(_cups_vars_t *vars, /* I - Variables */ if (Output == _CUPS_OUTPUT_PLIST) puts(""); + skip_error: + ippDelete(response); response = NULL; @@ -2030,6 +2365,12 @@ do_tests(_cups_vars_t *vars, /* I - Variables */ free(expect->if_undefined); if (expect->with_value) free(expect->with_value); + if (expect->define_match) + free(expect->define_match); + if (expect->define_no_match) + free(expect->define_no_match); + if (expect->define_value) + free(expect->define_value); } num_expects = 0; @@ -2037,20 +2378,11 @@ do_tests(_cups_vars_t *vars, /* I - Variables */ free(displayed[i]); num_displayed = 0; - if (!pass) + if (!ignore_errors && !prev_pass) break; } - fclose(fp); - httpClose(http); - - return (pass); - - /* - * If we get here there was a fatal test error... - */ - - test_error: + test_exit: if (fp) fclose(fp); @@ -2080,12 +2412,18 @@ do_tests(_cups_vars_t *vars, /* I - Variables */ free(expect->if_undefined); if (expect->with_value) free(expect->with_value); + if (expect->define_match) + free(expect->define_match); + if (expect->define_no_match) + free(expect->define_no_match); + if (expect->define_value) + free(expect->define_value); } for (i = 0; i < num_displayed; i ++) free(displayed[i]); - return (0); + return (pass); } @@ -3317,6 +3655,7 @@ usage(void) "\n" "-C Send requests using chunking (default)\n" "-E Test with TLS encryption.\n" + "-I Ignore errors\n" "-L Send requests using content-length\n" "-S Test with SSL encryption.\n" "-V version Set default IPP version.\n" diff --git a/test/print-job.test b/test/print-job.test index 3f89d1626..a830a1244 100644 --- a/test/print-job.test +++ b/test/print-job.test @@ -1,26 +1,22 @@ # Print a test page using print-job { # The name of the test... - NAME "Print JPEG file using print-job" - - # The resource to use for the POST - # RESOURCE /admin + NAME "Print file using Print-Job" # The operation to use - OPERATION print-job + OPERATION Print-Job # Attributes, starting in the operation group... - GROUP operation + GROUP operation-attributes-tag ATTR charset attributes-charset utf-8 ATTR language attributes-natural-language en ATTR uri printer-uri $uri ATTR name requesting-user-name $user - ATTR mimetype document-format image/jpeg - GROUP job + GROUP job-attributes-tag ATTR integer copies 1 - FILE testfile.jpg + FILE $filename # What statuses are OK? STATUS successful-ok -- 2.39.2