summaryrefslogtreecommitdiff
path: root/runner/resultgen.c
diff options
context:
space:
mode:
authorPetri Latvala <petri.latvala@intel.com>2018-09-27 16:11:42 +0300
committerPetri Latvala <petri.latvala@intel.com>2018-10-03 13:26:24 +0300
commit5caab92d0b9c8516b7ea02809608fcd835af19d4 (patch)
tree5708b00ae8fa0e9a152cd139b6a3453e5b487dd5 /runner/resultgen.c
parentc5c0dd2e0b6fb2deb2b3e11212250e685177f8ac (diff)
runner: Add time_elapsed field to results
When starting a test run, drop a timestamp file. Do the same when ending a run. Slap those timestamps directly into the time_elapsed field in results.json. Using timestamps instead of measuring actual elapsed time goes against the naming of the field, but the name is chosen by piglit. Even though piglit itself uses timestamps. Corner cases: On incomplete test runs, the end timestamp will be missing. The time_elapsed field will only have the start timestamp. This matches piglit behaviour exactly. On incomplete but resumed test runs, the end timestamp will be the time when the resume finishes. Piglit doesn't do this, and instead leaves the end timestamp missing. Discussing which behaviour is better is left as an exercise to the readers. Signed-off-by: Petri Latvala <petri.latvala@intel.com> Cc: Arkadiusz Hiler <arkadiusz.hiler@intel.com> Cc: Tomi Sarvela <tomi.p.sarvela@intel.com> Reviewed-by: Arkadiusz Hiler <arkadiusz.hiler@intel.com>
Diffstat (limited to 'runner/resultgen.c')
-rw-r--r--runner/resultgen.c27
1 files changed, 21 insertions, 6 deletions
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++) {