[igt-dev] [PATCH i-g-t 3/8] lib/tests: Test that igt_describe works with dynamic subtests

Petri Latvala
2019-10-24T11:05:57Z

v2: Also test that calling igt_describe in a dynamic context asserts

Signed-off-by: Petri Latvala <petri.latvala@intel.com>
---
lib/tests/igt_describe.c | 30 +++++++++++++++++++++++++++++-
1 file changed, 29 insertions(+), 1 deletion(-)

diff --git a/lib/tests/igt_describe.c b/lib/tests/igt_describe.c
index 2ea47e9d..5e40569f 100644
--- a/lib/tests/igt_describe.c
+++ b/lib/tests/igt_describe.c
@@ -87,6 +87,14 @@ static void fake_main(int argc, char **argv) {
igt_subtest("F")
;

+ igt_describe("Subtest with dynamic subsubtests");
+ igt_subtest_with_dynamic_subsubtests("G") {
+ printf("should not be executed!\n");
+ igt_describe("should assert on execution");
+ igt_dynamic_subsubtest("should-not-list")
+ printf("should not be executed!\n");
+ }
+
igt_exit();
}

@@ -129,7 +137,10 @@ static const char DESCRIBE_ALL_OUTPUT[] = \
"\n"
"SUB F ../lib/tests/igt_describe.c:87:\n"
" verylongwordthatshoudlbeprintedeventhoughitspastthewrppinglimitverylongwordthatshoudlbeprintedeventhoughitspastthewrappinglimit\n"
- " verylongwordthatshoudlbeprintedeventhoughitspastthewrappinglimitverylongwordthatshoudlbeprintedeventhoughitspastthewrappinglimit\n\n";
+ " verylongwordthatshoudlbeprintedeventhoughitspastthewrappinglimitverylongwordthatshoudlbeprintedeventhoughitspastthewrappinglimit\n"
+ "\n"
+ "SUB G ../lib/tests/igt_describe.c:91:\n"
+ " Subtest with dynamic subsubtests\n\n";

static const char JUST_C_OUTPUT[] = \
"the top level description\n"
@@ -278,5 +289,22 @@ int main(int argc, char **argv)
close(errfd);
}

+ /* trying to igt_describe a dynamic subsubtest should assert */ {
+ static char err[4096];
+ char arg[] = "--run-subtest=G";
+ char *fake_argv[] = {prog, arg};
+ int fake_argc = ARRAY_SIZE(fake_argv);
+
+ pid_t pid = do_fork(fake_argc, fake_argv, &outfd, &errfd);
+
+ read_whole_pipe(errfd, err, sizeof(err));
+
+ internal_assert(_wait(pid, &status) != -1);
+ internal_assert_wsignaled(status, SIGABRT);
+
+ close(outfd);
+ close(errfd);
+ }
+
return 0;
}
--
2.19.1