no message
This commit is contained in:
13
.idea/workspace.xml
generated
13
.idea/workspace.xml
generated
@@ -7,16 +7,19 @@
|
|||||||
</component>
|
</component>
|
||||||
<component name="ChangeListManager">
|
<component name="ChangeListManager">
|
||||||
<list default="true" id="e42177c3-2328-4b27-8a01-35779b2beb99" name="Default Changelist" comment="">
|
<list default="true" id="e42177c3-2328-4b27-8a01-35779b2beb99" name="Default Changelist" comment="">
|
||||||
|
<change afterPath="$PROJECT_DIR$/src/SapforTestingSystem/Json/SapforTask_json.java" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/src/Common/Constants/Constants.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Common/Constants/Constants.java" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/src/Common/ModesSupervisors/PackageModeSupervisor.java" beforeDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/src/Common/Current.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Common/Current.java" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/src/Common/ModesSupervisors/TestThread.java" beforeDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/src/Common/Global.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Common/Global.java" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/src/Common/PackageModeSupervisor.java" beforeDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/src/Common/UI/Menus_2023/MainMenuBar/MainMenuBar.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Common/UI/Menus_2023/MainMenuBar/MainMenuBar.java" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/src/Common/UI/Menus_2023/MainMenuBar/MainMenuBar.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Common/UI/Menus_2023/MainMenuBar/MainMenuBar.java" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/src/Common/Utils/Utils.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Common/Utils/Utils.java" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/src/Common/Utils/Utils.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Common/Utils/Utils.java" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/src/SapforTestingSystem/Json/SapforScenario_json.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/SapforTestingSystem/Json/SapforScenario_json.java" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/src/SapforTestingSystem/SapforTest/SapforTest.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/SapforTestingSystem/SapforTest/SapforTest.java" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/src/SapforTestingSystem/SapforTestingPlaner/SapforTestingPlanner.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/SapforTestingSystem/SapforTestingPlaner/SapforTestingPlanner.java" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/src/SapforTestingSystem/SapforTestingPlaner/SapforTestingPlanner.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/SapforTestingSystem/SapforTestingPlaner/SapforTestingPlanner.java" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/src/Visual_DVM_2021/Passes/All/SPF_CreateParallelVariant.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Visual_DVM_2021/Passes/All/SPF_CreateParallelVariant.java" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/src/SapforTestingSystem/ThreadsPlanner/ThreadsPlanner.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/SapforTestingSystem/ThreadsPlanner/ThreadsPlanner.java" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/src/Visual_DVM_2021/Passes/All/PerformScenario.java" beforeDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/src/Visual_DVM_2021/Passes/All/StartSapforTests.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Visual_DVM_2021/Passes/All/StartSapforTests.java" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/src/Visual_DVM_2021/Passes/All/StartSapforTests.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Visual_DVM_2021/Passes/All/StartSapforTests.java" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/src/Visual_DVM_2021/Passes/PassCode_2021.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Visual_DVM_2021/Passes/PassCode_2021.java" afterDir="false" />
|
||||||
</list>
|
</list>
|
||||||
<option name="SHOW_DIALOG" value="false" />
|
<option name="SHOW_DIALOG" value="false" />
|
||||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||||
|
|||||||
@@ -1,91 +0,0 @@
|
|||||||
package Common.ModesSupervisors;
|
|
||||||
import Common.Global;
|
|
||||||
import Common.Utils.InterruptThread;
|
|
||||||
import Common.Utils.Utils;
|
|
||||||
import SapforTestingSystem.Json.SapforScenario_json;
|
|
||||||
import SapforTestingSystem.SapforTest.SapforTest;
|
|
||||||
import org.apache.commons.io.FileUtils;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.nio.charset.Charset;
|
|
||||||
import java.util.LinkedHashMap;
|
|
||||||
import java.util.Stack;
|
|
||||||
import java.util.Vector;
|
|
||||||
|
|
||||||
//рудимент.
|
|
||||||
public class PackageModeSupervisor {
|
|
||||||
Thread interruptThread = new InterruptThread(5000, () -> {
|
|
||||||
System.exit(0);
|
|
||||||
return null;
|
|
||||||
});
|
|
||||||
//--->>
|
|
||||||
int kernels = 4;
|
|
||||||
//--->>
|
|
||||||
SapforScenario_json scenario;
|
|
||||||
//--->>
|
|
||||||
File packageWorkspace;
|
|
||||||
//--->>
|
|
||||||
File sapfor_drv;
|
|
||||||
File scenarioFile;
|
|
||||||
//--->>
|
|
||||||
LinkedHashMap<String, SapforTest> allTests = new LinkedHashMap<>();
|
|
||||||
//--->>>
|
|
||||||
Vector<String> activeTests = new Vector<>();
|
|
||||||
Stack<String> waitingTests = new Stack<>();
|
|
||||||
//--->>
|
|
||||||
public void init() throws Exception {
|
|
||||||
packageWorkspace = new File(Global.Home);
|
|
||||||
scenarioFile = new File(packageWorkspace, "scenario.txt");
|
|
||||||
sapfor_drv = new File(packageWorkspace, "SAPFOR_F.exe");
|
|
||||||
String packed = FileUtils.readFileToString(scenarioFile, Charset.defaultCharset());
|
|
||||||
scenario = Utils.gson.fromJson(packed, SapforScenario_json.class);
|
|
||||||
//--->>
|
|
||||||
for (String test : scenario.tests) {
|
|
||||||
allTests.put(test, new SapforTest(Global.Home, test));
|
|
||||||
waitingTests.push(test);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public boolean isFinished(String test) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
//--->>
|
|
||||||
public boolean checkActiveTests() throws Exception {
|
|
||||||
/*
|
|
||||||
Vector<String> finishedTests = new Vector<>();
|
|
||||||
for (String test: activeTests){
|
|
||||||
if (isFinished(test))
|
|
||||||
finishedTests.add(test);
|
|
||||||
}
|
|
||||||
for (String test: finishedTests){
|
|
||||||
activeTests.remove(test);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
public boolean startWaitingTests() throws Exception {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
public void finalize(){
|
|
||||||
Global.Log.Print("END");
|
|
||||||
}
|
|
||||||
//--->>
|
|
||||||
public void Do() {
|
|
||||||
try {
|
|
||||||
Global.Log.Print("START");
|
|
||||||
interruptThread.start();
|
|
||||||
//--->>
|
|
||||||
init();
|
|
||||||
//--->>
|
|
||||||
while (checkActiveTests() && startWaitingTests()) {
|
|
||||||
Thread.sleep(1000);
|
|
||||||
}
|
|
||||||
finalize();
|
|
||||||
//--->>
|
|
||||||
} catch (Exception ex) {
|
|
||||||
ex.printStackTrace();
|
|
||||||
}
|
|
||||||
finally {
|
|
||||||
System.exit(0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
package Common.ModesSupervisors;
|
|
||||||
import Common.Global;
|
|
||||||
public class TestThread extends Thread{
|
|
||||||
public TestThread(int num){
|
|
||||||
super(() -> {
|
|
||||||
try {
|
|
||||||
while (true) {
|
|
||||||
Global.Log.Print("Test thread " +num+ "action");
|
|
||||||
Thread.sleep(1000);
|
|
||||||
}
|
|
||||||
} catch (Exception ex) {
|
|
||||||
ex.printStackTrace();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -4,7 +4,6 @@ import Common.UI.Menus_2023.MenuBarButton;
|
|||||||
import Common.UI.Menus_2023.VisualiserMenuBar;
|
import Common.UI.Menus_2023.VisualiserMenuBar;
|
||||||
import Common.UI.UI;
|
import Common.UI.UI;
|
||||||
import Repository.Component.PerformanceAnalyzer.PerformanceAnalyzer;
|
import Repository.Component.PerformanceAnalyzer.PerformanceAnalyzer;
|
||||||
import SapforTestingSystem.SapforTestingPlaner.SapforTestingPlanner;
|
|
||||||
import Visual_DVM_2021.Passes.PassCode_2021;
|
import Visual_DVM_2021.Passes.PassCode_2021;
|
||||||
import Visual_DVM_2021.Passes.Pass_2021;
|
import Visual_DVM_2021.Passes.Pass_2021;
|
||||||
|
|
||||||
@@ -53,7 +52,7 @@ public class MainMenuBar extends VisualiserMenuBar {
|
|||||||
//-
|
//-
|
||||||
setPreferredSize(new Dimension(0, 30));
|
setPreferredSize(new Dimension(0, 30));
|
||||||
//---
|
//---
|
||||||
|
/*
|
||||||
add(new MenuBarButton() {
|
add(new MenuBarButton() {
|
||||||
{
|
{
|
||||||
setIcon("/icons/Apply.png");
|
setIcon("/icons/Apply.png");
|
||||||
@@ -64,6 +63,8 @@ public class MainMenuBar extends VisualiserMenuBar {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
*/
|
||||||
//---
|
//---
|
||||||
ShowProject(false);
|
ShowProject(false);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ import java.util.regex.Pattern;
|
|||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import java.util.stream.IntStream;
|
import java.util.stream.IntStream;
|
||||||
public class Utils {
|
public class Utils {
|
||||||
public static final Gson gson = new GsonBuilder().excludeFieldsWithoutExposeAnnotation().create();
|
public static Gson gson = new GsonBuilder().excludeFieldsWithoutExposeAnnotation().create();
|
||||||
public static Object jsonFromFile(File file, Class json_class) throws Exception {
|
public static Object jsonFromFile(File file, Class json_class) throws Exception {
|
||||||
String packed = FileUtils.readFileToString(file, Charset.defaultCharset());
|
String packed = FileUtils.readFileToString(file, Charset.defaultCharset());
|
||||||
return Utils.gson.fromJson(packed, json_class);
|
return Utils.gson.fromJson(packed, json_class);
|
||||||
|
|||||||
@@ -7,5 +7,5 @@ public class SapforScenario_json {
|
|||||||
@Expose
|
@Expose
|
||||||
public List<String> tests = new Vector<>();
|
public List<String> tests = new Vector<>();
|
||||||
@Expose
|
@Expose
|
||||||
public List<SapforPackage_json> packages= new Vector<>(); //пары пакеты + флаги
|
public List<SapforPackage_json> packages= new Vector<>();
|
||||||
}
|
}
|
||||||
|
|||||||
3
src/SapforTestingSystem/Json/SapforTask_json.java
Normal file
3
src/SapforTestingSystem/Json/SapforTask_json.java
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
package SapforTestingSystem.Json;
|
||||||
|
public class SapforTask_json {
|
||||||
|
}
|
||||||
@@ -1,15 +1,160 @@
|
|||||||
package SapforTestingSystem.SapforTest;
|
package SapforTestingSystem.SapforTest;
|
||||||
import GlobalData.Tasks.TaskState;
|
import Common.Constants.Constants;
|
||||||
|
import Common.Utils.Utils;
|
||||||
|
import ProjectData.Project.db_project_info;
|
||||||
|
import Visual_DVM_2021.Passes.PassCode_2021;
|
||||||
|
import Visual_DVM_2021.Passes.PassException;
|
||||||
|
import org.apache.commons.io.FileUtils;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.nio.charset.Charset;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Comparator;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Vector;
|
||||||
public class SapforTest {
|
public class SapforTest {
|
||||||
public String description;
|
File root;
|
||||||
public File home;
|
File sapfor_drv;
|
||||||
public TaskState state;
|
String flags;
|
||||||
|
Vector<PassCode_2021> codes;
|
||||||
|
//-----
|
||||||
|
File parentTask;
|
||||||
|
File task;
|
||||||
|
//-----
|
||||||
|
Process process = null;
|
||||||
|
int exit_code = Constants.Nan;
|
||||||
|
//----
|
||||||
|
File outputFile = null;
|
||||||
|
File errorsFile = null;
|
||||||
//--
|
//--
|
||||||
public SapforTest(String packageHome, String description_in) {
|
Vector<String> outputLines;
|
||||||
description = description_in;
|
Vector<String> errorsLines;
|
||||||
state = TaskState.Waiting;
|
//---
|
||||||
home = new File(packageHome, description);
|
//---
|
||||||
|
public SapforTest(File sapfor_drv_in, File root_in, String flags_in, List<PassCode_2021> codes_in) {
|
||||||
|
sapfor_drv = sapfor_drv_in;
|
||||||
|
root = root_in;
|
||||||
|
flags = flags_in;
|
||||||
|
codes = new Vector<>(codes_in);
|
||||||
|
}
|
||||||
|
protected static boolean checkLines(Vector<String> lines) {
|
||||||
|
for (String line : lines) {
|
||||||
|
if (line.toLowerCase().contains("internal error")) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (line.toLowerCase().contains("exception")) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (line.contains("[ERROR]")) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
protected boolean performSapforScript(String name, File workspace, String command, String outName, String errName) throws Exception {
|
||||||
|
process = null;
|
||||||
|
exit_code = Constants.Nan;
|
||||||
|
//---
|
||||||
|
File data_workspace = new File(workspace, db_project_info.data);
|
||||||
|
Utils.CheckDirectory(data_workspace);
|
||||||
|
outputFile = new File(data_workspace, outName);
|
||||||
|
errorsFile = new File(data_workspace, errName);
|
||||||
|
Utils.delete_with_check(outputFile);
|
||||||
|
Utils.delete_with_check(errorsFile);
|
||||||
|
//---
|
||||||
|
File file = new File(data_workspace, name + ".bat");
|
||||||
|
FileUtils.write(file,
|
||||||
|
Utils.DQuotes(sapfor_drv.getAbsolutePath())
|
||||||
|
+ (flags.isEmpty() ? "" : (" " + flags))
|
||||||
|
+ " -noLogo"
|
||||||
|
+ " " + command +
|
||||||
|
" 1>" +
|
||||||
|
Utils.DQuotes(outputFile.getAbsolutePath()) +
|
||||||
|
" 2>" +
|
||||||
|
Utils.DQuotes(errorsFile.getAbsolutePath()),
|
||||||
|
Charset.defaultCharset());
|
||||||
|
if (!file.setExecutable(true))
|
||||||
|
throw new PassException("Не удалось сделать файл скрипта " + name + " исполняемым!");
|
||||||
|
//--
|
||||||
|
ProcessBuilder procBuilder = new ProcessBuilder(file.getAbsolutePath());
|
||||||
|
procBuilder.directory(workspace);
|
||||||
|
process = procBuilder.start();
|
||||||
|
exit_code = process.waitFor();
|
||||||
|
if (exit_code != 0)
|
||||||
|
throw new PassException("Процесс завершился с кодом " + exit_code);
|
||||||
|
process = null;
|
||||||
|
//---
|
||||||
|
outputLines = new Vector<>(FileUtils.readLines(outputFile));
|
||||||
|
errorsLines = new Vector<>(FileUtils.readLines(errorsFile));
|
||||||
|
return checkLines(outputLines) && checkLines(errorsLines);
|
||||||
|
}
|
||||||
|
protected boolean parse() throws Exception {
|
||||||
|
if (performSapforScript("parse", parentTask,
|
||||||
|
"-parse *.f *.for *.fdv *.f90 *.f77",
|
||||||
|
"parse_out.txt", "parse_err.txt")
|
||||||
|
&& (new File(parentTask, "dvm.proj")).exists()) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
// taskResult.state = TaskState.DoneWithErrors;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
protected boolean transformation(PassCode_2021 code) throws Exception {
|
||||||
|
task = new File(parentTask, "v1");
|
||||||
|
Utils.CheckAndCleanDirectory(task); //папка для преобразования.
|
||||||
|
if (performSapforScript("transformation", parentTask,
|
||||||
|
code.getTestingCommand() + " -F " + Utils.DQuotes(task.getAbsolutePath()),
|
||||||
|
"out.txt",
|
||||||
|
"err.txt"
|
||||||
|
)) {
|
||||||
|
//taskResult.state = TaskState.Done;
|
||||||
|
//taskResult.versions.add(new SapforVersion_json(task.getAbsolutePath(), code.getDescription()));
|
||||||
|
parentTask = task;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
Utils.delete_with_check(task);
|
||||||
|
// taskResult.state = TaskState.DoneWithErrors;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
protected boolean variants() throws Exception {
|
||||||
|
if (performSapforScript("create_variants", parentTask, " -t 13 -allVars",
|
||||||
|
"out.txt",
|
||||||
|
"err.txt"
|
||||||
|
)) {
|
||||||
|
//найти папки с вариантами.
|
||||||
|
File[] files_ = parentTask.listFiles((dir, name) -> dir.isDirectory() && Utils.isParallelVersionName(name));
|
||||||
|
if ((files_ != null) && (files_.length > 0)) {
|
||||||
|
Vector<File> files = new Vector<>(Arrays.asList(files_));
|
||||||
|
files.sort(Comparator.comparingInt(o -> Integer.parseInt(o.getName().substring(1))));
|
||||||
|
/*
|
||||||
|
taskResult.state = TaskState.Done;
|
||||||
|
for (File file : files)
|
||||||
|
taskResult.variants.add(new SapforVersion_json(file.getAbsolutePath(), PassCode_2021.SPF_CreateParallelVariant.getDescription()));
|
||||||
|
*/
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// taskResult.state = TaskState.DoneWithErrors;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
public void Do() throws Exception {
|
||||||
|
parentTask = root;
|
||||||
|
//--
|
||||||
|
// taskResult = new SapforTask();
|
||||||
|
// taskResult.test_description = test;
|
||||||
|
// taskResult.sapfortaskspackage_2023_id = Integer.parseInt(packageWorkspace.getName());
|
||||||
|
// taskResult.versions.add(new SapforVersion_json(parentTask.getAbsolutePath(), "исходная"));
|
||||||
|
//--
|
||||||
|
for (PassCode_2021 code : codes) {
|
||||||
|
if (parse()) {
|
||||||
|
if (code.equals(PassCode_2021.CreateParallelVariants))
|
||||||
|
variants();
|
||||||
|
else if (!transformation(code))
|
||||||
|
break;
|
||||||
|
} else
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
//---
|
||||||
|
//results.tasks.add(taskResult);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,19 +1,32 @@
|
|||||||
package SapforTestingSystem.SapforTestingPlaner;
|
package SapforTestingSystem.SapforTestingPlaner;
|
||||||
|
import Common.Global;
|
||||||
|
import Common.Utils.Utils;
|
||||||
|
import SapforTestingSystem.Json.SapforPackage_json;
|
||||||
|
import SapforTestingSystem.Json.SapforScenario_json;
|
||||||
|
import SapforTestingSystem.SapforTest.SapforTest;
|
||||||
import SapforTestingSystem.ThreadsPlanner.ThreadsPlanner;
|
import SapforTestingSystem.ThreadsPlanner.ThreadsPlanner;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.nio.file.Paths;
|
||||||
public class SapforTestingPlanner extends ThreadsPlanner {
|
public class SapforTestingPlanner extends ThreadsPlanner {
|
||||||
public SapforTestingPlanner() {
|
public SapforTestingPlanner() throws Exception {
|
||||||
super(2000, 4);
|
super(2000, 1);
|
||||||
//--
|
SapforScenario_json scenario_json = (SapforScenario_json) Utils.jsonFromFile(new File(Global.Home, "scenario.txt"), SapforScenario_json.class);
|
||||||
/*
|
//формирование списка задач.
|
||||||
for (int i = 1; i <= 20; ++i) {
|
for (SapforPackage_json sapforPackage_json : scenario_json.packages) {
|
||||||
int thread_number = i;
|
for (String testName : scenario_json.tests) {
|
||||||
addThread(() -> {
|
addThread(() -> {
|
||||||
for (int j=1; j<=4; ++j) {
|
try {
|
||||||
Global.Log.Print("thread " + thread_number+" j="+j);
|
new SapforTest(
|
||||||
Utils.sleep(1000);
|
new File(Global.Home, "SAPFOR_F.exe"),
|
||||||
|
Paths.get(Global.Home, sapforPackage_json.id, testName).toFile(),
|
||||||
|
sapforPackage_json.flags,
|
||||||
|
sapforPackage_json.codes).Do();
|
||||||
|
} catch (Exception exception) {
|
||||||
|
Global.Log.PrintException(exception);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
*/
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,7 +37,6 @@ public abstract class ThreadsPlanner {
|
|||||||
}
|
}
|
||||||
//--
|
//--
|
||||||
} catch (Exception exception) {
|
} catch (Exception exception) {
|
||||||
exception.printStackTrace();
|
|
||||||
Global.Log.PrintException(exception);
|
Global.Log.PrintException(exception);
|
||||||
}
|
}
|
||||||
Global.Log.Print("Planner finished");
|
Global.Log.Print("Planner finished");
|
||||||
|
|||||||
@@ -1,231 +0,0 @@
|
|||||||
package Visual_DVM_2021.Passes.All;
|
|
||||||
import Common.Constants.Constants;
|
|
||||||
import Common.Global;
|
|
||||||
import Common.Utils.Utils;
|
|
||||||
import ProjectData.Project.db_project_info;
|
|
||||||
import SapforTestingSystem.Json.SapforVersion_json;
|
|
||||||
import SapforTestingSystem.Json.ScenarioResults_json;
|
|
||||||
import SapforTestingSystem.Json.SapforScenario_json;
|
|
||||||
import SapforTestingSystem.SapforTask.SapforTask;
|
|
||||||
import SapforTestingSystem.SapforTasksPackage.SapforTasksPackage;
|
|
||||||
import Visual_DVM_2021.Passes.PassCode_2021;
|
|
||||||
import Visual_DVM_2021.Passes.PassException;
|
|
||||||
import Visual_DVM_2021.Passes.Pass_2021;
|
|
||||||
import org.apache.commons.io.FileUtils;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.nio.charset.Charset;
|
|
||||||
import java.nio.file.Paths;
|
|
||||||
import java.util.Vector;
|
|
||||||
//создание дерева версий одного теста по заданному сценарию.
|
|
||||||
public class PerformScenario extends Pass_2021<SapforScenario_json> {
|
|
||||||
SapforTasksPackage tasks_package;
|
|
||||||
File scenarioFile;
|
|
||||||
//---
|
|
||||||
File parentTask;
|
|
||||||
File task;
|
|
||||||
//---
|
|
||||||
Process process = null;
|
|
||||||
int exit_code = Constants.Nan;
|
|
||||||
//----
|
|
||||||
File outputFile = null;
|
|
||||||
File errorsFile = null;
|
|
||||||
//--
|
|
||||||
Vector<String> outputLines;
|
|
||||||
Vector<String> errorsLines;
|
|
||||||
//--
|
|
||||||
ScenarioResults_json results;
|
|
||||||
//-
|
|
||||||
SapforTask taskResult = null;
|
|
||||||
//--
|
|
||||||
@Override
|
|
||||||
protected boolean needsAnimation() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
//--
|
|
||||||
@Override
|
|
||||||
protected boolean canStart(Object... args) throws Exception {
|
|
||||||
//--
|
|
||||||
tasks_package = (SapforTasksPackage) args[0];
|
|
||||||
//---
|
|
||||||
// scenarioFile = new File(tasks_package.workspace, "scenario.txt");
|
|
||||||
String packed = FileUtils.readFileToString(scenarioFile, Charset.defaultCharset());
|
|
||||||
target = Utils.gson.fromJson(packed, SapforScenario_json.class);
|
|
||||||
//---
|
|
||||||
results = new ScenarioResults_json();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
protected void saveResults() throws Exception {
|
|
||||||
for (SapforTask task : results.tasks) {
|
|
||||||
if (!task.versions.isEmpty()) {
|
|
||||||
File taskResultFile = Paths.get(task.versions.firstElement().version, db_project_info.data, "results.txt").toFile();
|
|
||||||
FileUtils.write(taskResultFile, Utils.jsonToPrettyFormat(Utils.gson.toJson(task)));
|
|
||||||
}
|
|
||||||
task.id = Global.db.IncSapforMaxTaskId();
|
|
||||||
Global.db.Insert(task);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
protected void body() throws Exception {
|
|
||||||
for (String test : target.tests) {
|
|
||||||
ShowMessage1(test);
|
|
||||||
//--
|
|
||||||
// parentTask = new File(tasks_package.workspace, test);
|
|
||||||
//--
|
|
||||||
taskResult = new SapforTask();
|
|
||||||
taskResult.test_description = test;
|
|
||||||
taskResult.sapfortaskspackage_2023_id = tasks_package.id;
|
|
||||||
taskResult.versions.add(new SapforVersion_json(parentTask.getAbsolutePath(), "исходная"));
|
|
||||||
//--
|
|
||||||
/*
|
|
||||||
for (PassCode_2021 code : target.codes) {
|
|
||||||
ShowMessage2("Синтаксический анализ");
|
|
||||||
if (parse()) {
|
|
||||||
ShowMessage2(code.getDescription());
|
|
||||||
if (code.equals(PassCode_2021.CreateParallelVariants))
|
|
||||||
variants();
|
|
||||||
else if (!transformation(code))
|
|
||||||
break;
|
|
||||||
} else
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
//---
|
|
||||||
results.tasks.add(taskResult);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
protected boolean performSapforScript(String name, File workspace, String flags, String command, String outName, String errName) throws Exception {
|
|
||||||
process = null;
|
|
||||||
exit_code = Constants.Nan;
|
|
||||||
//---
|
|
||||||
File data_workspace = new File(workspace, db_project_info.data);
|
|
||||||
Utils.CheckDirectory(data_workspace);
|
|
||||||
outputFile = new File(data_workspace, outName);
|
|
||||||
errorsFile = new File(data_workspace, errName);
|
|
||||||
Utils.delete_with_check(outputFile);
|
|
||||||
Utils.delete_with_check(errorsFile);
|
|
||||||
//---
|
|
||||||
File file = new File(data_workspace, name + ".bat");
|
|
||||||
/*
|
|
||||||
FileUtils.write(file,
|
|
||||||
Utils.DQuotes(target.sapfor_drv)
|
|
||||||
+ (flags.isEmpty() ? "" : (" " + flags))
|
|
||||||
+ " -noLogo"
|
|
||||||
+ " " + command +
|
|
||||||
" 1>" +
|
|
||||||
Utils.DQuotes(outputFile.getAbsolutePath()) +
|
|
||||||
" 2>" +
|
|
||||||
Utils.DQuotes(errorsFile.getAbsolutePath()),
|
|
||||||
Charset.defaultCharset());
|
|
||||||
*/
|
|
||||||
if (!file.setExecutable(true))
|
|
||||||
throw new PassException("Не удалось сделать файл скрипта " + name + " исполняемым!");
|
|
||||||
//--
|
|
||||||
ProcessBuilder procBuilder = new ProcessBuilder(file.getAbsolutePath());
|
|
||||||
procBuilder.directory(workspace);
|
|
||||||
process = procBuilder.start();
|
|
||||||
exit_code = process.waitFor();
|
|
||||||
if (exit_code != 0)
|
|
||||||
throw new PassException("Процесс завершился с кодом " + exit_code);
|
|
||||||
process = null;
|
|
||||||
//---
|
|
||||||
outputLines = new Vector<>(FileUtils.readLines(outputFile));
|
|
||||||
errorsLines = new Vector<>(FileUtils.readLines(errorsFile));
|
|
||||||
return checkLines(outputLines) && checkLines(errorsLines);
|
|
||||||
}
|
|
||||||
protected boolean checkLines(Vector<String> lines) {
|
|
||||||
for (String line : lines) {
|
|
||||||
if (line.toLowerCase().contains("internal error")) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (line.toLowerCase().contains("exception")) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (line.contains("[ERROR]")) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
protected boolean parse() throws Exception {
|
|
||||||
/*
|
|
||||||
if (performSapforScript("parse", parentTask, target.flags,
|
|
||||||
"-parse *.f *.for *.fdv *.f90 *.f77",
|
|
||||||
"parse_out.txt", "parse_err.txt")
|
|
||||||
&& (new File(parentTask, "dvm.proj")).exists()) {
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
taskResult.state = TaskState.DoneWithErrors;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
protected boolean transformation(PassCode_2021 code) throws Exception {
|
|
||||||
/*
|
|
||||||
task = new File(parentTask, "v1");
|
|
||||||
Utils.CheckAndCleanDirectory(task); //папка для преобразования.
|
|
||||||
if (performSapforScript("transformation", parentTask, target.flags,
|
|
||||||
code.getTestingCommand() + " -F " + Utils.DQuotes(task.getAbsolutePath()),
|
|
||||||
"out.txt",
|
|
||||||
"err.txt"
|
|
||||||
)) {
|
|
||||||
taskResult.state = TaskState.Done;
|
|
||||||
taskResult.versions.add(new SapforVersion_json(task.getAbsolutePath(), code.getDescription()));
|
|
||||||
clearSapforFiles(parentTask);
|
|
||||||
parentTask = task;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
Utils.delete_with_check(task);
|
|
||||||
clearSapforFiles(parentTask);
|
|
||||||
taskResult.state = TaskState.DoneWithErrors;
|
|
||||||
*/
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
protected boolean variants() throws Exception {
|
|
||||||
/*
|
|
||||||
if (performSapforScript("create_variants", parentTask, target.flags, " -t 13 -allVars",
|
|
||||||
"out.txt",
|
|
||||||
"err.txt"
|
|
||||||
)) {
|
|
||||||
clearSapforFiles(parentTask);
|
|
||||||
//найти папки с вариантами.
|
|
||||||
File[] files_ = parentTask.listFiles((dir, name) -> dir.isDirectory() && Utils.isParallelVersionName(name));
|
|
||||||
if ((files_ != null) && (files_.length > 0)) {
|
|
||||||
Vector<File> files = new Vector<>(Arrays.asList(files_));
|
|
||||||
files.sort(Comparator.comparingInt(o -> Integer.parseInt(o.getName().substring(1))));
|
|
||||||
taskResult.state = TaskState.Done;
|
|
||||||
for (File file : files)
|
|
||||||
taskResult.variants.add(new SapforVersion_json(file.getAbsolutePath(), PassCode_2021.SPF_CreateParallelVariant.getDescription()));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
clearSapforFiles(parentTask);
|
|
||||||
taskResult.state = TaskState.DoneWithErrors;
|
|
||||||
*/
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
protected void performFinish() throws Exception {
|
|
||||||
saveResults();
|
|
||||||
}
|
|
||||||
public void clearSapforFiles(File dir) throws Exception {
|
|
||||||
//очистка dep и proj файлов.
|
|
||||||
try {
|
|
||||||
File[] files = dir.listFiles();
|
|
||||||
if (files != null) {
|
|
||||||
for (File file : files) {
|
|
||||||
if (file.isFile()) {
|
|
||||||
String ext = Utils.getExtension(file).toLowerCase();
|
|
||||||
if (ext.equals("dep") || (ext.equals("proj"))) {
|
|
||||||
Utils.delete_with_check(file);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (Exception ex) {
|
|
||||||
ex.printStackTrace();
|
|
||||||
}
|
|
||||||
//--
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -231,7 +231,6 @@ public class StartSapforTests extends Pass_2021<SapforScenario> {
|
|||||||
File scenarioFile = new File(target.workspace, "scenario.txt");
|
File scenarioFile = new File(target.workspace, "scenario.txt");
|
||||||
SapforScenario_json scenario_json = new SapforScenario_json();
|
SapforScenario_json scenario_json = new SapforScenario_json();
|
||||||
scenario_json.tests.addAll(allTests.keySet());
|
scenario_json.tests.addAll(allTests.keySet());
|
||||||
//scenario_json.flags = SapforConfigurationInterface.getFlags(configuration);
|
|
||||||
//----
|
//----
|
||||||
Global.db.Update(target);
|
Global.db.Update(target);
|
||||||
ShowMessage1("Создание рабочих пространств...");
|
ShowMessage1("Создание рабочих пространств...");
|
||||||
@@ -276,23 +275,14 @@ public class StartSapforTests extends Pass_2021<SapforScenario> {
|
|||||||
}
|
}
|
||||||
//--
|
//--
|
||||||
Utils.jsonToFile(scenario_json, scenarioFile);
|
Utils.jsonToFile(scenario_json, scenarioFile);
|
||||||
|
//--
|
||||||
|
Utils.startScript_(scenarioWorkspace, scenarioWorkspace, "start", "java -jar VisualSapfor.jar");
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
protected void showFinish() throws Exception {
|
protected void showFinish() throws Exception {
|
||||||
Global.db.sapforScenarios.ShowUI(target.getPK());
|
Global.db.sapforScenarios.ShowUI(target.getPK());
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
protected void performDone() throws Exception {
|
|
||||||
/*
|
|
||||||
//тут должен быть планировщик и очередь пакетов. отдельной нитью.
|
|
||||||
for (SapforTasksPackage_2023 sapforTasksPackage_2023 : target) {
|
|
||||||
File workspaceFile = new File(sapforTasksPackage_2023.workspace);
|
|
||||||
// Utils.startScript(workspaceFile, workspaceFile, "start", "java -jar VisualSapfor.jar");
|
|
||||||
Utils.startScript_(workspaceFile, workspaceFile, "start", "java -jar VisualSapfor.jar");
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
protected void showDone() throws Exception {
|
protected void showDone() throws Exception {
|
||||||
Global.db.sapforScenarios.ShowUI();
|
Global.db.sapforScenarios.ShowUI();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ public enum PassCode_2021 {
|
|||||||
//-
|
//-
|
||||||
StartSapforTests,
|
StartSapforTests,
|
||||||
DeleteSapforTasksPackage,
|
DeleteSapforTasksPackage,
|
||||||
PerformScenario,
|
|
||||||
AnalyseSapforPackageResults,
|
AnalyseSapforPackageResults,
|
||||||
OpenSapforTest,
|
OpenSapforTest,
|
||||||
PerformSapforTasksPackage,
|
PerformSapforTasksPackage,
|
||||||
@@ -328,8 +327,6 @@ public enum PassCode_2021 {
|
|||||||
return "Открыть результирующую версию теста.";
|
return "Открыть результирующую версию теста.";
|
||||||
case AnalyseSapforPackageResults:
|
case AnalyseSapforPackageResults:
|
||||||
return "Анализ результатов пакета задач";
|
return "Анализ результатов пакета задач";
|
||||||
case PerformScenario:
|
|
||||||
return "Выполнить сценарий SAPFOR (пакетный режим)";
|
|
||||||
case StartSapforTests:
|
case StartSapforTests:
|
||||||
return "Создать задачи тестирования SAPFOR";
|
return "Создать задачи тестирования SAPFOR";
|
||||||
case SPF_SharedMemoryParallelization:
|
case SPF_SharedMemoryParallelization:
|
||||||
|
|||||||
Reference in New Issue
Block a user