реализованы таймауты в 40 секунд у тестирования сапфора. копирование сапфора при тестировании заменено на символические ссылки.

This commit is contained in:
2026-01-18 04:41:43 +03:00
parent 3583978152
commit 7cae2097e7
4 changed files with 51 additions and 28 deletions

View File

@@ -207,8 +207,10 @@ public abstract class Sapfor extends OSDComponent {
Utils_.CheckDirectory(data_workspace);
File outputFile = new File(data_workspace, outName);
File errorsFile = new File(data_workspace, errName);
// File logFile = new File(data_workspace, "log.txt");
Utils_.forceDeleteWithCheck(outputFile);
Utils_.forceDeleteWithCheck(errorsFile);
// Utils_.forceDeleteWithCheck(logFile);
//---
File file = new File(data_workspace, name + (Utils_.isWindows() ? ".bat" : ".sh"));
FileUtils.write(file,
@@ -224,33 +226,36 @@ public abstract class Sapfor extends OSDComponent {
if (!file.setExecutable(true))
throw new Exception("Не удалось сделать файл скрипта " + name + " исполняемым!");
//-- Windows
boolean flag = false;
//запустить процесс
boolean process_started = false;
do {
try {
ProcessBuilder procBuilder = new ProcessBuilder(file.getAbsolutePath());
procBuilder.directory(workspace);
process = procBuilder.start();
//-
for (int i=0; i<40; ++i){
if (process.waitFor(1, TimeUnit.SECONDS)){
//дождались. все хорошо.
exit_code=0;
break;
}
}
//-
if (exit_code!=0){
//процесс все еще не завершен. Убить.
process.destroyForcibly();
}
//-
flag = true; //флаг означал что запуск процесса состоялся. не столь важно успешно или нет.
process_started = true;
} catch (Exception ex) {
Utils_.MainLog.PrintException(ex);
Utils_.sleep(1000);
}
}
while (!flag);
while (!process_started);
//--
for (int i=0; i<40; ++i){
if (process.waitFor(1, TimeUnit.SECONDS)){
//дождались. все хорошо.
exit_code=0;
// FileUtils.writeStringToFile(logFile,sapfor_drv.getName()+" done for "+i+" seconds");
break;
}
}
if (exit_code!=0){
// FileUtils.writeStringToFile(logFile,sapfor_drv.getName()+" timeout");
//-
Process killer = Runtime.getRuntime().exec("pkill -SIGKILL -f "+sapfor_drv.getName());
killer.waitFor();
//-
}
process = null;
//---
Vector<String> outputLines = new Vector<>(FileUtils.readLines(outputFile));