Commit: 6f991739b53474b6d93a119fd8514f1f5fa20b40 Author: Matt Ficken <v-maf...@microsoft.com> Tue, 8 Jan 2013 14:03:22 -0800 Parents: e6842c50bec5fbe1e5ec073860930089443fada7 Branches: master
Link: http://git.php.net/?p=pftt2.git;a=commitdiff;h=6f991739b53474b6d93a119fd8514f1f5fa20b40 Log: includes XSL stylesheet with result-packs Former-commit-id: afcac9227fa83d8c5c1ee842fad043ffc6830655 Changed paths: M src/com/mostc/pftt/host/Host.java M src/com/mostc/pftt/main/Config.java M src/com/mostc/pftt/main/PfttMain.java M src/com/mostc/pftt/model/phpt/PhpBuild.java M src/com/mostc/pftt/model/phpt/PhptTestCase.java M src/com/mostc/pftt/model/sapi/AbstractManagedProcessesWebServerManager.java M src/com/mostc/pftt/model/sapi/ApacheManager.java M src/com/mostc/pftt/model/sapi/BuiltinWebServerManager.java M src/com/mostc/pftt/model/sapi/EApacheVersion.java M src/com/mostc/pftt/model/sapi/IISManager.java M src/com/mostc/pftt/model/smoke/RequiredExtensionsSmokeTest.java M src/com/mostc/pftt/model/smoke/RequiredFeaturesSmokeTest.java M src/com/mostc/pftt/results/ConsoleManager.java A src/com/mostc/pftt/results/PhptResultPackIndexDotHtmlWriter.groovy M src/com/mostc/pftt/results/PhptResultPackWriter.java M src/com/mostc/pftt/results/PhptTestResult.java A src/com/mostc/pftt/results/PhptTestResultStylesheetWriter.groovy M src/com/mostc/pftt/runner/AbstractPhptTestCaseRunner2.java M src/com/mostc/pftt/runner/HttpTestCaseRunner.java M src/com/mostc/pftt/runner/PhptTestPackRunner.java M src/com/mostc/pftt/scenario/AbstractINIScenario.java M src/com/mostc/pftt/scenario/AbstractSMBScenario.java M src/com/mostc/pftt/scenario/LocalFileSystemScenario.java M src/com/mostc/pftt/scenario/SMBCSCOptionScenario.java M src/com/mostc/pftt/scenario/SMBDFSRScenario.java M src/com/mostc/pftt/scenario/SMBDeduplicationScenario.java M src/com/mostc/pftt/util/DebuggerManager.java M src/com/mostc/pftt/util/DownloadUtil.java M src/com/mostc/pftt/util/StringUtil.java M src/com/mostc/pftt/util/WinDebugManager.java
diff --git a/src/com/mostc/pftt/host/Host.java b/src/com/mostc/pftt/host/Host.java index 8972010..99ffd16 100644 --- a/src/com/mostc/pftt/host/Host.java +++ b/src/com/mostc/pftt/host/Host.java @@ -42,7 +42,7 @@ public abstract class Host { public static final int DEV = 0; public static final int ONE_HOUR = 3600; /** should always have a timeout... should NOT let something run forever */ - public static final int FOUR_HOURS = 0;// TODO ONE_HOUR * 4; + public static final int FOUR_HOURS = ONE_HOUR * 4; public static final int ONE_MINUTE = 60; /** removes the file extension from file. @@ -904,7 +904,7 @@ public abstract class Host { else cm.println(getClass(), "Unable to unzip: "+zip_file); } catch ( Exception ex ) { - cm.printStackTrace(ex); + cm.addGlobalException(getClass(), "unzip", ex, ""); } return false; } @@ -930,5 +930,23 @@ public abstract class Host { } return base; } + + /** counts the number of parent directories from from to to (its parent, parent of its parent, etc...) + * + * countUp('a/b/c', 'a') => 2 + * + * @param from + * @param to + * @return + */ + public static int countUp(String from, String to) { + from = toUnixPath(from); + to = toUnixPath(to); + if (from.equals(to)) + return 0; + else if (from.startsWith(to)) + from = from.substring(to.length()); + return from.split("/").length+1; + } } // end public abstract class Host diff --git a/src/com/mostc/pftt/main/Config.java b/src/com/mostc/pftt/main/Config.java index 751ab80..c4b56fa 100644 --- a/src/com/mostc/pftt/main/Config.java +++ b/src/com/mostc/pftt/main/Config.java @@ -100,7 +100,7 @@ public final class Config { if (cm==null) ex.printStackTrace(); else - cm.printStackTrace(ex); + cm.addGlobalException(getClass(), "configureSMTP", ex, ""); } return false; } @@ -120,7 +120,7 @@ public final class Config { if (cm==null) ex.printStackTrace(); else - cm.printStackTrace(ex); + cm.addGlobalException(getClass(), "configureFTPClient", ex, ""); } return false; } diff --git a/src/com/mostc/pftt/main/PfttMain.java b/src/com/mostc/pftt/main/PfttMain.java index fbb9413..117b106 100644 --- a/src/com/mostc/pftt/main/PfttMain.java +++ b/src/com/mostc/pftt/main/PfttMain.java @@ -59,11 +59,6 @@ import com.mostc.pftt.util.WindowsSnapshotDownloadUtil.FindBuildTestPackPair; * */ -// TODO restarting_and_retrying -// TODO 7zip result-pack -// TODO upload result-pack -// TODO fbc report gen - public class PfttMain { protected Host host; @@ -180,8 +175,7 @@ public class PfttMain { try { Desktop.getDesktop().browse(new File(html_file).toURI()); } catch ( Exception ex ) { - cm.printStackTrace(ex); - cm.println("Report", "unable to show HTML file: "+html_file); + cm.addGlobalException(getClass(), "show_report", ex, "unable to show HTML file: "+html_file); } } @@ -272,6 +266,7 @@ public class PfttMain { System.out.println("-stress_each <0+> - runs each test-case N times consecutively"); System.out.println("-stress_all <0+> - runs all tests N times in loop"); System.out.println("-results_only - displays only test results and no other information (for automation)."); + System.out.println("-pftt-debug - shows additional information to help debug problems with PFTT itself"); System.out.println("-disable_debug_prompt - disables asking you if you want to debug PHP crashes (for automation. default=enabled)"); System.out.println("-phpt-not-in-place - copies PHPTs to a temporary dir and runs PHPTs from there (default=disabled, test in-place)"); System.out.println("-dont-cleanup-test-pack - doesn't delete temp dir created by -phpt-not-in-place or SMB scenario (default=delete)"); @@ -524,8 +519,7 @@ public class PfttMain { try { host.execElevated("git pull", Host.FOUR_HOURS, host.getPfttDir()).printOutputIfCrash(PfttMain.class.getSimpleName(), cm); } catch ( Exception ex ) { - cm.printStackTrace(ex); - cm.println("upgrade", "error upgrading PFTT"); + cm.addGlobalException(PfttMain.class, "cmd_upgrade", ex, "error upgrading PFTT"); } } @@ -583,7 +577,7 @@ public class PfttMain { int args_i = 0; Config config = null; - boolean is_uac = false, windebug = false, show_gui = false, force = false, disable_debug_prompt = false, results_only = false, dont_cleanup_test_pack = false, phpt_not_in_place = false; + boolean is_uac = false, windebug = false, pftt_debug = false, show_gui = false, force = false, disable_debug_prompt = false, results_only = false, dont_cleanup_test_pack = false, phpt_not_in_place = false; String source_pack = null; PhpDebugPack debug_pack = null; LinkedList<File> config_files = new LinkedList<File>(); @@ -693,6 +687,8 @@ public class PfttMain { } else if (args[args_i].startsWith("-uac")) { // ignore: intercepted and handled by bin/pftt.cmd batch script is_uac = true; + } else if (args[args_i].startsWith("-pftt-debug")) { + pftt_debug = true; } else if (args[args_i].startsWith("-windebug")) { // also intercepted and handled by bin/pftt.cmd batch script windebug = true; @@ -728,7 +724,7 @@ public class PfttMain { System.err.println("PFTT: not implemented: stress_each="+stress_each+" stress_all="+stress_all+" ignored"); } - ConsoleManager cm = new ConsoleManager(source_pack, debug_pack, force, windebug, results_only, show_gui, disable_debug_prompt, dont_cleanup_test_pack, phpt_not_in_place); + ConsoleManager cm = new ConsoleManager(source_pack, debug_pack, force, windebug, results_only, show_gui, disable_debug_prompt, dont_cleanup_test_pack, phpt_not_in_place, pftt_debug); if (config_files.size()>0) { config = Config.loadConfigFromFiles(cm, (File[])config_files.toArray(new File[config_files.size()])); diff --git a/src/com/mostc/pftt/model/phpt/PhpBuild.java b/src/com/mostc/pftt/model/phpt/PhpBuild.java index b283efe..b6e7cc4 100644 --- a/src/com/mostc/pftt/model/phpt/PhpBuild.java +++ b/src/com/mostc/pftt/model/phpt/PhpBuild.java @@ -64,7 +64,7 @@ public class PhpBuild extends Build { php_cgi_exe = null; // mark as not found return true; } catch ( Exception ex ) { - cm.printStackTrace(ex); + cm.addGlobalException(getClass(), "open", ex, ""); } return false; } // end public boolean open diff --git a/src/com/mostc/pftt/model/phpt/PhptTestCase.java b/src/com/mostc/pftt/model/phpt/PhptTestCase.java index 227729e..9fea1b2 100644 --- a/src/com/mostc/pftt/model/phpt/PhptTestCase.java +++ b/src/com/mostc/pftt/model/phpt/PhptTestCase.java @@ -380,7 +380,7 @@ public class PhptTestCase extends TestCase { // provide the regular expression and the original section from the PHPT test - twriter.show_exception(host, scenario_set, this, ex, expected_str, oexpected_str); + twriter.addTestException(host, scenario_set, this, ex, expected_str, oexpected_str); expected_re = new RE(); // marker to avoid trying again this.expected_re = new WeakReference<RE>(expected_re); return expected_re; diff --git a/src/com/mostc/pftt/model/sapi/AbstractManagedProcessesWebServerManager.java b/src/com/mostc/pftt/model/sapi/AbstractManagedProcessesWebServerManager.java index 00303bb..ce38bd3 100644 --- a/src/com/mostc/pftt/model/sapi/AbstractManagedProcessesWebServerManager.java +++ b/src/com/mostc/pftt/model/sapi/AbstractManagedProcessesWebServerManager.java @@ -114,13 +114,8 @@ public abstract class AbstractManagedProcessesWebServerManager extends WebServer break; } } catch ( IOException ex ) { - cm.printStackTrace(ex); } finally { - try { - sock.close(); - } catch ( Exception ex1 ) { - cm.printStackTrace(ex1); // TODO - } + sock.close(); } } if (!connected) { diff --git a/src/com/mostc/pftt/model/sapi/ApacheManager.java b/src/com/mostc/pftt/model/sapi/ApacheManager.java index 8d277ab..78cdde2 100644 --- a/src/com/mostc/pftt/model/sapi/ApacheManager.java +++ b/src/com/mostc/pftt/model/sapi/ApacheManager.java @@ -7,6 +7,7 @@ import java.util.Map; import javax.annotation.concurrent.ThreadSafe; +import com.mostc.pftt.host.ExecOutput; import com.mostc.pftt.host.Host; import com.mostc.pftt.model.phpt.EPhptTestStatus; import com.mostc.pftt.model.phpt.PhpBuild; @@ -26,7 +27,6 @@ import com.mostc.pftt.util.VisualStudioUtil; * */ -// TODO check that apache's version of OpenSSL == PHP's version of OpenSSL @ThreadSafe public class ApacheManager extends AbstractManagedProcessesWebServerManager { /** URL to ApacheLounge's Windows Builds (as a .ZIP file) */ @@ -44,6 +44,35 @@ public class ApacheManager extends AbstractManagedProcessesWebServerManager { this(EApacheVersion.DEFAULT); } + /** Both PHP and Apache MUST be built with same version of OpenSSL or some openssl functions (and PHPTs) will crash. + * + * @param cm + * @param host + * @param build + * @param apache_version + * @param apache_dir + * @return + */ + public static boolean checkOpenSSLVersion(ConsoleManager cm, Host host, PhpBuild build, EApacheVersion apache_version, String apache_dir) { + try { + if (!host.isWindows() || apache_version == EApacheVersion.APACHE_2_2 ) + return true; + String os = apache_dir + "\\bin\\openssl.exe"; + if (!host.exists(os)) { + // can't check + cm.println(ApacheManager.class, "Can't find OpenSSL.exe (can't check OpenSSL version, assuming its ok)"); + return true; + } + + ExecOutput eo = host.exec("\""+os+"\" version", Host.ONE_MINUTE); + System.err.println(eo.output); + return eo.output.contains("0.9.8"); + } catch ( Exception ex ) { + cm.addGlobalException(ApacheManager.class, "checkOpenSSLVersion", ex, "Error determining OpenSSL version"); + return true; + } + } + public static String httpd(EApacheVersion apache_version, Host host) { if (host.isWindows()) { if (apache_version==EApacheVersion.APACHE_2_2) @@ -97,7 +126,7 @@ public class ApacheManager extends AbstractManagedProcessesWebServerManager { if (cm==null) ex.printStackTrace(); else - cm.printStackTrace(ex); + cm.addGlobalException(ApacheManager.class, "decideApacheVersion", ex, ""); return EApacheVersion.FALLBACK; } } @@ -136,6 +165,13 @@ public class ApacheManager extends AbstractManagedProcessesWebServerManager { if (host!=this.cache_host||this.cache_httpd==null||this.cache_httpd.equals(httpd)) { // do this once VisualStudioUtil.setExeStackSize(cm, host, httpd, VisualStudioUtil.SIXTEEN_MEGABYTES); + + // check OpenSSL version + if (!checkOpenSSLVersion(cm, host, build, apache_version, Host.dirname(Host.dirname(httpd)))) { + cm.println(getClass(), "Apache built with different version of OpenSSL than the version PHP is built with. Can't use this Apache build!"); + return null; + } + this.cache_host = host; this.cache_httpd = httpd; } @@ -181,15 +217,13 @@ public class ApacheManager extends AbstractManagedProcessesWebServerManager { try { host.saveTextFile(php_conf_file, ini.toString()); } catch ( Exception ex ) { - cm.printStackTrace(ex); - cm.println(getName(), "Unable to save PhpIni: "+php_conf_file); + cm.addGlobalException(getClass(), "createManagedProcessWebServerInstance", ex, "Unable to save PhpIni: "+php_conf_file); return null; } try { host.saveTextFile(apache_conf_file, conf_str); } catch ( Exception ex ) { - cm.printStackTrace(ex); - cm.println(getName(), "Unable to save Apache configuration: "+apache_conf_file); + cm.addGlobalException(getClass(), "createManagedProcessWebServerInstance", ex, "Unable to save Apache configuration: "+apache_conf_file); return null; } @@ -262,7 +296,7 @@ public class ApacheManager extends AbstractManagedProcessesWebServerManager { try { return host.exec(httpd(apache_version, host)+" -V", Host.ONE_MINUTE).output; } catch ( Exception ex ) { - cm.printStackTrace(ex); + cm.addGlobalException(getClass(), "getInstanceInfo", ex, ""); return StringUtil.EMPTY; } } @@ -284,7 +318,7 @@ public class ApacheManager extends AbstractManagedProcessesWebServerManager { return true; } } catch ( Exception ex ) { - cm.printStackTrace(ex); + cm.addGlobalException(getClass(), "setup", ex, ""); } return false; } @@ -373,7 +407,7 @@ public class ApacheManager extends AbstractManagedProcessesWebServerManager { else return host.exec("/etc/init.d/apache start", Host.ONE_MINUTE).printOutputIfCrash(getClass(), cm).isSuccess(); } catch ( Exception ex ) { - cm.printStackTrace(ex); + cm.addGlobalException(getClass(), "start", ex, ""); } return false; } @@ -388,7 +422,7 @@ public class ApacheManager extends AbstractManagedProcessesWebServerManager { else return host.exec("/etc/init.d/apache stop", Host.ONE_MINUTE).printOutputIfCrash(getClass(), cm).isSuccess(); } catch ( Exception ex ) { - cm.printStackTrace(ex); + cm.addGlobalException(getClass(), "stop", ex, ""); } return false; } diff --git a/src/com/mostc/pftt/model/sapi/BuiltinWebServerManager.java b/src/com/mostc/pftt/model/sapi/BuiltinWebServerManager.java index f64960c..fb9cb4c 100644 --- a/src/com/mostc/pftt/model/sapi/BuiltinWebServerManager.java +++ b/src/com/mostc/pftt/model/sapi/BuiltinWebServerManager.java @@ -47,7 +47,7 @@ public class BuiltinWebServerManager extends AbstractManagedProcessesWebServerMa try { return build.getPhpInfo(cm, host); } catch ( Exception ex ) { - cm.printStackTrace(ex); + cm.addGlobalException(getClass(), "getInstanceInfo", ex, ""); return StringUtil.EMPTY; } } diff --git a/src/com/mostc/pftt/model/sapi/EApacheVersion.java b/src/com/mostc/pftt/model/sapi/EApacheVersion.java index e5613c7..a4f780f 100644 --- a/src/com/mostc/pftt/model/sapi/EApacheVersion.java +++ b/src/com/mostc/pftt/model/sapi/EApacheVersion.java @@ -79,7 +79,7 @@ public enum EApacheVersion { try { return isSupportedEx(cm, host, build); } catch ( Exception ex ) { - cm.printStackTrace(ex); + cm.addGlobalException(getClass(), "isSupported", ex, ""); return false; } } diff --git a/src/com/mostc/pftt/model/sapi/IISManager.java b/src/com/mostc/pftt/model/sapi/IISManager.java index b58cf2c..05cbb0d 100644 --- a/src/com/mostc/pftt/model/sapi/IISManager.java +++ b/src/com/mostc/pftt/model/sapi/IISManager.java @@ -53,7 +53,7 @@ public class IISManager extends WebServerManager { try { return do_start(host).printOutputIfCrash(getClass(), cm).isSuccess(); } catch ( Exception ex ) { - cm.printStackTrace(ex); + cm.addGlobalException(getClass(), "start", ex, ""); return false; } } @@ -66,7 +66,7 @@ public class IISManager extends WebServerManager { if (cm==null) ex.printStackTrace(); else - cm.printStackTrace(ex); + cm.addGlobalException(getClass(), "stop", ex, ""); return false; } } @@ -121,7 +121,7 @@ public class IISManager extends WebServerManager { // set docroot to the location of the installed test-pack return appcmd(host, "set vdir /vdir.name:\""+site_name+"/"+app_name+"\" /physicalPath:\""+doc_root+"\""); } catch ( Exception ex ) { - cm.printStackTrace(ex); + cm.addGlobalException(getClass(), "configure", ex, ""); } return null; } // end public ExecOutput configure @@ -136,7 +136,7 @@ public class IISManager extends WebServerManager { if (cm==null) ex.printStackTrace(); else - cm.printStackTrace(ex); + cm.addGlobalException(getClass(), "undoConfigure", ex, ""); } return false; } @@ -253,7 +253,7 @@ public class IISManager extends WebServerManager { try { return appcmd(host, "-v").output; } catch ( Exception ex ) { - cm.printStackTrace(ex); + cm.addGlobalException(getClass(), "getInstanceInfo", ex, ""); return StringUtil.EMPTY; } } @@ -294,9 +294,7 @@ public class IISManager extends WebServerManager { cm.println(getClass(), "IIS install failed"); } } catch ( Exception ex ) { - cm.printStackTrace(ex); - - cm.println(getClass(), "exception during IIS install."); + cm.addGlobalException(getClass(), "setup", ex, "exception during IIS install."); } return false; } diff --git a/src/com/mostc/pftt/model/smoke/RequiredExtensionsSmokeTest.java b/src/com/mostc/pftt/model/smoke/RequiredExtensionsSmokeTest.java index 0d0531b..fccaf75 100644 --- a/src/com/mostc/pftt/model/smoke/RequiredExtensionsSmokeTest.java +++ b/src/com/mostc/pftt/model/smoke/RequiredExtensionsSmokeTest.java @@ -93,7 +93,7 @@ public class RequiredExtensionsSmokeTest extends SmokeTest { } return ESmokeTestStatus.PASS; } catch ( Exception ex ) { - cm.printStackTrace(ex); + cm.addGlobalException(getClass(), "test", ex, ""); return ESmokeTestStatus.INTERNAL_EXCEPTION; } } // end public ESmokeTestStatus test diff --git a/src/com/mostc/pftt/model/smoke/RequiredFeaturesSmokeTest.java b/src/com/mostc/pftt/model/smoke/RequiredFeaturesSmokeTest.java index 8956367..7db1852 100644 --- a/src/com/mostc/pftt/model/smoke/RequiredFeaturesSmokeTest.java +++ b/src/com/mostc/pftt/model/smoke/RequiredFeaturesSmokeTest.java @@ -1228,7 +1228,7 @@ public class RequiredFeaturesSmokeTest extends SmokeTest { } return status; } catch ( Exception ex ) { - cm.printStackTrace(ex); + cm.addGlobalException(getClass(), "test", ex, ""); return ESmokeTestStatus.INTERNAL_EXCEPTION; } } // end public ESmokeTestStatus test diff --git a/src/com/mostc/pftt/results/ConsoleManager.java b/src/com/mostc/pftt/results/ConsoleManager.java index 4907d34..fc3092e 100644 --- a/src/com/mostc/pftt/results/ConsoleManager.java +++ b/src/com/mostc/pftt/results/ConsoleManager.java @@ -13,12 +13,12 @@ import com.mostc.pftt.ui.PhptDebuggerFrame; import com.mostc.pftt.util.ErrorUtil; public class ConsoleManager { - protected final boolean force, windebug, results_only, show_gui, disable_debug_prompt, dont_cleanup_test_pack, phpt_not_in_place; + protected final boolean force, windebug, results_only, show_gui, disable_debug_prompt, dont_cleanup_test_pack, phpt_not_in_place, pftt_debug; protected String source_pack; protected PhpDebugPack debug_pack; protected PhptDebuggerFrame gui; - public ConsoleManager(String source_pack, PhpDebugPack debug_pack, boolean force, boolean windebug, boolean results_only, boolean show_gui, boolean disable_debug_prompt, boolean dont_cleanup_test_pack, boolean phpt_not_in_place) { + public ConsoleManager(String source_pack, PhpDebugPack debug_pack, boolean force, boolean windebug, boolean results_only, boolean show_gui, boolean disable_debug_prompt, boolean dont_cleanup_test_pack, boolean phpt_not_in_place, boolean pftt_debug) { this.source_pack = source_pack; this.debug_pack = debug_pack; this.force = force; @@ -28,6 +28,7 @@ public class ConsoleManager { this.disable_debug_prompt = disable_debug_prompt; this.dont_cleanup_test_pack = dont_cleanup_test_pack; this.phpt_not_in_place = phpt_not_in_place; + this.pftt_debug = pftt_debug; } public void showGUI(PhptTestPackRunner test_pack_runner) { @@ -50,7 +51,7 @@ public class ConsoleManager { } public boolean isDisableDebugPrompt() { - return true||disable_debug_prompt; // TODO temp + return disable_debug_prompt; } public boolean isForce() { @@ -60,6 +61,10 @@ public class ConsoleManager { public boolean isWinDebug() { return windebug; } + + public boolean isPfttDebug() { + return pftt_debug; + } public void finishedTest(PhptTestCase test_case, EPhptTestStatus status) { System.out.println(status+" "+test_case.getName()); @@ -87,13 +92,24 @@ public class ConsoleManager { public void println(Class<?> clazz, String string) { println(clazz.getSimpleName(), string); } + + public void addGlobalException(Class<?> clazz, String method_name, Exception ex, String msg) { + addGlobalException(clazz.getSimpleName()+"#"+method_name, ex, msg); + } - public void printStackTrace(Exception ex) { - if (results_only) - return; - + protected PhptResultPackWriter w; + public void addGlobalException(String ctx_str, Exception ex, String msg) { String ex_str = ErrorUtil.toString(ex); - System.err.println(ex_str); + if (!results_only) { + System.err.println(ex_str); + } + if (w!=null) { + synchronized (w.global_exception_writer) { + w.global_exception_writer.println(ctx_str); + w.global_exception_writer.println(msg==null?"":msg); + w.global_exception_writer.print(ex_str); + } + } } public boolean isResultsOnly() { diff --git a/src/com/mostc/pftt/results/PhptResultPackIndexDotHtmlWriter.groovy b/src/com/mostc/pftt/results/PhptResultPackIndexDotHtmlWriter.groovy new file mode 100644 index 0000000..03cddc2 --- /dev/null +++ b/src/com/mostc/pftt/results/PhptResultPackIndexDotHtmlWriter.groovy @@ -0,0 +1,5 @@ +package com.mostc.pftt.results + +class PhptResultPackIndexDotHtmlWriter { + // TODO +} diff --git a/src/com/mostc/pftt/results/PhptResultPackWriter.java b/src/com/mostc/pftt/results/PhptResultPackWriter.java index 5ad575f..0f48794 100644 --- a/src/com/mostc/pftt/results/PhptResultPackWriter.java +++ b/src/com/mostc/pftt/results/PhptResultPackWriter.java @@ -40,7 +40,7 @@ public class PhptResultPackWriter extends PhptResultPack { private File telem_dir; protected final HashMap<Host,HashMap<ScenarioSet,HashMap<EPhptTestStatus,PrintWriter>>> status_list_map; protected Host host; - protected PrintWriter exception_writer; + protected PrintWriter global_exception_writer; protected int total_count = 0; protected ConsoleManager cm; protected final HashMap<Host,HashMap<ScenarioSet,HashMap<EPhptTestStatus,AtomicInteger>>> counts; @@ -53,9 +53,9 @@ public class PhptResultPackWriter extends PhptResultPack { protected static File makeName(ConsoleManager cm, Host host, File base, PhpBuild build, int i) throws Exception { StringBuilder sb = new StringBuilder(); - sb.append("/PFTT-Result-Pack-"); + sb.append("/"); sb.append(build.getVersionBranch(cm, host)); - sb.append("-"); + sb.append("-Result-Pack-"); sb.append(build.getBuildType(host)); sb.append("-"); sb.append(build.getVersionRevision(cm, host)); @@ -95,7 +95,7 @@ public class PhptResultPackWriter extends PhptResultPack { serial.setFeature("http://xmlpull.org/v1/doc/features.html#indent-output", true); // - + cm.w = this; this.host = host; this.cm = cm; @@ -107,7 +107,7 @@ public class PhptResultPackWriter extends PhptResultPack { results = new LinkedBlockingQueue<ResultQueueEntry>(); - exception_writer = new PrintWriter(new FileWriter(this.telem_dir+"/GLOBAL_EXCEPTIONS.txt")); + global_exception_writer = new PrintWriter(new FileWriter(this.telem_dir+"/GLOBAL_EXCEPTIONS.txt")); new Thread() { @Override @@ -151,15 +151,26 @@ public class PhptResultPackWriter extends PhptResultPack { ex.printStackTrace(); } - /* TODO for(EPhptTestStatus status:EPhptTestStatus.values()) { - PrintWriter pw = status_list_map.get(status); - pw.close(); - }*/ + try { + PhptTestResultStylesheetWriter.writeStylesheet(telem_dir + "/phptresult.xsl"); + } catch ( Exception ex ) { + ex.printStackTrace(); + } - // TODO store phpinfo + try { + for (Host h:status_list_map.keySet()) { + for (ScenarioSet s:status_list_map.get(h).keySet()) { + for (PrintWriter pw:status_list_map.get(h).get(s).values()) { + pw.close(); + } + } + } + } catch ( Exception ex ) { + ex.printStackTrace(); + } // store systeminfo - /* TODO try { + /* TODO store per host try { FileWriter fw = new FileWriter(new File(telem_dir, "system_info.txt")); fw.write(host.getSystemInfo()); fw.close(); @@ -235,26 +246,19 @@ public class PhptResultPackWriter extends PhptResultPack { return pass / (pass+fail); } - public void show_exception(Host this_host, ScenarioSet this_scenario_set, PhptTestCase test_file, Throwable ex) { - show_exception(this_host, this_scenario_set, test_file, ex, null); + public void addTestException(Host this_host, ScenarioSet this_scenario_set, PhptTestCase test_file, Throwable ex, Object a) { + addTestException(this_host, this_scenario_set, test_file, ex, a, null); } - public void show_exception(Host this_host, ScenarioSet this_scenario_set, PhptTestCase test_file, Throwable ex, Object a) { - show_exception(this_host, this_scenario_set, test_file, ex, a, null); - } - public void show_exception(Host this_host, ScenarioSet this_scenario_set, PhptTestCase test_case, Throwable ex, Object a, Object b) { + public void addTestException(Host this_host, ScenarioSet this_scenario_set, PhptTestCase test_case, Throwable ex, Object a, Object b) { String ex_str = ErrorUtil.toString(ex); if (a!=null) ex_str += " a="+a; if (b!=null) ex_str += " b="+b; - /*synchronized(exception_writer) { - exception_writer.println("EXCEPTION "+test_case); - exception_writer.println(ex_str); - exception_writer.flush(); // CRITICAL - }*/ - - System.err.println(ex_str); + if (!cm.isResultsOnly()) { + System.err.println(ex_str); + } // count exceptions as a result (the worst kind of failure, a pftt failure) addResult(this_host, this_scenario_set, new PhptTestResult(host, EPhptTestStatus.TEST_EXCEPTION, test_case, ex_str, null, null, null, null, null, null, null, null, null, null, null)); @@ -367,14 +371,15 @@ public class PhptResultPackWriter extends PhptResultPack { // write result info in XML format serial.startDocument(null, null); - result.serialize(serial, store_all); + // write result and reference to the XSL stylesheet + result.serialize(serial, store_all, StringUtil.repeat("../", Host.countUp(test_case_base_name, telem_dir.getAbsolutePath()))+"/phptresult.xsl"); serial.endDocument(); serial.flush(); out.close(); } catch ( Exception ex ) { - cm.printStackTrace(ex); + cm.addGlobalException(getClass(), "handleResult", ex, ""); } // @@ -389,7 +394,7 @@ public class PhptResultPackWriter extends PhptResultPack { fw.write(result.shell_script); fw.close(); } catch ( Exception ex ) { - cm.printStackTrace(ex); + cm.addGlobalException(getClass(), "handleResult", ex, ""); } try { @@ -397,7 +402,7 @@ public class PhptResultPackWriter extends PhptResultPack { fw.write(result.test_case.get(EPhptSection.FILE)); fw.close(); } catch ( Exception ex ) { - cm.printStackTrace(ex); + cm.addGlobalException(getClass(), "handleResult", ex, ""); } } // diff --git a/src/com/mostc/pftt/results/PhptTestResult.java b/src/com/mostc/pftt/results/PhptTestResult.java index 3479f20..2b04f8b 100644 --- a/src/com/mostc/pftt/results/PhptTestResult.java +++ b/src/com/mostc/pftt/results/PhptTestResult.java @@ -152,10 +152,14 @@ public class PhptTestResult { } public void serialize(XmlSerializer serial) throws IllegalArgumentException, IllegalStateException, IOException { - serialize(serial, shouldStoreAllInfo(status)); + serialize(serial, shouldStoreAllInfo(status), null); } - public void serialize(XmlSerializer serial, boolean include_all) throws IllegalArgumentException, IllegalStateException, IOException { + public void serialize(XmlSerializer serial, boolean include_all, String stylesheet) throws IllegalArgumentException, IllegalStateException, IOException { + if (StringUtil.isNotEmpty(stylesheet)) { + serial.processingInstruction("xml-stylesheet type=\"text/xsl\" href=\""+stylesheet+"\""); + } + serial.startTag(null, "phptResult"); if (status!=null) serial.attribute(null, "status", status.toString()); diff --git a/src/com/mostc/pftt/results/PhptTestResultStylesheetWriter.groovy b/src/com/mostc/pftt/results/PhptTestResultStylesheetWriter.groovy new file mode 100644 index 0000000..22ac429 --- /dev/null +++ b/src/com/mostc/pftt/results/PhptTestResultStylesheetWriter.groovy @@ -0,0 +1,79 @@ +package com.mostc.pftt.results + +final class PhptTestResultStylesheetWriter { + static def writeStylesheet(String file_path) { + FileWriter fw = new FileWriter(file_path) + fw.write(""" +<?xml version="1.0" encoding="UTF-8"?> +<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> + +<xsl:template match="/"> + +<html> +<head> +<title><xsl:value-of select="//phptResult/@testCase" /></title> +</head> +<body> + +<p>Test Case: <strong><xsl:value-of select="//phptResult/@testCase" /></strong></p> +<p>Status: <strong><xsl:value-of select="//phptResult/@status" /></strong> Actual Charset: <strong><xsl:value-of select="//phptResult/@actualcharset" /></strong></p> + +<h2>Actual</h2> +<pre><xsl:value-of select="//phptResult/actual" /></pre> +<h2>Diff</h2> +<pre><xsl:value-of select="//phptResult/diff" /></pre> +<h2>ENV</h2> +<table border="1"> +<xsl:for-each select="//phptResult/env"> + <tr> + <td><xsl:value-of select="@name"/></td> + <td><xsl:value-of select="."/></td> + </tr> +</xsl:for-each> +</table> +<h2>STDIN</h2> +<pre><xsl:value-of select="//phptResult/stdin" /></pre> +<h2>SAPI Output</h2> +<pre><xsl:value-of select="//phptResult/SAPIOutput" /></pre> +<h2>Pre-Override Actual</h2> +<pre><xsl:value-of select="//phptResult/preoverrideActual" /></pre> +<h2>INI</h2> +<pre><xsl:value-of select="//phptResult/ini" /></pre> +<h2>EXPECTF Output</h2> +<pre><xsl:value-of select="//phptResult/expectFOutput" /></pre> +<h2>Shell Script</h2> +<pre><xsl:value-of select="//phptResult/shellScript" /></pre> +<h2>Command</h2> +<table border="1"> +<xsl:for-each select="//phptResult/cmdArray/part"> + <tr> + <td><xsl:value-of select="."/></td> + </tr> +</xsl:for-each> +</table> +<h2>HTTP Request</h2> +<pre><xsl:value-of select="//phptResult/httpRequest" /></pre> +<h2>HTTP Response</h2> +<pre><xsl:value-of select="//phptResult/httpResponse" /></pre> + +<table border="1"> +<xsl:for-each select="//phptResult/phptTestCase/*"> + <tr> + <td><xsl:value-of select="name()"/></td> + <td><pre><xsl:value-of select="."/></pre></td> + </tr> +</xsl:for-each> +</table> + +</body> +</html> + +</xsl:template> + + +</xsl:stylesheet> +""") + fw.close() + } + +} diff --git a/src/com/mostc/pftt/runner/AbstractPhptTestCaseRunner2.java b/src/com/mostc/pftt/runner/AbstractPhptTestCaseRunner2.java index cddb852..c53d99e 100644 --- a/src/com/mostc/pftt/runner/AbstractPhptTestCaseRunner2.java +++ b/src/com/mostc/pftt/runner/AbstractPhptTestCaseRunner2.java @@ -416,7 +416,7 @@ request = "Content-Disposition: form-data; name=\"PHPSESSID\"\r\n" + try { expected_re_match = test_case.getExpectedCompiled(host, scenario_set, twriter).match(output_trim); } catch (Throwable ex) { - twriter.show_exception(host, scenario_set, test_case, ex, expected); + twriter.addTestException(host, scenario_set, test_case, ex, expected); throw ex; } if (expected_re_match||a(test_case)||output_trim.contains("<html>")) { @@ -438,7 +438,7 @@ request = "Content-Disposition: form-data; name=\"PHPSESSID\"\r\n" + try { expected_re_match = test_case.getExpectedCompiled(host, scenario_set, twriter).match(output_trim); } catch (Throwable ex) { - twriter.show_exception(host, scenario_set, test_case, ex, expected); + twriter.addTestException(host, scenario_set, test_case, ex, expected); throw ex; } if (expected_re_match) { diff --git a/src/com/mostc/pftt/runner/HttpTestCaseRunner.java b/src/com/mostc/pftt/runner/HttpTestCaseRunner.java index 6da1e62..4955062 100644 --- a/src/com/mostc/pftt/runner/HttpTestCaseRunner.java +++ b/src/com/mostc/pftt/runner/HttpTestCaseRunner.java @@ -96,7 +96,9 @@ public class HttpTestCaseRunner extends AbstractPhptTestCaseRunner2 { try { return do_http_execute(path, section, false); } catch ( IOException ex1 ) { // SocketTimeoutException or ConnectException - twriter.getConsoleManager().printStackTrace(ex1); + if (twriter.getConsoleManager().isPfttDebug()) { + ex1.printStackTrace(); + } // notify of crash so it gets reported everywhere web.notifyCrash("PFTT: timeout during test("+section+" SECTION): "+test_case.getName()+"\n"+ErrorUtil.toString(ex1), 0); diff --git a/src/com/mostc/pftt/runner/PhptTestPackRunner.java b/src/com/mostc/pftt/runner/PhptTestPackRunner.java index f35eaf2..e667a39 100644 --- a/src/com/mostc/pftt/runner/PhptTestPackRunner.java +++ b/src/com/mostc/pftt/runner/PhptTestPackRunner.java @@ -141,7 +141,7 @@ public class PhptTestPackRunner extends AbstractTestPackRunner { // copy test-pack onto (remote) file system active_test_pack = src_test_pack.install(host, test_pack_dir); } catch (Exception ex ) { - twriter.getConsoleManager().printStackTrace(ex); + twriter.getConsoleManager().addGlobalException(getClass(), "runTestList", ex, ""); } if (active_test_pack==null) { twriter.getConsoleManager().println(getClass(), "unable to install test-pack, giving up!"); @@ -245,7 +245,7 @@ public class PhptTestPackRunner extends AbstractTestPackRunner { continue; } } catch ( Exception ex ) { - twriter.getConsoleManager().printStackTrace(ex); + twriter.getConsoleManager().addGlobalException(getClass(), "groupTestCases", ex, ""); continue; } @@ -362,7 +362,7 @@ public class PhptTestPackRunner extends AbstractTestPackRunner { // execute any remaining thread safe jobs runThreadSafe(); } catch ( Exception ex ) { - twriter.getConsoleManager().printStackTrace(ex); + twriter.getConsoleManager().addGlobalException(getClass(), "run", ex, ""); } finally { if (run_thread.get()) // if #stopThisThread not called @@ -445,7 +445,7 @@ public class PhptTestPackRunner extends AbstractTestPackRunner { sapi_scenario.createPhptTestCaseRunner(this, group_key, test_case, twriter, host, scenario_set, build, src_test_pack, active_test_pack) .runTest(); } catch ( Throwable ex ) { - twriter.show_exception(host, scenario_set, test_case, ex, sa); + twriter.addTestException(host, scenario_set, test_case, ex, sa); } test_count.incrementAndGet(); diff --git a/src/com/mostc/pftt/scenario/AbstractINIScenario.java b/src/com/mostc/pftt/scenario/AbstractINIScenario.java index d239834..f826523 100644 --- a/src/com/mostc/pftt/scenario/AbstractINIScenario.java +++ b/src/com/mostc/pftt/scenario/AbstractINIScenario.java @@ -30,7 +30,7 @@ public abstract class AbstractINIScenario extends AbstractSerialScenario { return true; } } catch ( Exception ex ) { - cm.printStackTrace(ex); + cm.addGlobalException(getClass(), "setup", ex, ""); } return false; } // end public boolean setup diff --git a/src/com/mostc/pftt/scenario/AbstractSMBScenario.java b/src/com/mostc/pftt/scenario/AbstractSMBScenario.java index 75a1821..f7e0afb 100644 --- a/src/com/mostc/pftt/scenario/AbstractSMBScenario.java +++ b/src/com/mostc/pftt/scenario/AbstractSMBScenario.java @@ -81,7 +81,7 @@ public abstract class AbstractSMBScenario extends AbstractRemoteFileSystemScenar return false; } } catch (Exception ex ) { - cm.printStackTrace(ex); + cm.addGlobalException(getClass(), "createShare", ex, ""); return false; } @@ -112,7 +112,7 @@ public abstract class AbstractSMBScenario extends AbstractRemoteFileSystemScenar else return connectFromSamba(); } catch ( Exception ex ) { - cm.printStackTrace(ex); + cm.addGlobalException(getClass(), "connect", ex, ""); return false; } } else { @@ -156,7 +156,7 @@ public abstract class AbstractSMBScenario extends AbstractRemoteFileSystemScenar return true; } } catch ( Exception ex ) { - cm.printStackTrace(ex); + cm.addGlobalException(getClass(), "deleteShare", ex, ""); } return false; } @@ -165,7 +165,7 @@ public abstract class AbstractSMBScenario extends AbstractRemoteFileSystemScenar try { return host.exec("NET USE "+local_drive+" /DELETE", Host.ONE_MINUTE).printOutputIfCrash(getClass(), cm).isSuccess(); } catch ( Exception ex ) { - cm.printStackTrace(ex); + cm.addGlobalException(getClass(), "disconnect", ex, ""); } return false; } diff --git a/src/com/mostc/pftt/scenario/LocalFileSystemScenario.java b/src/com/mostc/pftt/scenario/LocalFileSystemScenario.java index adb8ec5..74a3890 100644 --- a/src/com/mostc/pftt/scenario/LocalFileSystemScenario.java +++ b/src/com/mostc/pftt/scenario/LocalFileSystemScenario.java @@ -32,7 +32,7 @@ public class LocalFileSystemScenario extends AbstractFileSystemScenario { host.mkdirs(getTestPackStorageDir(host)); return true; } catch ( Exception ex ) { - cm.printStackTrace(ex); + cm.addGlobalException(LocalFileSystemScenario.class, "notifyPrepareStorageDir", ex, ""); return false; } } diff --git a/src/com/mostc/pftt/scenario/SMBCSCOptionScenario.java b/src/com/mostc/pftt/scenario/SMBCSCOptionScenario.java index 2d86430..ee5f0ae 100644 --- a/src/com/mostc/pftt/scenario/SMBCSCOptionScenario.java +++ b/src/com/mostc/pftt/scenario/SMBCSCOptionScenario.java @@ -31,10 +31,9 @@ public abstract class SMBCSCOptionScenario extends AbstractOptionScenario { return true; } } catch ( Exception ex ) { - cm.printStackTrace(ex); - cm.println(getName(), "Unable to "+(isEnable()?"enable":"disable")+" CSC"); + cm.addGlobalException(getClass(), "setup", ex, "Unable to "+(isEnable()?"enable":"disable")+" CSC"); } return false; - } + } // end public boolean setup -} +} // end public abstract class SMBCSCOptionScenario diff --git a/src/com/mostc/pftt/scenario/SMBDFSRScenario.java b/src/com/mostc/pftt/scenario/SMBDFSRScenario.java index ae51349..5a04847 100644 --- a/src/com/mostc/pftt/scenario/SMBDFSRScenario.java +++ b/src/com/mostc/pftt/scenario/SMBDFSRScenario.java @@ -57,7 +57,7 @@ public class SMBDFSRScenario extends AbstractSMBScenario { cm.println(getName(), "can't exec powershell script: "+tmp_file); } } catch ( Exception ex ) { - cm.printStackTrace(ex); + cm.addGlobalException(getClass(), "setup", ex, ""); } return false; } @@ -67,4 +67,4 @@ public class SMBDFSRScenario extends AbstractSMBScenario { return true; } -} +} // end public class SMBDFSRScenario diff --git a/src/com/mostc/pftt/scenario/SMBDeduplicationScenario.java b/src/com/mostc/pftt/scenario/SMBDeduplicationScenario.java index aabb9cc..189ffdd 100644 --- a/src/com/mostc/pftt/scenario/SMBDeduplicationScenario.java +++ b/src/com/mostc/pftt/scenario/SMBDeduplicationScenario.java @@ -96,8 +96,7 @@ public class SMBDeduplicationScenario extends AbstractSMBScenario { return true; } } catch ( Exception ex ) { - cm.printStackTrace(ex); - cm.println(getName(), "Unable to enable deduplication"); + cm.addGlobalException(getClass(), "notifyPrepareStorageDir", ex, "Unable to enable deduplication"); } return false; } // end public boolean notifyPrepareStorageDir @@ -115,11 +114,12 @@ public class SMBDeduplicationScenario extends AbstractSMBScenario { if (remote_host.exec("powershell -Command {Start-Dedupjob -Volume "+volume+" -Type Optimization -Wait}", Host.FOUR_HOURS).printOutputIfCrash(getClass(), cm).isSuccess()) { cm.println(getName(), "Deduplication completed successfully."); return true; + } else { + cm.println(getName(), "Deduplication failed"); } } catch ( Exception ex ) { - cm.printStackTrace(ex); + cm.addGlobalException(getClass(), "notifyTestPackInstalled", ex, "Deduplication failed"); } - cm.println(getName(), "Deduplication failed"); return false; } diff --git a/src/com/mostc/pftt/util/DebuggerManager.java b/src/com/mostc/pftt/util/DebuggerManager.java index 99092d6..91268be 100644 --- a/src/com/mostc/pftt/util/DebuggerManager.java +++ b/src/com/mostc/pftt/util/DebuggerManager.java @@ -75,7 +75,7 @@ public abstract class DebuggerManager { else this.src_path = host.joinMultiplePaths(def_source_path, build.guessSourcePackPath(cm, host)); } catch ( Exception ex ) { - cm.printStackTrace(ex); + cm.addGlobalException(getClass(), "ensureFindSourceAndDebugPack", ex, ""); } try { if (StringUtil.isEmpty(def_debug_path)) @@ -83,7 +83,7 @@ public abstract class DebuggerManager { else this.debug_path = host.joinMultiplePaths(def_debug_path, build.guessDebugPackPath(cm, host)); } catch ( Exception ex ) { - cm.printStackTrace(ex); + cm.addGlobalException(getClass(), "ensureFindSourceAndDebugPack", ex, ""); } } // end protected void ensureFindSourceAndDebugPack diff --git a/src/com/mostc/pftt/util/DownloadUtil.java b/src/com/mostc/pftt/util/DownloadUtil.java index a4f29b6..0e0da41 100644 --- a/src/com/mostc/pftt/util/DownloadUtil.java +++ b/src/com/mostc/pftt/util/DownloadUtil.java @@ -37,7 +37,7 @@ public class DownloadUtil { try { return downloadAndUnzip(cm, host, new URL(remote_url), local_dir); } catch ( Exception ex ) { - cm.printStackTrace(ex); + cm.addGlobalException(DownloadUtil.class, "downloadAndUnzip", ex, ""); return false; } } @@ -89,15 +89,14 @@ public class DownloadUtil { out_file.close(); } catch ( Exception ex ) { - cm.printStackTrace(ex); - cm.println(DownloadUtil.class, "error downloading file: "+remote_url); + cm.addGlobalException(DownloadUtil.class, "downloadAndUnzip", ex, "error downloading file: "+remote_url); return false; } finally { if ( response == null || !connStrategy.keepAlive(response, context)) { try { conn.close(); } catch ( Exception ex ) { - cm.printStackTrace(ex); + cm.addGlobalException(DownloadUtil.class, "downloadAndUnzip", ex, ""); } } } @@ -113,9 +112,9 @@ public class DownloadUtil { return true; } catch ( Exception ex ) { - cm.printStackTrace(ex); + cm.addGlobalException(DownloadUtil.class, "downloadAndUnzip", ex, ""); return false; } - } + } // end public static boolean downloadAndUnzip -} +} // end public class DownloadUtil diff --git a/src/com/mostc/pftt/util/StringUtil.java b/src/com/mostc/pftt/util/StringUtil.java index 7c83175..79b8e62 100644 --- a/src/com/mostc/pftt/util/StringUtil.java +++ b/src/com/mostc/pftt/util/StringUtil.java @@ -348,8 +348,13 @@ public final class StringUtil { return false; } - private StringUtil() {} - + public static String repeat(String patt, int count) { + StringBuilder sb = new StringBuilder(patt.length()*count); + for ( int i=0 ; i < count ; i++ ) + sb.append(patt); + return sb.toString(); + } + private StringUtil() {} } // end public class StringUtil diff --git a/src/com/mostc/pftt/util/WinDebugManager.java b/src/com/mostc/pftt/util/WinDebugManager.java index a4458ac..8b7c967 100644 --- a/src/com/mostc/pftt/util/WinDebugManager.java +++ b/src/com/mostc/pftt/util/WinDebugManager.java @@ -44,7 +44,7 @@ public class WinDebugManager extends DebuggerManager { try { return new WinDebug(host, win_dbg_exe, toServerName(server_name), src_path, debug_path, build.getBuildPath(), process_id); } catch ( Exception ex ) { - cm.printStackTrace(ex); + cm.addGlobalException(getClass(), "newDebugger", ex, ""); } } return null;