4 Copies all the Zend tests to a temporary directory, runs them in interp mode,
5 then copies the good ones to test/zend/good and the bad ones to test/zend/bad.
17 # Don't even pull these into the repo.
18 # We want runnig the bad tests to still complete.
21 '/ext/sockets/tests/socket_select-wrongparams-1.phpt',
22 '/ext/spl/tests/array_012.phpt',
23 '/ext/spl/tests/observer_003.phpt',
24 '/ext/spl/tests/observer_004.phpt',
25 '/ext/spl/tests/observer_005.phpt',
26 '/ext/spl/tests/observer_006.phpt',
27 '/ext/spl/tests/observer_009.phpt',
28 '/ext/standard/tests/array/array_pad_variation2.phpt',
29 '/ext/standard/tests/file/bug27508.phpt',
30 '/ext/standard/tests/general_functions/sleep_error.phpt',
31 '/ext/standard/tests/general_functions/usleep_error.phpt',
32 '/ext/zlib/tests/gzgetc_basic.phpt',
33 '/ext/zlib/tests/gzgets_basic.phpt',
34 '/tests/func/005a.phpt',
35 '/tests/run-test/test010.phpt',
38 '/Zend/tests/020.phpt',
39 '/Zend/tests/bug35239.phpt',
40 '/Zend/tests/bug54265.phpt',
41 '/Zend/tests/bug55705.phpt',
42 '/Zend/tests/callable_type_hint_001.phpt',
43 '/Zend/tests/callable_type_hint_003.phpt',
44 '/Zend/tests/heredoc_005.phpt',
45 '/Zend/tests/jump13.phpt',
46 '/ext/bz2/tests/004.phpt',
47 '/ext/date/tests/bug50055.phpt',
48 '/ext/gd/tests/crafted_gd2.phpt',
49 '/ext/pcntl/tests/pcntl_exec.phpt',
50 '/ext/pcntl/tests/pcntl_exec_2.phpt',
51 '/ext/pcntl/tests/pcntl_exec_3.phpt',
52 '/ext/session/tests/bug61728.phpt',
53 '/ext/session/tests/session_module_name_variation2.phpt',
54 '/tests/func/010.phpt',
55 '/tests/lang/bug21820.phpt',
56 '/tests/lang/func_get_arg.003.phpt',
57 '/tests/lang/func_get_args.003.phpt',
58 '/tests/lang/func_num_args.003.phpt',
59 '/tests/lang/operators/divide_basiclong_64bit.phpt',
60 '/tests/lang/operators/modulus_basiclong_64bit.phpt',
62 # intermittent segfaults
63 '/Zend/tests/001.phpt',
64 '/Zend/tests/002.phpt',
65 '/Zend/tests/003.phpt',
67 # spews files until they work
68 '/ext/spl/tests/SplFileInfo_getExtension_basic.phpt',
69 '/ext/spl/tests/SplFileObject_fgetcsv_basic.phpt',
70 '/ext/spl/tests/SplFileObject_fgetcsv_delimiter_basic.phpt',
71 '/ext/spl/tests/SplFileObject_fgetcsv_delimiter_error.phpt',
72 '/ext/spl/tests/SplFileObject_fgetcsv_enclosure_basic.phpt',
73 '/ext/spl/tests/SplFileObject_fgetcsv_enclosure_error.phpt',
74 '/ext/spl/tests/SplFileObject_fgetcsv_escape_basic.phpt',
75 '/ext/spl/tests/SplFileObject_fgetcsv_escape_default.phpt',
76 '/ext/spl/tests/SplFileObject_fgetcsv_escape_error.phpt',
77 '/ext/spl/tests/SplFileObject_getflags_basic.phpt',
78 '/ext/spl/tests/SplFileObject_getflags_error001.phpt',
79 '/ext/spl/tests/SplFileObject_getflags_error002.phpt',
80 '/ext/spl/tests/SplFileObject_rewind_error001.phpt',
81 '/ext/spl/tests/SplFileObject_setCsvControl_basic.phpt',
82 '/ext/spl/tests/SplFileObject_setCsvControl_error001.phpt',
83 '/ext/spl/tests/SplFileObject_setCsvControl_error002.phpt',
84 '/ext/spl/tests/SplFileObject_setCsvControl_variation001.phpt',
85 '/ext/standard/tests/file/fopen_variation14-win32.phpt',
86 '/ext/standard/tests/file/fopen_variation15-win32.phpt',
87 '/ext/standard/tests/file/mkdir_variation5-win32.phpt',
88 '/ext/standard/tests/file/mkdir_variation5-win32.phpt',
89 '/ext/standard/tests/file/readfile_variation4.phpt',
90 '/ext/standard/tests/file/windows_links/bug48746.phpt',
91 '/ext/standard/tests/file/windows_links/bug48746_1.phpt',
92 '/ext/standard/tests/file/windows_links/bug48746_2.phpt',
93 '/ext/xmlwriter/tests/001.phpt',
94 '/ext/xmlwriter/tests/004.phpt',
95 '/ext/xmlwriter/tests/005.phpt',
96 '/ext/xmlwriter/tests/006.phpt',
97 '/ext/xmlwriter/tests/OO_001.phpt',
98 '/ext/xmlwriter/tests/OO_004.phpt',
99 '/ext/xmlwriter/tests/OO_005.phpt',
100 '/ext/xmlwriter/tests/OO_006.phpt',
103 '/ext/xmlwriter/examples/',
105 # not implemented extensions
149 # For mark these as failing
151 # SESSION is bused on husdon
152 '/zend/unset_cv05.php',
153 '/zend/unset_cv06.php',
155 # unpredictable numbers - we need param matching
156 '/ext-date/bug35143.php',
157 '/ext-date/gettimeofday_basic.php',
158 '/ext-date/localtime_basic.php',
159 '/ext-date/time_basic.php',
160 '/ext-openssl/openssl_random_pseudo_bytes.php',
161 '/ext-pcntl/pcntl_fork_basic.php',
162 '/ext-posix/posix_getpgid_basic.php',
163 '/ext-posix/posix_getpgrp_basic.php',
164 '/ext-posix/posix_getpid_basic.php',
165 '/ext-posix/posix_getppid_basic.php',
166 '/ext-posix/posix_getsid_basic.php',
167 '/ext-posix/posix_times.php',
168 '/ext-posix/posix_times_basic.php',
169 '/ext-sockets/socket_getsockname.php',
170 '/ext-standard/array/array_diff_assoc_variation6.php',
171 '/ext-standard/file/fileinode_variation1.php',
172 '/ext-standard/file/filestat.php',
173 '/ext-standard/fstat.php',
174 '/ext-standard/fstat_basic.php',
175 '/ext-standard/general_functions/bug39322.php',
176 '/ext-standard/general_functions/getmypid_basic.php',
177 '/ext-standard/general_functions/getrusage_basic.php',
178 '/ext-standard/touch_basic.php',
179 '/tests-basic/bug29971.php',
181 # not implemented extensions
182 'phar', # this appears in filenames
184 # works in interp but not others
185 '/tests-lang/bug25922.php',
186 '/zend/bug34064.php',
187 '/zend/objects_029.php',
188 '/zend/objects_030.php',
189 '/ext-standard-strings/bug44242.php',
191 # line number is inconsistent on stack overflow
192 '/zend/bug41633_3.php',
195 '/ext-standard-array/array_diff_assoc_variation6.php',
196 '/zend/bug35239.php',
197 '/zend/bug54265.php',
199 # our build machines have no members in group 0...
200 '/ext-posix/posix_getgrgid.php',
203 # Random other files that zend wants
205 '/ext-curl/curl_testdata1.txt',
206 '/ext-curl/curl_testdata2.txt',
207 '/ext-exif/bug48378.jpeg',
209 '/ext-gd/bug37346.gif',
210 '/ext-gd/bug38112.gif',
211 '/ext-gd/bug43121.gif',
212 '/ext-gd/conv_test.gif',
213 '/ext-gd/conv_test.jpeg',
214 '/ext-gd/conv_test.png',
215 '/ext-gd/conv_test.xbm',
219 '/ext-gd/test8859.ttf',
220 '/ext-gd/test_gif.gif',
221 '/ext-intl/ut_common.inc',
222 '/ext-ldap/connect.inc',
223 '/ext-mbstring/common.inc',
224 '/ext-mcrypt/vectors.txt',
225 '/ext-mysql/connect.inc',
226 '/ext-openssl/005_crt.txt',
227 '/ext-openssl/bug37820cert.pem',
228 '/ext-openssl/bug37820key.pem',
229 '/ext-openssl/bug39217cert1.txt',
230 '/ext-openssl/bug39217cert2.txt',
231 '/ext-openssl/cert.crt',
232 '/ext-openssl/openssl.cnf',
233 '/ext-openssl/private.key',
234 '/ext-openssl/public.key',
235 '/ext-pdo/pdo_test.inc',
236 '/ext-pdo_mysql/config.inc',
237 '/ext-pdo_mysql/common.phpt',
238 '/ext-pdo_sqlite/config.inc',
239 '/ext-pdo_sqlite/common.phpt',
240 '/ext-session/save_handler.inc',
241 '/ext-simplexml/bug24392.xml',
242 '/ext-soap-bugs/bug30928.wsdl',
243 '/ext-soap-bugs/bug41337.wsdl',
244 '/ext-soap-bugs/bug42692.wsdl',
245 '/ext-soap-schema/test_schema.inc',
246 '/ext-soap-soap12/soap12-test.inc',
247 '/ext-soap-soap12/soap12-test.wsdl',
248 '/ext-spl/testclass.class.inc',
249 '/ext-sqlite3/new_db.inc',
250 '/ext-sqlite3/stream_test.inc',
251 '/ext-standard-general_functions/004.data',
252 '/ext-standard-array/compare_function.inc',
253 '/ext-standard-class_object/AutoLoaded.inc',
254 '/ext-standard-class_object/AutoInterface.inc',
255 '/ext-standard-class_object/AutoTrait.inc',
256 '/ext-standard-file/test.csv',
257 '/ext-standard-file/test2.csv',
258 '/ext-standard-file/test3.csv',
259 '/ext-standard-file/fopen_include_path.inc',
260 '/ext-standard-general_functions/bug41445.ini',
261 '/ext-standard-image/bug13213.jpg',
262 '/ext-standard-image/246x247.png',
263 '/ext-standard-image/384x385.png',
264 '/ext-standard-image/testAPP.jpg',
265 '/ext-standard-image/test13pix.swf',
266 '/ext-standard-image/test1pix.jpg',
267 '/ext-standard-serialize/autoload_implements.p5c',
268 '/ext-standard-serialize/autoload_interface.p5c',
269 '/ext-xml/xmltest.xml',
270 '/ext-xmlreader/012.dtd',
271 '/ext-xmlreader/012.xml',
272 '/ext-xmlreader/dtdexample.dtd',
273 '/ext-xmlreader/relaxNG.rng',
274 '/ext-xmlreader/relaxNG2.rng',
275 '/ext-xmlreader/relaxNG3.rng',
276 '/ext-zlib/004.txt.gz',
277 '/tests-classes/autoload_derived.p5c',
278 '/tests-classes/autoload_implements.p5c',
279 '/tests-classes/autoload_interface.p5c',
280 '/tests-classes/autoload_root.p5c',
281 '/tests-classes/constants_basic_003.inc',
282 '/tests-classes/interface_optional_arg_003.inc',
283 '/tests-lang/015.inc',
284 '/tests-lang/016.inc',
285 '/tests-lang/023-2.inc',
286 '/tests-lang/inc.inc',
287 '/tests-lang/inc_throw.inc',
288 '/tests/quicktester.inc',
289 '/zend/bug54804.inc',
300 # Map strings from one style to another
302 # generic inconsistencies
303 ('Variable passed to ([^\s]+)\(\) is not an array or object',
304 'Invalid operand type was used: expecting an array'),
306 ('bcsqrt\(\): ', ''),
307 ('bcpowmod\(\): ', ''),
310 parser
= argparse
.ArgumentParser()
315 help="zend path to import tests from."
322 help="only import tests whose path matches this regex."
327 help="leave around test/zend/all directory."
333 help="print out extra stuff."
335 args
= parser
.parse_args()
341 except OSError as exc
: # Python >2.5
344 def walk(filename
, source
):
345 dest_filename
= os
.path
.basename(filename
)
346 source_dir
= source
.lower().replace('/tests', '').replace('/', '-')
348 cur_dir
= os
.path
.dirname(__file__
)
349 dest_subdir
= os
.path
.join(cur_dir
, '../test/zend/all', source_dir
)
351 full_dest_filename
= os
.path
.join(dest_subdir
, dest_filename
)
353 # Exactly mirror zend's directories incase some tests depend on random crap.
354 # We'll only move things we want into 'good'
355 shutil
.copyfile(filename
, full_dest_filename
)
357 full_dest_filename
= full_dest_filename
.replace('.phpt', '.php')
359 if not '.phpt' in filename
:
362 print "Importing %s" % filename
364 def split(pattern
, str):
365 return re
.split(r
'\n\s*--'+pattern
+'--\s*\n', str, 1)
367 def parse_headers(zend
):
370 for line
in zend
.split('\n'):
371 header
= re
.match('--([_A-Z]+)--', line
)
373 cur_header
= header
.group(1)
374 sections
[cur_header
] = []
376 sections
[cur_header
].append(line
)
379 sections
= parse_headers(file(filename
).read())
380 for i
in sections
.keys():
381 sections
[i
] = '\n'.join(sections
[i
])
383 unsupported_sections
= ('INI', 'POST_RAW')
384 for name
in unsupported_sections
:
385 if sections
.has_key(name
):
386 print "Unsupported test with section --%s--: " % name
, filename
389 if not sections
.has_key('FILE'):
390 print "Malformed test, no --FILE--: ", filename
393 for key
in ('EXPECT', 'EXPECTF', 'EXPECTREGEX'):
394 if sections
.has_key(key
):
397 # tests are really inconsistent about whitespace
398 exp
= re
.sub(r
'(\r\n|\r|\n)', '\n', exp
.strip())
400 exp
= exp
.replace('in %s on', 'in %s/%s/%s on' %
401 ('hphp/test/zend/all', source_dir
, dest_filename
))
403 # PHP puts a newline in that we don't
404 exp
= exp
.replace('\n\nFatal error:', '\nFatal error:')
405 exp
= exp
.replace('\n\nWarning:', '\nWarning:')
406 exp
= exp
.replace('\n\nNotice:', '\nNotice:')
408 match_rest_of_line
= '%a'
409 if key
== 'EXPECTREGEX':
410 match_rest_of_line
= '.+'
412 exp
= re
.sub(r
'Fatal\\? error\\?:.*',
413 'HipHop Fatal error: '+match_rest_of_line
, exp
)
414 exp
= re
.sub(r
'Warning\\?:.*',
415 'HipHop Warning: '+match_rest_of_line
, exp
)
416 exp
= re
.sub(r
'Notice\\?:.*',
417 'HipHop Notice: '+match_rest_of_line
, exp
)
420 exp
= re
.sub(error
[0], error
[1], exp
)
424 if sections
.has_key('EXPECT'):
425 exp
= sections
['EXPECT']
426 # we use %a for error messages so always write expectf
427 file(full_dest_filename
+'.expectf', 'w').write(exp
)
428 elif sections
.has_key('EXPECTREGEX'):
429 exp
= sections
['EXPECTREGEX']
430 file(full_dest_filename
+'.expectregex', 'w').write(exp
)
431 elif sections
.has_key('EXPECTF'):
432 exp
= sections
['EXPECTF']
433 file(full_dest_filename
+'.expectf', 'w').write(exp
)
435 print "Malformed test, no --EXPECT*--: ", filename
438 test
= sections
['FILE']
440 if sections
.has_key('POST'):
443 '<?php\nparse_str("' + sections
['POST'] + '", $_POST);\n'
445 if sections
.has_key('GET'):
448 '<?php\nparse_str("' + sections
['GET'] + '", $_GET);\n'
450 if sections
.has_key('COOKIE'):
453 '<?php\n$_COOKIE = http_parse_cookie("' +
454 sections
['COOKIE'] + '");\n'
456 if sections
.has_key('ENV'):
457 for line
in sections
['ENV'].split('\n'):
458 boom
= line
.split('=')
459 if len(boom
) == 2 and boom
[0] and boom
[1]:
462 '<?php\n$_ENV[%s] = %s;\n' % (boom
[0], boom
[1])
464 if sections
.has_key('CLEAN'):
465 test
+= sections
['CLEAN']
467 # If you put an exception in here, please send a pull request upstream to
468 # php-src. Then when it gets merged kill your hack.
469 if 'bug60771.php' in full_dest_filename
:
470 test
= test
.replace("?>", "unlink('test.php');\n?>")
471 if 'bug44805.php' in full_dest_filename
:
472 test
= test
.replace("1)) {\n\tunlink($file2", "2)) {\n\tunlink($file2")
473 if 'bug24054.php' in full_dest_filename
:
474 test
= test
.replace("quicktester.inc", "tests/quicktester.inc")
475 if 'ext-bz2/with_strings.php' in full_dest_filename
:
476 test
= test
.replace("../..", "")
477 if 'ext-bz2/bug51997.php' in full_dest_filename
:
478 test
= test
.replace("testfile.bz2", "bug51997.bz2")
479 if 'ext-bz2/with_files.php' in full_dest_filename
:
480 test
= test
.replace("testfile.bz2", "with_files.bz2")
481 if 'ext-xmlreader/003.php' in full_dest_filename
:
482 test
= test
.replace("_002.xml", "_003.xml")
483 if 'ext-xmlreader/004.php' in full_dest_filename
:
484 test
= test
.replace("_002.xml", "_004.xml")
485 if 'ext-standard-file/bug45181.php' in full_dest_filename
:
486 test
= test
.replace('rmdir("bug45181_x");',
487 'chdir("..");\nrmdir("bug45181_x");')
488 if 'bug61139.php' in full_dest_filename
:
489 test
+= "\nunlink('someFile');\n?>"
490 if '/ext-pdo_' in full_dest_filename
:
491 test
= test
.replace('/../../../ext/pdo/tests/pdo_test.inc',
492 '/../ext-pdo/pdo_test.inc')
493 if '/ext-zlib/gzseek_variation7.php' in full_dest_filename
:
494 test
= test
.replace('temp3.txt.gz', 'gzseek_variation7.gz')
495 if '/ext-zlib/gzseek_basic2.php' in full_dest_filename
:
496 test
= test
.replace('temp3.txt.gz', 'gzseek_basic2.gz')
497 if '/ext-zlib/gzseek_variation1.php' in full_dest_filename
:
498 test
= test
.replace('temp3.txt.gz', 'gzseek_variation1.gz')
499 if '/ext-zlib/gzseek_variation4.php' in full_dest_filename
:
500 test
= test
.replace('temp3.txt.gz', 'gzseek_variation4.gz')
501 if '/ext-zlib/gzseek_variation5.php' in full_dest_filename
:
502 test
= test
.replace('temp3.txt.gz', 'gzseek_variation5.gz')
503 if '/ext-standard-strings/vfprintf_' in full_dest_filename
:
504 test
= test
.replace('dump.txt', dest_filename
+ '.txt')
505 if '/ext-standard-file/touch_basic.php' in full_dest_filename
:
506 test
= test
.replace('touch.dat', 'touch_basic.dat')
507 if '/ext-standard-file/touch_variation2.php' in full_dest_filename
:
508 test
= test
.replace('touch.dat', 'touch_variation2.dat')
509 if '/ext-standard-file/file_put_contents_variation9.php' in full_dest_filename
:
510 test
= test
.replace('fileGetContentsVar9', 'filePutContentsVar9')
511 if '/ext-standard-network/tcp4loop.php' in full_dest_filename
:
512 test
= test
.replace('31337', '31338')
513 if '/ext-standard-file/fpassthru_variation.php' in full_dest_filename
:
514 test
= test
.replace('passthru.tmp', 'fpassthru_variation.tmp')
516 file(full_dest_filename
, 'w').write(test
)
519 test_dirs
= (('Zend/tests'), ('tests'), ('sapi'), ('ext'))
520 def should_import(filename
):
521 for bad
in no_import
:
526 for source
in test_dirs
:
527 for root
, dirs
, files
in os
.walk(os
.path
.join(args
.zend_path
, source
)):
528 for filename
in files
:
529 full_file
= os
.path
.join(root
, filename
)
531 def matches(regexes
):
534 for regex
in regexes
:
535 if re
.search(regex
, full_file
):
539 if matches(args
.only
) and should_import(full_file
):
540 walk(full_file
, root
.replace(args
.zend_path
, ''))
542 if not os
.path
.isdir('test/zend/all'):
544 print "No test/zend/all. Maybe no tests were imported?"
547 print "Running all tests from test/zend/bad"
548 shutil
.copytree('test/zend/bad', 'test/zend/all')
550 print "Running all tests from zend/all"
552 file('test/zend/hphp_config.hdf', 'w').write('')
553 file('test/zend/config.hdf', 'w').write(
554 'Eval {\n EnableObjDestructCall = true\n }'
557 stdout
= subprocess
.Popen(
559 'tools/verify_to_json.php',
566 stdout
=subprocess
.PIPE
,
567 stderr
=subprocess
.STDOUT
570 # segfaults also print on stderr
571 stdout
= re
.sub('\nsh: line 1:.*', '', stdout
)
572 # fbmake, you are crazy
573 results
= json
.loads('['+stdout
.strip().replace("\n", ",\n")+']')[-1]['results']
579 filename
= test
['name']
580 good_file
= filename
.replace('all', 'good', 1)
581 bad_file
= filename
.replace('all', 'bad', 1)
582 mkdir_p(os
.path
.dirname(good_file
))
583 mkdir_p(os
.path
.dirname(bad_file
))
585 good
= (test
['status'] == 'passed')
586 for test
in bad_tests
:
591 dest_file
= good_file
592 delete_file
= bad_file
596 delete_file
= good_file
599 exps
= glob
.glob(filename
+'.expect*')
601 # this file is probably generated while running tests :(
604 source_file_exp
= exps
[0]
605 _
, dest_ext
= os
.path
.splitext(source_file_exp
)
606 os
.rename(filename
, dest_file
)
607 file(dest_file
+dest_ext
, 'w').write(
608 file(source_file_exp
).read().replace('/all', '/' + subpath
)
610 os
.unlink(source_file_exp
)
611 for f
in glob
.glob(delete_file
+"*"):
614 # extra random files needed for tests...
615 for root
, dirs
, files
in os
.walk('test/zend/all'):
616 for filename
in files
:
617 filename
= os
.path
.join(root
, filename
)
619 for name
in other_files
:
621 dest
= filename
.replace('all', 'good', 1)
622 dir = os
.path
.dirname(dest
)
624 shutil
.copyfile(filename
, dest
)
627 shutil
.rmtree('test/zend/all')