~ubuntu-branches/ubuntu/lucid/php5/lucid

« back to all changes in this revision

Viewing changes to run-tests.php

  • Committer: Bazaar Package Importer
  • Author(s): Chuck Short
  • Date: 2010-03-16 09:09:50 UTC
  • mfrom: (1.1.18 upstream) (0.3.10 sid)
  • Revision ID: james.westby@ubuntu.com-20100316090950-e36m0pzranoixifd
Tags: 5.3.2-1ubuntu1
* Merge from debian unstable: 
  - debian/control:
    * Dropped firebird2.1-dev, libc-client-dev, libmcrypt-dev as it is in universe.
    * Dropped libmysqlclient15-dev, build against mysql 5.1.
    * Dropped libcurl-dev not in the archive.
    * Suggest php5-suhosin rather than recommends.
    * Dropped php5-imap, php5-interbase, php5-mcrypt since we have versions already in
      universe.
    * Dropped libonig-dev and libqgdbm since its in universe. (will be re-added in lucid+1)
    * Dropped locales-all.
  - modulelist: Drop imap, interbase, and mcrypt.
  - debian/rules:
    * Dropped building of mcrypt, imap, and interbase.
    * Install apport hook for php5.
  - Dropped debian/patches/libedit_is_editline.patch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
4
4
   +----------------------------------------------------------------------+
5
5
   | PHP Version 5, 6                                                     |
6
6
   +----------------------------------------------------------------------+
7
 
   | Copyright (c) 1997-2009 The PHP Group                                |
 
7
   | Copyright (c) 1997-2010 The PHP Group                                |
8
8
   +----------------------------------------------------------------------+
9
9
   | This source file is subject to version 3.01 of the PHP license,      |
10
10
   | that is bundled with this package in the file LICENSE, and is        |
24
24
   +----------------------------------------------------------------------+
25
25
 */
26
26
 
27
 
/* $Id: run-tests.php 286503 2009-07-29 10:06:55Z cellog $ */
 
27
/* $Id: run-tests.php 293036 2010-01-03 09:23:27Z sebastian $ */
28
28
 
29
29
/* Sanity check to ensure that pcre extension needed by this script is available.
30
30
 * In the event it is not, print a nice error message indicating that this script will
80
80
        }       
81
81
}
82
82
 
 
83
// (unicode) is available from 6.0.0
 
84
if (PHP_VERSION_ID < 60000) {
 
85
        define('STRING_TYPE', 'string');
 
86
} else {
 
87
        define('STRING_TYPE', 'unicode');
 
88
}
 
89
 
83
90
// If timezone is not set, use UTC.
84
91
if (ini_get('date.timezone') == '') {
85
92
        date_default_timezone_set('UTC');
355
362
                        if ($sum_results['FAILED']) {
356
363
                                foreach ($PHP_FAILED_TESTS['FAILED'] as $test_info) {
357
364
                                        $failed_tests_data .= $sep . $test_info['name'] . $test_info['info'];
358
 
                                        $failed_tests_data .= $sep . file_get_contents(realpath($test_info['output']));
359
 
                                        $failed_tests_data .= $sep . file_get_contents(realpath($test_info['diff']));
 
365
                                        $failed_tests_data .= $sep . file_get_contents(realpath($test_info['output']), FILE_BINARY);
 
366
                                        $failed_tests_data .= $sep . file_get_contents(realpath($test_info['diff']), FILE_BINARY);
360
367
                                        $failed_tests_data .= $sep . "\n\n";
361
368
                                }
362
369
                                $status = "failed";
634
641
                                        $html_output = is_resource($html_file);
635
642
                                        break;
636
643
                                case '--version':
637
 
                                        echo '$Revision: 286503 $' . "\n";
 
644
                                        echo '$Revision: 293036 $' . "\n";
638
645
                                        exit(1);
639
646
 
640
647
                                default:
1130
1137
        }
1131
1138
}
1132
1139
 
 
1140
function binary_section($section)
 
1141
{
 
1142
        return PHP_MAJOR_VERSION < 6 || 
 
1143
                (
 
1144
                        $section == 'FILE'                      ||
 
1145
                $section == 'FILEEOF'           ||
 
1146
                        $section == 'EXPECT'            ||
 
1147
                        $section == 'EXPECTF'           ||
 
1148
                        $section == 'EXPECTREGEX'       ||
 
1149
                        $section == 'EXPECTHEADERS'     ||
 
1150
                        $section == 'SKIPIF'            ||
 
1151
                        $section == 'CLEAN'
 
1152
                );
 
1153
}
 
1154
 
1133
1155
//
1134
1156
//  Run an individual test case.
1135
1157
//
1159
1181
        // Load the sections of the test file.
1160
1182
        $section_text = array('TEST' => '');
1161
1183
 
1162
 
        $fp = fopen($file, "rt") or error("Cannot open test file: $file");
 
1184
        $fp = fopen($file, "rb") or error("Cannot open test file: $file");
1163
1185
 
1164
1186
        $borked = false;
1165
1187
        $bork_info = '';
1187
1209
        while (!feof($fp)) {
1188
1210
                $line = fgets($fp);
1189
1211
 
 
1212
                if ($line === false) {
 
1213
                        break;
 
1214
                }
 
1215
 
1190
1216
                // Match the beginning of a section.
1191
 
                if (preg_match('/^--([_A-Z]+)--/', $line, $r)) {
 
1217
                if (preg_match(b'/^--([_A-Z]+)--/', $line, $r)) {
1192
1218
                        $section = $r[1];
 
1219
                        settype($section, STRING_TYPE);
1193
1220
 
1194
1221
                        if (isset($section_text[$section])) {
1195
1222
                                $bork_info = "duplicated $section section";
1196
1223
                                $borked    = true;
1197
1224
                        }
1198
1225
 
1199
 
                        $section_text[$section] = '';
 
1226
                        $section_text[$section] = binary_section($section) ? b'' : '';
1200
1227
                        $secfile = $section == 'FILE' || $section == 'FILEEOF' || $section == 'FILE_EXTERNAL';
1201
1228
                        $secdone = false;
1202
1229
                        continue;
1203
1230
                }
1204
1231
 
 
1232
                if (!binary_section($section)) {
 
1233
                        $line = unicode_decode($line, "utf-8");
 
1234
                        if ($line == false) {
 
1235
                                $bork_info = "cannot read test";
 
1236
                                $borked = true;
 
1237
                                break;
 
1238
                        }
 
1239
                }
 
1240
 
1205
1241
                // Add to the section text.
1206
1242
                if (!$secdone) {
1207
1243
                        $section_text[$section] .= $line;
1208
1244
                }
1209
1245
 
1210
1246
                // End of actual test?
1211
 
                if ($secfile && preg_match('/^===DONE===\s*$/', $line)) {
 
1247
                if ($secfile && preg_match(b'/^===DONE===\s*$/', $line)) {
1212
1248
                        $secdone = true;
1213
1249
                }
1214
1250
        }
1233
1269
                        }
1234
1270
 
1235
1271
                        if (@count($section_text['FILEEOF']) == 1) {
1236
 
                                $section_text['FILE'] = preg_replace("/[\r\n]+$/", '', $section_text['FILEEOF']);
 
1272
                                $section_text['FILE'] = preg_replace(b"/[\r\n]+$/", b'', $section_text['FILEEOF']);
1237
1273
                                unset($section_text['FILEEOF']);
1238
1274
                        }
1239
1275
 
1242
1278
                                $section_text['FILE_EXTERNAL'] = dirname($file) . '/' . trim(str_replace('..', '', $section_text['FILE_EXTERNAL']));
1243
1279
 
1244
1280
                                if (file_exists($section_text['FILE_EXTERNAL'])) {
1245
 
                                        $section_text['FILE'] = file_get_contents($section_text['FILE_EXTERNAL']);
 
1281
                                        $section_text['FILE'] = file_get_contents($section_text['FILE_EXTERNAL'], FILE_BINARY);
1246
1282
                                        unset($section_text['FILE_EXTERNAL']);
1247
1283
                                } else {
1248
1284
                                        $bork_info = "could not load --FILE_EXTERNAL-- " . dirname($file) . '/' . trim($section_text['FILE_EXTERNAL']);
1426
1462
                                $env['USE_ZEND_ALLOC'] = '1';
1427
1463
                        }
1428
1464
 
1429
 
                        $output = system_with_timeout("$extra $php $pass_options -q $ini_settings $test_skipif", $env);
 
1465
                        $output = system_with_timeout("$extra $php $pass_options -q $ini_settings -d display_errors=0 $test_skipif", $env);
1430
1466
 
1431
1467
                        if (!$cfg['keep']['skip']) {
1432
1468
                                @unlink($test_skipif);
1776
1812
                                // quote a non re portion of the string
1777
1813
                                $temp = $temp . preg_quote(substr($wanted_re, $startOffset, ($start - $startOffset)),  b'/');
1778
1814
                                // add the re unquoted.
1779
 
                                $temp = $temp . b'(' . substr($wanted_re, $start+2, ($end - $start-2)). b')';
 
1815
                                if ($end > $start) {
 
1816
                                        $temp = $temp . b'(' . substr($wanted_re, $start+2, ($end - $start-2)). b')';
 
1817
                                }
1780
1818
                                $startOffset = $end + 2;
1781
1819
                        }
1782
1820
                        $wanted_re = $temp;
1956
1994
function comp_line($l1, $l2, $is_reg)
1957
1995
{
1958
1996
        if ($is_reg) {
1959
 
                return preg_match((binary) "/^$l1$/s", (binary) $l2);
 
1997
                return preg_match(b'/^'. (binary) $l1 . b'$/s', (binary) $l2);
1960
1998
        } else {
1961
1999
                return !strcmp((binary) $l1, (binary) $l2);
1962
2000
        }