From: Petri Latvala <petri.latvala@intel.com>
To: igt-dev@lists.freedesktop.org
Cc: Tomi Sarvela <tomi.p.sarvela@intel.com>,
Petri Latvala <petri.latvala@intel.com>,
Martin Peres <martin.peres@linux.intel.com>
Subject: [igt-dev] [PATCH i-g-t] runner: Implement --dry-run
Date: Tue, 22 Jan 2019 12:47:23 +0200 [thread overview]
Message-ID: <20190122104723.24625-1-petri.latvala@intel.com> (raw)
Actually implement --dry-run to not execute tests. With dry-run
active, attempting to execute will figure out the list of things to
execute, serialize them along with settings, and stop. This will be
useful for CI that wants to post-mortem on failed test rounds to
generate a list of tests that should have been executed and produce
json result files (full of 'notrun') for proper statistics.
Signed-off-by: Petri Latvala <petri.latvala@intel.com>
Cc: Andi Shyti <andi.shyti@intel.com>
Cc: Martin Peres <martin.peres@linux.intel.com>
Cc: Arkadiusz Hiler <arkadiusz.hiler@intel.com>
Cc: Tomi Sarvela <tomi.p.sarvela@intel.com>
---
runner/executor.c | 7 +++++
runner/executor.h | 1 +
runner/runner_tests.c | 70 +++++++++++++++++++++++++++++++++++++++++++
3 files changed, 78 insertions(+)
diff --git a/runner/executor.c b/runner/executor.c
index 54c530b7..3f1eb010 100644
--- a/runner/executor.c
+++ b/runner/executor.c
@@ -1153,6 +1153,8 @@ bool initialize_execute_state(struct execute_state *state,
init_time_left(state, settings);
+ state->dry = settings->dry_run;
+
return true;
}
@@ -1204,6 +1206,11 @@ bool execute(struct execute_state *state,
double time_spent = 0.0;
bool status = true;
+ if (state->dry) {
+ printf("Dry run, not executing. Invoke igt_resume if you want to execute.\n");
+ return false;
+ }
+
if ((resdirfd = open(settings->results_path, O_DIRECTORY | O_RDONLY)) < 0) {
/* Initialize state should have done this */
fprintf(stderr, "Error: Failure opening results path %s\n",
diff --git a/runner/executor.h b/runner/executor.h
index 12883f15..6c83e649 100644
--- a/runner/executor.h
+++ b/runner/executor.h
@@ -14,6 +14,7 @@ struct execute_state
*/
double time_left;
double resuming;
+ bool dry;
};
enum {
diff --git a/runner/runner_tests.c b/runner/runner_tests.c
index 6213b8e7..0965612a 100644
--- a/runner/runner_tests.c
+++ b/runner/runner_tests.c
@@ -742,6 +742,76 @@ igt_main
}
}
+ igt_subtest_group {
+ char dirname[] = "tmpdirXXXXXX";
+ struct job_list list;
+ int dirfd = -1, subdirfd = -1, fd = -1;
+
+ igt_fixture {
+ init_job_list(&list);
+ igt_require(mkdtemp(dirname) != NULL);
+ rmdir(dirname);
+ }
+
+ igt_subtest("dry-run-option") {
+ struct execute_state state;
+ const char *argv[] = { "runner",
+ "--dry-run",
+ testdatadir,
+ dirname,
+ };
+
+ igt_assert(parse_options(ARRAY_SIZE(argv), (char**)argv, &settings));
+ igt_assert(create_job_list(&list, &settings));
+
+ igt_assert(initialize_execute_state(&state, &settings, &list));
+ igt_assert_eq(state.next, 0);
+ igt_assert(state.dry);
+ igt_assert_eq(list.size, 5);
+
+ igt_assert_f((dirfd = open(dirname, O_DIRECTORY | O_RDONLY)) >= 0,
+ "Dry run initialization didn't create the results directory.\n");
+
+ /* Execute from just initialize_execute_state should fail */
+ igt_assert(!execute(&state, &settings, &list));
+ igt_assert(openat(dirfd, "0", O_DIRECTORY | O_RDONLY) < 0);
+ igt_assert_f((fd = openat(dirfd, "metadata.txt", O_RDONLY)) >= 0,
+ "Dry run initialization didn't serialize settings.\n");
+ close(fd);
+ igt_assert_f((fd = openat(dirfd, "joblist.txt", O_RDONLY)) >= 0,
+ "Dry run initialization didn't serialize the job list.\n");
+ close(fd);
+ igt_assert_f((fd = openat(dirfd, "uname.txt", O_RDONLY)) < 0,
+ "Dry run initialization created uname.txt.\n");
+
+ igt_assert(initialize_execute_state_from_resume(dirfd, &state, &settings, &list));
+ igt_assert_eq(state.next, 0);
+ igt_assert(!state.dry);
+ igt_assert_eq(list.size, 5);
+ /* initialize_execute_state_from_resume() closes the dirfd */
+ igt_assert_f((dirfd = open(dirname, O_DIRECTORY | O_RDONLY)) >= 0,
+ "Dry run resume somehow deleted the results directory.\n");
+
+ /* Execute from resume should work */
+ igt_assert(execute(&state, &settings, &list));
+ igt_assert_f((fd = openat(dirfd, "uname.txt", O_RDONLY)) >= 0,
+ "Dry run resume didn't create uname.txt.\n");
+ close(fd);
+ igt_assert_f((subdirfd = openat(dirfd, "0", O_DIRECTORY | O_RDONLY)) >= 0,
+ "Dry run resume didn't create result directory.\n");
+ igt_assert_f((fd = openat(subdirfd, "journal.txt", O_RDONLY)) >= 0,
+ "Dry run resume didn't create a journal.\n");
+ }
+
+ igt_fixture {
+ close(fd);
+ close(dirfd);
+ close(subdirfd);
+ clear_directory(dirname);
+ free_job_list(&list);
+ }
+ }
+
igt_subtest_group {
char dirname[] = "tmpdirXXXXXX";
struct job_list list;
--
2.19.1
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev
next reply other threads:[~2019-01-22 10:47 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-22 10:47 Petri Latvala [this message]
2019-01-22 11:08 ` [igt-dev] ✓ Fi.CI.BAT: success for runner: Implement --dry-run Patchwork
2019-01-22 11:57 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork
2019-01-22 12:14 ` [igt-dev] [PATCH i-g-t] " Martin Peres
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=20190122104723.24625-1-petri.latvala@intel.com \
--to=petri.latvala@intel.com \
--cc=igt-dev@lists.freedesktop.org \
--cc=martin.peres@linux.intel.com \
--cc=tomi.p.sarvela@intel.com \
/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