summaryrefslogtreecommitdiff
path: root/runner
diff options
context:
space:
mode:
Diffstat (limited to 'runner')
-rw-r--r--runner/executor.c33
-rw-r--r--runner/resultgen.c27
2 files changed, 51 insertions, 9 deletions
diff --git a/runner/executor.c b/runner/executor.c
index d0539aa1..4552b02c 100644
--- a/runner/executor.c
+++ b/runner/executor.c
@@ -9,6 +9,7 @@
#include <sys/select.h>
#include <sys/signalfd.h>
#include <sys/stat.h>
+#include <sys/time.h>
#include <sys/types.h>
#include <sys/utsname.h>
#include <sys/wait.h>
@@ -860,7 +861,9 @@ static bool clear_old_results(char *path)
return false;
}
- if (unlinkat(dirfd, "uname.txt", 0) && errno != ENOENT) {
+ if (remove_file(dirfd, "uname.txt") ||
+ remove_file(dirfd, "starttime.txt") ||
+ remove_file(dirfd, "endtime.txt")) {
close(dirfd);
fprintf(stderr, "Error clearing old results: %s\n", strerror(errno));
return false;
@@ -892,6 +895,15 @@ static bool clear_old_results(char *path)
return true;
}
+static double timeofday_double()
+{
+ struct timeval tv;
+
+ if (!gettimeofday(&tv, NULL))
+ return tv.tv_sec + tv.tv_usec / 1000000.0;
+ return 0.0;
+}
+
bool initialize_execute_state_from_resume(int dirfd,
struct execute_state *state,
struct settings *settings,
@@ -973,7 +985,7 @@ bool execute(struct execute_state *state,
struct job_list *job_list)
{
struct utsname unamebuf;
- int resdirfd, testdirfd, unamefd;
+ int resdirfd, testdirfd, unamefd, timefd;
if ((resdirfd = open(settings->results_path, O_DIRECTORY | O_RDONLY)) < 0) {
/* Initialize state should have done this */
@@ -991,13 +1003,23 @@ bool execute(struct execute_state *state,
/* TODO: On resume, don't rewrite, verify that content matches current instead */
if ((unamefd = openat(resdirfd, "uname.txt", O_CREAT | O_WRONLY | O_TRUNC, 0666)) < 0) {
- fprintf(stderr, "Error: Failure creating opening uname.txt: %s\n",
+ fprintf(stderr, "Error: Failure opening uname.txt: %s\n",
strerror(errno));
close(testdirfd);
close(resdirfd);
return false;
}
+ if ((timefd = openat(resdirfd, "starttime.txt", O_CREAT | O_WRONLY | O_EXCL, 0666)) >= 0) {
+ /*
+ * Ignore failure to open. If this is a resume, we
+ * don't want to overwrite. For other errors, we
+ * ignore the start time.
+ */
+ dprintf(timefd, "%f\n", timeofday_double());
+ close(timefd);
+ }
+
init_watchdogs(settings);
if (!uname(&unamebuf)) {
@@ -1031,6 +1053,11 @@ bool execute(struct execute_state *state,
}
}
+ if ((timefd = openat(resdirfd, "endtime.txt", O_CREAT | O_WRONLY | O_EXCL, 0666)) >= 0) {
+ dprintf(timefd, "%f\n", timeofday_double());
+ close(timefd);
+ }
+
close(testdirfd);
close(resdirfd);
close_watchdogs(settings);
diff --git a/runner/resultgen.c b/runner/resultgen.c
index e8a60083..11eff9d3 100644
--- a/runner/resultgen.c
+++ b/runner/resultgen.c
@@ -987,9 +987,9 @@ bool generate_results(int dirfd)
{
struct settings settings;
struct job_list job_list;
- struct json_object *obj;
+ struct json_object *obj, *elapsed;
struct results results;
- int resultsfd, testdirfd, unamefd;
+ int resultsfd, testdirfd, fd;
const char *json_string;
size_t i;
@@ -1020,17 +1020,33 @@ bool generate_results(int dirfd)
json_object_new_string(settings.name) :
json_object_new_string(""));
- if ((unamefd = openat(dirfd, "uname.txt", O_RDONLY)) >= 0) {
+ if ((fd = openat(dirfd, "uname.txt", O_RDONLY)) >= 0) {
char buf[128];
- ssize_t r = read(unamefd, buf, 128);
+ ssize_t r = read(fd, buf, sizeof(buf));
if (r > 0 && buf[r - 1] == '\n')
r--;
json_object_object_add(obj, "uname",
json_object_new_string_len(buf, r));
- close(unamefd);
+ close(fd);
+ }
+
+ elapsed = json_object_new_object();
+ json_object_object_add(elapsed, "__type__", json_object_new_string("TimeAttribute"));
+ if ((fd = openat(dirfd, "starttime.txt", O_RDONLY)) >= 0) {
+ char buf[128] = {};
+ read(fd, buf, sizeof(buf));
+ json_object_object_add(elapsed, "start", json_object_new_double(atof(buf)));
+ close(fd);
+ }
+ if ((fd = openat(dirfd, "endtime.txt", O_RDONLY)) >= 0) {
+ char buf[128] = {};
+ read(fd, buf, sizeof(buf));
+ json_object_object_add(elapsed, "end", json_object_new_double(atof(buf)));
+ close(fd);
}
+ json_object_object_add(obj, "time_elapsed", elapsed);
create_result_root_nodes(obj, &results);
@@ -1045,7 +1061,6 @@ bool generate_results(int dirfd)
*
* - lspci
* - options
- * - time_elapsed
*/
for (i = 0; i < job_list.size; i++) {