]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
Add EXPECT-ALL directive to ipptool (STR #4469)
authormsweet <msweet@a1ca3aef-8c08-0410-bb20-df032aa958be>
Tue, 3 Feb 2015 19:25:57 +0000 (19:25 +0000)
committermsweet <msweet@a1ca3aef-8c08-0410-bb20-df032aa958be>
Tue, 3 Feb 2015 19:25:57 +0000 (19:25 +0000)
git-svn-id: svn+ssh://src.apple.com/svn/cups/cups.org/trunk@12484 a1ca3aef-8c08-0410-bb20-df032aa958be

CHANGES.txt
doc/help/man-ipptool.html
doc/help/man-ipptoolfile.html
man/ipptool.man
man/ipptoolfile.man
test/ipptool.c

index 0b938c33a4d6bf025cf2a2ba44a9f2f30dd8476c..915317c40c16f13b80465afc77dbe23f3196d094 100644 (file)
@@ -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 (<rdar://problem/18126570>)
        - 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)
index aba14e5510c5b2ac34292d608f26da54a7570b5d..7f0dd54965d4d67ff8df082b30c36d8a369169f7 100644 (file)
@@ -215,7 +215,7 @@ IANA IPP Registry (<a href="http://www.iana.org/assignments/ipp\-registrations)"
 PWG Internet Printing Protocol Workgroup (<a href="http://www.pwg.org/ipp">http://www.pwg.org/ipp</a>)
 RFC 2911 (<a href="http://tools.ietf.org/html/rfc2911)">http://tools.ietf.org/html/rfc2911)</a>,
 <h2 class="title"><a name="COPYRIGHT">Copyright</a></h2>
-Copyright &copy; 2007-2014 by Apple Inc.
+Copyright &copy; 2007-2015 by Apple Inc.
 
 </body>
 </html>
index 3fffb25f11d85f8fe1c4c083a5dc4bf87c8c8721..b7cb09c835722af24b991da27649b3d74b674e80 100644 (file)
@@ -131,6 +131,9 @@ test report.
 <dd style="margin-left: 5.0em"><dt><b>EXPECT ?</b><i>attribute-name predicate(s)</i>
 <dd style="margin-left: 5.0em"><dt><b>EXPECT !</b><i>attribute-name</i>
 <dd style="margin-left: 5.0em">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".
+<dt><b>EXPECT-ALL </b><i>attribute-name </i>[ <i>predicate(s) </i>]
+<dd style="margin-left: 5.0em"><dt><b>EXPECT-ALL ?</b><i>attribute-name predicate(s)</i>
+<dd style="margin-left: 5.0em">Specifies that the response must/may include the named attribute and that all occurrences of that attribute must match the given predicates.
 <dt><b>FILE filename</b>
 <dd style="margin-left: 5.0em">Specifies a file to include at the end of the request. This is typically used when sending a test print file.
 <dt><b>GROUP tag</b>
@@ -495,7 +498,7 @@ IANA IPP Registry (<a href="http://www.iana.org/assignments/ipp-registrations)">
 PWG Internet Printing Protocol Workgroup (<a href="http://www.pwg.org/ipp)">http://www.pwg.org/ipp)</a>,
 RFC 2911 (<a href="http://tools.ietf.org/html/rfc3911">http://tools.ietf.org/html/rfc3911</a>)
 <h2 class="title"><a name="COPYRIGHT">Copyright</a></h2>
-Copyright &copy; 2007-2014 by Apple Inc.
+Copyright &copy; 2007-2015 by Apple Inc.
 
 </body>
 </html>
index 9fa9f05d452c4442793840b22b707919d9b515a2..9c9410c023fa6de68148d5ff885577298bdc6664 100644 (file)
@@ -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$".
 .\"
index c4e9cf40adb1faa780550b593078b874a1e1c6dd..fda8516cecbcf48b5e011ae6e45d3db56d6f2818 100644 (file)
@@ -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$".
 .\"
index b151b8930704e65abdc6cd56dc3c3148de3b1b57..c970e73d19f4a0cb52f1f8836b46ff19b9d1bcf3 100644 (file)
@@ -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);
        }
       }