Re: [ext/posix/tests/posix_strerror_error.phpt]

From: Date: Sat, 03 May 2008 17:05:32 +0000
Subject: Re: [ext/posix/tests/posix_strerror_error.phpt]
References: 1  Groups: php.qa 
Request: Send a blank email to php-qa+get-64277@lists.php.net to get a copy of this message
Eric Stewart wrote:
The following is a patched version of the ext/posix/tests/posix_strerror_error.phpt test file. Hi Eric - I've tested this on Linux and the result is different. Here is the diff on Linux 64:
014+ string(34) "Unknown error 18446744073709550617" 014- string(%d) "Unknown error: -999" So with the previous %d version this test would have passed on Linux. There are three options now. 1) Use %i - means it will pass on all platforms 2) Make this a separate MAC specific test (with a SKIPIF), and add SKIPIF to the others to make sure they don't get run on Mac. 3) Raise a bug because it's a difference in behaviour My preference is (3), I don't like differences in behaviour :-). If someone decides that it's an acceptable difference then (2 )is the next best. I don't like (1) - it weakens the test on all platforms. Zoe
A quick note to whoever reviews this test for commit: I replaced the %e in the second to last line of the expected output section to -999. As -999 is explicitly passed in it should be the only value passed out, not any possible digit. If you feel this is wrong, then the -999 can be replaced with %i which will also cause the test to pass. This was not the only error in the test file, but it's the only one containing ambiguity. --TEST-- Test posix_strerror() function : error conditions --SKIPIF-- <?php if(!extension_loaded("posix")) print "skip - POSIX extension not loaded"; ?> --FILE-- <?php /* Prototype : proto string posix_strerror(int errno) * Description: Retrieve the system error message associated with the given errno. * Source code: ext/posix/posix.c * Alias to functions: */ echo "*** Testing posix_strerror() : error conditions ***\n"; echo "\n-- Testing posix_strerror() function with Zero arguments --\n"; var_dump( posix_strerror() ); echo "\n-- Testing posix_strerror() function with more than expected no. of arguments --\n"; $errno = posix_get_last_error(); $extra_arg = 10; var_dump( posix_strerror($errno, $extra_arg) ); echo "\n-- Testing posix_strerror() function with invalid error number --\n"; $errno = -999; var_dump( posix_strerror($errno) ); echo "Done"; ?> --EXPECTF-- *** Testing posix_strerror() : error conditions *** -- Testing posix_strerror() function with Zero arguments -- Warning: posix_strerror() expects exactly 1 parameter, 0 given in %s on line %d bool(false) -- Testing posix_strerror() function with more than expected no. of arguments -- Warning: posix_strerror() expects exactly 1 parameter, 2 given in %s on line %d bool(false) -- Testing posix_strerror() function with invalid error number -- string(%d) "Unknown error: -999" Done Eric Stewart e.stewart@mac.com


« previous php.qa (#64277) next »