fix a bug in logger; fix test warnings

This commit is contained in:
zemal 2017-08-17 11:04:42 +08:00
parent 1b3f8de5e5
commit be9d4d04e7
4 changed files with 7 additions and 10 deletions

View File

@ -48,8 +48,8 @@ void log_write(int level, const char *source_filename, const int line, const FIL
va_end(ap);
int count = snprintf(buffer, log_buffer_size,
"%s [%s] [%s:%d]%s\n",
LOG_LEVEL_NOTE[level], datetime, source_filename, line, log_buffer);
"%s [%s] [%s:%s]%s\n",
LOG_LEVEL_NOTE[level], datetime, source_filename, line_str, log_buffer);
fprintf(stdout, "%s", buffer);
int log_fd = fileno((FILE *) log_fp);
if (flock(log_fd, LOCK_EX) == 0) {

View File

@ -86,6 +86,9 @@ void run(struct config *_config, struct result *_result) {
kill_pid(child_pid);
ERROR_EXIT(WAIT_FAILED);
}
// get end time
gettimeofday(&end, NULL);
_result->real_time = (int) (end.tv_sec * 1000 + end.tv_usec / 1000 - start.tv_sec * 1000 - start.tv_usec / 1000);
// process exited, we may need to cancel timeout killer thread
if (_config->max_real_time != UNLIMITED) {
@ -99,10 +102,6 @@ void run(struct config *_config, struct result *_result) {
resource_usage.ru_utime.tv_usec / 1000);
_result->memory = resource_usage.ru_maxrss * 1024;
// get end time
gettimeofday(&end, NULL);
_result->real_time = (int) (end.tv_sec * 1000 + end.tv_usec / 1000 - start.tv_sec * 1000 - start.tv_usec / 1000);
if (_result->exit_code != 0) {
_result->result = RUNTIME_ERROR;
}

View File

@ -1,5 +1,5 @@
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
int main()
{

View File

@ -1,6 +1,4 @@
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
int main(int argc, char *argv[]) {
sleep(4000);