From: Petri Latvala <petri.latvala@intel.com>
To: igt-dev@lists.freedesktop.org
Cc: Petri Latvala <petri.latvala@intel.com>
Subject: [igt-dev] [PATCH i-g-t v2 04/11] runner/resultgen: Hoist handling of dynamic subtest output to a helper
Date: Tue, 17 Dec 2019 11:47:53 +0200 [thread overview]
Message-ID: <20191217094800.30687-4-petri.latvala@intel.com> (raw)
In-Reply-To: <20191217094800.30687-1-petri.latvala@intel.com>
v2: Rebase
Signed-off-by: Petri Latvala <petri.latvala@intel.com>
Reviewed-by: Arkadiusz Hiler <arkadiusz.hiler@intel.com>
---
runner/resultgen.c | 136 ++++++++++++++++++++++++++-------------------
1 file changed, 78 insertions(+), 58 deletions(-)
diff --git a/runner/resultgen.c b/runner/resultgen.c
index f91c6884..4a5d329c 100644
--- a/runner/resultgen.c
+++ b/runner/resultgen.c
@@ -496,6 +496,75 @@ static const char *find_subtest_end_limit(struct matches matches,
return bufend;
}
+static void process_dynamic_subtest_output(const char *piglit_name,
+ const char *igt_version,
+ size_t igt_version_len,
+ struct matches matches,
+ int begin_idx,
+ int result_idx,
+ const char *beg,
+ const char *end,
+ const char *key,
+ struct json_object *tests,
+ struct subtest *subtest)
+{
+ size_t k;
+
+ if (result_idx < 0) {
+ /* If the subtest itself is incomplete, stop at the next start/end of a subtest */
+ for (result_idx = begin_idx + 1;
+ result_idx < matches.size;
+ result_idx++) {
+ if (matches.items[result_idx].what == STARTING_SUBTEST ||
+ matches.items[result_idx].what == SUBTEST_RESULT)
+ break;
+ }
+ }
+
+ for (k = begin_idx + 1; k < result_idx; k++) {
+ struct json_object *current_dynamic_test = NULL;
+ int dyn_result_idx = -1;
+ char dynamic_name[256];
+ char dynamic_piglit_name[256];
+ const char *dynbeg, *dynend;
+
+ if (matches.items[k].what != STARTING_DYNAMIC_SUBTEST)
+ continue;
+
+ if (sscanf(matches.items[k].where + strlen(STARTING_DYNAMIC_SUBTEST), "%s", dynamic_name) != 1) {
+ /* Cannot parse name, just ignore this one */
+ continue;
+ }
+
+ dyn_result_idx = find_subtest_idx_limited(matches, end, DYNAMIC_SUBTEST_RESULT, PATTERN_RESULT, dynamic_name, k, result_idx);
+
+ dynbeg = find_subtest_begin_limit(matches, k, dyn_result_idx, beg, end);
+ dynend = find_subtest_end_limit(matches, k, dyn_result_idx, beg, end);
+
+ generate_piglit_name_for_dynamic(piglit_name, dynamic_name, dynamic_piglit_name, sizeof(dynamic_piglit_name));
+
+ add_dynamic_subtest(subtest, strdup(dynamic_name));
+ current_dynamic_test = get_or_create_json_object(tests, dynamic_piglit_name);
+
+ json_object_object_add(current_dynamic_test, key,
+ json_object_new_string_len(dynbeg, dynend - dynbeg));
+ add_igt_version(current_dynamic_test, igt_version, igt_version_len);
+
+ if (!json_object_object_get_ex(current_dynamic_test, "result", NULL)) {
+ const char *dynresulttext;
+ double dyntime;
+
+ parse_subtest_result(dynamic_name,
+ DYNAMIC_SUBTEST_RESULT,
+ &dynresulttext, &dyntime,
+ dyn_result_idx < 0 ? NULL : matches.items[dyn_result_idx].where,
+ dynend);
+ set_result(current_dynamic_test, dynresulttext);
+ set_runtime(current_dynamic_test, dyntime);
+ }
+ }
+}
+
static bool fill_from_output(int fd, const char *binary, const char *key,
struct subtest_list *subtests,
struct json_object *tests)
@@ -514,7 +583,7 @@ static bool fill_from_output(int fd, const char *binary, const char *key,
NULL
};
struct matches matches = {};
- size_t i, k;
+ size_t i;
if (fstat(fd, &statbuf))
return false;
@@ -588,63 +657,14 @@ static bool fill_from_output(int fd, const char *binary, const char *key,
set_runtime(current_test, time);
}
- /*
- * Look for dynamic subtests: If any, they are within
- * the subtest output.
- */
- if (result_idx < 0) {
- /* If the subtest itself is incomplete, stop at the next start/end of a subtest */
- for (result_idx = begin_idx + 1;
- result_idx < matches.size;
- result_idx++) {
- if (matches.items[result_idx].what == STARTING_SUBTEST ||
- matches.items[result_idx].what == SUBTEST_RESULT)
- break;
- }
- }
-
- for (k = begin_idx + 1; k < result_idx; k++) {
- struct json_object *current_dynamic_test = NULL;
- int dyn_result_idx = -1;
- char dynamic_name[256];
- char dynamic_piglit_name[256];
- const char *dynbeg, *dynend;
-
- if (matches.items[k].what != STARTING_DYNAMIC_SUBTEST)
- continue;
-
- if (sscanf(matches.items[k].where + strlen(STARTING_DYNAMIC_SUBTEST), "%s", dynamic_name) != 1) {
- /* Cannot parse name, just ignore this one */
- continue;
- }
-
- dyn_result_idx = find_subtest_idx_limited(matches, end, DYNAMIC_SUBTEST_RESULT, PATTERN_RESULT, dynamic_name, k, result_idx);
-
- dynbeg = find_subtest_begin_limit(matches, k, dyn_result_idx, beg, end);
- dynend = find_subtest_end_limit(matches, k, dyn_result_idx, beg, end);
-
- generate_piglit_name_for_dynamic(piglit_name, dynamic_name, dynamic_piglit_name, sizeof(dynamic_piglit_name));
-
- add_dynamic_subtest(&subtests->subs[i], strdup(dynamic_name));
- current_dynamic_test = get_or_create_json_object(tests, dynamic_piglit_name);
-
- json_object_object_add(current_dynamic_test, key,
- json_object_new_string_len(dynbeg, dynend - dynbeg));
- add_igt_version(current_dynamic_test, igt_version, igt_version_len);
-
- if (!json_object_object_get_ex(current_dynamic_test, "result", NULL)) {
- const char *dynresulttext;
- double dyntime;
-
- parse_subtest_result(dynamic_name,
- DYNAMIC_SUBTEST_RESULT,
- &dynresulttext, &dyntime,
- dyn_result_idx < 0 ? NULL : matches.items[dyn_result_idx].where,
- dynend);
- set_result(current_dynamic_test, dynresulttext);
- set_runtime(current_dynamic_test, dyntime);
- }
- }
+ process_dynamic_subtest_output(piglit_name,
+ igt_version, igt_version_len,
+ matches,
+ begin_idx, result_idx,
+ beg, end,
+ key,
+ tests,
+ &subtests->subs[i]);
}
free_matches(&matches);
--
2.19.1
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev
next prev parent reply other threads:[~2019-12-17 9:48 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-12-17 9:47 [igt-dev] [PATCH i-g-t 01/11] runner/resultgen: Extract igt-version field handling to a helper Petri Latvala
2019-12-17 9:47 ` [igt-dev] [PATCH i-g-t v2 02/11] runner/resultgen: Extract finding begin/end lines for a subtest " Petri Latvala
2019-12-27 8:45 ` Arkadiusz Hiler
2019-12-17 9:47 ` [igt-dev] [PATCH i-g-t v2 03/11] runner/resultgen: Extract finding begin/end pointers for test output to helpers Petri Latvala
2019-12-17 9:47 ` Petri Latvala [this message]
2019-12-17 9:47 ` [igt-dev] [PATCH i-g-t v2 05/11] runner/resultgen: Extrude dynamic subtest result texts Petri Latvala
2019-12-17 9:47 ` [igt-dev] [PATCH i-g-t 06/11] runner/resultgen: Add support for extra validation hook in find_matches() Petri Latvala
2019-12-17 9:47 ` [igt-dev] [PATCH i-g-t 07/11] runner/resultgen: Make subtest result line finding more robust Petri Latvala
2019-12-17 9:47 ` [igt-dev] [PATCH i-g-t 08/11] runner/json_tests: Adapt to dynamic subtest result parsing Petri Latvala
2019-12-17 9:47 ` [igt-dev] [PATCH i-g-t 09/11] runner/resultgen: Don't report subtest result if it has dynamic subtests Petri Latvala
2019-12-17 9:47 ` [igt-dev] [PATCH i-g-t 10/11] runner/json_tests: Adapt to no longer reporting subtests with " Petri Latvala
2019-12-17 9:48 ` [igt-dev] [PATCH i-g-t 11/11] runner/json_tests: Add test for parsing dynamic subtests with same name Petri Latvala
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20191217094800.30687-4-petri.latvala@intel.com \
--to=petri.latvala@intel.com \
--cc=igt-dev@lists.freedesktop.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox