function create_instance_from_path($program_path) { global $conf_max_instances; // Find unused instance ID do { $instance = rand(0, $conf_max_instances); $path = instance_path($instance); } while (file_exists($path)); directoryCleanup($path); `cp -R {$program_path}/* {$path}`; return $instance; }
$profiler = find_best_profiler($task['language']); // Add tool versions to buildhost description $buildhost_description['compiler_version'] = $compiler['version']; if ($debugger) { $buildhost_description['debugger_version'] = $debugger['version']; } if ($profiler) { $buildhost_description['profiler_version'] = $profiler['version']; } update_status("STA001", "Starting up..."); // Begin process $filelist = find_sources($task, $instance); if ($filelist == array()) { error("ERR004", "No sources found"); } $exe_file = instance_path($instance) . "/bs_exec_{$program_id}"; $debug_exe_file = $exe_file . "_debug"; // Compile if ($task['compile'] === "true") { $compile_result = do_compile($filelist, $exe_file, $compiler, $task['compiler_options'], $instance); if ($compile_result['status'] == COMPILE_SUCCESS) { update_status("STA002", "Compile succeeded"); } else { update_status("STA003", "Compile failed"); done(); } } else { $exe_file = $task['exe_file']; $debug_exe_file = $task['debug_exe_file']; } // Run
function test_adjust_lines(&$file, &$line, $adj, $instance) { if ($line < $adj['global_top_pos']) { // Error in includes? unpossible } else { if ($line < $adj['original_source_pos']) { $file = "TEST_CODE_GLOBAL_TOP"; $line -= $adj['global_top_pos']; } else { if ($line < $adj['global_above_pos']) { // For languages that don't copy sources from main_filename this shouldn't happen $file = substr($adj['orig_filename'], strlen(instance_path($instance)) + 1); $line -= $adj['original_source_pos']; } else { if ($line < $adj['test_code_pos']) { $file = "TEST_CODE_GLOBAL_ABOVE"; $line -= $adj['global_above_pos']; } else { $file = "TEST_CODE"; $line -= $adj['test_code_pos']; } } } } }