Skip to content
Newer
Older
100644 184 lines (140 sloc) 5.36 KB
08fead5 Added README.TESTING
Yasuo Ohgaki authored Mar 5, 2002
1 [IMPORTANT NOTICE]
2 ------------------
aba1396 Catch up with recent test scripts changes
Yasuo Ohgaki authored Mar 12, 2002
3 Do _not_ ask to developers why some or all tests are failed under
08fead5 Added README.TESTING
Yasuo Ohgaki authored Mar 5, 2002
4 your environment! Let us know if you find why it fails. Thank you.
5
6
aba1396 Catch up with recent test scripts changes
Yasuo Ohgaki authored Mar 12, 2002
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
08fead5 Added README.TESTING
Yasuo Ohgaki authored Mar 5, 2002
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
aba1396 Catch up with recent test scripts changes
Yasuo Ohgaki authored Mar 12, 2002
18 as follows
08fead5 Added README.TESTING
Yasuo Ohgaki authored Mar 5, 2002
19
3de2e94 -c option is for path.
Yasuo Ohgaki authored Mar 18, 2002
20 ./sapi/cli/php -c /path/to/php.ini/ run-tests.php [ext/some_extension_name]
08fead5 Added README.TESTING
Yasuo Ohgaki authored Mar 5, 2002
21
22
23 [Which "php" executable "make test" look for]
24 ---------------------------------------------
96f7bcc Update info and synch example test.
Marcus Boerger authored Sep 12, 2002
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
aba1396 Catch up with recent test scripts changes
Yasuo Ohgaki authored Mar 12, 2002
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.
08fead5 Added README.TESTING
Yasuo Ohgaki authored Mar 5, 2002
32
aba1396 Catch up with recent test scripts changes
Yasuo Ohgaki authored Mar 12, 2002
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.
08fead5 Added README.TESTING
Yasuo Ohgaki authored Mar 5, 2002
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:
96f7bcc Update info and synch example test.
Marcus Boerger authored Sep 12, 2002
45 ./sapi/cli/php -c /path/to/php.ini/ run-tests.php ext/standard
08fead5 Added README.TESTING
Yasuo Ohgaki authored Mar 5, 2002
46
aba1396 Catch up with recent test scripts changes
Yasuo Ohgaki authored Mar 12, 2002
47 If you use php.ini other than php.ini-dist, you may see more failed
48 tests.
08fead5 Added README.TESTING
Yasuo Ohgaki authored Mar 5, 2002
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
96f7bcc Update info and synch example test.
Marcus Boerger authored Sep 12, 2002
58 Tester can easily execute tests selectively with as follows.
08fead5 Added README.TESTING
Yasuo Ohgaki authored Mar 5, 2002
59
96f7bcc Update info and synch example test.
Marcus Boerger authored Sep 12, 2002
60 Examples:
3de2e94 -c option is for path.
Yasuo Ohgaki authored Mar 18, 2002
61 ./sapi/cli/php -c /path/to/php.ini/ run-tests.php ext/mbstring
96f7bcc Update info and synch example test.
Marcus Boerger authored Sep 12, 2002
62 ./sapi/cli/php -c /path/to/php.ini/ run-tests.php ext/mbstring/020.phpt
08fead5 Added README.TESTING
Yasuo Ohgaki authored Mar 5, 2002
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
32a77ef Update documentation
Marcus Boerger authored Oct 22, 2002
73 ext/myext/tests/myext.php - actual testfile executed
96f7bcc Update info and synch example test.
Marcus Boerger authored Sep 12, 2002
74 ext/myext/tests/myext.log - log of test execution (L)
75 ext/myext/tests/myext.exp - expected output (E)
76 ext/myext/tests/myext.out - output from test script (O)
77 ext/myext/tests/myext.diff - diff of .out and .exp (D)
08fead5 Added README.TESTING
Yasuo Ohgaki authored Mar 5, 2002
78
96f7bcc Update info and synch example test.
Marcus Boerger authored Sep 12, 2002
79 Tester can verify these files, if failed test is actually a bug or not.
80
81 NOTE: The files generated by tests can be selected by setting the
82 environment variable TEST_PHP_LOG_FORMAT. For each file you want to be
83 generated use the character in brackets as shown above (default is LEOD).
32a77ef Update documentation
Marcus Boerger authored Oct 22, 2002
84 The php file will be generated allways.
96f7bcc Update info and synch example test.
Marcus Boerger authored Sep 12, 2002
85
86 NOTE: You can set environment variable TEST_PHP_DETAILED to enable
87 detailed test information.
08fead5 Added README.TESTING
Yasuo Ohgaki authored Mar 5, 2002
88
89
90 [Creating new test files]
91 -------------------------
92 Writing test file is very easy if you are used to PHP. Test file
93 has following format. Here is a actual test file from iconv module.
94
95 ===== ext/iconv/002.phpt =======
96 --TEST--
97 UCS4BE to ASCII
98 --SKIPIF--
99 <?php include('skipif.inc'); ?>
100 --FILE--
101 <?php include('002.inc'); ?>
102 --EXPECT--
103 &#97;&#98;&#99;&#100;
104 abcd
105 ===== end of ext/iconv/002.phpt =======
106
96f7bcc Update info and synch example test.
Marcus Boerger authored Sep 12, 2002
107 As you can see the file has the following sections:
108
08fead5 Added README.TESTING
Yasuo Ohgaki authored Mar 5, 2002
109 "--TEST--" is title of the test.
96f7bcc Update info and synch example test.
Marcus Boerger authored Sep 12, 2002
110 "--SKIPIF--" is condition when to skip this test (optional).
111 "--POST--" is POST variable passed to test script (optional).
112 "--GET--" is GET variable passed to test script (optional).
113 "--INI--" each line contains an ini setting e.g. foo=bar (optional).
08fead5 Added README.TESTING
Yasuo Ohgaki authored Mar 5, 2002
114 "--FILE--" is the test script.
115 "--EXPECT--" is the expected output from the test script.
116
117 ext/iconv/002.phpt uses 2 files. "skipif.inc" is used to skip
118 test when test cannot be performed such as iconv module is not
119 compiled or loaded.
120
121 ==== ext/iconv/skipif.inc ====
122 <?php
123 // This script prints "skip" if condition does not meet.
124
125 if (!extension_loaded("iconv") && ini_get("enable_dl")) {
126 $dlext = (substr(PHP_OS, 0, 3) == "WIN") ? ".dll" : ".so";
127 @dl("iconv$dlext");
128 }
129 if (!extension_loaded("iconv")) {
130 die("skip\n");
131 }
132 ?>
133 ==== end of ext/iconv/skipif.inc ====
134
135 ext/inconv/002.inc is the test script. "run-tests.php" script
136 executes test script with CGI executable.
137
138 ==== ext/iconv/002.inc ===
139 <?php
140 /*
141 Expected output:
142 &#97;&#98;&#99;&#100;
143 abcd
144 */
145
146 $s = unpack("V*", iconv("ascii","UCS-4LE", "abcd"));
147 foreach($s as $c) { print "&#$c;"; } print "\n";
148
149 $s = pack("NNNN", 97, 98, 99, 100);
150 $q = iconv("UCS-4BE", "ascii", $s);
151 print $q; print "\n";
152 ?>
153 === end of ext/iconv/002.inc ===
154
96f7bcc Update info and synch example test.
Marcus Boerger authored Sep 12, 2002
155 Test script and skipif code may be directly written into *.phpt.
08fead5 Added README.TESTING
Yasuo Ohgaki authored Mar 5, 2002
156 However, it is recommended to use other files for ease of writing
96f7bcc Update info and synch example test.
Marcus Boerger authored Sep 12, 2002
157 test scripts.
08fead5 Added README.TESTING
Yasuo Ohgaki authored Mar 5, 2002
158
159
160 [How to help us]
161 ----------------
162 If you find bug in PHP, you can submit bug report AND test script
163 for us. You don't have to write complete script, just give us test
164 script with following format. Please test the script and make sure
165 you write the correct ACTUAL OUTPUT and EXPECTED OUTPUT before you
166 submit.
167
168 <?php
169 /*
170 Bug #12345
171 substr() bug. Do not return expected string.
172
173 ACTUAL OUTPUT
174 XYXA
175
176 EXPECTED OUTPUT
177 ABCD
178 */
179
180 $str = "XYZABCD";
181 echo substr($str,3,7);
182
183 ?>
Something went wrong with that request. Please try again.