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 2/4] runner_tests: Replace magic numbers with named constants
Date: Tue, 14 Jan 2020 11:17:43 +0200 [thread overview]
Message-ID: <20200114091745.4555-2-petri.latvala@intel.com> (raw)
In-Reply-To: <20200114091745.4555-1-petri.latvala@intel.com>
We have some handcrafted test binaries in runner/testdata/ for runner
testing, and hardcoded numbers for the total amount of subtests and
test binaries all over the runner's unit tests. Replace magic numbers
with clear defines so new tests can easily be added.
Signed-off-by: Petri Latvala <petri.latvala@intel.com>
Cc: Arkadiusz Hiler <arkadiusz.hiler@intel.com>
---
runner/runner_tests.c | 29 +++++++++++++++++++----------
1 file changed, 19 insertions(+), 10 deletions(-)
diff --git a/runner/runner_tests.c b/runner/runner_tests.c
index 39d4a078..9bbc4252 100644
--- a/runner/runner_tests.c
+++ b/runner/runner_tests.c
@@ -20,6 +20,15 @@
static const char testdatadir[] = TESTDATA_DIRECTORY;
+/*
+ * The total sum of subtests in the tests in runner/testdata/. Note
+ * that test binaries without subtests should still be counted as one
+ * for this macro.
+ */
+#define NUM_TESTDATA_SUBTESTS 5
+/* The total number of test binaries in runner/testdata/ */
+#define NUM_TESTDATA_BINARIES 3
+
static void igt_assert_eqstr(const char *one, const char *two)
{
if (one == NULL && two == NULL)
@@ -650,11 +659,11 @@ igt_main
}
}
- job_list_filter_test("nofilters", "-n", "placeholderargs", 5, 3);
+ job_list_filter_test("nofilters", "-n", "placeholderargs", NUM_TESTDATA_SUBTESTS, NUM_TESTDATA_BINARIES);
job_list_filter_test("binary-include", "-t", "successtest", 2, 1);
- job_list_filter_test("binary-exclude", "-x", "successtest", 3, 2);
+ job_list_filter_test("binary-exclude", "-x", "successtest", NUM_TESTDATA_SUBTESTS - 2, NUM_TESTDATA_BINARIES - 1);
job_list_filter_test("subtest-include", "-t", "first-subtest", 1, 1);
- job_list_filter_test("subtest-exclude", "-x", "second-subtest", 4, 3);
+ job_list_filter_test("subtest-exclude", "-x", "second-subtest", NUM_TESTDATA_SUBTESTS - 1, NUM_TESTDATA_BINARIES);
job_list_filter_test("piglit-names", "-t", "igt@successtest", 2, 1);
job_list_filter_test("piglit-names-subtest", "-t", "igt@successtest@first", 1, 1);
@@ -869,7 +878,7 @@ igt_main
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_eq(list->size, NUM_TESTDATA_SUBTESTS);
igt_assert_f((dirfd = open(dirname, O_DIRECTORY | O_RDONLY)) >= 0,
"Dry run initialization didn't create the results directory.\n");
@@ -890,7 +899,7 @@ igt_main
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);
+ igt_assert_eq(list->size, NUM_TESTDATA_SUBTESTS);
/* 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");
@@ -940,7 +949,7 @@ igt_main
igt_assert(initialize_execute_state(&state, settings, list));
igt_assert_eq(state.next, 0);
- igt_assert_eq(list->size, 5);
+ igt_assert_eq(list->size, NUM_TESTDATA_SUBTESTS);
igt_assert_f((dirfd = open(dirname, O_DIRECTORY | O_RDONLY)) >= 0,
"Execute state initialization didn't create the results directory.\n");
igt_assert_f((fd = openat(dirfd, "metadata.txt", O_RDONLY)) >= 0,
@@ -1096,7 +1105,7 @@ igt_main
igt_assert(parse_options(ARRAY_SIZE(argv), (char**)argv, settings));
igt_assert(create_job_list(list, settings));
- igt_assert(list->size == 3);
+ igt_assert(list->size == NUM_TESTDATA_BINARIES);
if (!strcmp(list->entries[0].binary, "no-subtests")) {
struct job_list_entry tmp = list->entries[0];
@@ -1120,7 +1129,7 @@ igt_main
igt_assert(initialize_execute_state_from_resume(dirfd, &state, settings, list));
igt_assert_eq(state.next, 1);
- igt_assert_eq(list->size, 3);
+ igt_assert_eq(list->size, NUM_TESTDATA_BINARIES);
}
igt_fixture {
@@ -1154,12 +1163,12 @@ igt_main
struct execute_state state;
const char *argv[] = { "runner",
multiple ? "--multiple-mode" : "--sync",
- "-t", "-subtest",
+ "-t", "successtest.*-subtest",
testdatadir,
dirname,
};
char testdirname[16];
- size_t expected_tests = multiple ? 2 : 3;
+ size_t expected_tests = multiple ? 1 : 2;
size_t i;
igt_assert(parse_options(ARRAY_SIZE(argv), (char**)argv, settings));
--
2.20.1
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev
next prev parent reply other threads:[~2020-01-14 9:17 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-01-14 9:17 [igt-dev] [PATCH i-g-t 1/4] lib: Don't dump log buffer when dynamic subtest failure is inherited Petri Latvala
2020-01-14 9:17 ` Petri Latvala [this message]
2020-01-14 9:17 ` [igt-dev] [PATCH i-g-t 3/4] runner_tests: Add new mockup test binary Petri Latvala
2020-01-14 9:17 ` [igt-dev] [PATCH i-g-t 4/4] runner_tests: Test that dynamic subtest failure is handled correctly Petri Latvala
2020-01-15 13:09 ` Arkadiusz Hiler
2020-01-16 11:47 ` Petri Latvala
2020-01-14 9:38 ` [igt-dev] ✗ GitLab.Pipeline: warning for series starting with [i-g-t,1/4] lib: Don't dump log buffer when dynamic subtest failure is inherited Patchwork
2020-01-14 10:12 ` [igt-dev] ✓ Fi.CI.BAT: success " Patchwork
2020-01-16 10:36 ` [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=20200114091745.4555-2-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