2024-09-15 01:36:19 +03:00
|
|
|
|
package Visual_DVM_2021.Passes.All;
|
|
|
|
|
|
import Common.Current;
|
|
|
|
|
|
import Common.Global;
|
|
|
|
|
|
import Common.UI.UI;
|
|
|
|
|
|
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;
|
2024-09-16 15:41:43 +03:00
|
|
|
|
import TestingSystem.DVM.DVMConfiguration.DVMConfiguration;
|
2024-09-15 01:36:19 +03:00
|
|
|
|
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;
|
2024-09-16 16:03:39 +03:00
|
|
|
|
public class StartSelectedDVMConfigurations extends PublishServerObject<TestingServer, DVMPackage> {
|
2024-09-15 01:36:19 +03:00
|
|
|
|
Vector<DVMConfiguration> configurations;
|
|
|
|
|
|
Vector<Group> groups;
|
|
|
|
|
|
Vector<Test> tests;
|
|
|
|
|
|
LinkedHashMap<Integer, Vector<Test>> testByGroups;
|
|
|
|
|
|
Vector<DVMCompilationTask> tasks;
|
|
|
|
|
|
int tasks_count;
|
2024-09-16 16:03:39 +03:00
|
|
|
|
public StartSelectedDVMConfigurations() {
|
2024-09-15 01:36:19 +03:00
|
|
|
|
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 {
|
2024-09-16 16:03:39 +03:00
|
|
|
|
configurations = Global.testingServer.db.dvm_configurations.getCheckedOrCurrent();
|
2024-09-15 01:36:19 +03:00
|
|
|
|
groups = new Vector<>();
|
|
|
|
|
|
tests = new Vector<>();
|
|
|
|
|
|
testByGroups = new LinkedHashMap<>();
|
|
|
|
|
|
tasks = new Vector<>();
|
|
|
|
|
|
tasks_count=0;
|
|
|
|
|
|
//---
|
|
|
|
|
|
if (!Current.getAccount().CheckRegistered(Log)) {
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
2024-09-16 16:03:39 +03:00
|
|
|
|
if (configurations.isEmpty()){
|
|
|
|
|
|
Log.Writeln_("Не отмечено ни одной конфигурации, или отсутствует текущая конфигурация.");
|
2024-09-15 01:36:19 +03:00
|
|
|
|
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()
|
|
|
|
|
|
);
|
|
|
|
|
|
//----
|
2024-09-16 16:03:39 +03:00
|
|
|
|
for (DVMConfiguration configuration: configurations) {
|
|
|
|
|
|
groups = configuration.getGroups();
|
|
|
|
|
|
tests = configuration.getTests(groups, testByGroups);
|
|
|
|
|
|
//--
|
|
|
|
|
|
for (Group group : groups) {
|
|
|
|
|
|
Vector<Test> groupTests = testByGroups.get(group.id);
|
|
|
|
|
|
for (Test test : groupTests)
|
|
|
|
|
|
tasks.addAll(createTasksCGT(configuration, group, test));
|
|
|
|
|
|
}
|
2024-09-15 01:36:19 +03:00
|
|
|
|
}
|
|
|
|
|
|
return UI.Question("Будет запущено " + tasks_count + " задач. Продолжить");
|
|
|
|
|
|
}
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
|
|
|
protected void ServerAction() throws Exception {
|
2024-09-16 15:41:43 +03:00
|
|
|
|
//занесение информации об участвующих конфигурациях
|
2024-09-15 01:36:19 +03:00
|
|
|
|
target.saveConfigurations(configurations);
|
|
|
|
|
|
target.saveTasks(tasks, tasks_count);
|
|
|
|
|
|
super.ServerAction();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|