Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 182 lines (138 sloc) 5.389 kb
08fead5b »
2002-03-05 Added README.TESTING
1 [IMPORTANT NOTICE]
2 ------------------
aba1396f »
2002-03-12 Catch up with recent test scripts changes
3 Do _not_ ask to developers why some or all tests are failed under
08fead5b »
2002-03-05 Added README.TESTING
4 your environment! Let us know if you find why it fails. Thank you.
5
6
aba1396f »
2002-03-12 Catch up with recent test scripts changes
7 [Testing Basics]
8 ----------------
9 To execute test scripts, you must build PHP with some SAPI, then you
10 type "make test" to execute all or some test scripts saved under
08fead5b »
2002-03-05 Added README.TESTING
11 "tests" directory under source root directory.
12
13 Usage:
14 make test
15
16 "make test" basically executes "run-tests.php" script
17 under source root. Therefore you can execute the script
aba1396f »
2002-03-12 Catch up with recent test scripts changes
18 as follows
08fead5b »
2002-03-05 Added README.TESTING
19
3de2e94c »
2002-03-18 -c option is for path.
20 ./sapi/cli/php -c /path/to/php.ini/ run-tests.php [ext/some_extension_name]
08fead5b »
2002-03-05 Added README.TESTING
21
22
23 [Which "php" executable "make test" look for]
24 ---------------------------------------------
96f7bcce »
2002-09-12 Update info and synch example test.
25 You must use TEST_PHP_EXECUTABLE environment variable to explicitly
26 select the php executable to be used to run the tests. That can either
27 be the CLI or CGI executable.
28
aba1396f »
2002-03-12 Catch up with recent test scripts changes
29 "make test" executes "run-tests.php" script with "php" binary. Some
30 test scripts such as session must be executed by CGI SAPI. Therefore,
31 you must build PHP with CGI SAPI to perform all tests.
08fead5b »
2002-03-05 Added README.TESTING
32
aba1396f »
2002-03-12 Catch up with recent test scripts changes
33 NOTE: PHP binary executing "run-tests.php" and php binary used for
34 executing test scripts may differ. If you use different PHP binary for
35 executing "run-tests.php" script, you may get errors.
08fead5b »
2002-03-05 Added README.TESTING
36
37
38 [Which php.ini is used]
39 -----------------------
40 "make test" force to use php.ini-dist as default config file. If
41 you would like to test with other configuration file, user
42 "run-tests.php" script.
43
44 Example:
96f7bcce »
2002-09-12 Update info and synch example test.
45 ./sapi/cli/php -c /path/to/php.ini/ run-tests.php ext/standard
08fead5b »
2002-03-05 Added README.TESTING
46
aba1396f »
2002-03-12 Catch up with recent test scripts changes
47 If you use php.ini other than php.ini-dist, you may see more failed
48 tests.
08fead5b »
2002-03-05 Added README.TESTING
49
50
51 [Which test scripts are executed]
52 ---------------------------------
53 "run-tests.php" ("make test") executes all test scripts by default
54 by looking all directory named "tests". If there are files have "phpt"
55 extension, "run-tests.php" takes test php code from the file and
56 executes it.
57
96f7bcce »
2002-09-12 Update info and synch example test.
58 Tester can easily execute tests selectively with as follows.
08fead5b »
2002-03-05 Added README.TESTING
59
96f7bcce »
2002-09-12 Update info and synch example test.
60 Examples:
3de2e94c »
2002-03-18 -c option is for path.
61 ./sapi/cli/php -c /path/to/php.ini/ run-tests.php ext/mbstring
96f7bcce »
2002-09-12 Update info and synch example test.
62 ./sapi/cli/php -c /path/to/php.ini/ run-tests.php ext/mbstring/020.phpt
08fead5b »
2002-03-05 Added README.TESTING
63
64
65 [Test results]
66 --------------
67 Test results are printed to standard output. If there is a failed test,
68 "run-tests.php" script saves the result, expected result and code
69 executed to the test script directory. For example, if
70 ext/myext/tests/myext.phpt is failed to pass, following files are
71 created:
72
96f7bcce »
2002-09-12 Update info and synch example test.
73 ext/myext/tests/myext.log - log of test execution (L)
74 ext/myext/tests/myext.exp - expected output (E)
75 ext/myext/tests/myext.out - output from test script (O)
76 ext/myext/tests/myext.diff - diff of .out and .exp (D)
08fead5b »
2002-03-05 Added README.TESTING
77
96f7bcce »
2002-09-12 Update info and synch example test.
78 Tester can verify these files, if failed test is actually a bug or not.
79
80 NOTE: The files generated by tests can be selected by setting the
81 environment variable TEST_PHP_LOG_FORMAT. For each file you want to be
82 generated use the character in brackets as shown above (default is LEOD).
83
84 NOTE: You can set environment variable TEST_PHP_DETAILED to enable
85 detailed test information.
08fead5b »
2002-03-05 Added README.TESTING
86
87
88 [Creating new test files]
89 -------------------------
90 Writing test file is very easy if you are used to PHP. Test file
91 has following format. Here is a actual test file from iconv module.
92
93 ===== ext/iconv/002.phpt =======
94 --TEST--
95 UCS4BE to ASCII
96 --SKIPIF--
97 <?php include('skipif.inc'); ?>
98 --FILE--
99 <?php include('002.inc'); ?>
100 --EXPECT--
101 &#97;&#98;&#99;&#100;
102 abcd
103 ===== end of ext/iconv/002.phpt =======
104
96f7bcce »
2002-09-12 Update info and synch example test.
105 As you can see the file has the following sections:
106
08fead5b »
2002-03-05 Added README.TESTING
107 "--TEST--" is title of the test.
96f7bcce »
2002-09-12 Update info and synch example test.
108 "--SKIPIF--" is condition when to skip this test (optional).
109 "--POST--" is POST variable passed to test script (optional).
110 "--GET--" is GET variable passed to test script (optional).
111 "--INI--" each line contains an ini setting e.g. foo=bar (optional).
08fead5b »
2002-03-05 Added README.TESTING
112 "--FILE--" is the test script.
113 "--EXPECT--" is the expected output from the test script.
114
115 ext/iconv/002.phpt uses 2 files. "skipif.inc" is used to skip
116 test when test cannot be performed such as iconv module is not
117 compiled or loaded.
118
119 ==== ext/iconv/skipif.inc ====
120 <?php
121 // This script prints "skip" if condition does not meet.
122
123 if (!extension_loaded("iconv") && ini_get("enable_dl")) {
124 $dlext = (substr(PHP_OS, 0, 3) == "WIN") ? ".dll" : ".so";
125 @dl("iconv$dlext");
126 }
127 if (!extension_loaded("iconv")) {
128 die("skip\n");
129 }
130 ?>
131 ==== end of ext/iconv/skipif.inc ====
132
133 ext/inconv/002.inc is the test script. "run-tests.php" script
134 executes test script with CGI executable.
135
136 ==== ext/iconv/002.inc ===
137 <?php
138 /*
139 Expected output:
140 &#97;&#98;&#99;&#100;
141 abcd
142 */
143
144 $s = unpack("V*", iconv("ascii","UCS-4LE", "abcd"));
145 foreach($s as $c) { print "&#$c;"; } print "\n";
146
147 $s = pack("NNNN", 97, 98, 99, 100);
148 $q = iconv("UCS-4BE", "ascii", $s);
149 print $q; print "\n";
150 ?>
151 === end of ext/iconv/002.inc ===
152
96f7bcce »
2002-09-12 Update info and synch example test.
153 Test script and skipif code may be directly written into *.phpt.
08fead5b »
2002-03-05 Added README.TESTING
154 However, it is recommended to use other files for ease of writing
96f7bcce »
2002-09-12 Update info and synch example test.
155 test scripts.
08fead5b »
2002-03-05 Added README.TESTING
156
157
158 [How to help us]
159 ----------------
160 If you find bug in PHP, you can submit bug report AND test script
161 for us. You don't have to write complete script, just give us test
162 script with following format. Please test the script and make sure
163 you write the correct ACTUAL OUTPUT and EXPECTED OUTPUT before you
164 submit.
165
166 <?php
167 /*
168 Bug #12345
169 substr() bug. Do not return expected string.
170
171 ACTUAL OUTPUT
172 XYXA
173
174 EXPECTED OUTPUT
175 ABCD
176 */
177
178 $str = "XYZABCD";
179 echo substr($str,3,7);
180
181 ?>
Something went wrong with that request. Please try again.