All of lore.kernel.org
 help / color / mirror / Atom feed
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] lib/tests: Add tests for magic control blocks nesting
Date: Tue, 5 May 2020 09:41:02 +0300	[thread overview]
Message-ID: <20200505064102.GJ9497@platvala-desk.ger.corp.intel.com> (raw)
In-Reply-To: <20200504112623.285610-3-arkadiusz.hiler@intel.com>

On Mon, May 04, 2020 at 02:26:23PM +0300, Arkadiusz Hiler wrote:
> Cc: Petri Latvala <petri.latvala@intel.com>
> Signed-off-by: Arkadiusz Hiler <arkadiusz.hiler@intel.com>


Reviewed-by: Petri Latvala <petri.latvala@intel.com>

Is igt_fork usage covered elsewhere?



> ---
>  lib/tests/igt_nesting.c      | 261 +++++++++++++++++++++++++++++++++++
>  lib/tests/igt_tests_common.h |   5 +
>  lib/tests/meson.build        |   1 +
>  3 files changed, 267 insertions(+)
>  create mode 100644 lib/tests/igt_nesting.c
> 
> diff --git a/lib/tests/igt_nesting.c b/lib/tests/igt_nesting.c
> new file mode 100644
> index 00000000..de674b6b
> --- /dev/null
> +++ b/lib/tests/igt_nesting.c
> @@ -0,0 +1,261 @@
> +/*
> + * Copyright © 2020 Intel Corporation
> + *
> + * Permission is hereby granted, free of charge, to any person obtaining a
> + * copy of this software and associated documentation files (the "Software"),
> + * to deal in the Software without restriction, including without limitation
> + * the rights to use, copy, modify, merge, publish, distribute, sublicense,
> + * and/or sell copies of the Software, and to permit persons to whom the
> + * Software is furnished to do so, subject to the following conditions:
> + *
> + * The above copyright notice and this permission notice (including the next
> + * paragraph) shall be included in all copies or substantial portions of the
> + * Software.
> + *
> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
> + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
> + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
> + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
> + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
> + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
> + * IN THE SOFTWARE.
> + *
> + */
> +
> +#include "igt_core.h"
> +#include "igt_tests_common.h"
> +#include "drmtest.h"
> +
> +char test[] = "test";
> +char *fake_argv[] = { test };
> +int fake_argc = ARRAY_SIZE(fake_argv);
> +
> +static void all_valid_simple_test(void)
> +{
> +	igt_simple_init(fake_argc, fake_argv);
> +
> +	igt_skip("o:");
> +	igt_assert(false);
> +
> +	igt_exit();
> +}
> +
> +static void all_valid(void)
> +{
> +	igt_subtest_init(fake_argc, fake_argv);
> +
> +	igt_fixture {
> +	}
> +
> +	igt_subtest_group {
> +		igt_subtest_group {
> +		}
> +
> +		igt_fixture {
> +		}
> +
> +		igt_subtest("a")
> +		{
> +			igt_skip("o:\n");
> +		}
> +
> +		igt_subtest("b")
> +		{
> +			igt_assert(false);
> +		}
> +
> +		igt_subtest_with_dynamic("c") {
> +			igt_dynamic("d")
> +			{
> +				igt_skip("o:\n");
> +			}
> +
> +			igt_dynamic("e")
> +			{
> +				igt_assert(false);
> +			}
> +		}
> +
> +		igt_subtest_with_dynamic("f") {
> +			igt_skip("o:\n");
> +		}
> +
> +		igt_subtest_with_dynamic("g") {
> +		}
> +	}
> +
> +	igt_exit();
> +}
> +
> +static void invalid_subtest_in_simple_test(void)
> +{
> +	igt_simple_init(fake_argc, fake_argv);
> +
> +	igt_subtest("a") {
> +	}
> +
> +	igt_exit();
> +}
> +
> +static void invalid_subtest_group_in_simple_test(void)
> +{
> +	igt_simple_init(fake_argc, fake_argv);
> +
> +	igt_subtest_group {
> +	}
> +
> +	igt_exit();
> +}
> +
> +static void invalid_subtest_with_dynamic_in_simple_test(void)
> +{
> +	igt_simple_init(fake_argc, fake_argv);
> +
> +	igt_subtest_with_dynamic("a") {
> +	}
> +
> +	igt_exit();
> +}
> +
> +static void invalid_dynamic_in_simple_test(void)
> +{
> +	igt_simple_init(fake_argc, fake_argv);
> +
> +	igt_dynamic("a") {
> +	}
> +
> +	igt_exit();
> +}
> +
> +static void invalid_fixture_in_fixture(void)
> +{
> +	igt_subtest_init(fake_argc, fake_argv);
> +
> +	igt_fixture {
> +		igt_fixture {
> +		}
> +	}
> +
> +	igt_exit();
> +}
> +
> +static void invalid_subtest_in_subtest(void)
> +{
> +	igt_subtest_init(fake_argc, fake_argv);
> +
> +	igt_subtest("a") {
> +		igt_subtest("b") {
> +		}
> +	}
> +
> +	igt_exit();
> +}
> +
> +static void invalid_top_level_dynamic(void)
> +{
> +	igt_subtest_init(fake_argc, fake_argv);
> +
> +	igt_dynamic("a") {
> +	}
> +
> +	igt_exit();
> +}
> +
> +static void invalid_dynamic_in_regular_subtest(void)
> +{
> +	igt_subtest_init(fake_argc, fake_argv);
> +
> +	igt_subtest("a") {
> +		igt_dynamic("b") {
> +		}
> +	}
> +
> +	igt_exit();
> +}
> +
> +static void invalid_fixture_in_subtest(void)
> +{
> +	igt_subtest_init(fake_argc, fake_argv);
> +
> +	igt_subtest("a") {
> +		igt_fixture {
> +		}
> +	}
> +
> +	igt_exit();
> +}
> +
> +static void invalid_top_level_skip(void)
> +{
> +	igt_subtest_init(fake_argc, fake_argv);
> +
> +	igt_skip("o:\n");
> +
> +	igt_exit();
> +}
> +
> +static void invalid_top_level_assert(void)
> +{
> +	igt_subtest_init(fake_argc, fake_argv);
> +
> +	igt_assert(false);
> +
> +	igt_exit();
> +}
> +
> +static void invalid_dynamic_in_dynamic(void)
> +{
> +	igt_subtest_init(fake_argc, fake_argv);
> +
> +	igt_subtest_with_dynamic("a") {
> +		igt_dynamic("b") {
> +			igt_dynamic("c") {
> +			}
> +		}
> +	}
> +
> +	igt_exit();
> +}
> +
> +typedef void (*fork_fun)(void);
> +
> +int main(int argc, char **argv)
> +{
> +	int status;
> +
> +	/* test the invalid nesting scenarios */ {
> +		fork_fun should_sigabort[] = {
> +			invalid_subtest_in_simple_test,
> +			invalid_subtest_group_in_simple_test,
> +			invalid_subtest_with_dynamic_in_simple_test,
> +			invalid_dynamic_in_simple_test,
> +			invalid_fixture_in_fixture,
> +			invalid_subtest_in_subtest,
> +			invalid_top_level_dynamic,
> +			invalid_dynamic_in_regular_subtest,
> +			invalid_fixture_in_subtest,
> +			invalid_top_level_skip,
> +			invalid_top_level_assert,
> +			invalid_dynamic_in_dynamic,
> +		};
> +
> +		for (int i = 0; i < ARRAY_SIZE(should_sigabort); ++i) {
> +			status = do_fork(should_sigabort[i]);
> +			internal_assert_wsignaled(status, SIGABRT);
> +		}
> +	}
> +
> +	/* test the valid nesting scenarios */ {
> +		fork_fun should_not_signal[] = {
> +			all_valid_simple_test,
> +			all_valid,
> +		};
> +
> +		for (int i = 0; i < ARRAY_SIZE(should_not_signal); ++i) {
> +			status = do_fork(should_not_signal[i]);
> +			internal_assert_not_wsignaled(status);
> +		}
> +	}
> +
> +	return 0;
> +}
> diff --git a/lib/tests/igt_tests_common.h b/lib/tests/igt_tests_common.h
> index f285d657..fa8ad920 100644
> --- a/lib/tests/igt_tests_common.h
> +++ b/lib/tests/igt_tests_common.h
> @@ -51,6 +51,11 @@ static inline void internal_assert_wsignaled(int wstatus, int signal)
>  			WTERMSIG(wstatus) == signal);
>  }
>  
> +static inline void internal_assert_not_wsignaled(int wstatus)
> +{
> +	internal_assert(!WIFSIGNALED(wstatus));
> +}
> +
>  static inline int do_fork(void (*test_to_run)(void))
>  {
>  	int pid, status;
> diff --git a/lib/tests/meson.build b/lib/tests/meson.build
> index 22aa19da..47ef303a 100644
> --- a/lib/tests/meson.build
> +++ b/lib/tests/meson.build
> @@ -12,6 +12,7 @@ lib_tests = [
>  	'igt_fork_helper',
>  	'igt_list_only',
>  	'igt_invalid_subtest_name',
> +	'igt_nesting',
>  	'igt_no_exit',
>  	'igt_segfault',
>  	'igt_simulation',
> -- 
> 2.25.2
> 
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

  reply	other threads:[~2020-05-05  6:41 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-04 11:26 [igt-dev] [PATCH i-g-t 1/3] lib/igt_core: Make assert on invalid magic blocks nesting more verbose Arkadiusz Hiler
2020-05-04 11:26 ` [igt-dev] [PATCH i-g-t 2/3] lib/igt_core: Disallow nesting of igt_dynamic inside igt_dynamic Arkadiusz Hiler
2020-05-05  6:36   ` Petri Latvala
2020-05-04 11:26 ` [igt-dev] [PATCH i-g-t 3/3] lib/tests: Add tests for magic control blocks nesting Arkadiusz Hiler
2020-05-05  6:41   ` Petri Latvala [this message]
2020-05-05 12:32     ` Arkadiusz Hiler
2020-05-04 12:15 ` [igt-dev] ✓ Fi.CI.BAT: success for series starting with [i-g-t,1/3] lib/igt_core: Make assert on invalid magic blocks nesting more verbose Patchwork
2020-05-04 21:33 ` [igt-dev] ✗ Fi.CI.IGT: failure " Patchwork
2020-05-05 12:33   ` Arkadiusz Hiler
2020-05-05  6:36 ` [igt-dev] [PATCH i-g-t 1/3] " 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=20200505064102.GJ9497@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.