use of org.eclipse.titan.executor.views.notification.Notification in project titan.EclipsePlug-ins by eclipse.
the class SingleExecutor method processConsoleOutput.
/**
* Processes the output of the Main Controller
* <p>
* Note that the output is not reported in full lines.
*
* @param text the newly reported text
*
* @see #readFullLineOnly(BufferedReader)
*/
private void processConsoleOutput(final String text) {
builder.append(text);
StringReader reader = new StringReader(builder.toString());
BufferedReader stdout = new BufferedReader(reader);
fastOffset = 0;
readFullLineOnly(stdout);
while (null != fastLine) {
if (verdictExtraction && (executionFinished.reset(fastLine).matches())) {
String reason = executionFinished.group(2);
if (reasonMatcher.reset(reason).matches()) {
executedTests.add(new ExecutedTestcase((new Formatter()).format(PADDEDDATETIMEFORMAT, new Date()).toString(), executionFinished.group(1), reasonMatcher.group(1), reasonMatcher.group(2)));
} else {
executedTests.add(new ExecutedTestcase((new Formatter()).format(PADDEDDATETIMEFORMAT, new Date()).toString(), executionFinished.group(1), executionFinished.group(2), ""));
}
if (project == null) {
return;
}
try {
project.refreshLocal(IResource.DEPTH_INFINITE, null);
} catch (CoreException e) {
ErrorReporter.logExceptionStackTrace(e);
}
}
addNotification(new Notification((new Formatter()).format(PADDEDDATETIMEFORMAT, new Date()).toString(), "", "", fastLine));
builder.delete(0, fastOffset);
if (Activator.getMainView() != null) {
Activator.getMainView().refreshIfSelected(mainControllerRoot);
} else {
TestExecutionView.refreshInput(this);
}
fastOffset = 0;
readFullLineOnly(stdout);
}
try {
stdout.close();
} catch (IOException e) {
ErrorReporter.logExceptionStackTrace(e);
}
reader.close();
}
use of org.eclipse.titan.executor.views.notification.Notification in project titan.EclipsePlug-ins by eclipse.
the class BaseExecutor method startHostControllers.
public final void startHostControllers() {
if (hostControllers == null || hostControllers.isEmpty()) {
addNotification(new Notification((new Formatter()).format(PADDEDDATETIMEFORMAT, new Date()).toString(), "", "", NO_HOSTCONTROLLER_SPECIFIED));
return;
}
ProcessBuilder pb = new ProcessBuilder();
Map<String, String> env = pb.environment();
if (!appendEnvironmentalVariables) {
env.clear();
}
if (environmentalVariables != null) {
try {
EnvironmentHelper.resolveVariables(env, environmentalVariables);
} catch (CoreException e) {
ErrorReporter.logExceptionStackTrace(e);
}
}
EnvironmentHelper.setTitanPath(env);
EnvironmentHelper.set_LICENSE_FILE_PATH(env);
IProject actualProject = DynamicLinkingHelper.getProject(projectName);
if (actualProject != null) {
EnvironmentHelper.set_LD_LIBRARY_PATH(actualProject, env);
}
Process proc;
HostController controller;
List<String> shellCommand;
MessageConsoleStream stream = TITANConsole.getConsole().newMessageStream();
String command;
for (int i = 0; i < hostControllers.size(); i++) {
StringBuilder hostControllerLabel = new StringBuilder("Host Controller instance " + (i + 1));
controller = hostControllers.get(i);
command = controller.command();
command = command.replace(REPLACEABLEHOSTNAME, controller.host());
URI path;
boolean oldStyleWorkingDir = true;
if (actualProject == null) {
path = URIUtil.toURI(controller.workingdirectory());
} else {
path = URIUtil.toURI(controller.workingdirectory());
if (!path.isAbsolute()) {
oldStyleWorkingDir = false;
path = TITANPathUtilities.resolvePathURI(controller.workingdirectory(), actualProject.getLocation().toOSString());
}
}
String workingDirResult = PathConverter.convert(oldStyleWorkingDir ? controller.workingdirectory() : URIUtil.toPath(path).toOSString(), true, TITANConsole.getConsole());
command = command.replace(REPLACEABLEHOSTWORKIGNDIRECTORY, workingDirResult);
boolean oldStyleExecutable = true;
if (actualProject == null) {
path = URIUtil.toURI(controller.executable());
} else {
path = URIUtil.toURI(controller.executable());
if (!path.isAbsolute()) {
oldStyleExecutable = false;
path = TITANPathUtilities.resolvePathURI(controller.executable(), actualProject.getLocation().toOSString());
}
}
String executableResult = PathConverter.convert(oldStyleExecutable ? controller.executable() : URIUtil.toPath(path).toOSString(), true, TITANConsole.getConsole());
String result = PathUtil.getRelativePath(workingDirResult, executableResult);
if (!result.equals(executableResult)) {
result = "./" + result;
}
command = command.replace(REPLACEABLEHOSTEXECUTABLE, result);
if ("NULL".equals(mcHost)) {
command = command.replace(REPLACEABLEMCHOST, "0.0.0.0");
} else {
command = command.replace(REPLACEABLEMCHOST, mcHost);
}
command = command.replace(REPLACEABLEMCPORT, mcPort);
shellCommand = new ArrayList<String>();
shellCommand.add("sh");
shellCommand.add("-c");
shellCommand.add(command);
for (String c : shellCommand) {
stream.print(c + ' ');
}
stream.println();
pb.command(shellCommand);
if (workingdirectoryPath != null) {
pb.directory(new File(workingdirectoryPath));
}
try {
proc = pb.start();
HostJob job = new HostJob(hostControllerLabel.toString(), proc, this);
innerHostControllers.add(job);
job.setPriority(Job.DECORATE);
job.setUser(true);
job.schedule();
} catch (IOException e) {
ErrorReporter.logExceptionStackTrace(e);
}
}
}
use of org.eclipse.titan.executor.views.notification.Notification in project titan.EclipsePlug-ins by eclipse.
the class JniExecutor method insertNotify.
/**
* Inserts a notification message into the notifications view.
*
* @param time the MainController reported time, when the notification message was created
* @param source the source line info of the notification message
* @param severity the severity of the message
* @param msg the message to be shown
*/
@Override
public void insertNotify(final Timeval time, final String source, final int severity, final String msg) {
if (loggingIsEnabled && consoleLogging) {
consoleStream.println(source + ": " + msg);
}
Formatter formatter = new Formatter();
formatter.format(DATETIMEFORMAT, new Date(time.tv_sec * 1000), time.tv_usec);
if (severityLevelExtraction) {
addNotification(new Notification(formatter.toString(), SeverityResolver.getSeverityString(severity), source, msg));
} else {
addNotification(new Notification(formatter.toString(), EMPTY_STRING, source, msg));
}
if (verdictExtraction && executionFinishedMatcher.reset(msg).matches()) {
String reason = executionFinishedMatcher.group(2);
if (reasonMatcher.reset(reason).matches()) {
executedTests.add(new ExecutedTestcase(formatter.toString(), executionFinishedMatcher.group(1), reasonMatcher.group(1), reasonMatcher.group(2)));
} else {
executedTests.add(new ExecutedTestcase(formatter.toString(), executionFinishedMatcher.group(1), executionFinishedMatcher.group(2), ""));
}
}
}
use of org.eclipse.titan.executor.views.notification.Notification in project titan.EclipsePlug-ins by eclipse.
the class CliExecutor method processWelcomeScreen.
/**
* Processes the welcome screen.
* This is needed as sometimes the process already forgets about this information,
* when the listeners get installed.
* It waits for main controller output lines and returns if it received any of these messages:
* <li>Listening on TCP port ...
* <li>Listening on IP address ... and TCP port ...
* <li>Error: ...
* It stores the IP address and TCP port gathered from the message
*
* @param stdout the output of the process to be parsed.
*/
private void processWelcomeScreen(final BufferedReader stdout) {
String line;
boolean started = false;
try {
line = stdout.readLine();
while (!started && line != null) {
Matcher m = SUCCESSFUL_STARTUP_PATTERN.matcher(line);
if (m.matches()) {
started = true;
consoleTimeStampLength = m.group(1).length();
mcHost = m.group(3);
mcPort = m.group(4);
suspectedLastState = JniExecutor.MC_LISTENING;
if (consoleTimeStampLength < line.length()) {
line = line.substring(consoleTimeStampLength);
}
} else {
m = FULL_SUCCESSFUL_STARTUP_PATTERN.matcher(line);
if (m.matches()) {
started = true;
consoleTimeStampLength = m.group(1).length();
mcHost = m.group(4);
mcPort = m.group(5);
suspectedLastState = JniExecutor.MC_LISTENING;
if (consoleTimeStampLength < line.length()) {
line = line.substring(consoleTimeStampLength);
}
} else {
m = ERROR_STARTUP_PATTERN.matcher(line);
if (m.matches()) {
started = true;
suspectedLastState = JniExecutor.MC_LISTENING;
} else {
line = stdout.readLine();
continue;
}
}
}
addNotification(new Notification((new Formatter()).format(PADDEDDATETIMEFORMAT, new Date()).toString(), "", "", line));
}
} catch (IOException e) {
ErrorReporter.logExceptionStackTrace(e);
}
}
Aggregations