Commit 5cf29247 authored by balaskoa's avatar balaskoa
Browse files

Merge branch 'master' of github.com:eclipse/titan.EclipsePlug-ins into master

Change-Id: I0967e82d64dcb84ca685643d73526f784e1b6358
parents 34c11eff c6eb1c48
......@@ -22,10 +22,12 @@ public final class ProductIdentityHelper {
private static final Pattern PRODUCT_PATTERN1 = Pattern.compile("^([A-Z]{3,5}[ ][0-9]{3}[ ][0-9]{2,4})/([0-9]+)[ ](R.+)$");
private static final Matcher PRODUCT_PATTERN1_MATCHER = PRODUCT_PATTERN1.matcher("");
private static final Pattern PRODUCT_PATTERN2 = Pattern.compile("^([A-Z]{3,5}[ ][0-9]{3}[ ][0-9]{2,4})[ ](R.+)$");
private static final Pattern PRODUCT_PATTERN2 = Pattern.compile("^([0-9]{1,2})/([A-Z]{3,5}[ ][0-9]{3}[ ][0-9]{2,4})[ ](R.+)$");
private static final Matcher PRODUCT_PATTERN2_MATCHER = PRODUCT_PATTERN2.matcher("");
private static final Pattern PRODUCT_PATTERN3 = Pattern.compile("^(R.+)$");
private static final Pattern PRODUCT_PATTERN3 = Pattern.compile("^([A-Z]{3,5}[ ][0-9]{3}[ ][0-9]{2,4})[ ](R.+)$");
private static final Matcher PRODUCT_PATTERN3_MATCHER = PRODUCT_PATTERN3.matcher("");
private static final Pattern PRODUCT_PATTERN4 = Pattern.compile("^(R.+)$");
private static final Matcher PRODUCT_PATTERN4_MATCHER = PRODUCT_PATTERN4.matcher("");
private static final Pattern RNUMBER_PATTERN1 = Pattern.compile("^R([0-9]+)([A-Z]+)([0-9]+)$");
private static final Matcher RNUMBER_PATTERN1_MATCHER = RNUMBER_PATTERN1.matcher("");
......@@ -63,10 +65,14 @@ public final class ProductIdentityHelper {
productNumberSuffix = PRODUCT_PATTERN1_MATCHER.group(2);
rNumber = PRODUCT_PATTERN1_MATCHER.group(3);
} else if (PRODUCT_PATTERN2_MATCHER.reset(versionString).matches()) {
productNumber = PRODUCT_PATTERN2_MATCHER.group(1);
rNumber = PRODUCT_PATTERN2_MATCHER.group(2);
productNumberSuffix = PRODUCT_PATTERN2_MATCHER.group(1);
productNumber = PRODUCT_PATTERN2_MATCHER.group(2);
rNumber = PRODUCT_PATTERN2_MATCHER.group(3);
} else if (PRODUCT_PATTERN3_MATCHER.reset(versionString).matches()) {
rNumber = PRODUCT_PATTERN3_MATCHER.group(1);
productNumber = PRODUCT_PATTERN3_MATCHER.group(1);
rNumber = PRODUCT_PATTERN3_MATCHER.group(2);
} else if (PRODUCT_PATTERN4_MATCHER.reset(versionString).matches()) {
rNumber = PRODUCT_PATTERN4_MATCHER.group(1);
} else {
if (location != null) {
location.reportSemanticError("Wrong format for product version information: The accepted formats resemble CRL 113 200/1 R9A or 7/CAX 105 7730 R2A");
......
......@@ -139,7 +139,7 @@ $ ./mctr_cli.exe Perf2.cfg
*************************************************************************
* TTCN-3 Test Executor - Main Controller 2 *
* Version: 7/CAX 105 7730 R2A *
* Version: 7/CAX 105 7730 R2A *
* Copyright (c) 2000-2020 Ericsson Telecom AB *
* All rights reserved. This program and the accompanying materials *
* are made available under the terms of the Eclipse Public License v2.0 *
......
......@@ -14,6 +14,7 @@ import java.io.InputStreamReader;
import java.math.BigInteger;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.concurrent.locks.Condition;
import java.util.concurrent.locks.ReentrantLock;
import org.eclipse.titan.runtime.core.TTCN_Runtime;
......@@ -59,7 +60,9 @@ public class Cli extends UserInterface {
private final ConfigData mycfg = new ConfigData();
private int executeListIndex;
private final ReentrantLock mutex;
private final Condition wakeup_condition;
private MainController mainController;
private File config_file;
public Cli() {
loggingEnabled = true;
......@@ -67,6 +70,8 @@ public class Cli extends UserInterface {
waitState = waitStateEnum.WAIT_NOTHING;
executeListIndex = 0;
mutex = new ReentrantLock();
wakeup_condition = mutex.newCondition();
config_file = null;
}
public void setMainController(final MainController mainController) {
......@@ -88,7 +93,7 @@ public class Cli extends UserInterface {
printWelcome();
if (args.length == 1) {
final File config_file = new File(args[0]);
config_file = new File(args[0]);
System.out.printf("Using configuration file: %s\n", config_file.getName());
final CfgAnalyzer cfgAnalyzer = new CfgAnalyzer();
......@@ -98,7 +103,8 @@ public class Cli extends UserInterface {
//cleanup?
return 1;
} else {
mycfg.set_log_file(args[0]);
//TODO: its the config file, not the log file
//mycfg.set_log_file(args[0]);
final MCSectionHandler mcSectionHandler = cfgAnalyzer.getMcSectionHandler();
final ExecuteSectionHandler executeSectionHandler = cfgAnalyzer.getExecuteSectionHandler();
......@@ -153,6 +159,7 @@ public class Cli extends UserInterface {
try {
if (waitState != waitStateEnum.WAIT_NOTHING && conditionHolds(waitState)) {
waitState = waitStateEnum.WAIT_NOTHING;
signal();
}
} finally {
mutex.unlock();
......@@ -168,7 +175,7 @@ public class Cli extends UserInterface {
@Override
public void notify(final Timeval timestamp, final String source, final int severity, final String message) {
// TODO Auto-generated method stub
System.out.printf("%s: %s\n", source, message);
}
@Override
......@@ -327,9 +334,10 @@ public class Cli extends UserInterface {
waitMCState(waitStateEnum.WAIT_HC_CONNECTED);
// download config file
//FIXME incorrect we need to send the processed contents not the name of the file.
mainController.configure(mycfg.getLog_file_name());
mainController.configure(ConfigData.getConfigFileContent(config_file));
waitMCState(waitStateEnum.WAIT_ACTIVE);
if (mainController.get_state() != mcStateEnum.MC_ACTIVE) {
System.out.println(mainController.get_state());
System.out.println("Error during initialization. Cannot continue in batch mode.");
error_flag = true;
}
......@@ -431,16 +439,42 @@ public class Cli extends UserInterface {
}
private void waitMCState(final waitStateEnum newWaitState) {
mutex.lock();
if (newWaitState != waitStateEnum.WAIT_NOTHING) {
if (conditionHolds(newWaitState) == true) {
if (conditionHolds(newWaitState)) {
waitState = waitStateEnum.WAIT_NOTHING;
} else {
waitState = newWaitState;
await();
}
} else {
System.err.println("Cli.waitMCState: invalid argument");
mutex.unlock();
return;
}
mutex.unlock();
}
private void lock() {
mutex.lock();
}
private void unlock() {
mutex.unlock();
}
private void signal() {
wakeup_condition.signal();
}
private void await() {
try {
wakeup_condition.await();
} catch (InterruptedException e) {
// TODO Auto-generated catch block
System.err.println(e.getMessage());
e.printStackTrace();
}
}
/**
......
......@@ -7,6 +7,10 @@
******************************************************************************/
package org.eclipse.titan.runtime.core.mctr;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.math.BigInteger;
import java.util.List;
......@@ -125,4 +129,24 @@ public class ConfigData {
public void setKill_timer(final Double kill_timer) {
this.kill_timer = kill_timer;
}
//Package-private
static String getConfigFileContent(File config_file) {
StringBuilder contentBuilder = new StringBuilder();
try (BufferedReader br = new BufferedReader(new FileReader(config_file)))
{
String currentLine;
while ((currentLine = br.readLine()) != null)
{
contentBuilder.append(currentLine).append("\n");
}
}
catch (IOException e)
{
e.printStackTrace();
}
return contentBuilder.toString();
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment