уничтожение процесса тестирования.
This commit is contained in:
@@ -4,8 +4,10 @@ import com.google.gson.annotations.Expose;
|
||||
import java.util.List;
|
||||
import java.util.Vector;
|
||||
public class SapforScenario_json {
|
||||
@Expose
|
||||
public String sapfor_drv = ""; //файл с сапфором. Имя уникально для сценария.
|
||||
@Expose
|
||||
public List<String> tests = new Vector<>();
|
||||
@Expose
|
||||
public List<SapforPackage_json> packages= new Vector<>();
|
||||
public List<SapforPackage_json> packages = new Vector<>();
|
||||
}
|
||||
|
||||
@@ -9,16 +9,17 @@ import SapforTestingSystem.ThreadsPlanner.ThreadsPlanner;
|
||||
import java.io.File;
|
||||
import java.nio.file.Paths;
|
||||
public class SapforTestingPlanner extends ThreadsPlanner {
|
||||
SapforScenario_json scenario_json = null;
|
||||
public SapforTestingPlanner() throws Exception {
|
||||
super(Global.properties.threadsTimeout, Global.properties.threadsNum);
|
||||
SapforScenario_json scenario_json = (SapforScenario_json) Utils.jsonFromFile(new File(Global.Home, "scenario.txt"), SapforScenario_json.class);
|
||||
scenario_json = (SapforScenario_json) Utils.jsonFromFile(new File(Global.Home, "scenario.txt"), SapforScenario_json.class);
|
||||
//формирование списка задач.
|
||||
for (SapforPackage_json sapforPackage_json : scenario_json.packages) {
|
||||
for (String testName : scenario_json.tests) {
|
||||
addThread(() -> {
|
||||
try {
|
||||
new SapforTest(
|
||||
new File(Global.Home, "SAPFOR_F.exe"),
|
||||
new File(Global.Home, scenario_json.sapfor_drv),
|
||||
Paths.get(Global.Home, sapforPackage_json.id, testName).toFile(),
|
||||
sapforPackage_json.flags,
|
||||
sapforPackage_json.codes).Do();
|
||||
@@ -28,5 +29,17 @@ public class SapforTestingPlanner extends ThreadsPlanner {
|
||||
});
|
||||
}
|
||||
}
|
||||
interruptThread.start();
|
||||
}
|
||||
@Override
|
||||
public void Interrupt() throws Exception {
|
||||
System.out.println("killing "+scenario_json.sapfor_drv+"...");
|
||||
String kill_command = Global.isWindows? ("taskkill /FI \"IMAGENAME eq " + scenario_json.sapfor_drv+ "\" /F /T"):
|
||||
("killall -SIGKILL " + scenario_json.sapfor_drv);
|
||||
Process killer = Runtime.getRuntime().exec(kill_command);
|
||||
killer.waitFor();
|
||||
System.out.println("done!");
|
||||
//todo для надежности сделать еще один kill с внешнего процесса.
|
||||
// может быть гонка, что нить успеет запустить процесс уже после интеррупта.
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,12 @@ import java.util.LinkedHashMap;
|
||||
import java.util.Vector;
|
||||
public abstract class ThreadsPlanner {
|
||||
//-->
|
||||
Thread interruptThread = new InterruptThread(5000, () -> {
|
||||
protected Thread interruptThread = new InterruptThread(5000, () -> {
|
||||
try {
|
||||
Interrupt();
|
||||
} catch (Exception exception) {
|
||||
Global.Log.PrintException(exception);
|
||||
}
|
||||
System.exit(0);
|
||||
return null;
|
||||
});
|
||||
@@ -42,6 +47,8 @@ public abstract class ThreadsPlanner {
|
||||
Global.Log.Print("Planner finished");
|
||||
finalize();
|
||||
}
|
||||
public void Interrupt() throws Exception {
|
||||
}
|
||||
protected void checkActiveThreads() throws Exception {
|
||||
Vector<Integer> toExclude = new Vector<>();
|
||||
//--
|
||||
|
||||
Reference in New Issue
Block a user