Commit:    3062281b34d7a7811d923a7de48f18c25407b9a9
Author:    Matt Ficken <v-maf...@microsoft.com>         Thu, 17 Jan 2013 
23:48:44 -0800
Parents:   4f9938ad08f2f43c5741fe39f71966de69ee4b4b
Branches:  master

Link:       
http://git.php.net/?p=pftt2.git;a=commitdiff;h=3062281b34d7a7811d923a7de48f18c25407b9a9

Log:
fix for regular expression engine bugs (causing *CSV* PHPT failures)


Former-commit-id: 1a17c37af8129f5901e21ced200b8583558f3c26

Changed paths:
  A  app/pChart2.1.3.zip
  A  app/punbb-1.4.2.zip
  M  src/com/mostc/pftt/host/LocalHost.java
  A  src/com/mostc/pftt/model/custom/ACLPermutationTest.java
  M  src/com/mostc/pftt/model/phpt/PhpIni.java
  M  src/com/mostc/pftt/model/phpt/PhptTestCase.java
  M  src/com/mostc/pftt/model/sapi/ApacheManager.java
  M  src/com/mostc/pftt/runner/AbstractPhptTestCaseRunner.java
  M  src/com/mostc/pftt/runner/AbstractPhptTestCaseRunner2.java
  M  src/com/mostc/pftt/runner/CliPhptTestCaseRunner.java
  M  src/com/mostc/pftt/runner/HttpTestCaseRunner.java
  A  src/com/mostc/pftt/scenario/PChartScenario.java
  A  src/com/mostc/pftt/scenario/PunBBScenario.java
  A  src/com/mostc/pftt/scenario/SuhosinScenario.java
  M  src/com/mostc/pftt/ui/PhptHostTab.java
  M  src/com/mostc/pftt/util/StringUtil.java

diff --git a/app/pChart2.1.3.zip b/app/pChart2.1.3.zip
new file mode 100644
index 0000000..92841ff
Binary files /dev/null and b/app/pChart2.1.3.zip differ
diff --git a/app/punbb-1.4.2.zip b/app/punbb-1.4.2.zip
new file mode 100644
index 0000000..3da5413
Binary files /dev/null and b/app/punbb-1.4.2.zip differ
diff --git a/src/com/mostc/pftt/host/LocalHost.java 
b/src/com/mostc/pftt/host/LocalHost.java
index 0c9a363..f9a0b7b 100644
--- a/src/com/mostc/pftt/host/LocalHost.java
+++ b/src/com/mostc/pftt/host/LocalHost.java
@@ -153,21 +153,9 @@ public class LocalHost extends Host {
                        if (ce==null) {
                                fos.write(text.getBytes());
                        } else {
-                               
-                               
-                               //fos.write(text.getBytes(charset));
-                       
-                               ByteBuffer bbuf = 
ByteBuffer.allocate(50+text.length()*2);
-                               //try {
-                               //CharsetEncoder ce = charset.newEncoder(); // 
TODO share
+                               ByteBuffer bbuf = 
ByteBuffer.allocate(50+(text.length()*2));
                                ce.encode(CharBuffer.wrap(text.toCharArray()), 
bbuf, true);
-                               /*} catch ( Exception ex ) {
-                                       //ex.printStackTrace(); // TODO
-                                       return;
-                               }*/
-                               fos.getChannel().write(bbuf);
-                       
-                       
+                               fos.write(bbuf.array(), 0, bbuf.limit());
                        }
                } finally {
                        fos.close();
diff --git a/src/com/mostc/pftt/model/custom/ACLPermutationTest.java 
b/src/com/mostc/pftt/model/custom/ACLPermutationTest.java
new file mode 100644
index 0000000..f5f322d
--- /dev/null
+++ b/src/com/mostc/pftt/model/custom/ACLPermutationTest.java
@@ -0,0 +1,7 @@
+package com.mostc.pftt.model.custom;
+
+import com.mostc.pftt.model.TestCase;
+
+public abstract class ACLPermutationTest extends TestCase {
+       // TODO
+}
diff --git a/src/com/mostc/pftt/model/phpt/PhpIni.java 
b/src/com/mostc/pftt/model/phpt/PhpIni.java
index cb39aed..8bdbe75 100644
--- a/src/com/mostc/pftt/model/phpt/PhpIni.java
+++ b/src/com/mostc/pftt/model/phpt/PhpIni.java
@@ -63,7 +63,7 @@ public class PhpIni {
        public static final String ISO_8859_1 = "ISO-8859-1";
        public static final String U_INVALID_SUBSTITUTE = 
"U_INVALID_SUBSTITUTE";
        public static final String DOT_HTML = ".html";
-       public static final String E_ALL_OR_E_STRICT = 
"E_ALL|E_STRICT|E_WARNING|E_PARSE|E_NOTICE|E_COMPILE_ERROR|E_RECOVERABLE_ERROR|E_ERROR|E_CORE_ERROR";
 // TODO E_WARN
+       public static final String E_ALL_OR_E_STRICT = "E_ALL|E_STRICT";// TODO 
|E_WARNING|E_PARSE|E_NOTICE|E_COMPILE_ERROR|E_RECOVERABLE_ERROR|E_ERROR|E_CORE_ERROR";
 // TODO E_WARN
        //
        private static String dllName(String name) {
                // FUTURE macos x and solaris support
@@ -99,6 +99,7 @@ public class PhpIni {
        public static final String EXT_XSL = dllName("xsl");
        public static PhpIni createDefaultIniCopy(Host host, PhpBuild build) {
                PhpIni ini = new PhpIni();
+               ini.putSingle("default_mimetype", "text/plain");
                ini.putMulti(OUTPUT_HANDLER, StringUtil.EMPTY);
                ini.putMulti(OPEN_BASEDIR, StringUtil.EMPTY);
                ini.putMulti(SAFE_MODE, 0);
diff --git a/src/com/mostc/pftt/model/phpt/PhptTestCase.java 
b/src/com/mostc/pftt/model/phpt/PhptTestCase.java
index 1f71c8f..05dbfa0 100644
--- a/src/com/mostc/pftt/model/phpt/PhptTestCase.java
+++ b/src/com/mostc/pftt/model/phpt/PhptTestCase.java
@@ -70,10 +70,15 @@ public class PhptTestCase extends TestCase {
                        new String[]{"ext/standard/tests/dir/"},
                        new String[]{"ext/standard/tests/sockets/", 
"ext/sockets/"},
                        new String[]{"tests/security/"},
+                       // the bug38450* tests fail randomly under apache if 
run on apache instance
+                       // with other tests - run them (serially) on their own 
apache instance
+                       new String[]{"ext/standard/tests/file/bug38450"},
                        new String[]{"ext/standard/tests/network/"},
                        new String[]{"ext/session", 
"tests/basic/bug20539.phpt"},
-                       new String[]{"ext/mysql/", "ext/pdo_mysql/"},
+                       new String[]{"ext/mysql/", "ext/pdo_mysql/", 
"ext/mysqli/"},
                        new String[]{"ext/pgsql/", "ext/pdo_pgsql/"},
+                       // several 61367 tests that aren't thread-safe (temp 
files)
+                       new String[]{"ext/libxml/tests/bug61367"},
                        new String[]{"sapi/cli/php_cli_server_"},
                        new String[]{"sapi/cgi/"},
                        new String[]{"ext/firebird/", "ext/pdo_firebird/"},
@@ -83,6 +88,7 @@ public class PhptTestCase extends TestCase {
                        new String[]{"ext/odbc/", "ext/pdo_odbc/"},
                        new String[]{"ext/pdo/"}, // for any remaining pdo tests
                        new String[]{"ext/xmlrpc/"},
+                       new String[]{"ext/xmlwriter/"},
                        new String[]{"ext/soap/"},
                        new String[]{"ext/fileinfo/"},
                        new String[]{"ext/ldap/"},
@@ -352,7 +358,6 @@ public class PhptTestCase extends TestCase {
                        expected_str = oexpected_str = 
getTrim(EPhptSection.EXPECTF);
                        
                        expected_str = prepareExpectF(expected_str);
-                       //expected_str = expected_str.replace("\r\n", 
".").replace("\r", ".").replace("\n", "."); // TODO test
                } else {
                        return null;
                }
@@ -368,7 +373,6 @@ public class PhptTestCase extends TestCase {
                        REProgram wanted_re_prog = new 
RECompiler().compile(expected_str);
                        
                        expected_re = new RE(wanted_re_prog);
-                       expected_re.setMatchFlags(RE.MATCH_MULTILINE); // TODO 
test
                        this.expected_re = new WeakReference<RE>(expected_re);
                        return expected_re;
                } catch ( Throwable ex ) {
@@ -405,8 +409,6 @@ public class PhptTestCase extends TestCase {
                        expected_str = getTrim(EPhptSection.EXPECTF);
                        
                        expected_str = prepareExpectF(expected_str);
-                       
-                       //expected_str = expected_str.replace("\r\n", 
".").replace("\r", ".").replace("\n", "."); // TODO test
                } else {
                        return;
                }
@@ -424,7 +426,6 @@ public class PhptTestCase extends TestCase {
                re.dumpProgram(dump_pw);
                
                RE r = new RE(rp);
-               r.setMatchFlags(RE.MATCH_MULTILINE); // TODO test
                r.matchDump(actual_str, output_pw);
                
                for (int i = 0; i < r.getParenCount(); i++) {
@@ -441,11 +442,6 @@ public class PhptTestCase extends TestCase {
         * @return
         */
        public static String prepareExpectF(String expected_str) {
-               /*System.err.println(expected_str);
-               expected_str = expected_str.replace("\\n", "");//\\\\n"); // 
TODO
-               System.err.println("===");
-               System.err.println(expected_str);*/
-               
                // do preg_quote, but miss out any %r delimited sections
                int start, end;
                String temp = "";
@@ -494,16 +490,16 @@ public class PhptTestCase extends TestCase {
                expected_str = StringUtil.replaceAll(PAT_A, "(.|\\\\n|\\\\r)*", 
expected_str);
                expected_str = StringUtil.replaceAll(PAT_w, "\\\\s*", 
expected_str);
                expected_str = StringUtil.replaceAll(PAT_i, "[+-]?\\\\d+", 
expected_str);
-               expected_str = StringUtil.replaceAll(PAT_d, "\\\\d+", 
expected_str);
+               expected_str = StringUtil.replaceAll(PAT_d, "\\d+", 
expected_str);
                expected_str = StringUtil.replaceAll(PAT_x, "[0-9a-fA-F]+", 
expected_str);
                expected_str = StringUtil.replaceAll(PAT_f, 
"[+-]?\\.?\\\\d+\\.?\\\\d*(?:[Ee][+-]?\\\\d+)?", expected_str);
                // 2 .. (produced by 2 %c) will be ignored... can only have 1 
%c or 1 .
                expected_str = StringUtil.replaceAll(PAT_double_c, "%c", 
expected_str);
                expected_str = StringUtil.replaceAll(PAT_c, ".", expected_str);
                
-               //expected_str = expected_str.replace("\r\n", 
".").replace("\r", ".").replace("\n", "."); // TODO test
-               //expected_str = expected_str.replace("\\r", "\\\\r");
-               return expected_str;
+               // TODO
+               expected_str = expected_str.replace("\r\n", 
".*\r\n").replace("\r", ".*\r").replace("\n", ".*\n");
+               return ".*"+expected_str+".*"; // TODO test
        } // end public static String prepareExpectF
        static final Pattern PAT_s = Pattern.compile("%s");
        static final Pattern PAT_S = Pattern.compile("%S");
diff --git a/src/com/mostc/pftt/model/sapi/ApacheManager.java 
b/src/com/mostc/pftt/model/sapi/ApacheManager.java
index c2ad961..6d46757 100644
--- a/src/com/mostc/pftt/model/sapi/ApacheManager.java
+++ b/src/com/mostc/pftt/model/sapi/ApacheManager.java
@@ -230,8 +230,10 @@ public class ApacheManager extends 
AbstractManagedProcessesWebServerManager {
                        return null;
                }
                
+               final String cmdline = httpd+" -X -f 
"+host.fixPath(apache_conf_file);
+               
                // @see #createWebServerInstance for where command is executed 
to create httpd.exe process
-               return new ApacheWebServerInstance(apache_version, this, 
httpd+" -X -f "+host.fixPath(apache_conf_file), ini, env, listen_address, port, 
host, conf_dir, apache_conf_file, error_log);
+               return new ApacheWebServerInstance(apache_version, this, 
cmdline, ini, env, listen_address, port, host, conf_dir, apache_conf_file, 
error_log);
        } // end protected ManagedProcessWebServerInstance 
createManagedProcessWebServerInstance
        
        public class ApacheWebServerInstance extends 
ManagedProcessWebServerInstance {
@@ -382,7 +384,11 @@ public class ApacheManager extends 
AbstractManagedProcessesWebServerManager {
                        sb.append("EnableMMAP off\n");
                        sb.append("EnableSendfile off\n");
                }
+               // CRITICAL: for a few tests (ex: 
ext/standard/tests/file/bug/61637.phpt), make sure that response is NOT wrapped 
in html tags
+               //sb.append("DefaultType text/plain\n");
+               // TODO
                sb.append("<Directory />\n");
+               //sb.append("    ForceType text/plain\n");
                sb.append("    AllowOverride none\n");
                //sb.append("    Require all denied\n");
                sb.append("</Directory>\n");
diff --git a/src/com/mostc/pftt/runner/AbstractPhptTestCaseRunner.java 
b/src/com/mostc/pftt/runner/AbstractPhptTestCaseRunner.java
index 13ed0d5..c70d36a 100644
--- a/src/com/mostc/pftt/runner/AbstractPhptTestCaseRunner.java
+++ b/src/com/mostc/pftt/runner/AbstractPhptTestCaseRunner.java
@@ -121,7 +121,7 @@ public abstract class AbstractPhptTestCaseRunner {
        } // end public static boolean willSkip
        
        static boolean a(PhptTestCase test_case) {
-               return !test_case.getName().contains("csv");
+               return false;
        }
                
 } // end public abstract class AbstractPhptTestCaseRunner
diff --git a/src/com/mostc/pftt/runner/AbstractPhptTestCaseRunner2.java 
b/src/com/mostc/pftt/runner/AbstractPhptTestCaseRunner2.java
index 898128e..c887a2a 100644
--- a/src/com/mostc/pftt/runner/AbstractPhptTestCaseRunner2.java
+++ b/src/com/mostc/pftt/runner/AbstractPhptTestCaseRunner2.java
@@ -30,6 +30,7 @@ import 
com.mostc.pftt.runner.LocalPhptTestPackRunner.PhptThread;
 import com.mostc.pftt.scenario.ScenarioSet;
 import com.mostc.pftt.util.GZIPOutputStreamLevel;
 import com.mostc.pftt.util.StringUtil;
+import com.mostc.pftt.util.StringUtil.LengthLimitStringWriter;
 
 public abstract class AbstractPhptTestCaseRunner2 extends 
AbstractPhptTestCaseRunner {
        protected final ConsoleManager cm;
@@ -62,10 +63,16 @@ public abstract class AbstractPhptTestCaseRunner2 extends 
AbstractPhptTestCaseRu
                if (skipif_file == null || !evalSkipIf(executeSkipIf())) {
                        // no SKIPIF section or executed SKIPIF says to execute 
the TEST section
                        prepareTest();
+                       //
                        String test_output = executeTest();
                        if (not_crashed) {
+                               //
                                evalTest(test_output, 
test_case.getCommonCharset());
-                               executeClean();
+                               
+                               // some tests create files/dirs which, which 
will cause the test to fail again
+                               // if its run in-place from the same test-pack
+                               if (!cm.isPhptNotInPlace()&&test_clean!=null)
+                                       executeClean();
                        }
                }
        }
@@ -120,7 +127,12 @@ public abstract class AbstractPhptTestCaseRunner2 extends 
AbstractPhptTestCaseRu
                //
        
                test_file = host.joinIntoOnePath(test_dir, base_file_name + 
".php");
-               test_clean = host.joinIntoOnePath(test_dir, base_file_name + 
".clean.php");
+               
+               if (test_case.containsSection(EPhptSection.CLEAN)) {
+                       test_clean = host.joinIntoOnePath(test_dir, 
base_file_name + ".clean.php");
+                       
+                       host.saveTextFile(test_clean, 
test_case.get(EPhptSection.CLEAN));
+               } // else test_clean = null;
                
                
                if (StringUtil.isEmpty(ini.getExtensionDir()))
@@ -388,7 +400,6 @@ public abstract class AbstractPhptTestCaseRunner2 extends 
AbstractPhptTestCaseRu
                                        
                        boolean expected_re_match;
                        
-                       output = output.replace("\\n", ""); // TODO test
                        output = remove_header_from_output(output);
                        String output_trim = output.trim();
                        
@@ -505,8 +516,8 @@ public abstract class AbstractPhptTestCaseRunner2 extends 
AbstractPhptTestCaseRu
                                //
                                // (this is an expensive operation so it 
shouldn't be done for every test. there shouldn't be
                                //  very many FAIL tests so this shouldn't be 
done very much)
-                               StringWriter dump_sw = new StringWriter(1024);
-                               StringWriter output_sw = new StringWriter(2048);
+                               LengthLimitStringWriter dump_sw = new 
LengthLimitStringWriter();
+                               LengthLimitStringWriter output_sw = new 
LengthLimitStringWriter();
                                PrintWriter dump_pw = new PrintWriter(dump_sw);
                                PrintWriter output_pw = new 
PrintWriter(output_sw);
                                
diff --git a/src/com/mostc/pftt/runner/CliPhptTestCaseRunner.java 
b/src/com/mostc/pftt/runner/CliPhptTestCaseRunner.java
index a942bb1..ed0e40b 100644
--- a/src/com/mostc/pftt/runner/CliPhptTestCaseRunner.java
+++ b/src/com/mostc/pftt/runner/CliPhptTestCaseRunner.java
@@ -246,21 +246,9 @@ public class CliPhptTestCaseRunner extends 
AbstractPhptTestCaseRunner2 {
        
        @Override
        protected void executeClean() throws Exception {
-               if (test_case.containsSection(EPhptSection.CLEAN)) {
-                       host.saveTextFile(test_clean, 
test_case.getTrim(EPhptSection.CLEAN), null);
-               
-                       env.remove(ENV_REQUEST_METHOD);
-                       env.remove(ENV_QUERY_STRING);
-                       env.remove(ENV_PATH_TRANSLATED);
-                       env.remove(ENV_SCRIPT_FILENAME);
-                       env.remove(ENV_REQUEST_METHOD);
-                       
-                       // execute cleanup script
-                       // FUTURE should cleanup script be ignored??
-                       host.exec(selected_php_exe+" "+test_clean, 
Host.ONE_MINUTE, env, null, active_test_pack.getDirectory());
-
-                       host.delete(test_clean);
-               }
+               // execute cleanup script
+               // FUTURE should cleanup script be ignored??
+               host.exec(selected_php_exe+" "+test_clean, Host.ONE_MINUTE, 
env, null, active_test_pack.getDirectory());
        } // end void executeClean
 
        @Override
diff --git a/src/com/mostc/pftt/runner/HttpTestCaseRunner.java 
b/src/com/mostc/pftt/runner/HttpTestCaseRunner.java
index d71dbfe..a44d9bf 100644
--- a/src/com/mostc/pftt/runner/HttpTestCaseRunner.java
+++ b/src/com/mostc/pftt/runner/HttpTestCaseRunner.java
@@ -3,6 +3,8 @@ package com.mostc.pftt.runner;
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.net.Socket;
+import java.net.URLEncoder;
+import java.util.HashMap;
 import java.util.Map;
 
 import org.apache.http.Header;
@@ -44,6 +46,7 @@ import com.mostc.pftt.util.StringUtil;
  *
  */
 
+// TODO error msg should tell how many times web server was restarted
 public class HttpTestCaseRunner extends AbstractPhptTestCaseRunner2 {
        protected final WebServerManager smgr;
        protected final HttpParams params;
@@ -61,7 +64,17 @@ public class HttpTestCaseRunner extends 
AbstractPhptTestCaseRunner2 {
                this.smgr = smgr;
                this.web = web;
                // CRITICAL: need this to get ENV from this TestCaseGroup
-               this.env = env;
+               if (env!=null && 
((env.containsKey("TEMP")&&env.get("TEMP").equals(".")) || 
(env.containsKey("TMP")&&env.get("TMP").equals(".")))) {
+                       // checks for case like: 
ext/phar/commit/tar/phar_commitwrite.phpt
+                       this.env = new HashMap<String,String>(7);
+                       this.env.putAll(env);
+                       // TODO
+                       this.env.put("TEMP", 
active_test_pack.getDirectory()+"/"+Host.dirname(test_case.getName()));
+                       this.env.put("TMP", 
active_test_pack.getDirectory()+"/"+Host.dirname(test_case.getName()));
+               } else {
+                       this.env = env;
+               }
+               //
                
                this.request_bytes = new ByteArrayOutputStream(256);
                this.response_bytes = new ByteArrayOutputStream(4096);
@@ -99,17 +112,88 @@ public class HttpTestCaseRunner extends 
AbstractPhptTestCaseRunner2 {
                        
                        return true;
                } else if (test_case.isNamed(
-                               // fpassthru() doesn't run on Apache
+                               // fpassthru() system() and exec() doesn't run 
on Apache
                                
"ext/standard/tests/popen_pclose_basic-win32.phpt", 
+                               "sapi/cli/tests/bug61546.phpt",
+                               "ext/standard/tests/file/bug41874.phpt",
+                               "ext/standard/tests/file/bug41874_1.phpt",
+                               "ext/standard/tests/file/bug41874_2.phpt",
+                               "ext/standard/tests/file/bug41874_3.phpt",
+                               
"ext/standard/tests/file/popen_pclose_basic-win32.phpt",
+                               // changing memory limit under mod_php after 
script started is N/A
+                               "tests/lang/bug45392.phpt",
                                // this test will return different output on 
apache/iis
                                
"ext/standard/tests/general_functions/get_cfg_var_variation8.phpt",
                                "tests/basic/bug54514.phpt",
+                               "sapi/tests/test005.phpt",
+                               //////////////////
+                               "ext/standard/tests/strings/004.phpt",
+                               "ext/mbstring/tests/bug63447_001.phpt",
+                               "ext/mbstring/tests/bug63447_002.phpt",
+                               "ext/iconv/tests/ob_iconv_handler.phpt",
+                               "ext/mbstring/tests/mb_strcut.phpt",
+                               
"ext/mbstring/tests/mb_decode_numericentity.phpt",
+                               //////////////////
+                               "ext/standard/tests/file/parse_ini_file.phpt",
+                               "tests/basic/rfc1867_missing_boundary.phpt",
+                               "ext/xml/tests/xml006.phpt",
+                               "zend/tests/bug48930.phpt",
+                               "ext/json/tests/002.phpt",
+                               "ext/zlib/tests/bug55544-win.phpt",
+                               "tests/basic/025.phpt",
+                               "ext/standard/tests/array/bug34066_1.phpt",
+                               "tests/basic/rfc1867_invalid_boundary.phpt",
+                               "zend/tests/bug54268.phpt",
+                               "tests/basic/rfc1867_post_max_size.phpt",
+                               "ext/dom/tests/bug37456.phpt",
+                               "ext/libxml/tests/bug61367-read.phpt",
+                               
"zend/tests/multibyte/multibyte_encoding_003.phpt",
+                               "ext/standard/tests/general_functions/002.phpt",
+                               
"zend/tests/multibyte/multibyte_encoding_002.phpt",
+                               "tests/basic/rfc1867_garbled_mime_headers.phpt",
+                               "ext/standard/tests/array/bug34066.phpt",
+                               "ext/standard/tests/general_functions/006.phpt",
+                               "ext/libxml/tests/bug61367-write.phpt",
+                               
"ext/session/tests/rfc1867_invalid_settings-win.phpt",
+                               
"ext/session/tests/rfc1867_invalid_settings_2-win.phpt",
+                               
"ext/standard/tests/versioning/php_sapi_name_variation001.phpt",
+                               
"ext/standard/tests/math/rad2deg_variation.phpt",
+                               "ext/standard/tests/strings/strtoupper.phpt",
+                               
"ext/standard/tests/strings/sprintf_variation47.phpt",
+                               
"ext/standard/tests/general_functions/bug41445_1.phpt",
+                               "ext/standard/tests/strings/htmlentities.phpt",
+                               
"ext/standard/tests/strings/fprintf_variation_001.phpt",
+                               
"ext/standard/tests/general_functions/var_dump.phpt",
+                               "ext/session/tests/003.phpt",
+                               "ext/session/tests/023.phpt",
+                               
"ext/standard/tests/streams/stream_get_meta_data_socket_variation3.phpt",
+                               
"ext/standard/tests/streams/stream_get_meta_data_socket_variation4.phpt",
+                               /////////////////
                                // getopt returns false under web server (ok)
-                               
"ext/standard/tests/general_functions/bug43293_2.phpt"
+                               
"ext/standard/tests/general_functions/bug43293_1.phpt",
+                               
"ext/standard/tests/general_functions/bug43293_2.phpt",
+                               // fopen("stdout") not supported under apache
+                               "tests/strings/002.phpt"
                                )) {
                        twriter.addResult(host, scenario_set, new 
PhptTestResult(host, EPhptTestStatus.XSKIP, test_case, "test is not valid on 
web servers", null, null, null, null, null, null, null, null, null, null, 
null));
                        
                        return true;
+               } else if (host.isWindows() && test_case.isNamed(
+                       // on Windows/Apache, already start with output 
buffering
+                       // so the expected output is different (but is not a 
bug)
+                       "tests/output/ob_get_level_basic_001.phpt",
+                       "tests/output/ob_get_length_basic_001.phpt",
+                       "tests/output/ob_clean_basic_001.phpt",
+                       "tests/output/ob_get_status.phpt",
+                       "tests/output/ob_010.phpt",
+                       "tests/output/ob_011.phpt",
+                       "tests/output/bug60321.phpt",
+                       "ext/phar/tests/phar_create_in_cwd.phpt",
+                       "ext/phar/tests/phar_commitwrite.phpt",
+                       "tests/output/ob_start_error_005.phpt")) {
+                       twriter.addResult(host, scenario_set, new 
PhptTestResult(host, EPhptTestStatus.XSKIP, test_case, "test is not valid on 
web servers", null, null, null, null, null, null, null, null, null, null, 
null));
+                       
+                       return true;
                } else {
                        return false;
                }
@@ -132,16 +216,6 @@ public class HttpTestCaseRunner extends 
AbstractPhptTestCaseRunner2 {
         * @throws Exception
         */
        protected String http_execute(String path, EPhptSection section) throws 
Exception {
-               if (test_case.containsSection(EPhptSection.GET)) {
-                       String query_string = 
test_case.getTrim(EPhptSection.GET);
-                       // query_string needs to be added to the GET path
-                       if (StringUtil.isNotEmpty(query_string)) {
-                               // tests like ext/filter/tests/004.skip.php put 
HTML tags in query_string 
-                               // which are not legal in URLs
-                               path = path + "?" + 
query_string.replaceAll("<", "&lt;").replaceAll(">", "&gt;");
-                       }
-               }
-               
                try {
                        try {
                                return do_http_execute(path, section, false);
@@ -204,11 +278,11 @@ public class HttpTestCaseRunner extends 
AbstractPhptTestCaseRunner2 {
                        if (web!=null) {
                                synchronized(web) {
                                        WebServerInstance _web = 
smgr.getWebServerInstance(cm, host, build, ini, env, 
active_test_pack.getDirectory(), web, test_case);
-                                       if (_web!=web) {
+                                       if (_web!=this.web) {
                                                this.web = _web;
                                                is_replacement = true;
                                        
-                                               if (web.isCrashed()) {
+                                               if (web==null||web.isCrashed()) 
{
                                                        markTestAsCrash();
                                                        
                                                        // test will fail 
(because this(`PFTT: server...`) is the actual output which won't match the 
expected output)
@@ -222,7 +296,13 @@ public class HttpTestCaseRunner extends 
AbstractPhptTestCaseRunner2 {
                        if (web==null) {
                                // test should be a FAIL or CRASH
                                // its certainly the fault of a test (not PFTT) 
if not this test
-                               return "PFTT: no web server available!\n";
+                               this.web = smgr.getWebServerInstance(cm, host, 
build, ini, env, active_test_pack.getDirectory(), web, test_case);
+                               
+                               if (web==null||web.isCrashed()) {
+                                       markTestAsCrash();
+                                       
+                                       return "PFTT: no web server 
available!\n";
+                               }
                        }
                                
                        // CRITICAL: keep track of test cases running on web 
server
@@ -284,6 +364,9 @@ public class HttpTestCaseRunner extends 
AbstractPhptTestCaseRunner2 {
                        HttpGet request = new HttpGet(path);
                        if (cookie_str!=null)
                                request.setHeader("Cookie", cookie_str);
+                       // CRITICAL: tell web server to return plain-text (not 
HTMl) 
+                       // for some reason(w/o this), apache returns HTML 
formatted responses for tests like ext/standard/tests/array/rsort.phpt
+                       request.setHeader("Accept", "text/plain");
                        request.setParams(params);
                        
                        httpexecutor.preProcess(request, httpproc, context);
@@ -379,9 +462,45 @@ public class HttpTestCaseRunner extends 
AbstractPhptTestCaseRunner2 {
                return http_execute(skipif_file, EPhptSection.SKIPIF);
        }
 
+       @SuppressWarnings("deprecation")
        @Override
        protected String executeTest() throws Exception {
-               return http_execute(test_file, EPhptSection.TEST);
+               String request_uri = this.test_file;
+               
+               if (env!=null&&env.containsKey("REQUEST_URI")) {
+                       // ex: ext/phar/tests/frontcontroller17.phpt
+                       request_uri = 
Host.dirname(request_uri)+"/"+env.get("REQUEST_URI");
+               }
+               
+               if (test_case.containsSection(EPhptSection.GET)) {
+                       String query_string = 
test_case.getTrim(EPhptSection.GET);
+                       // query_string needs to be added to the GET path
+                       if (StringUtil.isNotEmpty(query_string)) {
+                               // a good, complex example for this is 
ext/filter/tests/004.skip.php
+                               // it puts HTML tags and other illegal chars in 
query_string (uses both HTTP GET and POST)
+                               //
+                               // illegal chars need to be URL-Encoded 
(percent-encoding, escaped)... 
+                               // this is NOT the same as escaping entities in 
HTML
+                               //
+                               // @see 
https://en.wikipedia.org/wiki/Percent-encoding
+                               // @see 
https://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references
+                               //
+                               String[] names_and_values = 
query_string.split("[&|\\=]");
+                               StringBuilder query_string_sb = new 
StringBuilder();
+                               for ( int i=0 ; i < names_and_values.length ; 
i+=2 ) {
+                                       if (query_string_sb.length()>0)
+                                               query_string_sb.append('&');
+                                       
query_string_sb.append(names_and_values[i]);
+                                       query_string_sb.append('=');
+                                       if (names_and_values.length>i+1)
+                                               
query_string_sb.append(URLEncoder.encode(names_and_values[i+1]));
+                               }
+                               
+                               request_uri = test_file + "?" + query_string_sb;
+                       }
+               } // end if containsSection(GET)
+               
+               return http_execute(request_uri, EPhptSection.TEST);
        }
 
        @Override
diff --git a/src/com/mostc/pftt/scenario/PChartScenario.java 
b/src/com/mostc/pftt/scenario/PChartScenario.java
new file mode 100644
index 0000000..37d9d57
--- /dev/null
+++ b/src/com/mostc/pftt/scenario/PChartScenario.java
@@ -0,0 +1,31 @@
+package com.mostc.pftt.scenario;
+
+import com.mostc.pftt.host.Host;
+import com.mostc.pftt.model.phpt.PhpBuild;
+import com.mostc.pftt.results.ConsoleManager;
+
+public class PChartScenario extends ZipApplication {
+
+       @Override
+       protected String getZipAppFileName() {
+               // TODO Auto-generated method stub
+               return null;
+       }
+
+       @Override
+       protected boolean configure(ConsoleManager cm, Host host, PhpBuild 
build, ScenarioSet scenario_set, String app_dir) {
+               // TODO Auto-generated method stub
+               return false;
+       }
+
+       @Override
+       public String getName() {
+               return "PChart";
+       }
+
+       @Override
+       public boolean isImplemented() {
+               return false;
+       }
+
+}
diff --git a/src/com/mostc/pftt/scenario/PunBBScenario.java 
b/src/com/mostc/pftt/scenario/PunBBScenario.java
new file mode 100644
index 0000000..cc26861
--- /dev/null
+++ b/src/com/mostc/pftt/scenario/PunBBScenario.java
@@ -0,0 +1,32 @@
+package com.mostc.pftt.scenario;
+
+import com.mostc.pftt.host.Host;
+import com.mostc.pftt.model.phpt.PhpBuild;
+import com.mostc.pftt.results.ConsoleManager;
+
+public class PunBBScenario extends ZipDbApplication {
+
+       @Override
+       protected String getZipAppFileName() {
+               // TODO Auto-generated method stub
+               return null;
+       }
+
+       @Override
+       protected boolean configure(ConsoleManager cm, Host host, PhpBuild 
build,
+                       ScenarioSet scenario_set, String app_dir) {
+               // TODO Auto-generated method stub
+               return false;
+       }
+
+       @Override
+       public String getName() {
+               return "PunBB";
+       }
+
+       @Override
+       public boolean isImplemented() {
+               return false;
+       }
+
+}
diff --git a/src/com/mostc/pftt/scenario/SuhosinScenario.java 
b/src/com/mostc/pftt/scenario/SuhosinScenario.java
new file mode 100644
index 0000000..f225218
--- /dev/null
+++ b/src/com/mostc/pftt/scenario/SuhosinScenario.java
@@ -0,0 +1,15 @@
+package com.mostc.pftt.scenario;
+
+public class SuhosinScenario extends Scenario {
+
+       @Override
+       public String getName() {
+               return "Suhosin";
+       }
+
+       @Override
+       public boolean isImplemented() {
+               return false;
+       }
+
+}
diff --git a/src/com/mostc/pftt/ui/PhptHostTab.java 
b/src/com/mostc/pftt/ui/PhptHostTab.java
index 3ea3381..a31b73f 100644
--- a/src/com/mostc/pftt/ui/PhptHostTab.java
+++ b/src/com/mostc/pftt/ui/PhptHostTab.java
@@ -305,7 +305,7 @@ public class PhptHostTab extends JSplitPane {
                                                fail++;
                                                
fail_label.setText(Integer.toString(fail));
                                                
-                                               
pass_bar.setString(Float.toString(PhptResultPack.round1( (float)( (double)pass 
/ ((double)( pass + fail + crash )) )))+"%"); // 1 decimal places nn.y
+                                               
pass_bar.setString(Float.toString(PhptResultPack.round1( (float)( ((float)pass) 
/ ((float)( pass + fail + crash )) )))+"%"); // 1 decimal places nn.y
                                                pass_bar.setMaximum(fail+pass);
                                                
total_label.setText(""+(fail+pass));
                                                
diff --git a/src/com/mostc/pftt/util/StringUtil.java 
b/src/com/mostc/pftt/util/StringUtil.java
index 5603972..92aa87c 100644
--- a/src/com/mostc/pftt/util/StringUtil.java
+++ b/src/com/mostc/pftt/util/StringUtil.java
@@ -1,8 +1,11 @@
 package com.mostc.pftt.util;
 
+import java.io.IOException;
+import java.io.Writer;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
+import com.github.mattficken.io.IOUtil;
 import com.mostc.pftt.util.apache.regexp.RE;
 import com.mostc.pftt.util.apache.regexp.RECompiler;
 import com.mostc.pftt.util.apache.regexp.REProgram;
@@ -351,6 +354,54 @@ public final class StringUtil {
                return sb.toString();
        }
        
+       /** replacement for StringWriter that will silent ignore write requests 
if
+        * too many chars have been written.
+        * 
+        * This avoids OutOfMemoryErrors.
+        * 
+        */
+       public static class LengthLimitStringWriter extends Writer {
+               protected final StringBuilder sb;
+               protected final int max;
+               
+               /**
+                * 
+                * @param cap - initial capacity
+                * @param max - maximum capacity - will not exceed this
+                */
+               public LengthLimitStringWriter(int cap, int max) {
+                       this.sb = new StringBuilder(cap);
+                       this.max = max;
+               }
+               
+               public LengthLimitStringWriter() {
+                       this(512, IOUtil.QUARTER_MEGABYTE);
+               }
+
+               @Override
+               public void close() throws IOException {
+                       
+               }
+
+               @Override
+               public void flush() throws IOException {
+                       
+               }
+
+               @Override
+               public void write(char[] chars, int off, int len) throws 
IOException {
+                       len = Math.min(len, max - sb.length());
+                       if (len>0)
+                               sb.append(chars, off, len);
+               }
+               
+               @Override
+               public String toString() {
+                       return sb.toString();
+               }
+               
+       } // end public static class LengthLimitStringWriter
+       
        private StringUtil() {}
        
 } // end public class StringUtil

Reply via email to