You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

179 lines
6.4 KiB

22 years ago
23 years ago
23 years ago
23 years ago
  1. [IMPORTANT NOTICE]
  2. ------------------
  3. Failed tests usualy indicate a problem with your local system setup
  4. and not within PHP itself (at least for official PHP release versions).
  5. You may decide to automaticaly submit a test summary to our QA workflow
  6. at the end of a test run.
  7. Please do *not* submit a failed test as a bug or ask for help on why
  8. it failed on your system without providing substantial backup information
  9. on *why* the test failed on your special setup. Thank you :-)
  10. [Testing Basics]
  11. ----------------
  12. The easiest way to test your PHP build is to run "make test" from the
  13. command line after successfully compiling. This will run the complete
  14. tests for all enabled functionalities and extensions using the PHP
  15. CLI binary.
  16. To execute test scripts, you must build PHP with some SAPI, then you
  17. type "make test" to execute all or some test scripts saved under
  18. "tests" directory under source root directory.
  19. Usage:
  20. make test
  21. "make test" basically executes "run-tests.php" script
  22. under the source root (parallel builds will not work). Therefore you
  23. can execute the script as follows:
  24. TEST_PHP_EXECUTABLE=sapi/cli/php \
  25. sapi/cli/php [-c /path/to/php.ini] run-tests.php [ext/foo/tests/GLOB]
  26. [Which "php" executable "make test" look for]
  27. ---------------------------------------------
  28. You must use TEST_PHP_EXECUTABLE environment variable to explicitly
  29. select the php executable to be used to run the tests. That can either
  30. be the CLI or CGI executable.
  31. "make test" executes "run-tests.php" script with "php" binary. Some
  32. test scripts such as session must be executed by CGI SAPI. Therefore,
  33. you must build PHP with CGI SAPI to perform all tests.
  34. NOTE: PHP binary executing "run-tests.php" and php binary used for
  35. executing test scripts may differ. If you use different PHP binary for
  36. executing "run-tests.php" script, you may get errors.
  37. [Which php.ini is used]
  38. -----------------------
  39. "make test" uses the same php.ini file as it would once installed.
  40. The tests have been written to be independent of that php.ini file,
  41. so if you find a test that is affected by a setting, please report
  42. this, so we can address the issue.
  43. [Which test scripts are executed]
  44. ---------------------------------
  45. "run-tests.php" ("make test"), without any arguments executes all
  46. test scripts by extracting all directories named "tests"
  47. from the source root and any subdirectories below. If there are files,
  48. which have a "phpt" extension, "run-tests.php" looks at the sections
  49. in these files, determines whether it should run it, by evaluating
  50. the 'SKIP' section. If the test is eligible for execution, the 'FILE'
  51. section is extracted into a ".php" file (with the same name besides
  52. the extension) and gets executed.
  53. When an argument is given or TESTS environment variable is set, the
  54. GLOB is expanded by the shell and any file with extension "*.phpt" is
  55. regarded as a test file.
  56. Tester can easily execute tests selectively with as follows.
  57. Examples:
  58. ./sapi/cli/php run-tests.php ext/mbstring/*
  59. ./sapi/cli/php run-tests.php ext/mbstring/020.phpt
  60. [Test results]
  61. --------------
  62. Test results are printed to standard output. If there is a failed test,
  63. the "run-tests.php" script saves the result, the expected result and the
  64. code executed to the test script directory. For example, if
  65. ext/myext/tests/myext.phpt fails to pass, the following files are created:
  66. ext/myext/tests/myext.php - actual test file executed
  67. ext/myext/tests/myext.log - log of test execution (L)
  68. ext/myext/tests/myext.exp - expected output (E)
  69. ext/myext/tests/myext.out - output from test script (O)
  70. ext/myext/tests/myext.diff - diff of .out and .exp (D)
  71. Failed tests are always bugs. Either the test is bugged or not considering
  72. factors applying to the tester's environment, or there is a bug in PHP.
  73. If this is a known bug, we strive to provide bug numbers, in either the
  74. test name or the file name. You can check the status of such a bug, by
  75. going to: http://bugs.php.net/12345 where 12345 is the bug number.
  76. For clarity and automated processing, bug numbers are prefixed by a hash
  77. sign '#' in test names and/or test cases are named bug12345.phpt.
  78. NOTE: The files generated by tests can be selected by setting the
  79. environment variable TEST_PHP_LOG_FORMAT. For each file you want to be
  80. generated use the character in brackets as shown above (default is LEOD).
  81. The php file will be generated always.
  82. NOTE: You can set environment variable TEST_PHP_DETAILED to enable
  83. detailed test information.
  84. [Automated testing]
  85. If you like to keep up to speed, with latest developments and quality
  86. assurance, setting the environment variable NO_INTERACTION to 1, will not
  87. prompt the tester for any user input.
  88. Normally, the exit status of "make test" is zero, regardless of the results
  89. of independent tests. Set the environment variable REPORT_EXIT_STATUS to 1,
  90. and "make test" will set the exit status ("$?") to non-zero, when an
  91. individual test has failed.
  92. Example script to be run by cron(1):
  93. ========== qa-test.sh =============
  94. #!/bin/sh
  95. CO_DIR=$HOME/cvs/php5
  96. MYMAIL=qa-test@domain.com
  97. TMPDIR=/var/tmp
  98. TODAY=`date +"%Y%m%d"`
  99. # Make sure compilation enviroment is correct
  100. CONFIGURE_OPTS='--disable-all --enable-cli --with-pcre'
  101. export MAKE=gmake
  102. export CC=gcc
  103. # Set test environment
  104. export NO_INTERACTION=1
  105. export REPORT_EXIT_STATUS=1
  106. cd $CO_DIR
  107. cvs update . >>$TMPDIR/phpqatest.$TODAY
  108. ./cvsclean ; ./buildconf ; ./configure $CONFIGURE_OPTS ; $MAKE
  109. $MAKE test >>$TMPDIR/phpqatest.$TODAY 2>&1
  110. if test $? -gt 0
  111. then
  112. cat $TMPDIR/phpqatest.$TODAY | mail -s"PHP-QA Test Failed for $TODAY" $MYMAIL
  113. fi
  114. ========== end of qa-test.sh =============
  115. NOTE: the exit status of run-tests.php will be 1 when
  116. REPORT_EXIT_STATUS is set. The result of "make test" may be higher
  117. than that. At present, gmake 3.79.1 returns 2, so it is
  118. advised to test for non-zero, rather then a specific value.
  119. [Creating new test files]
  120. -------------------------
  121. Writing test file is very easy if you are used to PHP.
  122. See the HOWTO at http://qa.php.net/write-test.php
  123. [How to help us]
  124. ----------------
  125. If you find bug in PHP, you can submit bug report AND test script
  126. for us. You don't have to write complete script, just give us test
  127. script with following format. Please test the script and make sure
  128. you write the correct ACTUAL OUTPUT and EXPECTED OUTPUT before you
  129. submit.
  130. <?php
  131. /*
  132. Bug #12345
  133. substr() bug. Do not return expected string.
  134. ACTUAL OUTPUT
  135. XYXA
  136. EXPECTED OUTPUT
  137. ABCD
  138. */
  139. $str = "XYZABCD";
  140. echo substr($str,3,7);
  141. ?>