diff options
author | Frank Schoenheit [fs] <frank.schoenheit@oracle.com> | 2010-10-04 19:55:06 +0200 |
---|---|---|
committer | Frank Schoenheit [fs] <frank.schoenheit@oracle.com> | 2010-10-04 19:55:06 +0200 |
commit | 3cf32543d4a64f2d8186cd9d65752f5d8bff099a (patch) | |
tree | 5b74b2dd66657f6fe830a3ef1c95668fe2f7c8ad /qadevOOo | |
parent | 0e788afb627639d2d463d5d8061ebbec849b219f (diff) | |
parent | 664c84c6d716e0ec08d1bd95719ea9aa8ecc4dcb (diff) |
dba34b: pulled DEV300:m89
Diffstat (limited to 'qadevOOo')
-rw-r--r-- | qadevOOo/runner/graphical/EnhancedComplexTestCase.java | 23 | ||||
-rw-r--r-- | qadevOOo/runner/graphical/JPEGCreator.java | 3 | ||||
-rw-r--r-- | qadevOOo/runner/graphical/JPEGEvaluator.java | 2 | ||||
-rw-r--r-- | qadevOOo/runner/graphical/Office.java | 1 | ||||
-rw-r--r-- | qadevOOo/runner/graphical/OpenOfficePostscriptCreator.java | 3 | ||||
-rw-r--r-- | qadevOOo/runner/graphical/ParameterHelper.java | 3 | ||||
-rw-r--r-- | qadevOOo/runner/graphical/PostscriptCreator.java | 3 | ||||
-rw-r--r-- | qadevOOo/runner/helper/OfficeProvider.java | 6 | ||||
-rw-r--r-- | qadevOOo/runner/helper/ProcessHandler.java | 187 | ||||
-rw-r--r-- | qadevOOo/runner/org/openoffice/Runner.java | 2 |
10 files changed, 211 insertions, 22 deletions
diff --git a/qadevOOo/runner/graphical/EnhancedComplexTestCase.java b/qadevOOo/runner/graphical/EnhancedComplexTestCase.java index c3ec2b3e8336..3d496826f5f2 100644 --- a/qadevOOo/runner/graphical/EnhancedComplexTestCase.java +++ b/qadevOOo/runner/graphical/EnhancedComplexTestCase.java @@ -45,7 +45,7 @@ abstract public class EnhancedComplexTestCase extends ComplexTestCase implements private void callEntry(String _sEntry, ParameterHelper _aParam) { // log.println("- next file is: ------------------------------"); - log.println("File: " + _sEntry); + log.println(" File: " + _sEntry); // TODO: check if 'sEntry' is a guilty document. File aFile = new File(_aParam.getInputPath()); String sPath = _aParam.getInputPath(); @@ -254,8 +254,15 @@ private void callEntry(String _sEntry, ParameterHelper _aParam) for (int i=0;i<aList.size();i++) { String sEntry = aList.get(i); - callEntry(sEntry, _aParam); - + try + { + callEntry(sEntry, _aParam); + } + catch (AssureException e) + { + // we only need to catch the assure() + // nOkStatus += 2; + } // we want to know the current status of the run through // if the status is greater (more bad) then the current, // we will remember this. Only the very bad status will @@ -469,9 +476,13 @@ private void callEntry(String _sEntry, ParameterHelper _aParam) { String sPSFile = aList.get(i); - // TODO: this information has to come out of the ini files - String sStatusRunThrough = ""; - String sStatusMessage = ""; + // Read information out of the ini files + String sIndexFile2 = FileHelper.appendPath(sPath, sPSFile + ".ini"); + IniFile aIniFile2 = new IniFile(sIndexFile2); + String sStatusRunThrough = aIniFile2.getValue("global", "state"); + String sStatusMessage = ""; // aIniFile2.getValue("global", "info"); + aIniFile2.close(); + String sHTMLFile = sPSFile + ".html"; aOutputter.indexLine(sHTMLFile, sPSFile, sStatusRunThrough, sStatusMessage); diff --git a/qadevOOo/runner/graphical/JPEGCreator.java b/qadevOOo/runner/graphical/JPEGCreator.java index a4336229e448..7deee0d0d8f6 100644 --- a/qadevOOo/runner/graphical/JPEGCreator.java +++ b/qadevOOo/runner/graphical/JPEGCreator.java @@ -61,7 +61,8 @@ public class JPEGCreator extends EnhancedComplexTestCase public void checkOneFile(String _sDocumentName, String _sResult, ParameterHelper _aParams) throws OfficeException { - GlobalLogWriter.println("Document: " + _sDocumentName + " results: " + _sResult); + GlobalLogWriter.println(" Document: " + _sDocumentName); + GlobalLogWriter.println(" results: " + _sResult); // IOffice aOffice = new Office(_aParams, _sResult); // aOffice.start(); // aOffice.load(_sDocumentName); diff --git a/qadevOOo/runner/graphical/JPEGEvaluator.java b/qadevOOo/runner/graphical/JPEGEvaluator.java index 07b265b62355..049e96b15999 100644 --- a/qadevOOo/runner/graphical/JPEGEvaluator.java +++ b/qadevOOo/runner/graphical/JPEGEvaluator.java @@ -51,6 +51,8 @@ public class JPEGEvaluator extends EnhancedComplexTestCase GlobalLogWriter.set(log); ParameterHelper aParam = new ParameterHelper(param); + // aParam.getTestParameters().put("current_ok_status", -1); + // run through all documents found in Inputpath foreachResultCreateHTML(aParam); } diff --git a/qadevOOo/runner/graphical/Office.java b/qadevOOo/runner/graphical/Office.java index 8ecee36cc742..59eeb160f2d9 100644 --- a/qadevOOo/runner/graphical/Office.java +++ b/qadevOOo/runner/graphical/Office.java @@ -48,6 +48,7 @@ public class Office implements IOffice m_sResult = _sResult; if (_aParam.getReferenceType().toLowerCase().equals("ooo") || + _aParam.getReferenceType().toLowerCase().equals("o3") || _aParam.getReferenceType().toLowerCase().equals("ps") || _aParam.getReferenceType().toLowerCase().equals("pdf")) { diff --git a/qadevOOo/runner/graphical/OpenOfficePostscriptCreator.java b/qadevOOo/runner/graphical/OpenOfficePostscriptCreator.java index d918634f8d30..7111d5e0f794 100644 --- a/qadevOOo/runner/graphical/OpenOfficePostscriptCreator.java +++ b/qadevOOo/runner/graphical/OpenOfficePostscriptCreator.java @@ -102,6 +102,7 @@ public class OpenOfficePostscriptCreator implements IOffice { String sDocumentName = FileHelper.appendPath(m_sOutputURL, m_sBasename); if (m_aParameterHelper.getReferenceType().toLowerCase().equals("ooo") || + m_aParameterHelper.getReferenceType().toLowerCase().equals("o3") || m_aParameterHelper.getReferenceType().toLowerCase().equals("ps") ) { String sPrintURL = sDocumentName + ".ps"; @@ -1380,9 +1381,9 @@ public class OpenOfficePostscriptCreator implements IOffice // Watcher Object is need in log object to give a simple way to say if a running office is alive. // As long as a log comes, it pings the Watcher and says the office is alive, if not an // internal counter increase and at a given point (300 seconds) the office is killed. - GlobalLogWriter.println("Set office watcher"); if (GlobalLogWriter.get().getWatcher() == null) { + GlobalLogWriter.println("Set office watcher"); OfficeWatcher aWatcher = (OfficeWatcher)m_aParameterHelper.getTestParameters().get("Watcher"); GlobalLogWriter.get().setWatcher(aWatcher); } diff --git a/qadevOOo/runner/graphical/ParameterHelper.java b/qadevOOo/runner/graphical/ParameterHelper.java index 598ee6c53007..a3608b191f63 100644 --- a/qadevOOo/runner/graphical/ParameterHelper.java +++ b/qadevOOo/runner/graphical/ParameterHelper.java @@ -267,7 +267,8 @@ public class ParameterHelper // check if MultiServiceFactory is given if (getReferenceType().toLowerCase().equals("pdf") || getReferenceType().toLowerCase().equals("ps") || - getReferenceType().toLowerCase().equals("ooo")) + getReferenceType().toLowerCase().equals("ooo") || + getReferenceType().toLowerCase().equals("o3") ) { if (xMSF == null) { diff --git a/qadevOOo/runner/graphical/PostscriptCreator.java b/qadevOOo/runner/graphical/PostscriptCreator.java index ab7ad4536fa6..7109b4851b1b 100644 --- a/qadevOOo/runner/graphical/PostscriptCreator.java +++ b/qadevOOo/runner/graphical/PostscriptCreator.java @@ -59,7 +59,8 @@ public class PostscriptCreator extends EnhancedComplexTestCase public void checkOneFile(String _sDocumentName, String _sResult, ParameterHelper _aParams) throws OfficeException { - GlobalLogWriter.println("Document: " + _sDocumentName + " results: " + _sResult); + GlobalLogWriter.println(" Document: " + _sDocumentName); + GlobalLogWriter.println(" results: " + _sResult); IOffice aOffice = new Office(_aParams, _sResult); PerformanceContainer a = new PerformanceContainer(); diff --git a/qadevOOo/runner/helper/OfficeProvider.java b/qadevOOo/runner/helper/OfficeProvider.java index 8589de47ea82..1d4950ee5404 100644 --- a/qadevOOo/runner/helper/OfficeProvider.java +++ b/qadevOOo/runner/helper/OfficeProvider.java @@ -59,7 +59,7 @@ import util.utils; public class OfficeProvider implements AppProvider { - protected static boolean debug = false; + private static boolean debug = false; /** * copy the user layer to a safe place, usualy to $TMP/user_backup$USER @@ -355,7 +355,7 @@ public class OfficeProvider implements AppProvider if (rInitialObject != null) { - debug = true; + // debug = true; dbg("resolved url"); xMSF = UnoRuntime.queryInterface(XMultiServiceFactory.class, rInitialObject); @@ -434,7 +434,7 @@ public class OfficeProvider implements AppProvider { XMultiServiceFactory msf = null; String exc = ""; - debug = true; + // debug = true; dbg("trying to connect to " + cncstr); diff --git a/qadevOOo/runner/helper/ProcessHandler.java b/qadevOOo/runner/helper/ProcessHandler.java index 519c7473a50f..8e37a58a370e 100644 --- a/qadevOOo/runner/helper/ProcessHandler.java +++ b/qadevOOo/runner/helper/ProcessHandler.java @@ -26,6 +26,7 @@ ************************************************************************/ package helper; +import java.io.BufferedReader; import java.io.InputStream; import java.io.File; import java.io.PrintWriter; @@ -140,9 +141,12 @@ public class ProcessHandler private Process m_aProcess = null; private TestParameters param = null; private boolean debug = false; - private boolean bUseOutput = true; + private int m_nProcessTimeout = 0; + private String m_sProcessKiller; + private ProcessWatcher m_aWatcher; + /** * Creates instance with specified external command. * Debug info and output @@ -357,6 +361,24 @@ public class ProcessHandler } /** + * If not equal 0, the time to maximal wait. + * @param _n + */ + public void setProcessTimeout(int _n) + { + m_nProcessTimeout = _n; + } + + /** + * This command will call after ProcessTimeout is arrived. + * @param _s + */ + public void setProcessKiller(String _s) + { + m_sProcessKiller = _s; + } + + /** * This method do an asynchronous execution of the commands. To avoid a interruption on long running processes * caused by <CODE>OfficeWatcher</CODE>, the OfficeWatcher get frequently a ping. * @see helper.OfficeWatcher @@ -404,7 +426,7 @@ public class ProcessHandler if (sOutputText.length() == memText.length()) { changedText = false; - // dbg("runCommand Could not detect changes in output stream!!!"); + // dbg("runCommand Could not detect changes in output stream!!!"); } hangcheck = 10; memText = this.getOutputText(); @@ -524,6 +546,21 @@ public class ProcessHandler return m_nExactStartTimeInMillisec; } + private void showEnvVars() + { + if (envVars != null) + { + for (int i = 0; i < envVars.length; i++) + { + log.println("env: " + envVars[i]); + } + } + else + { + log.println("env: null"); + } + } + protected void execute() { if (isStarted()) @@ -536,27 +573,32 @@ public class ProcessHandler { if (cmdLine == null) { - log.print(utils.getDateTime() + "execute: Starting command from array: "); + log.println(utils.getDateTime() + "execute: Starting command from array: "); for (int i = 0; i < cmdLineArray.length; i++) { - log.print(cmdLineArray[i]); - log.print(" "); + log.println(cmdLineArray[i]); + // log.print(" "); } + showEnvVars(); log.println(""); initialExactStartTime(); + initializeProcessKiller(); m_aProcess = runtime.exec(cmdLineArray, envVars); } else { if (workDir != null) { - log.println(utils.getDateTime() + "execute: Starting command: " + cmdLine + " " + - workDir.getAbsolutePath()); + log.println(utils.getDateTime() + "execute: Starting command: "); + log.println(cmdLine + " path=" + workDir.getAbsolutePath()); + showEnvVars(); m_aProcess = runtime.exec(cmdLine, envVars, workDir); } else { - log.println(utils.getDateTime() + "execute: Starting command: " + cmdLine); + log.println(utils.getDateTime() + "execute: Starting command: "); + log.println(cmdLine); + showEnvVars(); m_aProcess = runtime.exec(cmdLine, envVars); } } @@ -835,5 +877,134 @@ public class ProcessHandler { bUseOutput = false; } + // ------------------------------------------------------------------------- + class ProcessWatcher extends Thread + { + + private int m_nTimeoutInSec; + private String m_sProcessToStart; + private boolean m_bInterrupt; + + public ProcessWatcher(int _nTimeOut, String _sProcess) + { + m_nTimeoutInSec = _nTimeOut; + m_sProcessToStart = _sProcess; + m_bInterrupt = false; + } + + /** + * returns true, if the thread should hold on + * @return + */ + public synchronized boolean isInHoldOn() + { + return m_bInterrupt; + } + /** + * Marks the thread to hold on, next time + * STUPID: The thread must poll this flag itself. + * + * Reason: interrupt() seems not to work as expected. + */ + public synchronized void holdOn() + { + m_bInterrupt = true; + interrupt(); + } + public void run() + { + while (m_nTimeoutInSec > 0) + { + m_nTimeoutInSec--; + try + { + sleep(1000); + } + catch(java.lang.InterruptedException e) + { + // interrupt flag is set back to 'not interrupted' :-( + } + if (isInHoldOn()) + { + break; + } + } + if (m_nTimeoutInSec <= 0 && !isInHoldOn()) // not zero, so we are interrupted. + { + system(m_sProcessToStart); + } + } + + /** + * Start an external Process + * @param _sProcess + */ + private void system(String _sProcess) + { + if (_sProcess == null) + { + return; + } + + try + { + + // run a _sProcess command + // using the Runtime exec method: + Process p = Runtime.getRuntime().exec(_sProcess); + + BufferedReader stdInput = new BufferedReader(new InputStreamReader(p.getInputStream())); + + BufferedReader stdError = new BufferedReader(new InputStreamReader(p.getErrorStream())); + + // read the output from the command + String s; + while ((s = stdInput.readLine()) != null) + { + System.out.println("out:" + s); + } + + // read any errors from the attempted command + while ((s = stdError.readLine()) != null) + { + System.out.println("err:" + s); + } + + } + catch (java.io.IOException e) + { + System.out.println("exception caught: "); + e.printStackTrace(); + } + + } + } + + /** + * If the timeout only given by setProcessTimeout(int seconds) function is != 0, + * a extra thread is created and after time has run out, the ProcessKiller string + * given by function setProcessKiller(string) will execute. + * So it is possible to kill a running office after a given time of seconds. + */ + private void initializeProcessKiller() + { + if (m_nProcessTimeout != 0) + { + m_aWatcher = new ProcessWatcher(m_nProcessTimeout, m_sProcessKiller); + m_aWatcher.start(); + } + } + + /** + * to stop the extra thread, before he will kill a running office. This will stop the thread. + */ + public void stopWatcher() + { + if (m_aWatcher != null) + { + m_aWatcher.holdOn(); + shortWait(5000); + } + } } diff --git a/qadevOOo/runner/org/openoffice/Runner.java b/qadevOOo/runner/org/openoffice/Runner.java index 41f96a4d384e..f6397deb3e2b 100644 --- a/qadevOOo/runner/org/openoffice/Runner.java +++ b/qadevOOo/runner/org/openoffice/Runner.java @@ -184,7 +184,7 @@ public class Runner public static boolean run(String... args) { - System.out.println("OOoRunner Main() version from 20100630 (yyyymmdd)"); + System.out.println("OOoRunner Main() version from 20100922 (yyyymmdd)"); setStartTime(getTime()); |