From: Petri Latvala <petri.latvala@intel.com>
To: Arkadiusz Hiler <arkadiusz.hiler@intel.com>
Cc: igt-dev@lists.freedesktop.org
Subject: Re: [igt-dev] [PATCH i-g-t 3/3] igt/core: Disallow igt_require/skip in non-main threads
Date: Thu, 18 Jun 2020 15:59:55 +0300 [thread overview]
Message-ID: <20200618125955.GL20883@platvala-desk.ger.corp.intel.com> (raw)
In-Reply-To: <20200616141450.1181127-3-arkadiusz.hiler@intel.com>
On Tue, Jun 16, 2020 at 05:14:50PM +0300, Arkadiusz Hiler wrote:
> Handling magic control blocks and longjmp() out of them in threads is
> hard.
>
> The test should state the requirements before it starts spinning
> threads.
>
> Signed-off-by: Arkadiusz Hiler <arkadiusz.hiler@intel.com>
Reviewed-by: Petri Latvala <petri.latvala@intel.com>
> ---
> lib/igt_core.c | 3 +++
> lib/tests/igt_thread.c | 34 +++++++++++++++++++++++++++++++++-
> 2 files changed, 36 insertions(+), 1 deletion(-)
>
> diff --git a/lib/igt_core.c b/lib/igt_core.c
> index ccf06cf4..cedd8168 100644
> --- a/lib/igt_core.c
> +++ b/lib/igt_core.c
> @@ -1475,6 +1475,9 @@ void __igt_skip_check(const char *file, const int line,
> int err = errno;
> char *err_str = NULL;
>
> + if (!igt_thread_is_main())
> + assert(!"igt_require/skip allowed only in the main thread!");
> +
> if (err)
> igt_assert_neq(asprintf(&err_str, "Last errno: %i, %s\n", err, strerror(err)),
> -1);
> diff --git a/lib/tests/igt_thread.c b/lib/tests/igt_thread.c
> index 1a734e6d..3fb90416 100644
> --- a/lib/tests/igt_thread.c
> +++ b/lib/tests/igt_thread.c
> @@ -43,6 +43,12 @@ static void *failure_thread(void *data)
> return NULL;
> }
>
> +static void *require_thread(void *data)
> +{
> + igt_require(false);
> + return NULL;
> +}
> +
> static void one_subtest_fail(void) {
> igt_subtest_init(fake_argc, fake_argv);
>
> @@ -103,10 +109,21 @@ static void simple_failure(void) {
> igt_exit();
> }
>
> +static void require_non_main_thread(void) {
> + pthread_t thread;
> +
> + igt_simple_init(fake_argc, fake_argv);
> +
> + pthread_create(&thread, 0, require_thread, NULL);
> + pthread_join(thread, NULL);
> +
> + igt_exit();
> +}
> +
> int main(int argc, char **argv)
> {
> int status;
> - int outfd;
> + int outfd, errfd;
> pid_t pid;
>
> /* failing should be limited just to a single subtest */ {
> @@ -190,5 +207,20 @@ int main(int argc, char **argv)
> close(outfd);
> }
>
> + /* require in a thread should SIGABRT */ {
> + static char err[4096];
> +
> + pid = do_fork_bg_with_pipes(require_non_main_thread, NULL, &errfd);
> +
> + read_whole_pipe(errfd, err, sizeof(err));
> +
> + internal_assert(safe_wait(pid, &status) != -1);
> + internal_assert_wsignaled(status, SIGABRT);
> +
> + internal_assert(strstr(err, "allowed only in the main thread"));
> +
> + close(errfd);
> + }
> +
> return 0;
> }
> --
> 2.25.4
>
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev
next prev parent reply other threads:[~2020-06-18 12:59 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-16 14:14 [igt-dev] [PATCH i-g-t 1/3] lib/core: Print thred:tid with igt_log for non-main threads Arkadiusz Hiler
2020-06-16 14:14 ` [igt-dev] [PATCH i-g-t 2/3] lib/core: Handle asserts in threads Arkadiusz Hiler
2020-06-18 12:59 ` Petri Latvala
2020-06-16 14:14 ` [igt-dev] [PATCH i-g-t 3/3] igt/core: Disallow igt_require/skip in non-main threads Arkadiusz Hiler
2020-06-18 12:59 ` Petri Latvala [this message]
2020-06-16 16:55 ` [igt-dev] ✗ GitLab.Pipeline: warning for series starting with [i-g-t,1/3] lib/core: Print thred:tid with igt_log for " Patchwork
2020-06-16 17:06 ` [igt-dev] ✓ Fi.CI.BAT: success " Patchwork
2020-06-16 18:25 ` [igt-dev] ✗ Fi.CI.IGT: failure " Patchwork
2020-06-17 13:52 ` Arkadiusz Hiler
2020-06-17 14:37 ` [igt-dev] ✓ Fi.CI.BAT: success for series starting with [i-g-t,1/3] lib/core: Print thred:tid with igt_log for non-main threads (rev2) Patchwork
2020-06-17 16:44 ` [igt-dev] ✗ Fi.CI.IGT: failure " Patchwork
2020-06-18 12:51 ` [igt-dev] [PATCH i-g-t 1/3] lib/core: Print thred:tid with igt_log for non-main threads Petri Latvala
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=20200618125955.GL20883@platvala-desk.ger.corp.intel.com \
--to=petri.latvala@intel.com \
--cc=arkadiusz.hiler@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