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.

170 lines
5.8 KiB

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