Skip to content

Commit

Permalink
Test suite: If holding supported, add a new print job for cancelling
Browse files Browse the repository at this point in the history
On some quicker machines the print-job operation finishes quicker than
we can cancel it in the test - so add job-hold-until job template
attribute if the printer supports it, which will hold the job until it
is cancelled by the next test.

The next test passes because it has both statuses (correct and error one)
as expected, but cupsd generates an additional error in log if the job
cancelling fails, which would be more dirty to cover in run-stp-test.sh.

There is a loophole when the error is still generated - if the printer/machine
is quick enough to finish the job, but the machine/printer doesn't support job
holding at the same time. IMHO the current patch should cover most cases.
  • Loading branch information
zdohnal committed Jan 26, 2024
1 parent b546688 commit 851dc81
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 1 deletion.
42 changes: 42 additions & 0 deletions examples/ipp-1.1.test
Original file line number Diff line number Diff line change
Expand Up @@ -843,6 +843,48 @@ DEFINE IPP_URI_SCHEME "/^ipps?://.+$$/"
}


# Test Print-Job operation with optional job-hold-until job template attribute
#
# Optional by: RFC 8011 section 5.2.2
#
# Needed to hold the job to ensure the next test - cancel-job - passes. On some quicker
# machines the job can finish quicker than we are able to cancel it, which does not fail
# the IPP test because the STATUS is expected, but the count of the caught errors differs.
{
SKIP-IF-NOT-DEFINED OPTIONAL_HOLD_JOB

NAME "RFC 8011 section 5.2.2: Print-Job Operation with optional job-hold-until job template attribute"
OPERATION Print-Job
GROUP operation-attributes-tag
ATTR charset attributes-charset utf-8
ATTR naturalLanguage attributes-natural-language en
ATTR uri printer-uri $uri
ATTR name requesting-user-name $user
ATTR name job-name $filename
ATTR boolean ipp-attribute-fidelity false
ATTR name document-name $filename
ATTR keyword compression none
ATTR keyword job-hold-until indefinite
ATTR mimeMediaType document-format $filetype
FILE $filename

STATUS successful-ok
STATUS client-error-document-format-not-supported
STATUS server-error-job-canceled
STATUS server-error-busy REPEAT-MATCH REPEAT-LIMIT 30

EXPECT job-uri OF-TYPE uri COUNT 1 IN-GROUP job-attributes-tag WITH-VALUE "$IPP_URI_SCHEME"
EXPECT job-id OF-TYPE integer COUNT 1 IN-GROUP job-attributes-tag
WITH-VALUE >0
EXPECT job-state OF-TYPE unknown|enum COUNT 1 IN-GROUP job-attributes-tag
WITH-VALUE 3,4,5,6,7,8,9
EXPECT job-state-reasons OF-TYPE keyword IN-GROUP job-attributes-tag
EXPECT ?job-state-message OF-TYPE text IN-GROUP job-attributes-tag
EXPECT ?number-of-intervening-jobs OF-TYPE integer
IN-GROUP job-attributes-tag WITH-VALUE >-1
}


# Test Cancel-Job operation
#
# Required by: RFC 8011 section 4.3.3
Expand Down
2 changes: 1 addition & 1 deletion test/run-stp-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1049,7 +1049,7 @@ fi

# Requests logged
count=`wc -l $BASE/log/access_log | awk '{print $1}'`
expected=`expr 35 + 18 + 30 + $pjobs \* 8 + $pprinters \* $pjobs \* 4 + 2 + 2 + 5 + 4`
expected=`expr 36 + 18 + 30 + $pjobs \* 8 + $pprinters \* $pjobs \* 4 + 2 + 2 + 5 + 4`
if test $count != $expected; then
echo "FAIL: $count requests logged, expected $expected."
echo " <p>FAIL: $count requests logged, expected $expected.</p>" >>$strfile
Expand Down

0 comments on commit 851dc81

Please sign in to comment.