Переглянути джерело

tests/loader.c: print execution time

Nathalie Furmento 12 роки тому
батько
коміт
6ef1bdb9c1
1 змінених файлів з 14 додано та 4 видалено
  1. 14 4
      tests/loader.c

+ 14 - 4
tests/loader.c

@@ -148,6 +148,10 @@ int main(int argc, char *argv[])
 	char *launcher_args;
 	char *top_srcdir;
 	struct sigaction sa;
+	int   ret;
+	struct timeval start;
+	struct timeval end;
+	double timing;
 
 	test_args = NULL;
 	timeout = 0;
@@ -254,6 +258,8 @@ int main(int argc, char *argv[])
 		exit(EXIT_FAILURE);
 	}
 
+	ret = EXIT_SUCCESS;
+	gettimeofday(&start, NULL);
 	alarm(timeout);
 	if (child_pid == waitpid(child_pid, &child_exit_status, 0))
 	{
@@ -269,7 +275,7 @@ int main(int argc, char *argv[])
 				if (status != AUTOTEST_SKIPPED_TEST)
 					fprintf(stdout, "`%s' exited with return code %d\n",
 						test_name, status);
-				return status;
+				ret = status;
 			}
 		}
 		else if (WIFSIGNALED(child_exit_status))
@@ -277,15 +283,19 @@ int main(int argc, char *argv[])
 			fprintf(stderr, "[error] `%s' killed with signal %d; test marked as failed\n",
 				test_name, WTERMSIG(child_exit_status));
 			launch_gdb(test_name);
-			return EXIT_FAILURE;
+			ret = EXIT_FAILURE;
 		}
 		else
 		{
 			fprintf(stderr, "[error] `%s' did not terminate normally; test marked as failed\n",
 				test_name);
-			return EXIT_FAILURE;
+			ret = EXIT_FAILURE;
 		}
 	}
 
-	return EXIT_SUCCESS;
+	gettimeofday(&end, NULL);
+	timing = (double)((end.tv_sec - start.tv_sec)*1000000 + (end.tv_usec - start.tv_usec));
+	fprintf(stderr, "Execution of test '%s' took %f s\n", test_name, timing/1000000);
+
+	return ret;
 }