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 02/11] runner/resultgen: Extract finding begin/end lines for a subtest to a helper
Date: Mon, 2 Dec 2019 15:01:00 +0200 [thread overview]
Message-ID: <20191202130109.929-3-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 | 99 ++++++++++++++++++++++++----------------------
1 file changed, 51 insertions(+), 48 deletions(-)
diff --git a/runner/resultgen.c b/runner/resultgen.c
index 31bc0bb1..be058327 100644
--- a/runner/resultgen.c
+++ b/runner/resultgen.c
@@ -376,6 +376,54 @@ static void add_igt_version(struct json_object *testobj,
}
+static int find_subtest_idx_limited(struct matches matches,
+ const char *bufend,
+ const char *linekey,
+ const char *pattern,
+ const char *subtest_name,
+ int first,
+ int last)
+{
+ char *full_line;
+ int line_len;
+ int k;
+
+ /*
+ * The pattern is a string literal in all call-sites, and we
+ * don't want to disable this warning globally
+ */
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wformat-nonliteral"
+ line_len = asprintf(&full_line, pattern, linekey, subtest_name);
+#pragma GCC diagnostic pop
+
+ if (line_len < 0)
+ return -1;
+
+ for (k = first; k < last; k++)
+ if (matches.items[k].what == linekey &&
+ !memcmp(matches.items[k].where,
+ full_line,
+ min(line_len, bufend - matches.items[k].where)))
+ break;
+
+ free(full_line);
+
+ if (k == last)
+ k = -1;
+
+ return k;
+}
+
+static int find_subtest_idx(struct matches matches,
+ const char *bufend,
+ const char *linekey,
+ const char *pattern,
+ const char *subtest_name)
+{
+ return find_subtest_idx_limited(matches, bufend, linekey, pattern, subtest_name, 0, matches.size);
+}
+
static bool fill_from_output(int fd, const char *binary, const char *key,
struct subtest_list *subtests,
struct json_object *tests)
@@ -439,44 +487,16 @@ static bool fill_from_output(int fd, const char *binary, const char *key,
matches = find_matches(buf, bufend, needles);
for (i = 0; i < subtests->size; i++) {
- char *this_sub_begin, *this_sub_result;
int begin_idx = -1, result_idx = -1;
const char *resulttext;
const char *beg, *end;
double time;
- int begin_len;
- int result_len;
generate_piglit_name(binary, subtests->subs[i].name, piglit_name, sizeof(piglit_name));
current_test = get_or_create_json_object(tests, piglit_name);
- begin_len = asprintf(&this_sub_begin, "%s%s\n", STARTING_SUBTEST, subtests->subs[i].name);
- result_len = asprintf(&this_sub_result, "%s%s: ", SUBTEST_RESULT, subtests->subs[i].name);
-
- if (begin_len < 0 || result_len < 0) {
- fprintf(stderr, "Failure generating strings\n");
- return false;
- }
-
- for (k = 0; k < matches.size; k++) {
- if (matches.items[k].what == STARTING_SUBTEST &&
- !memcmp(matches.items[k].where,
- this_sub_begin,
- min(begin_len, bufend - matches.items[k].where))) {
- beg = matches.items[k].where;
- begin_idx = k;
- }
- if (matches.items[k].what == SUBTEST_RESULT &&
- !memcmp(matches.items[k].where,
- this_sub_result,
- min(result_len, bufend - matches.items[k].where))) {
- end = matches.items[k].where;
- result_idx = k;
- }
- }
-
- free(this_sub_begin);
- free(this_sub_result);
+ 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 */
@@ -562,31 +582,14 @@ static bool fill_from_output(int fd, const char *binary, const char *key,
int dyn_result_idx = -1;
char dynamic_name[256];
char dynamic_piglit_name[256];
- char *this_dyn_result;
- int dyn_result_len;
const char *dynbeg, *dynend;
- int n;
if (sscanf(matches.items[k].where + strlen(STARTING_DYNAMIC_SUBTEST), "%s", dynamic_name) != 1) {
/* Cannot parse name, just ignore this one */
continue;
}
- dyn_result_len = asprintf(&this_dyn_result, "%s%s: ", DYNAMIC_SUBTEST_RESULT, dynamic_name);
- if (dyn_result_len < 0)
- continue;
-
- for (n = k + 1; n < result_idx; n++) {
- if (matches.items[n].what == DYNAMIC_SUBTEST_RESULT &&
- !memcmp(matches.items[n].where,
- this_dyn_result,
- min(dyn_result_len, bufend - matches.items[n].where))) {
- dyn_result_idx = n;
- break;
- }
- }
-
- free(this_dyn_result);
+ dyn_result_idx = find_subtest_idx_limited(matches, end, DYNAMIC_SUBTEST_RESULT, "%s%s: ", dynamic_name, k, result_idx);
if (k == 0)
dynbeg = beg;
--
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 ` Petri Latvala [this message]
2019-12-03 13:33 ` [igt-dev] [PATCH i-g-t 02/11] runner/resultgen: Extract finding begin/end lines for a subtest " Arkadiusz Hiler
2019-12-11 12:46 ` Arkadiusz Hiler
2019-12-02 13:01 ` [igt-dev] [PATCH i-g-t 03/11] runner/resultgen: Extract finding begin/end pointers for test output to helpers Petri Latvala
2019-12-02 13:01 ` [igt-dev] [PATCH i-g-t 04/11] runner/resultgen: Hoist handling of dynamic subtest output to a helper 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-3-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