|
Home About Us A-Z Index Search * Contact Us Register Login Press ShopThe Open Brand -- Problem Reporting and Interpretations System |
Problem Report 0203 Details
Show help | Quick Search | Submit a Test Suite Support Request | Click here to view your privileges
This page provides all information on Problem Report 0203.
Report 0203 Actions
Problem Report Number 0203 Submitter's Classification Test Suite problem State Resolved Resolution Test Suite Deficiency (TSD) Problem Resolution ID TSD.X.0203 Raised 1995-01-06 08:00 Updated 2003-03-13 08:00 Published 1995-01-18 08:00 Product Standard Internationalised System Calls and Libraries (XPG4) Certification Program The Open Brand certification program Test Suite VSX4 version 4.3.4 Test Identification XPG4.os/genuts/getopt 1 Problem Summary TSD4.203 The VSX4 suite is expecting optind to only be incremented by 1 when an option is missing an operand. Our implementation is incrementing optind by 2 which we believe is consistent with XPG4: "The {geto... Problem Text
The VSX4 suite is expecting optind to only be incremented by 1 when an
option is missing an operand. Our implementation is incrementing
optind by 2 which we believe is consistent with XPG4:
"The {getopt()} function returns the next option character (if one
is found) from {argv} that matches a character in {optstring}, if
there is one that matches. If the option takes an argument,
{getopt()} sets the variable {optarg} to point to the
option-argument as follows:
1. If the option was the last character in the string pointed
to by an element of {argv}, then {optind} is incremented by
2. If the resulting value of {optind} is not less than
{argc}, this indicates a missing option-argument, and
{getopt()} returns an error indication."
It's a little difficult to tell which situation the second failure is
coming from but the fact that optind is expected to be 2 tells us that
it must be the second instance of the ":ab:cd:e"/"-ab" test, after the
"-a" option was successfully processed. The input value of 0 for
optind in the second failure is a little deceiving also. The zero is
meant to indicate N/C or "no change", the value is kept from the
previous call to getopt() which we know must be 1 since the first
":ab:cd:e"/"-ab" test passed.
Even though in both failure cases an argument was missing for an
option, we believe getopt() should increment optind by 2 but it really
shouldn't matter. Since there is a missing argument, we known the
input optind must equal argc-1. If optind is incremented is
incremented by any positive value, the result should be the same.
optind is no longer less than argc and the next getopt() will return
-1 indicating there are no more options to parse out. We believe
incrementing by 1 or by 2 should be acceptable, although the standard
indicates optind should be incremented by 2.Test Output
/tset/XPG4.os/genuts/getopt/T.getopt 1 Failed
Test Description:
When the variable opterr is not set to zero and a call to getopt() is
made with optind and the arguments argc, argv, and the option string
optstring as per the table below, then getopt() outputs the
corresponding information, if any, to standard error and returns the
value and sets the variables optind, optarg, and optopt as specified
in the corresponding columns of the table.
optstring Set of optind optarg Return stderr optopt
Arguments In Out
.
.
.
:ab:cd:e -a -d 2 3 NULL : No O/P d
:ab:cd:e -ab 1 1 Unset a No O/P Unset
:ab:cd:e -ab N/C 2 NULL : No O/P b
.
.
.
Test Strategy:
PARENT process will
CREATE [child process|process pair]
CHILD process will
REDIRECT standard error to file
CALL getopt(targc, targv, optstring)
VERIFY that the return value, diagnostics, and variables optind,
optarg and optopt are as expected
Test Information:
getopt() failed when called with :-
optstring : [:ab:cd:e]
arguments : [-a] [-d]
optind : [2]
getopt() failed on the following :-
optind : expected [3], actual [4]
getopt() failed when called with :-
optstring : [:ab:cd:e]
arguments : [-ab]
optind : [0]
getopt() failed on the following :-
optind : expected [2], actual [3]Review Information
Review Type TSMA Review Start Date null Completed null Status Complete Review Recommendation No Resolution Given Review Response
We accept that this is a test suite deficiency and recommend that a
permanent waiver is granted.
We do, however, note that many implementations only increment the optind
value by 1 in the case that the resulting value would be greater than or
equal to the value of argc. This seems to be a reasonable safety mechanism
against badly written applications which fail to check optind before using
it to reference an element in the argv array. We agree that, because of
this, the XSH specification should allow the optind counter to be incremented
by 1 or by 2 in the circumstances that the resulting value of optind would
not be less than argc.
Review Type SA Review Start Date null Completed null Status Complete Review Resolution Test Suite Deficiency (TSD) Review Conclusion
This is an agreed Test Suite Deficiency.
Problem Reporting System Options:
- View Report 0203
- List All PRs
- Search Reports
- Email the System Administrator
- View the The Open Brand Interpretations Database User Manual
Contact the Certification Authority