[igt-dev] [PATCH i-g-t 2/2] runner: Add unit test for resume when enough subtests are already run
Petri Latvala
petri.latvala at intel.com
Wed Oct 3 13:08:46 UTC 2018
Signed-off-by: Petri Latvala <petri.latvala at intel.com>
Cc: Arkadiusz Hiler <arkadiusz.hiler at intel.com>
---
runner/runner_tests.c | 54 +++++++++++++++++++++++++++++++++++++++++++
1 file changed, 54 insertions(+)
diff --git a/runner/runner_tests.c b/runner/runner_tests.c
index 37d27123..b18af3a0 100644
--- a/runner/runner_tests.c
+++ b/runner/runner_tests.c
@@ -800,6 +800,60 @@ 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);
+ }
+
+ igt_subtest("execute-initialize-all-subtests-started") {
+ struct execute_state state;
+ char *argv[] = { "runner",
+ "--multiple-mode",
+ "-t", "successtest at first-subtest",
+ "-t", "successtest at second-subtest",
+ testdatadir,
+ dirname,
+ };
+ char journaltext[] = "first-subtest\nsecond-subtest\n";
+
+ igt_assert(parse_options(ARRAY_SIZE(argv), argv, &settings));
+ igt_assert(create_job_list(&list, &settings));
+ igt_assert(list.size == 1);
+ igt_assert(list.entries[0].subtest_count == 2);
+
+ igt_assert(serialize_settings(&settings));
+ igt_assert(serialize_job_list(&list, &settings));
+
+ igt_assert((dirfd = open(dirname, O_DIRECTORY | O_RDONLY)) >= 0);
+ igt_assert(mkdirat(dirfd, "0", 0770) == 0);
+ igt_assert((subdirfd = openat(dirfd, "0", O_DIRECTORY | O_RDONLY)) >= 0);
+ igt_assert((fd = openat(subdirfd, "journal.txt", O_CREAT | O_WRONLY | O_EXCL, 0660)) >= 0);
+ igt_assert(write(fd, journaltext, strlen(journaltext)) == strlen(journaltext));
+
+ free_job_list(&list);
+ free_settings(&settings);
+ igt_assert(initialize_execute_state_from_resume(dirfd, &state, &settings, &list));
+
+ /* All subtests are in journal, the entry should be considered completed */
+ igt_assert_eq(state.next, 1);
+ igt_assert_eq(list.size, 1);
+ igt_assert_eq(list.entries[0].subtest_count, 4);
+ }
+
+ igt_fixture {
+ close(fd);
+ close(subdirfd);
+ close(dirfd);
+ clear_directory(dirname);
+ free_job_list(&list);
+ }
+ }
+
igt_subtest_group {
char dirname[] = "tmpdirXXXXXX";
struct job_list list;
--
2.18.0
More information about the igt-dev
mailing list