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 03/11] runner/resultgen: Extract finding begin/end pointers for test output to helpers
Date: Mon, 2 Dec 2019 15:01:01 +0200 [thread overview]
Message-ID: <20191202130109.929-4-petri.latvala@intel.com> (raw)
In-Reply-To: <20191202130109.929-1-petri.latvala@intel.com>
Signed-off-by: Petri Latvala <petri.latvala@intel.com>
---
runner/resultgen.c | 211 +++++++++++++++++++++++----------------------
1 file changed, 109 insertions(+), 102 deletions(-)
diff --git a/runner/resultgen.c b/runner/resultgen.c
index be058327..23bb3331 100644
--- a/runner/resultgen.c
+++ b/runner/resultgen.c
@@ -424,6 +424,71 @@ static int find_subtest_idx(struct matches matches,
return find_subtest_idx_limited(matches, bufend, linekey, pattern, subtest_name, 0, matches.size);
}
+static const char *find_subtest_begin_limit(struct matches matches,
+ int begin_idx,
+ int result_idx,
+ const char *buf,
+ const char *bufend)
+{
+ /* No matching output at all, include everything */
+ if (begin_idx < 0 && result_idx < 0)
+ return buf;
+
+ if (begin_idx < 0) {
+ /*
+ * Subtest didn't start, but we have the
+ * result. Probably because an igt_fixture
+ * made it fail/skip.
+ *
+ * We go backwards one match from the result match,
+ * and start from the next line.
+ */
+ if (result_idx > 0)
+ return next_line(matches.items[result_idx - 1].where, bufend);
+ else
+ return buf;
+ }
+
+ /* Include all non-special output before the beginning line. */
+ if (begin_idx == 0)
+ return buf;
+
+ return next_line(matches.items[begin_idx - 1].where, bufend);
+}
+
+static const char *find_subtest_end_limit(struct matches matches,
+ int begin_idx,
+ int result_idx,
+ const char *buf,
+ const char *bufend)
+{
+ int k;
+
+ /* No matching output at all, include everything */
+ if (begin_idx < 0 && result_idx < 0)
+ return bufend;
+
+ if (result_idx < 0) {
+ /*
+ * Incomplete result. Include all output up to the
+ * next starting subtest, or the result of one.
+ */
+ for (k = begin_idx + 1; k < matches.size; k++) {
+ if (matches.items[k].what == STARTING_SUBTEST ||
+ matches.items[k].what == SUBTEST_RESULT)
+ return matches.items[k].where;
+ }
+
+ return bufend;
+ }
+
+ /* Include all non-special output to the next match, whatever it is. */
+ if (result_idx < matches.size - 1)
+ return matches.items[result_idx + 1].where;
+
+ return bufend;
+}
+
static bool fill_from_output(int fd, const char *binary, const char *key,
struct subtest_list *subtests,
struct json_object *tests)
@@ -498,54 +563,8 @@ static bool fill_from_output(int fd, const char *binary, const char *key,
begin_idx = find_subtest_idx(matches, bufend, STARTING_SUBTEST, "%s%s\n", subtests->subs[i].name);
result_idx = find_subtest_idx(matches, bufend, SUBTEST_RESULT, "%s%s: ", subtests->subs[i].name);
- if (begin_idx < 0 && result_idx < 0) {
- /* No output at all */
- beg = buf;
- end = bufend;
- } else if (begin_idx < 0) {
- /*
- * Subtest didn't start, but we have the
- * result. Probably because an igt_fixture
- * made it fail/skip.
- *
- * Start the output right after the previous
- * subtest result/start.
- */
- if (result_idx > 0)
- beg = next_line(matches.items[result_idx - 1].where, bufend);
- else
- beg = buf;
- } else {
- /* Stretch output beginning backwards */
- if (begin_idx == 0)
- beg = buf;
- else
- beg = next_line(matches.items[begin_idx - 1].where, bufend);
- }
-
- if (result_idx < 0 && begin_idx < 0) {
- /* No output at all: Already handled above */
- } else if (result_idx < 0) {
- /*
- * Incomplete result. Include output up to the
- * next starting subtest or result.
- */
- for (k = begin_idx + 1; k < matches.size; k++) {
- if (matches.items[k].what == STARTING_SUBTEST ||
- matches.items[k].what == SUBTEST_RESULT)
- break;
- }
- if (k < matches.size)
- end = matches.items[k].where;
- else
- end = bufend;
- } else {
- /* Stretch output to the next starting subtest or result. */
- if (result_idx < matches.size - 1)
- end = matches.items[result_idx + 1].where;
- else
- end = bufend;
- }
+ beg = find_subtest_begin_limit(matches, begin_idx, result_idx, buf, bufend);
+ end = find_subtest_end_limit(matches, begin_idx, result_idx, buf, bufend);
json_object_object_add(current_test, key,
json_object_new_string_len(beg, end - beg));
@@ -567,68 +586,56 @@ static bool fill_from_output(int fd, const char *binary, const char *key,
* the subtest output.
*/
if (result_idx < 0) {
- /* If the subtest itself is incomplete, stop at the next start of a subtest */
+ /* 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)
+ 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++) {
- if (matches.items[k].what == STARTING_DYNAMIC_SUBTEST) {
- 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 (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, "%s%s: ", dynamic_name, k, result_idx);
-
- if (k == 0)
- dynbeg = beg;
- else
- dynbeg = next_line(matches.items[k - 1].where, end);
-
- if (dyn_result_idx < 0) {
- if (k < matches.size - 1)
- dynend = matches.items[k + 1].where;
- else
- dynend = end;
- } else {
- if (dyn_result_idx < matches.size - 1)
- dynend = matches.items[dyn_result_idx + 1].where;
- else
- dynend = 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);
- }
+ 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, "%s%s: ", 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);
}
}
}
--
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-02 13:01 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-12-02 13:00 [igt-dev] [PATCH i-g-t 00/11] runner: Don't report subtests that have dynamic subtests Petri Latvala
2019-12-02 13:00 ` [igt-dev] [PATCH i-g-t 01/11] runner/resultgen: Extract igt-version field handling to a helper Petri Latvala
2019-12-02 13:01 ` [igt-dev] [PATCH i-g-t 02/11] runner/resultgen: Extract finding begin/end lines for a subtest " Petri Latvala
2019-12-03 13:33 ` Arkadiusz Hiler
2019-12-11 12:46 ` Arkadiusz Hiler
2019-12-02 13:01 ` Petri Latvala [this message]
2019-12-02 13:01 ` [igt-dev] [PATCH i-g-t 04/11] runner/resultgen: Hoist handling of dynamic subtest output " Petri Latvala
2019-12-02 13:01 ` [igt-dev] [PATCH i-g-t 05/11] runner/resultgen: Extrude dynamic subtest result texts Petri Latvala
2019-12-02 13:01 ` [igt-dev] [PATCH i-g-t 06/11] runner/resultgen: Add support for extra validation hook in find_matches() Petri Latvala
2019-12-02 13:01 ` [igt-dev] [PATCH i-g-t 07/11] runner/resultgen: Make subtest result line finding more robust Petri Latvala
2019-12-02 13:01 ` [igt-dev] [PATCH i-g-t 08/11] runner/json_tests: Adapt to dynamic subtest result parsing Petri Latvala
2019-12-02 13:01 ` [igt-dev] [PATCH i-g-t 09/11] runner/resultgen: Don't report subtest result if it has dynamic subtests Petri Latvala
2019-12-02 13:01 ` [igt-dev] [PATCH i-g-t 10/11] runner/json_tests: Adapt to no longer reporting subtests with " Petri Latvala
2019-12-02 13:01 ` [igt-dev] [PATCH i-g-t 11/11] runner/json_tests: Add test for parsing dynamic subtests with same name Petri Latvala
2019-12-02 13:47 ` [igt-dev] ✓ Fi.CI.BAT: success for runner: Don't report subtests that have dynamic subtests Patchwork
2019-12-02 15:07 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork
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=20191202130109.929-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