summaryrefslogtreecommitdiff
path: root/runner
diff options
context:
space:
mode:
authorPetri Latvala <petri.latvala@intel.com>2018-08-16 14:11:46 +0300
committerPetri Latvala <petri.latvala@intel.com>2018-08-17 11:34:07 +0300
commite36199f1907d0246fb203f64592ab104f4dd1b81 (patch)
tree8f70e4f3c900e6391f1c5bacba53802f2f8ee5f1 /runner
parenta797cbf6918ae39c97632e66ae71617301131e51 (diff)
runner/resultgen: Implement the totals field
The totals field in the results json lists the total amount of particular test results, both overall and by binary. Signed-off-by: Petri Latvala <petri.latvala@intel.com> Cc: Arkadiusz Hiler <arkadiusz.hiler@intel.com> Reviewed-by: Arkadiusz Hiler <arkadiusz.hiler@intel.com>
Diffstat (limited to 'runner')
-rw-r--r--runner/resultgen.c90
1 files changed, 86 insertions, 4 deletions
diff --git a/runner/resultgen.c b/runner/resultgen.c
index d296f1c6..1c713b53 100644
--- a/runner/resultgen.c
+++ b/runner/resultgen.c
@@ -858,9 +858,89 @@ static void override_results(char *binary,
}
}
+static struct json_object *get_totals_object(struct json_object *totals,
+ const char *key)
+{
+ struct json_object *obj = NULL;
+
+ if (json_object_object_get_ex(totals, key, &obj))
+ return obj;
+
+ obj = json_object_new_object();
+ json_object_object_add(totals, key, obj);
+
+ json_object_object_add(obj, "crash", json_object_new_int(0));
+ json_object_object_add(obj, "pass", json_object_new_int(0));
+ json_object_object_add(obj, "dmesg-fail", json_object_new_int(0));
+ json_object_object_add(obj, "dmesg-warn", json_object_new_int(0));
+ json_object_object_add(obj, "skip", json_object_new_int(0));
+ json_object_object_add(obj, "incomplete", json_object_new_int(0));
+ json_object_object_add(obj, "timeout", json_object_new_int(0));
+ json_object_object_add(obj, "notrun", json_object_new_int(0));
+ json_object_object_add(obj, "fail", json_object_new_int(0));
+ json_object_object_add(obj, "warn", json_object_new_int(0));
+
+ return obj;
+}
+
+static void add_result_to_totals(struct json_object *totals,
+ const char *result)
+{
+ json_object *numobj = NULL;
+ int old;
+
+ if (!json_object_object_get_ex(totals, result, &numobj)) {
+ fprintf(stderr, "Warning: Totals object without count for %s\n", result);
+ return;
+ }
+
+ old = json_object_get_int(numobj);
+ json_object_object_add(totals, result, json_object_new_int(old + 1));
+}
+
+static void add_to_totals(char *binary,
+ struct subtests *subtests,
+ struct json_object *tests,
+ struct json_object *totals)
+{
+ struct json_object *test, *resultobj, *roottotal, *binarytotal;
+ char piglit_name[256];
+ const char *result;
+ size_t i;
+
+ generate_piglit_name(binary, NULL, piglit_name, sizeof(piglit_name));
+ roottotal = get_totals_object(totals, "");
+ binarytotal = get_totals_object(totals, piglit_name);
+
+ if (subtests->size == 0) {
+ test = get_or_create_json_object(tests, piglit_name);
+ if (!json_object_object_get_ex(test, "result", &resultobj)) {
+ fprintf(stderr, "Warning: No results set for %s\n", piglit_name);
+ return;
+ }
+ result = json_object_get_string(resultobj);
+ add_result_to_totals(roottotal, result);
+ add_result_to_totals(binarytotal, result);
+ return;
+ }
+
+ for (i = 0; i < subtests->size; i++) {
+ generate_piglit_name(binary, subtests->names[i], piglit_name, sizeof(piglit_name));
+ test = get_or_create_json_object(tests, piglit_name);
+ if (!json_object_object_get_ex(test, "result", &resultobj)) {
+ fprintf(stderr, "Warning: No results set for %s\n", piglit_name);
+ return;
+ }
+ result = json_object_get_string(resultobj);
+ add_result_to_totals(roottotal, result);
+ add_result_to_totals(binarytotal, result);
+ }
+}
+
static bool parse_test_directory(int dirfd,
struct job_list_entry *entry,
- struct json_object *tests)
+ struct json_object *tests,
+ struct json_object *totals)
{
int fds[_F_LAST];
struct subtests subtests = {};
@@ -884,6 +964,7 @@ static bool parse_test_directory(int dirfd,
}
override_results(entry->binary, &subtests, tests);
+ add_to_totals(entry->binary, &subtests, tests, totals);
close_outputs(fds);
@@ -894,7 +975,7 @@ bool generate_results(int dirfd)
{
struct settings settings;
struct job_list job_list;
- struct json_object *obj, *tests;
+ struct json_object *obj, *tests, *totals;
int resultsfd, testdirfd, unamefd;
const char *json_string;
size_t i;
@@ -950,11 +1031,12 @@ bool generate_results(int dirfd)
* - lspci
* - options
* - time_elapsed
- * - totals
*/
tests = json_object_new_object();
json_object_object_add(obj, "tests", tests);
+ totals = json_object_new_object();
+ json_object_object_add(obj, "totals", totals);
for (i = 0; i < job_list.size; i++) {
char name[16];
@@ -965,7 +1047,7 @@ bool generate_results(int dirfd)
break;
}
- if (!parse_test_directory(testdirfd, &job_list.entries[i], tests)) {
+ if (!parse_test_directory(testdirfd, &job_list.entries[i], tests, totals)) {
close(resultsfd);
return false;
}