void TaskThrottler::PostTask(const tracked_objects::Location& aLocation, UniquePtr<CancelableTask> aTask, const TimeStamp& aTimeStamp) { MonitorAutoLock lock(mMonitor); TASK_LOG("%p got a task posted; mOutstanding=%d\n", this, mOutstanding); aTask->SetBirthPlace(aLocation); if (mOutstanding) { CancelPendingTask(lock); if (TimeSinceLastRequest(aTimeStamp, lock) < mMaxWait) { mQueuedTask = Move(aTask); TASK_LOG("%p queued task %p\n", this, mQueuedTask.get()); // Make sure the queued task is sent after mMaxWait time elapses, // even if we don't get a TaskComplete() until then. TimeDuration timeout = mMaxWait - TimeSinceLastRequest(aTimeStamp, lock); mTimeoutTask = NewRunnableMethod(this, &TaskThrottler::OnTimeout); APZThreadUtils::RunDelayedTaskOnCurrentThread(mTimeoutTask, timeout); return; } // we've been waiting for more than the max-wait limit, so just fall through // and send the new task already. } mStartTime = aTimeStamp; aTask->Run(); mOutstanding = true; }
/** * Compile solution * * @param __self - task to be compiled * @param __cur_testing_dir - current testing directory * @param __cur_data_dir - directory with current data * @oaram __params - collecting params to return to WebIFACE * @return TRUE on success, FALSE or value less than zero in case of error */ static BOOL compile_solution (wt_task_t *__self, const char *__cur_testing_dir, const char *__cur_data_dir, assarr_t *__params) { char cmd[32768]; /* Generate command */ strcpy (cmd, ""); build_compiler_command (__self, __cur_testing_dir, __cur_data_dir, cmd); assarr_set_value (__params, "COMPILER_COMMAND", strdup (cmd)); /* Compile command not defined */ if (!strcmp (cmd, "")) { INF_DEBUG_LOG ("Task %ld. Compiler's command is undefined\n", __self->sid); TASK_LOG (*__self, "\n--------\nFatal error: Compiler command is " "undefined.\nTesting aborted.\n"); REPORT (__params, "Compiler command is undefined."); return -1; } if (!run_compiler (__self, cmd, __cur_testing_dir, __cur_data_dir, __params)) { return FALSE; } /* Some more checking */ return post_compiling_check (__self, __cur_testing_dir, __cur_data_dir, __params); }
void TaskThrottler::RunQueuedTask(const TimeStamp& aTimeStamp, const MonitorAutoLock& aProofOfLock) { TASK_LOG("%p running task %p\n", this, mQueuedTask.get()); mStartTime = aTimeStamp; mQueuedTask->Run(); mQueuedTask = nullptr; }
void TaskThrottler::CancelPendingTask(const MonitorAutoLock& aProofOfLock) { if (mQueuedTask) { TASK_LOG("%p cancelling task %p\n", this, mQueuedTask.get()); mQueuedTask->Cancel(); mQueuedTask = nullptr; CancelTimeoutTask(aProofOfLock); } }
/* Waits for motor commands and executes them as they arrive. */ void motor_handler_update_task(void *pdata) { TASK_LOG(printf("MotorHandler [task: update, status: start]\n")); while (true) { try { // Update the motor handler. motor->update(); } catch (ARCapException &e) { // Log exceptions. MOTORHANDLER_LOG(printf("%s\n", e.what())); } } }
void RenderTask::PrepareRenderInstruction( RenderInstruction& instruction, BufferIndex updateBufferIndex ) { DALI_ASSERT_DEBUG( NULL != mCameraAttachment ); TASK_LOG(Debug::General); Viewport viewport; bool viewportSet = QueryViewport( updateBufferIndex, viewport ); instruction.Reset( mCameraAttachment, GetFrameBufferId(), viewportSet ? &viewport : NULL, mClearEnabled ? &GetClearColor( updateBufferIndex ) : NULL ); }
/** * Print common information to task log file * * @param __self - task to print information about */ static void print_common_info (wt_task_t *__self) { TASK_LOG (*__self, "-- Common information:\n"); TASK_LOG (*__self, " Solution ID : %ld\n", __self->sid); TASK_LOG (*__self, " Problem ID : %s\n", (char*) assarr_get_value (__self->input_params, "PROBLEMID")); TASK_LOG (*__self, " Compiler ID : %s\n", (char*) assarr_get_value (__self->input_params, "COMPILERID")); TASK_LOG (*__self, " TESTS : %s\n", (char*) assarr_get_value (__self->input_params, "TESTS")); TASK_LOG (*__self, "\n"); }
/* * Main stuff of testing * * @param __self - task to be compiled * @param __cur_testing_dir - current testing directory * @param __points - collected points * @param __errors - solution's errors on tests * @oaram __params - collecting params to return to WebIFACE */ static void testing_main_loop (wt_task_t *__self, const char *__cur_data_dir, const char *__cur_testing_dir, int *__points, char *__errors, assarr_t *__params) { int i; INF_DEBUG_LOG ("Task %ld. Enter testing mainloop stuff\n", __self->sid); /* Bonus points (if all tests passed) */ int bonus = atoi (TASK_INPUT_PARAM (*__self, "BONUS")); /* I/O filenames */ /* Name of input file */ char *input_file = TASK_INPUT_PARAM (*__self, "INPUTFILE"); /* Name of output file */ char *output_file = TASK_INPUT_PARAM (*__self, "OUTPUTFILE"); /* Resource limits */ /* But why simple atof doesn't work? */ DWORD memory_limit = flexval_atolf (TASK_INPUT_PARAM (*__self, "MEMORYLIMIT")) * 1024; /* Kb */ DWORD time_limit = flexval_atolf (TASK_INPUT_PARAM (*__self, "TIMELIMIT")) * USEC_COUNT; /* usecs */ char full_input[4096], /* Full input filename */ full_output[4096], /* Full output filename */ checker_cmd[4096]; /* Command to execute */ /* String with all tests' results */ char tests_res_pchar[(MAX_ERRCODE + 1) * MAX_TESTS]; /* Process's descriptor */ run_process_info_t *proc = NULL; /* Filename to execute */ char execfn[4096] = {0}; /* Errors */ BOOL RE = FALSE, ML = FALSE, TL = FALSE, WA = FALSE, PE = FALSE, CR = FALSE; /* PChar-ed error for current test */ char cur_err_str[MAX_ERRCODE + 1]; BOOL acm = !strcmp (TASK_INPUT_PARAM (*__self, "ACM"), "TRUE"); /* Unpack tests' data */ char *tests_pchar = TASK_INPUT_PARAM (*__self, "TESTS"), effective_tests[4096]; char **tests_pchar_arr = 0; /* Points for tests */ int tests[MAX_TESTS]; /* Dummy pchar value */ char dummy[1024]; int compiler_chroot = COMPILER_SAFE_INT_KEY (TASK_COMPILER_ID (*__self), "ChRoot", -1); /* Get command for solution executing */ char *run_solution_cmd = COMPILER_SAFE_PCHAR_KEY (TASK_COMPILER_ID (*__self), "RunSolutionCmd", NULL); if (run_solution_cmd && strcmp (run_solution_cmd, "")) { /* We'll make some changes in this string, so we should */ /* close this string to make original stored in hive tree */ /* for correct freeing */ run_solution_cmd = strdup (run_solution_cmd); /* String may be enlarged when parameters will be substitued */ run_solution_cmd = realloc (run_solution_cmd, 65535); replace_defaults (run_solution_cmd, __cur_testing_dir, __cur_data_dir); } /* * TODO: Need to strip dupicated spaces in source string with tests */ trim (tests_pchar, effective_tests); int tests_count = explode (effective_tests, " ", &tests_pchar_arr); /* Per-compiler resource usage correction */ double time_corr, rss_corr; assarr_t *outputs = NULL, *checker_outputs = NULL; char *output = NULL; for (i = 0; i < tests_count; i++) { tests[i] = atoi (tests_pchar_arr[i]); } /* Free unwanted data */ free_explode_data (tests_pchar_arr); /* Some more initializations */ snprintf (full_input, BUF_SIZE (full_input), "%s/%s", __cur_testing_dir, input_file); snprintf (full_output, BUF_SIZE (full_output), "%s/%s", __cur_testing_dir, output_file); strcpy (tests_res_pchar, ""); TASK_LOG (*__self, "----\n"); /* Get executable file name */ INF_PCHAR_KEY (execfn, "FileToExec"); strcat (execfn, COMPILER_SAFE_PCHAR_KEY (TASK_COMPILER_ID (*__self), "OutputExtension", "")); if (run_solution_cmd) { REPLACE_VAR (run_solution_cmd, "executable", execfn); } else { run_solution_cmd = strdup (execfn); } if (compiler_chroot >= 0) { use_chroot = compiler_chroot; } /* Copying all libs/binaries needed for correct running of solution */ if (use_chroot) { copy_chroot_data (__cur_testing_dir); } /* Get corrections to apply when executing solution */ snprintf (dummy, BUF_SIZE (dummy), "ResourceCorrections/Compilers/%s/Time", TASK_COMPILER_ID (*__self)); INF_SAFE_FLOAT_KEY (time_corr, dummy, 0); snprintf (dummy, BUF_SIZE (dummy), "ResourceCorrections/Compilers/%s/RSS", TASK_COMPILER_ID (*__self)); INF_SAFE_FLOAT_KEY (rss_corr, dummy, 0); /* Apply corrections */ time_limit += time_corr * USEC_COUNT; memory_limit += rss_corr; if (fabs (time_corr) > 1e-8 || fabs (rss_corr) > 1e-8) { INF_DEBUG_LOG ("Using per-compiler corrections: RSS: %lf, time: %lf\n", rss_corr, time_corr); } if (need_store_output () && max_output_store_size > 0) { outputs = assarr_create (); output = malloc (max_output_store_size + 1); } if (need_store_checker_output ()) { checker_outputs = assarr_create (); } /* Cycle by tests */ INF_DEBUG_LOG ("Task %ld. Begin cycle by tests\n", __self->sid); for (i = 0; i < tests_count; i++) { LOOP_CHECK_ACTIVE; /* Some pre-initialization */ strcpy (cur_err_str, "OK"); /* Command to execute checker */ build_checker_cmd (__self, __cur_testing_dir, __cur_data_dir, i + 1, tests_count, checker_cmd); /* Copy test file (input file) */ INF_DEBUG_LOG ("Task %ld. Copy test\n", __self->sid); if (!copy_test (i + 1, tests_count, __cur_data_dir, __cur_testing_dir, input_file)) { TASK_LOG (*__self, "\n--------\n" "Fatal error: error copying test file #%d.\n" "Testing aborted.\n", i + 1); REPORT (__params, "Error copying test #%d.", i + 1); LOOPCRASH; } /* Execute solution */ SAFE_FREE_PROC (proc); INF_DEBUG_LOG ("Task %ld. Executing solution (cmd: %s)\n", __self->sid, run_solution_cmd); proc = run_create_process (run_solution_cmd, __cur_testing_dir, memory_limit, time_limit); /* Set security info */ run_set_usergroup (proc, solution_exec_uid, solution_exec_gid); run_set_chroot (proc, use_chroot); run_execute_process (proc); run_pwait (proc); INF_DEBUG_LOG ("Task %ld. Finish executing solution\n", __self->sid); LOOP_CHECK_ACTIVE; if (RUN_PROC_EXEC_ERROR (*proc)) { INF_DEBUG_LOG ("Task %ld. " "Fatal error duting executing solution: %s\n", __self->sid, RUN_PROC_ERROR_DESC (*proc)); TASK_LOG (*__self, "\n--------\n" "Fatal error: error executing solution " "at test #%d: %s.\nTesting aborted.\n", i + 1, RUN_PROC_ERROR_DESC (*proc)); REPORT (__params, "Error executing solution at test #%d: %s.", i + 1, RUN_PROC_ERROR_DESC (*proc)); LOOPCRASH; } INF_DEBUG_LOG ("Task %ld test #%d: solution exit with exit_code %d, " "rss_usage %lld and time_usage %lld\n", __self->sid, i, RUN_PROC_EXITCODE (*proc), RUN_PROC_RSSUSAGE (*proc), RUN_PROC_TIMEUSAGE (*proc)); if (RUN_PROC_PIPEBUF (*proc)) { INF_DEBUG_LOG ("Pipe from task %ld test #%d: %s\n", __self->sid, i, RUN_PROC_PIPEBUF (*proc)); } /* Overview solution's status */ if (RUN_PROC_MEMORYLIMIT (*proc)) { ERR (ML, "ML") } else if (RUN_PROC_TIMELIMIT (*proc)) { ERR (TL, "TL") } else if (PROCESS_RUNTIME_ERROR (*proc)) { ERR (RE, "RE") } else { if (!fexists (full_output)) { /* No output file. Presentation error. */ INF_DEBUG_LOG ("Task %ld. Output file not found after " "running solution.", __self->sid); ERR (PE, "PE"); } else { /* Need this here because in case of ACM rules */ /* macro ERR() may abort testing cycle */ if (outputs) { FILE *stream = fopen (full_output, "r"); snprintf (dummy, BUF_SIZE (dummy), "%d", i); if (stream) { size_t len = fread (output, 1, max_output_store_size, stream); output[len] = 0; assarr_set_value (outputs, dummy, strdup (output)); fclose (stream); } } /* Exec checker */ SAFE_FREE_PROC (proc); INF_DEBUG_LOG ("Task %ld. Executing checker (cmd: %s)\n", __self->sid, checker_cmd); proc = run_create_process (checker_cmd, __cur_data_dir, checker_memory_limit, checker_time_limit); run_execute_process (proc); run_pwait (proc); INF_DEBUG_LOG ("Task %ld. Finish executing checker\n", __self->sid); LOOP_CHECK_ACTIVE; /* Error while trying to execute checker */ if (RUN_PROC_EXEC_ERROR (*proc)) { INF_DEBUG_LOG ("Task %ld. " "Fatal error duting executing checker: %s\n", __self->sid, RUN_PROC_ERROR_DESC (*proc)); TASK_LOG (*__self, "\n--------\n" "Fatal error: error executing checker " "at test #%d: %s.\nTesting aborted.\n", i + 1, RUN_PROC_ERROR_DESC (*proc)); REPORT (__params, "Error executing checker at test #%d: %s.", i + 1, RUN_PROC_ERROR_DESC (*proc)); LOOPCRASH; } /* Checker finished by signal. */ if (RUN_PROC_TERMINATED (*proc)) { TASK_LOG (*__self, "\n--------\n" "Fatal error: Abnormal checker " "termionation at test #%d. " "TERM signal: %d.\nTesting aborted.\n", i + 1, RUN_PROC_TERMSIG (*proc)); REPORT (__params, "Abnormal checker termination at test #%d. " "TERM signal: %d.", i + 1, RUN_PROC_TERMSIG (*proc)); LOOPCRASH; } INF_DEBUG_LOG ("Task %ld. " "Checker finished working with exit code %d\n", __self->sid, RUN_PROC_EXITCODE (*proc)); /* Resource usage error while executing checker */ if (RUN_PROC_MEMORYLIMIT (*proc) || RUN_PROC_TIMELIMIT (*proc)) { INF_DEBUG_LOG ("Task %ld. " "Checker's resource usage error (%s)\n", __self->sid, ((RUN_PROC_MEMORYLIMIT (*proc)) ? ("Memory limit") : ("Time limit"))); #ifdef __DEBUG if (RUN_PROC_MEMORYLIMIT (*proc)) { INF_DEBUG_LOG ("Task %ld. Checker's memory limit was" " %lld but %lld was used\n", __self->sid, checker_memory_limit, RUN_PROC_RSSUSAGE (*proc)); } else { INF_DEBUG_LOG ("Task %ld. Checker's time limit was %lld " "but %lld was used\n", __self->sid, checker_time_limit, RUN_PROC_TIMEUSAGE (*proc)); } #endif TASK_LOG (*__self, "\n--------\n" "Fatal error: resource limit error while " "executing checker.\nTesting aborted.\n"); REPORT (__params, "Resource limit exceeded while executing " "checker at test #%d. ", i + 1); LOOPCRASH; } /* Store checker's output message */ if (checker_outputs && RUN_PROC_PIPEBUF (*proc)) { snprintf (dummy, BUF_SIZE (dummy), "%d", i); assarr_set_value (checker_outputs, dummy, strdup (RUN_PROC_PIPEBUF (*proc))); } /* Overview checker's exit code */ switch (RUN_PROC_EXITCODE (*proc)) { case _OK: /* Update points for task */ (*__points) += tests[i]; push_string ("OK", " ", tests_res_pchar); break; case _WA: ERR (WA, "WA"); break; case _PE: ERR (PE, "PE"); break; default: /* Unknown checker's exit code */ TASK_LOG (*__self, "\n--------\nFatal error: checker exited " "with unknown code: %d.\nBuffer from " "checker: %s\nTesting aborted.\n", RUN_PROC_EXITCODE (*proc), RUN_PROC_PIPEBUF (*proc)); REPORT (__params, "Checker exited with unknown code: %d\n" "Buffer from checker: %s", i + 1, RUN_PROC_PIPEBUF (*proc)); LOOPCRASH; break; } SAFE_FREE_PROC (proc); } } /* Delete input file (to reduce storaging of garbage) and */ /* correct handling of PE */ unlink (full_input); unlink (full_output); SAFE_FREE_PROC (proc); /* Log information about passed test */ LOG_TEST; } INF_DEBUG_LOG ("Task %ld. Testing mainloop finished\n", __self->sid); __done_: SAFE_FREE_PROC (proc); SAFE_FREE (run_solution_cmd); assarr_set_value (__params, "TESTS", strdup (tests_res_pchar)); if (use_chroot) { remove_chroot_data (__cur_testing_dir); } LOOP_DONE_CHECK_ACTIVE; if (!CR) { if (RE) push_string ("RE", " ", __errors); if (ML) push_string ("ML", " ", __errors); if (TL) push_string ("TL", " ", __errors); if (WA) push_string ("WA", " ", __errors); if (PE) push_string ("PE", " ", __errors); /* If errors' string is empty, no errors were occured */ /* in task's testing. So we can set bonus to points. */ if (!strcmp (__errors, "")) { (*__points) += bonus; strcpy (__errors, "OK"); } } STORE_OUTPUTS (outputs, "SOLUTION_OUTPUT"); STORE_OUTPUTS (checker_outputs, "CHECKER_OUTPUT"); SAFE_FREE (output); }
/** * Run compiler with profiling * * @paxram __self - task to be compiled * @param __cmd - command to execute * @param __cur_testing_dir - current testing directory * @param __cur_data_dir - directory with current data * @oaram __params - collecting params to return to WebIFACE * @return TRUE on success, FALSE otherwise */ static BOOL run_compiler (wt_task_t *__self, const char *__cmd, const char *__cur_testing_dir, const char *__cur_data_dir, assarr_t *__params) { DWORD compiler_ml, compiler_tl, common_compiler_ml, common_compiler_tl; run_process_info_t *proc; BOOL result = TRUE; /* Get compiler's limits */ common_compiler_ml = COMPILER_SAFE_COMMON_INT_KEY ("Limits/RSS", INFORMATICS_COMPILER_RSS_LIMIT); common_compiler_tl = COMPILER_SAFE_COMMON_FLOAT_KEY ("Limits/Time", INFORMATICS_COMPILER_TIME_LIMIT); compiler_ml = COMPILER_SAFE_INT_KEY (TASK_COMPILER_ID (*__self), "Limits/RSS", common_compiler_ml); compiler_tl = COMPILER_SAFE_FLOAT_KEY (TASK_COMPILER_ID (*__self), "Limits/Time", common_compiler_tl) * USEC_COUNT; /* Create process */ INF_DEBUG_LOG ("Task %ld. Executing compiler (cmd: %s)\n", __self->sid, __cmd); proc = run_create_process (__cmd, __cur_testing_dir, compiler_ml, compiler_tl); run_execute_process (proc); /* Execute process and.. */ run_pwait (proc); /* ..wait finishing of process */ INF_DEBUG_LOG ("Task %ld. Finish executing compiler\n", __self->sid); if (RUN_PROC_EXEC_ERROR (*proc)) { INF_DEBUG_LOG ("Task %ld. Executing compiler failed: %s\n", __self->sid, RUN_PROC_ERROR_DESC (*proc)); TASK_LOG (*__self, "\n--------\n" "Fatal error: error executing compiler: %s.\n" "Testing aborted.\n", RUN_PROC_ERROR_DESC (*proc)); REPORT (__params, "Error executing compiler: %s.", RUN_PROC_ERROR_DESC (*proc)); run_free_process (proc); return -1; } /* Set output buffer from pipe */ if (RUN_PROC_PIPEBUF (*proc)) { char *pchar = strdup (RUN_PROC_PIPEBUF (*proc)); if (strlen (pchar) > MAX_COMPILER_MSG_LEN) { pchar[MAX_COMPILER_MSG_LEN - 4] = 0; strcat (pchar, "..."); } assarr_set_value (__params, "COMPILER_MESSAGES", pchar); } /* Nonzero-coded exit - compilation error */ if (PROCESS_RUNTIME_ERROR (*proc)) { result = FALSE; } run_free_process (proc); return result; }
/** * Main testing thread */ static void testing_thread (gpointer __data, gpointer __user_data) { wt_task_t *task = __data; char pchar[65536]; /* Directories for current testing stuff */ char cur_testing_dir[4096]; char cur_data_dir[4096]; char lock_file[4096]; int points = 0, rc; char errors[MAX_TESTS * (MAX_ERRCODE + 1)]; FILE *stream; assarr_t *all_params; /* Update status of the task */ TASK_SET_STATUS (*task, TS_RUNNING); INF_DEBUG_LOG ("Started new thread for testing task %ld\n", task->sid); all_params = assarr_create (); /* Calculating current testing and data directories */ snprintf (cur_testing_dir, BUF_SIZE (cur_testing_dir), "%s/%ld", testing_dir, task->sid); snprintf (cur_data_dir, BUF_SIZE (cur_data_dir), "%s/%s/%s", data_dir, problems_dir, (char*) TASK_INPUT_PARAM (*task, "PROBLEMID")); /* Delete all unwanted data */ unlinkdir (cur_testing_dir); /* Create global testing root. */ /* Deny reading of this root to deny getting listing of this catalogue */ /* to executable solutions. */ fmkdir (testing_dir, 00773); /* Create current testing directory */ mutex_lock (lck_mutex); snprintf (lock_file, BUF_SIZE (lock_file), "%s/lock", cur_testing_dir); fmkdir (cur_testing_dir, 00777); flock_set (lock_file); mutex_unlock (lck_mutex); /* Some initialization */ points = 0; strcpy (errors, ""); /* Start logging */ print_common_info (task); /* * TODO: Add TASK_SET_RESULT_MESSAGE() in case of testing crash */ INF_DEBUG_LOG ("Task %ld. Check for required parameters\n", task->sid); /* Check for required data */ if (!check_required_params (task, pchar)) { strcpy (errors, "CR"); TASK_LOG (*task, "\n========\n" "Fatal error: Required params aren't defined: %s! " "Testing aborted.\n", pchar); REPORT (all_params, "Required params aren't defined: %s.", pchar); goto __done_; } /**** * TESTING STUFF */ /* * Step 0: Saving solution source to file */ INF_DEBUG_LOG ("Task %ld. Step 0: Save solution\n", task->sid); if (!save_solution (task, cur_testing_dir)) { strcpy (errors, "CR"); TASK_LOG (*task, "\n========\nFatal error: unable to save solution! " "Testing aborted.\n"); REPORT (all_params, "Error saving solution."); goto __done_; } /* * Step 1: Compiling colution */ INF_DEBUG_LOG ("Task %ld. Step 1: Compile solution\n", task->sid); rc = compile_solution (task, cur_testing_dir, cur_data_dir, all_params); TESTING_CHECK_ACTIVE; if (rc < 0) { /* Fatal errors while compile */ INF_DEBUG_LOG ("[EE] Task %ld. Ctirical error during solution " "compilation process\n"); points = 0; strcpy (errors, "CR"); TASK_LOG (*task, "\n========\nFatal error while compiling solution. " "Testing aborted.\n"); goto __done_; } if (!rc) { /* Simple compilation error */ points = 0; strcpy (errors, "CE"); goto __done_; } /* * Step 2: Exec solution at all tests */ testing_main_loop (task, cur_data_dir, cur_testing_dir, &points, errors, all_params); TESTING_CHECK_ACTIVE; __done_: /* Updating avaliable parameters */ snprintf (pchar, BUF_SIZE (pchar), "%d", points); assarr_set_value (all_params, "POINTS", strdup (pchar)); assarr_set_value (all_params, "ERRORS", strdup (errors)); /* Set output parameters for WebInterface */ set_output_params (task, all_params); /* Some uinitialization */ assarr_destroy (all_params, assarr_deleter_free_ref_data); if (strcmp (errors, "OK")) { snprintf (pchar, BUF_SIZE (pchar), "Points: %d. Errors: %s", points, errors); } else { int bonus = atoi (TASK_INPUT_PARAM (*task, "BONUS")); snprintf (pchar, BUF_SIZE (pchar), "Points: %d. Bonus: %d", points - bonus, bonus); } TASK_SET_RESULT_MESSAGE (*task, pchar); if (strcmp (errors, "CE") && strcmp (errors, "CR")) { TASK_LOG (*task, "\n========\nTesting completed: %s\n", pchar); } /* Save log */ snprintf (pchar, BUF_SIZE (pchar), "%s/%s", cur_testing_dir, SOLUTION_ERRORS_LOG); stream = fopen (pchar, "w"); if (stream) { fprintf (stream, "%s", log_banner); TASK_LOG_FLUSH (*task, stream); fclose (stream); } chmod (pchar, 00660); INF_DEBUG_LOG ("Task %ld tested\n", task->sid); /* Now task is completely tested */ TASK_SET_STATUS (*task, TS_FINISHED); goto __all_done_; __free_: assarr_destroy (all_params, assarr_deleter_free_ref_data); TASK_SET_STATUS (*task, TS_INTERRUPTED); __all_done_: flock_clear (lock_file); unlink_unwanted_testing_dirs (); INF_DEBUG_LOG ("Leave testing thread\n"); }
/* @test Executes the motor handler test suite. */ void motor_handler_test_task(void *pdata) { TASK_LOG(printf("MotorHandler [task: test, status: start]\n")); while (true) { motor->test(); } }