From: msweet Date: Tue, 3 Feb 2015 19:25:57 +0000 (+0000) Subject: Add EXPECT-ALL directive to ipptool (STR #4469) X-Git-Tag: v2.2b1~353 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e83646d5c2831ee4c71f8e6865aeab4b2b8cd1a0;p=thirdparty%2Fcups.git Add EXPECT-ALL directive to ipptool (STR #4469) git-svn-id: svn+ssh://src.apple.com/svn/cups/cups.org/trunk@12484 a1ca3aef-8c08-0410-bb20-df032aa958be --- diff --git a/CHANGES.txt b/CHANGES.txt index 0b938c33a4..915317c40c 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,4 +1,4 @@ -CHANGES.txt - 2.1b1 - 2015-01-27 +CHANGES.txt - 2.1b1 - 2015-02-03 -------------------------------- CHANGES IN CUPS V2.1b1 @@ -14,3 +14,5 @@ CHANGES IN CUPS V2.1b1 configuration changes () - No longer install banner files since third-party banner filters now supply their own (STR #4518) + - Added support for EXPECT-ALL directive in ipptool test files + (STR #4469) diff --git a/doc/help/man-ipptool.html b/doc/help/man-ipptool.html index aba14e5510..7f0dd54965 100644 --- a/doc/help/man-ipptool.html +++ b/doc/help/man-ipptool.html @@ -215,7 +215,7 @@ IANA IPP Registry (http://www.pwg.org/ipp) RFC 2911 (http://tools.ietf.org/html/rfc2911),

Copyright

-Copyright © 2007-2014 by Apple Inc. +Copyright © 2007-2015 by Apple Inc. diff --git a/doc/help/man-ipptoolfile.html b/doc/help/man-ipptoolfile.html index 3fffb25f11..b7cb09c835 100644 --- a/doc/help/man-ipptoolfile.html +++ b/doc/help/man-ipptoolfile.html @@ -131,6 +131,9 @@ test report.
EXPECT ?attribute-name predicate(s)
EXPECT !attribute-name
Specifies that the response must/may/must not include the named attribute. Additional requirements can be added as predicates - see the "EXPECT PREDICATES" section for more information on predicates. Attribute names can specify member attributes by separating the attribute and member names with the forward slash, for example "media-col/media-size/x-dimension". +
EXPECT-ALL attribute-name [ predicate(s) ] +
EXPECT-ALL ?attribute-name predicate(s) +
Specifies that the response must/may include the named attribute and that all occurrences of that attribute must match the given predicates.
FILE filename
Specifies a file to include at the end of the request. This is typically used when sending a test print file.
GROUP tag @@ -495,7 +498,7 @@ IANA IPP Registry ( PWG Internet Printing Protocol Workgroup (http://www.pwg.org/ipp), RFC 2911 (http://tools.ietf.org/html/rfc3911)

Copyright

-Copyright © 2007-2014 by Apple Inc. +Copyright © 2007-2015 by Apple Inc. diff --git a/man/ipptool.man b/man/ipptool.man index 9fa9f05d45..9c9410c023 100644 --- a/man/ipptool.man +++ b/man/ipptool.man @@ -3,7 +3,7 @@ .\" .\" ipptool man page for CUPS. .\" -.\" Copyright 2010-2014 by Apple Inc. +.\" Copyright 2010-2015 by Apple Inc. .\" .\" These coded instructions, statements, and computer programs are the .\" property of Apple Inc. and are protected by Federal copyright @@ -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 ipptool 1 "CUPS" "29 August 2014" "Apple Inc." +.TH ipptool 1 "CUPS" "3 February 2015" "Apple Inc." .SH NAME ipptool \- perform internet printing protocol requests .SH SYNOPSIS @@ -242,7 +242,7 @@ IANA IPP Registry (http://www.iana.org/assignments/ipp\-registrations), PWG Internet Printing Protocol Workgroup (http://www.pwg.org/ipp) RFC 2911 (http://tools.ietf.org/html/rfc2911), .SH COPYRIGHT -Copyright \[co] 2007-2014 by Apple Inc. +Copyright \[co] 2007-2015 by Apple Inc. .\" .\" End of "$Id$". .\" diff --git a/man/ipptoolfile.man b/man/ipptoolfile.man index c4e9cf40ad..fda8516cec 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" "15 May 2014" "Apple Inc." +.TH ipptoolfile 5 "CUPS" "3 February 2015" "Apple Inc." .SH NAME ipptoolfile \- ipptool file format .SH DESCRIPTION @@ -168,6 +168,11 @@ test report. \fBEXPECT !\fIattribute-name\fR Specifies that the response must/may/must not include the named attribute. Additional requirements can be added as predicates - see the "EXPECT PREDICATES" section for more information on predicates. Attribute names can specify member attributes by separating the attribute and member names with the forward slash, for example "media\-col/media\-size/x\-dimension". .TP 5 +\fBEXPECT-ALL \fIattribute-name \fR[ \fIpredicate(s) \fR] +.TP 5 +\fBEXPECT-ALL ?\fIattribute-name predicate(s)\fR +Specifies that the response must/may include the named attribute and that all occurrences of that attribute must match the given predicates. +.TP 5 \fBFILE filename\fR Specifies a file to include at the end of the request. This is typically used when sending a test print file. .TP 5 @@ -610,7 +615,7 @@ IANA IPP Registry (http://www.iana.org/assignments/ipp-registrations), PWG Internet Printing Protocol Workgroup (http://www.pwg.org/ipp), RFC 2911 (http://tools.ietf.org/html/rfc3911) .SH COPYRIGHT -Copyright \[co] 2007-2014 by Apple Inc. +Copyright \[co] 2007-2015 by Apple Inc. .\" .\" End of "$Id$". .\" diff --git a/test/ipptool.c b/test/ipptool.c index b151b89307..c970e73d19 100644 --- a/test/ipptool.c +++ b/test/ipptool.c @@ -70,7 +70,8 @@ typedef enum _cups_with_e /**** WITH flags ****/ typedef struct _cups_expect_s /**** Expected attribute info ****/ { int optional, /* Optional attribute? */ - not_expect; /* Don't expect attribute? */ + not_expect, /* Don't expect attribute? */ + expect_all; /* Expect all attributes to match/not match */ char *name, /* Attribute name */ *of_type, /* Type name */ *same_count_as, /* Parallel attribute name */ @@ -1993,12 +1994,14 @@ do_tests(FILE *outfile, /* I - Output file */ last_status->repeat_match = 0; last_status->repeat_no_match = 0; } - else if (!_cups_strcasecmp(token, "EXPECT")) + else if (!_cups_strcasecmp(token, "EXPECT") || !_cups_strcasecmp(token, "EXPECT-ALL")) { /* * Expected attributes... */ + int expect_all = !_cups_strcasecmp(token, "EXPECT-ALL"); + if (num_expects >= (int)(sizeof(expects) / sizeof(expects[0]))) { print_fatal_error(outfile, "Too many EXPECT's on line %d.", linenum); @@ -2018,6 +2021,7 @@ do_tests(FILE *outfile, /* I - Output file */ memset(last_expect, 0, sizeof(_cups_expect_t)); last_expect->repeat_limit = 1000; + last_expect->expect_all = expect_all; if (token[0] == '!') { @@ -2938,192 +2942,196 @@ do_tests(FILE *outfile, /* I - Output file */ get_variable(vars, expect->if_not_defined)) continue; - found = ippFindAttribute(response, expect->name, IPP_TAG_ZERO); + found = ippFindAttribute(response, expect->name, IPP_TAG_ZERO); - if ((found && expect->not_expect) || - (!found && !(expect->not_expect || expect->optional)) || - (found && !expect_matches(expect, found->value_tag)) || - (found && expect->in_group && - found->group_tag != expect->in_group)) - { - if (expect->define_no_match) - set_variable(outfile, vars, expect->define_no_match, "1"); - else if (!expect->define_match && !expect->define_value) + do + { + if ((found && expect->not_expect) || + (!found && !(expect->not_expect || expect->optional)) || + (found && !expect_matches(expect, found->value_tag)) || + (found && expect->in_group && + found->group_tag != expect->in_group)) { - if (found && expect->not_expect) - add_stringf(errors, "NOT EXPECTED: %s", expect->name); - else if (!found && !(expect->not_expect || expect->optional)) - add_stringf(errors, "EXPECTED: %s", expect->name); - else if (found) + if (expect->define_no_match) + set_variable(outfile, vars, expect->define_no_match, "1"); + else if (!expect->define_match && !expect->define_value) { - if (!expect_matches(expect, found->value_tag)) - add_stringf(errors, "EXPECTED: %s OF-TYPE %s (got %s)", - expect->name, expect->of_type, - ippTagString(found->value_tag)); - - if (expect->in_group && found->group_tag != expect->in_group) - add_stringf(errors, "EXPECTED: %s IN-GROUP %s (got %s).", - expect->name, ippTagString(expect->in_group), - ippTagString(found->group_tag)); - } - } - - if (expect->repeat_no_match && - repeat_count < expect->repeat_limit) - repeat_test = 1; - - continue; - } + if (found && expect->not_expect) + add_stringf(errors, "NOT EXPECTED: %s", expect->name); + else if (!found && !(expect->not_expect || expect->optional)) + add_stringf(errors, "EXPECTED: %s", expect->name); + else if (found) + { + if (!expect_matches(expect, found->value_tag)) + add_stringf(errors, "EXPECTED: %s OF-TYPE %s (got %s)", + expect->name, expect->of_type, + ippTagString(found->value_tag)); + + if (expect->in_group && found->group_tag != expect->in_group) + add_stringf(errors, "EXPECTED: %s IN-GROUP %s (got %s).", + expect->name, ippTagString(expect->in_group), + ippTagString(found->group_tag)); + } + } - if (found) - ippAttributeString(found, buffer, sizeof(buffer)); + if (expect->repeat_no_match && + repeat_count < expect->repeat_limit) + repeat_test = 1; - if (found && - !with_value(outfile, NULL, expect->with_value, expect->with_flags, found, - buffer, sizeof(buffer))) - { - if (expect->define_no_match) - set_variable(outfile, vars, expect->define_no_match, "1"); - else if (!expect->define_match && !expect->define_value && - !expect->repeat_match && !expect->repeat_no_match) - { - if (expect->with_flags & _CUPS_WITH_REGEX) - add_stringf(errors, "EXPECTED: %s %s /%s/", - expect->name, - (expect->with_flags & _CUPS_WITH_ALL) ? - "WITH-ALL-VALUES" : "WITH-VALUE", - expect->with_value); - else - add_stringf(errors, "EXPECTED: %s %s \"%s\"", - expect->name, - (expect->with_flags & _CUPS_WITH_ALL) ? - "WITH-ALL-VALUES" : "WITH-VALUE", - expect->with_value); - - with_value(outfile, errors, expect->with_value, expect->with_flags, found, - buffer, sizeof(buffer)); + break; } - if (expect->repeat_no_match && - repeat_count < expect->repeat_limit) - repeat_test = 1; - - continue; - } + if (found) + ippAttributeString(found, buffer, sizeof(buffer)); - if (found && expect->count > 0 && - found->num_values != expect->count) - { - if (expect->define_no_match) - set_variable(outfile, vars, expect->define_no_match, "1"); - else if (!expect->define_match && !expect->define_value) + if (found && + !with_value(outfile, NULL, expect->with_value, expect->with_flags, found, + buffer, sizeof(buffer))) { - add_stringf(errors, "EXPECTED: %s COUNT %d (got %d)", expect->name, - expect->count, found->num_values); - } - - if (expect->repeat_no_match && - repeat_count < expect->repeat_limit) - repeat_test = 1; + if (expect->define_no_match) + set_variable(outfile, vars, expect->define_no_match, "1"); + else if (!expect->define_match && !expect->define_value && + !expect->repeat_match && !expect->repeat_no_match) + { + if (expect->with_flags & _CUPS_WITH_REGEX) + add_stringf(errors, "EXPECTED: %s %s /%s/", + expect->name, + (expect->with_flags & _CUPS_WITH_ALL) ? + "WITH-ALL-VALUES" : "WITH-VALUE", + expect->with_value); + else + add_stringf(errors, "EXPECTED: %s %s \"%s\"", + expect->name, + (expect->with_flags & _CUPS_WITH_ALL) ? + "WITH-ALL-VALUES" : "WITH-VALUE", + expect->with_value); + + with_value(outfile, errors, expect->with_value, expect->with_flags, found, + buffer, sizeof(buffer)); + } - continue; - } + if (expect->repeat_no_match && + repeat_count < expect->repeat_limit) + repeat_test = 1; - if (found && expect->same_count_as) - { - attrptr = ippFindAttribute(response, expect->same_count_as, - IPP_TAG_ZERO); + break; + } - if (!attrptr || attrptr->num_values != found->num_values) + if (found && expect->count > 0 && + found->num_values != expect->count) { if (expect->define_no_match) set_variable(outfile, vars, expect->define_no_match, "1"); else if (!expect->define_match && !expect->define_value) { - if (!attrptr) - add_stringf(errors, - "EXPECTED: %s (%d values) SAME-COUNT-AS %s " - "(not returned)", expect->name, - found->num_values, expect->same_count_as); - else if (attrptr->num_values != found->num_values) - add_stringf(errors, - "EXPECTED: %s (%d values) SAME-COUNT-AS %s " - "(%d values)", expect->name, found->num_values, - expect->same_count_as, attrptr->num_values); + add_stringf(errors, "EXPECTED: %s COUNT %d (got %d)", expect->name, + expect->count, found->num_values); } if (expect->repeat_no_match && - repeat_count < expect->repeat_limit) + repeat_count < expect->repeat_limit) repeat_test = 1; - continue; + break; } - } - - if (found && expect->define_match) - set_variable(outfile, vars, expect->define_match, "1"); - if (found && expect->define_value) - { - if (!expect->with_value) + if (found && expect->same_count_as) { - int last = ippGetCount(found) - 1; - /* Last element in attribute */ + attrptr = ippFindAttribute(response, expect->same_count_as, + IPP_TAG_ZERO); - switch (ippGetValueTag(found)) + if (!attrptr || attrptr->num_values != found->num_values) { - case IPP_TAG_ENUM : - case IPP_TAG_INTEGER : - snprintf(buffer, sizeof(buffer), "%d", ippGetInteger(found, last)); - break; - - case IPP_TAG_BOOLEAN : - if (ippGetBoolean(found, last)) - strlcpy(buffer, "true", sizeof(buffer)); - else - strlcpy(buffer, "false", sizeof(buffer)); - break; + if (expect->define_no_match) + set_variable(outfile, vars, expect->define_no_match, "1"); + else if (!expect->define_match && !expect->define_value) + { + if (!attrptr) + add_stringf(errors, + "EXPECTED: %s (%d values) SAME-COUNT-AS %s " + "(not returned)", expect->name, + found->num_values, expect->same_count_as); + else if (attrptr->num_values != found->num_values) + add_stringf(errors, + "EXPECTED: %s (%d values) SAME-COUNT-AS %s " + "(%d values)", expect->name, found->num_values, + expect->same_count_as, attrptr->num_values); + } - case IPP_TAG_RESOLUTION : - { - int xres, /* Horizontal resolution */ - yres; /* Vertical resolution */ - ipp_res_t units; /* Resolution units */ + if (expect->repeat_no_match && + repeat_count < expect->repeat_limit) + repeat_test = 1; - xres = ippGetResolution(found, last, &yres, &units); + break; + } + } - if (xres == yres) - snprintf(buffer, sizeof(buffer), "%d%s", xres, units == IPP_RES_PER_INCH ? "dpi" : "dpcm"); - else - snprintf(buffer, sizeof(buffer), "%dx%d%s", xres, yres, units == IPP_RES_PER_INCH ? "dpi" : "dpcm"); - } - break; + if (found && expect->define_match) + set_variable(outfile, vars, expect->define_match, "1"); - case IPP_TAG_CHARSET : - case IPP_TAG_KEYWORD : - case IPP_TAG_LANGUAGE : - case IPP_TAG_MIMETYPE : - case IPP_TAG_NAME : - case IPP_TAG_NAMELANG : - case IPP_TAG_TEXT : - case IPP_TAG_TEXTLANG : - case IPP_TAG_URI : - case IPP_TAG_URISCHEME : - strlcpy(buffer, ippGetString(found, last, NULL), sizeof(buffer)); - break; + if (found && expect->define_value) + { + if (!expect->with_value) + { + int last = ippGetCount(found) - 1; + /* Last element in attribute */ - default : - ippAttributeString(found, buffer, sizeof(buffer)); - break; + switch (ippGetValueTag(found)) + { + case IPP_TAG_ENUM : + case IPP_TAG_INTEGER : + snprintf(buffer, sizeof(buffer), "%d", ippGetInteger(found, last)); + break; + + case IPP_TAG_BOOLEAN : + if (ippGetBoolean(found, last)) + strlcpy(buffer, "true", sizeof(buffer)); + else + strlcpy(buffer, "false", sizeof(buffer)); + break; + + case IPP_TAG_RESOLUTION : + { + int xres, /* Horizontal resolution */ + yres; /* Vertical resolution */ + ipp_res_t units; /* Resolution units */ + + xres = ippGetResolution(found, last, &yres, &units); + + if (xres == yres) + snprintf(buffer, sizeof(buffer), "%d%s", xres, units == IPP_RES_PER_INCH ? "dpi" : "dpcm"); + else + snprintf(buffer, sizeof(buffer), "%dx%d%s", xres, yres, units == IPP_RES_PER_INCH ? "dpi" : "dpcm"); + } + break; + + case IPP_TAG_CHARSET : + case IPP_TAG_KEYWORD : + case IPP_TAG_LANGUAGE : + case IPP_TAG_MIMETYPE : + case IPP_TAG_NAME : + case IPP_TAG_NAMELANG : + case IPP_TAG_TEXT : + case IPP_TAG_TEXTLANG : + case IPP_TAG_URI : + case IPP_TAG_URISCHEME : + strlcpy(buffer, ippGetString(found, last, NULL), sizeof(buffer)); + break; + + default : + ippAttributeString(found, buffer, sizeof(buffer)); + break; + } } - } - set_variable(outfile, vars, expect->define_value, buffer); - } + set_variable(outfile, vars, expect->define_value, buffer); + } - if (found && expect->repeat_match && - repeat_count < expect->repeat_limit) - repeat_test = 1; + if (found && expect->repeat_match && + repeat_count < expect->repeat_limit) + repeat_test = 1; + } + while (expect->expect_all && (found = ippFindNextAttribute(response, expect->name, IPP_TAG_ZERO)) != NULL); } }