public inbox for igt-dev@lists.freedesktop.org
 help / color / mirror / Atom feed
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 4/4] runner_tests: Test that dynamic subtest failure is handled correctly
Date: Tue, 14 Jan 2020 11:17:45 +0200	[thread overview]
Message-ID: <20200114091745.4555-4-petri.latvala@intel.com> (raw)
In-Reply-To: <20200114091745.4555-1-petri.latvala@intel.com>

See also: commit 0e6457f1bfe2 ("lib: Don't dump log buffer when
dynamic subtest failure is inherited")

This is quite an explicit top-to-bottom test that we don't get an
incorrect warn result for an innocent dynamic subtest. It is tested
here in runner_test instead of testing in lib/tests that the extra
lines are not printed, because not printing the extra lines is an
implementation detail that might change later. The issue is after all
about test results parsed by igt_runner.

Signed-off-by: Petri Latvala <petri.latvala@intel.com>
Cc: Arkadiusz Hiler <arkadiusz.hiler@intel.com>
---
 runner/meson.build    |  2 +-
 runner/runner_tests.c | 51 +++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 52 insertions(+), 1 deletion(-)

diff --git a/runner/meson.build b/runner/meson.build
index 404b8e04..7c2e8e0d 100644
--- a/runner/meson.build
+++ b/runner/meson.build
@@ -59,7 +59,7 @@ if jsonc.found()
 				 c_args : '-DTESTDATA_DIRECTORY="@0@"'.format(testdata_dir),
 				 link_with : runnerlib,
 				 install : false,
-				 dependencies : igt_deps)
+				 dependencies : [igt_deps, jsonc])
 	test('runner', runner_test, timeout : 300)
 
 	runner_json_test = executable('runner_json_test', runner_json_test_sources,
diff --git a/runner/runner_tests.c b/runner/runner_tests.c
index a232aa2b..6b0e6cc4 100644
--- a/runner/runner_tests.c
+++ b/runner/runner_tests.c
@@ -4,11 +4,14 @@
 #include <sys/types.h>
 #include <unistd.h>
 
+#include <json.h>
+
 #include "igt.h"
 
 #include "settings.h"
 #include "job_list.h"
 #include "executor.h"
+#include "resultgen.h"
 
 /*
  * NOTE: this test is using a lot of variables that are changed in igt_fixture,
@@ -1348,6 +1351,54 @@ igt_main
 			free(list);
 	}
 
+	igt_subtest_group {
+		struct job_list *list = malloc(sizeof(*list));
+		volatile int dirfd = -1;
+		char dirname[] = "tmpdirXXXXXX";
+
+		igt_fixture {
+			igt_require(mkdtemp(dirname) != NULL);
+			rmdir(dirname);
+
+			init_job_list(list);
+		}
+
+		igt_subtest("dynamic-subtest-failure-should-not-cause-warn") {
+			struct execute_state state;
+			struct json_object *results, *obj;
+			const char *argv[] = { "runner",
+					       "-t", "dynamic",
+					       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(execute(&state, settings, list));
+
+			igt_assert_f((dirfd = open(dirname, O_DIRECTORY | O_RDONLY)) >= 0,
+				     "Execute didn't create the results directory\n");
+			igt_assert_f((results = generate_results_json(dirfd)) != NULL,
+				     "Results parsing failed\n");
+
+			obj = results;
+			igt_assert(json_object_object_get_ex(obj, "tests", &obj));
+			igt_assert(json_object_object_get_ex(obj, "igt@dynamic@dynamic-subtest@passing", &obj));
+			igt_assert(json_object_object_get_ex(obj, "result", &obj));
+
+			igt_assert_eqstr(json_object_get_string(obj), "pass");
+
+			igt_assert_eq(json_object_put(results), 1);
+		}
+
+		igt_fixture {
+			close(dirfd);
+			clear_directory(dirname);
+			free_job_list(list);
+		}
+	}
+
 	igt_subtest("file-descriptor-leakage") {
 		int i;
 
-- 
2.20.1

_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

  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 ` [igt-dev] [PATCH i-g-t 2/4] runner_tests: Replace magic numbers with named constants Petri Latvala
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 ` Petri Latvala [this message]
2020-01-15 13:09   ` [igt-dev] [PATCH i-g-t 4/4] runner_tests: Test that dynamic subtest failure is handled correctly 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-4-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