summaryrefslogtreecommitdiff
path: root/qadevOOo
diff options
context:
space:
mode:
authorsb <sb@openoffice.org>2010-10-04 17:38:17 +0200
committersb <sb@openoffice.org>2010-10-04 17:38:17 +0200
commit3df1e65b733214219a587090c9ab2329f4a1d9bd (patch)
tree856696dda02ac7504052095ca86d950572d17bbb /qadevOOo
parentf509da6e63b4347edb7c93f1c0e91017b6127c35 (diff)
parent61c3452d89b74b28cfa04b706d7bf9262d17224d (diff)
sb132: merged in DEV300_m89
Diffstat (limited to 'qadevOOo')
-rw-r--r--qadevOOo/runner/graphical/EnhancedComplexTestCase.java23
-rw-r--r--qadevOOo/runner/graphical/JPEGCreator.java3
-rw-r--r--qadevOOo/runner/graphical/JPEGEvaluator.java2
-rw-r--r--qadevOOo/runner/graphical/Office.java1
-rw-r--r--qadevOOo/runner/graphical/OpenOfficePostscriptCreator.java3
-rw-r--r--qadevOOo/runner/graphical/ParameterHelper.java3
-rw-r--r--qadevOOo/runner/graphical/PostscriptCreator.java3
-rw-r--r--qadevOOo/runner/helper/OfficeProvider.java6
-rw-r--r--qadevOOo/runner/helper/ProcessHandler.java187
-rw-r--r--qadevOOo/runner/org/openoffice/Runner.java2
10 files changed, 212 insertions, 21 deletions
diff --git a/qadevOOo/runner/graphical/EnhancedComplexTestCase.java b/qadevOOo/runner/graphical/EnhancedComplexTestCase.java
index 020016111..2905e0d6b 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 922af500e..e5eda3fc3 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 c7de83cc0..51cc9687f 100644
--- a/qadevOOo/runner/graphical/JPEGEvaluator.java
+++ b/qadevOOo/runner/graphical/JPEGEvaluator.java
@@ -50,6 +50,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 23bd040cf..71e118d62 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 077ee4bd0..60fff9ba0 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 2450ce97c..3ae12bddc 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 33511df1e..ba3228cfb 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 54588117f..f14bf7e88 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 d3147ef22..1f8d59469 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,6 +141,11 @@ 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;
private boolean bUseOutput = true;
@@ -357,6 +363,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 +428,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 +548,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 +575,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 +879,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 f675be463..ae1edc88e 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());