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 1/2] runner/resultgen: Split json generation and file writing
Date: Tue, 23 Oct 2018 15:20:23 +0300 [thread overview]
Message-ID: <20181023122024.19347-1-petri.latvala@intel.com> (raw)
This allows testing to skip the file writing.
Signed-off-by: Petri Latvala <petri.latvala@intel.com>
Cc: Arkadiusz Hiler <arkadiusz.hiler@intel.com>
---
runner/resultgen.c | 36 +++++++++++++++++++++++-------------
runner/resultgen.h | 2 ++
2 files changed, 25 insertions(+), 13 deletions(-)
diff --git a/runner/resultgen.c b/runner/resultgen.c
index e059c65b..a62e400e 100644
--- a/runner/resultgen.c
+++ b/runner/resultgen.c
@@ -988,14 +988,13 @@ static void create_result_root_nodes(struct json_object *root,
json_object_object_add(root, "runtimes", results->runtimes);
}
-bool generate_results(int dirfd)
+struct json_object *generate_results_json(int dirfd)
{
struct settings settings;
struct job_list job_list;
struct json_object *obj, *elapsed;
struct results results;
- int resultsfd, testdirfd, fd;
- const char *json_string;
+ int testdirfd, fd;
size_t i;
init_settings(&settings);
@@ -1003,18 +1002,12 @@ bool generate_results(int dirfd)
if (!read_settings(&settings, dirfd)) {
fprintf(stderr, "resultgen: Cannot parse settings\n");
- return false;
+ return NULL;
}
if (!read_job_list(&job_list, dirfd)) {
fprintf(stderr, "resultgen: Cannot parse job list\n");
- return false;
- }
-
- /* TODO: settings.overwrite */
- if ((resultsfd = openat(dirfd, "results.json", O_WRONLY | O_CREAT | O_TRUNC, 0666)) < 0) {
- fprintf(stderr, "resultgen: Cannot create results file\n");
- return false;
+ return NULL;
}
obj = json_object_new_object();
@@ -1079,12 +1072,29 @@ bool generate_results(int dirfd)
if (!parse_test_directory(testdirfd, &job_list.entries[i], &settings, &results)) {
close(testdirfd);
- close(resultsfd);
- return false;
+ return NULL;
}
close(testdirfd);
}
+ return obj;
+}
+
+bool generate_results(int dirfd)
+{
+ struct json_object *obj = generate_results_json(dirfd);
+ const char *json_string;
+ int resultsfd;
+
+ if (obj == NULL)
+ return false;
+
+ /* TODO: settings.overwrite */
+ if ((resultsfd = openat(dirfd, "results.json", O_WRONLY | O_CREAT | O_TRUNC, 0666)) < 0) {
+ fprintf(stderr, "resultgen: Cannot create results file\n");
+ return false;
+ }
+
json_string = json_object_to_json_string_ext(obj, JSON_C_TO_STRING_PRETTY);
write(resultsfd, json_string, strlen(json_string));
close(resultsfd);
diff --git a/runner/resultgen.h b/runner/resultgen.h
index 83a0876b..ab0bf108 100644
--- a/runner/resultgen.h
+++ b/runner/resultgen.h
@@ -6,4 +6,6 @@
bool generate_results(int dirfd);
bool generate_results_path(char *resultspath);
+struct json_object *generate_results_json(int dirfd);
+
#endif
--
2.18.0
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev
next reply other threads:[~2018-10-23 12:20 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-23 12:20 Petri Latvala [this message]
2018-10-23 12:20 ` [igt-dev] [PATCH i-g-t 2/2] runner: Unit tests for json generation Petri Latvala
2018-10-23 13:29 ` [igt-dev] ✗ Fi.CI.BAT: failure for series starting with [i-g-t,1/2] runner/resultgen: Split json generation and file writing Patchwork
2018-10-23 15:08 ` Patchwork
2018-10-23 22:07 ` [igt-dev] ✓ Fi.CI.BAT: success " Patchwork
2018-10-24 1:42 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork
2018-11-05 15:14 ` [igt-dev] [PATCH i-g-t 1/2] " Arkadiusz Hiler
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=20181023122024.19347-1-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