181 lines
7.6 KiB
Java
181 lines
7.6 KiB
Java
package Visual_DVM_2021.Passes.All;
|
||
import Common.Current;
|
||
import Common.Global;
|
||
import Common.UI.UI;
|
||
import Common.UI.VisualCache.ConfigurationCache;
|
||
import Common.UI.VisualCache.VisualCaches;
|
||
import Common.Utils.Utils;
|
||
import GlobalData.Compiler.CompilerType;
|
||
import GlobalData.Machine.MachineType;
|
||
import GlobalData.User.UserState;
|
||
import TestingSystem.Common.Group.Group;
|
||
import TestingSystem.Common.Test.Test;
|
||
import TestingSystem.Common.TestingServer;
|
||
import TestingSystem.DVM.DVMConfiguration.DVMConfiguration;
|
||
import TestingSystem.DVM.DVMPackage.DVMPackage;
|
||
import TestingSystem.DVM.DVMTasks.DVMCompilationTask;
|
||
import TestingSystem.DVM.DVMTasks.DVMRunTask;
|
||
import Visual_DVM_2021.Passes.PassCode_2021;
|
||
import Visual_DVM_2021.Passes.Server.PublishServerObject;
|
||
|
||
import java.util.LinkedHashMap;
|
||
import java.util.Vector;
|
||
public class StartSelectedDVMConfigurations extends PublishServerObject<TestingServer, DVMPackage> {
|
||
Vector<DVMConfiguration> configurations;
|
||
Vector<Group> groups;
|
||
Vector<Test> tests;
|
||
LinkedHashMap<Integer, Vector<Test>> testByGroups;
|
||
Vector<DVMCompilationTask> tasks;
|
||
int tasks_count;
|
||
public StartSelectedDVMConfigurations() {
|
||
super(Global.testingServer, DVMPackage.class);
|
||
}
|
||
//пока пусть будет одна конфигурация и один пакет.
|
||
@Override
|
||
public String getIconPath() {
|
||
return "/icons/Start.png";
|
||
}
|
||
//--
|
||
public static String checkFlags(String flags_in) {
|
||
if (!flags_in.contains("-shared-dvm")) {
|
||
if (flags_in.isEmpty())
|
||
return "-shared-dvm";
|
||
else return flags_in + " -shared-dvm";
|
||
} else
|
||
return flags_in;
|
||
}
|
||
public static String checkEnvironments(String environmentsSet_in) {
|
||
if (!environmentsSet_in.contains("DVMH_NO_DIRECT_COPY")) {
|
||
if (environmentsSet_in.isEmpty())
|
||
return "DVMH_NO_DIRECT_COPY=" + Utils.DQuotes("1");
|
||
else
|
||
return environmentsSet_in + " " + "DVMH_NO_DIRECT_COPY=" + Utils.DQuotes("1");
|
||
} else
|
||
return environmentsSet_in;
|
||
}
|
||
//--
|
||
public Vector<DVMCompilationTask> createTasksCGT(
|
||
DVMConfiguration configuration,
|
||
Group group,
|
||
Test test
|
||
) {
|
||
Vector<DVMCompilationTask> compilationTasks = new Vector<>();
|
||
for (String flags : configuration.getFlagsArray()) {
|
||
String checked_flags = checkFlags(flags);
|
||
DVMCompilationTask dvmCompilationTask = new DVMCompilationTask(
|
||
configuration,
|
||
group,
|
||
test,
|
||
checked_flags
|
||
);
|
||
Vector<String> matrixes = configuration.getMatrixes(test.max_dim);
|
||
Vector<String> environments = configuration.getEnvironments();
|
||
for (String environmentSet : environments) {
|
||
String checkedEnvironments = checkEnvironments(environmentSet);
|
||
if (flags.trim().equalsIgnoreCase("-s")) {
|
||
dvmCompilationTask.runTasks.add(new DVMRunTask(
|
||
configuration,
|
||
group,
|
||
test,
|
||
"",
|
||
checked_flags,
|
||
checkedEnvironments,
|
||
configuration.getParamsText(),
|
||
target.kernels
|
||
));
|
||
tasks_count++;
|
||
} else
|
||
for (String matrix : matrixes) {
|
||
dvmCompilationTask.runTasks.add(new DVMRunTask(
|
||
configuration,
|
||
group,
|
||
test,
|
||
matrix,
|
||
checked_flags,
|
||
checkedEnvironments,
|
||
configuration.getParamsText(),
|
||
target.kernels));
|
||
tasks_count++;
|
||
}
|
||
}
|
||
compilationTasks.add(dvmCompilationTask);
|
||
}
|
||
return compilationTasks;
|
||
}
|
||
//--
|
||
@Override
|
||
protected boolean canStart(Object... args) throws Exception {
|
||
configurations = Global.testingServer.db.dvm_configurations.getCheckedOrCurrent();
|
||
groups = new Vector<>();
|
||
tests = new Vector<>();
|
||
testByGroups = new LinkedHashMap<>();
|
||
tasks = new Vector<>();
|
||
tasks_count=0;
|
||
//---
|
||
if (!Current.getAccount().CheckRegistered(Log)) {
|
||
return false;
|
||
}
|
||
if (configurations.isEmpty()){
|
||
Log.Writeln_("Не отмечено ни одной конфигурации, или отсутствует текущая конфигурация.");
|
||
return false;
|
||
}
|
||
if (Current.Check(Log, Current.Machine, Current.User, Current.Compiler)) {
|
||
if (!Current.getMachine().type.equals(MachineType.Server)) {
|
||
Log.Writeln_("Тестирование поддерживается только на одиночном удалённом сервере.");
|
||
return false;
|
||
}
|
||
if (!Current.getUser().state.equals(UserState.ready_to_work)) {
|
||
Log.Writeln_("Пользователь не готов к работе. Выполните инициализацию пользователя!");
|
||
return false;
|
||
}
|
||
if (!Current.getCompiler().type.equals(CompilerType.dvm)) {
|
||
Log.Writeln_("Тестирование поддерживается только для DVM компиляторов.");
|
||
return false;
|
||
}
|
||
if (!Current.getCompiler().versionLoaded)
|
||
passes.get(PassCode_2021.ShowCompilerVersion).Do(Current.getCompiler(), false);
|
||
//--
|
||
target = new DVMPackage(
|
||
Current.getAccount(),
|
||
Current.getMachine(),
|
||
Current.getUser(),
|
||
Current.getCompiler()
|
||
);
|
||
//----
|
||
for (DVMConfiguration configuration: configurations) {
|
||
ConfigurationCache cache = (ConfigurationCache) VisualCaches.GetCache(configuration);
|
||
groups = cache.getGroups();
|
||
tests = cache.getTests();
|
||
//-
|
||
for (Group group: groups){
|
||
Vector<Test> groupTests = new Vector<>();
|
||
for (Test test: tests){
|
||
if (test.group_id==group.id)
|
||
groupTests.add(test);
|
||
}
|
||
testByGroups.put(group.id, groupTests);
|
||
}
|
||
//--
|
||
for (Group group : groups) {
|
||
Vector<Test> groupTests = testByGroups.get(group.id);
|
||
for (Test test : groupTests)
|
||
tasks.addAll(createTasksCGT(configuration, group, test));
|
||
}
|
||
}
|
||
if (tasks_count==0){
|
||
Log.Writeln_("Задач не найдено.");
|
||
return false;
|
||
}
|
||
return UI.Question("Будет запущено " + tasks_count + " задач. Продолжить");
|
||
}
|
||
return false;
|
||
}
|
||
@Override
|
||
protected void ServerAction() throws Exception {
|
||
//занесение информации об участвующих конфигурациях
|
||
target.saveConfigurationsAsJson(configurations);
|
||
target.saveTasks(tasks, tasks_count);
|
||
super.ServerAction();
|
||
}
|
||
}
|