lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Wed, 24 Apr 2019 15:00:20 -0400
From:   Masayoshi Mizuma <msys.mizuma@...il.com>
To:     Brendan Higgins <brendanhiggins@...gle.com>
Cc:     corbet@....net, frowand.list@...il.com, keescook@...gle.com,
        kieran.bingham@...asonboard.com, mcgrof@...nel.org,
        robh@...nel.org, shuah@...nel.org, yamada.masahiro@...ionext.com,
        pmladek@...e.com, linux-doc@...r.kernel.org, amir73il@...il.com,
        dri-devel@...ts.freedesktop.org, Alexander.Levin@...rosoft.com,
        linux-kselftest@...r.kernel.org, linux-nvdimm@...ts.01.org,
        khilman@...libre.com, knut.omang@...cle.com, wfg@...ux.intel.com,
        joel@....id.au, jdike@...toit.com, dan.carpenter@...cle.com,
        devicetree@...r.kernel.org, linux-kbuild@...r.kernel.org,
        Tim.Bird@...y.com, Avinash Kondareddy <akndr41@...il.com>,
        linux-um@...ts.infradead.org, rostedt@...dmis.org,
        julia.lawall@...6.fr, kunit-dev@...glegroups.com, richard@....at,
        gregkh@...uxfoundation.org, linux-kernel@...r.kernel.org,
        daniel@...ll.ch, mpe@...erman.id.au, linux-fsdevel@...r.kernel.org
Subject: Re: [PATCH v1 11/17] kunit: test: add test managed resource tests

On Thu, Apr 04, 2019 at 03:06:46PM -0700, Brendan Higgins wrote:
> From: Avinash Kondareddy <akndr41@...il.com>
> 
> Tests how tests interact with test managed resources in their lifetime.
> 
> Signed-off-by: Avinash Kondareddy <akndr41@...il.com>
> Signed-off-by: Brendan Higgins <brendanhiggins@...gle.com>
> ---
>  kunit/test-test.c | 122 ++++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 122 insertions(+)
> 
> diff --git a/kunit/test-test.c b/kunit/test-test.c
> index 4bd7a34d0a6cb..54add8ca418a0 100644
> --- a/kunit/test-test.c
> +++ b/kunit/test-test.c
> @@ -135,3 +135,125 @@ static struct kunit_module kunit_try_catch_test_module = {
>  	.test_cases = kunit_try_catch_test_cases,
>  };
>  module_test(kunit_try_catch_test_module);
> +
> +/*
> + * Context for testing test managed resources
> + * is_resource_initialized is used to test arbitrary resources
> + */
> +struct kunit_test_resource_context {
> +	struct kunit test;
> +	bool is_resource_initialized;
> +};
> +
> +static int fake_resource_init(struct kunit_resource *res, void *context)
> +{
> +	struct kunit_test_resource_context *ctx = context;
> +
> +	res->allocation = &ctx->is_resource_initialized;
> +	ctx->is_resource_initialized = true;
> +	return 0;
> +}
> +
> +static void fake_resource_free(struct kunit_resource *res)
> +{
> +	bool *is_resource_initialized = res->allocation;
> +
> +	*is_resource_initialized = false;
> +}
> +
> +static void kunit_resource_test_init_resources(struct kunit *test)
> +{
> +	struct kunit_test_resource_context *ctx = test->priv;
> +
> +	kunit_init_test(&ctx->test, "testing_test_init_test");
> +
> +	KUNIT_EXPECT_TRUE(test, list_empty(&ctx->test.resources));
> +}
> +
> +static void kunit_resource_test_alloc_resource(struct kunit *test)
> +{
> +	struct kunit_test_resource_context *ctx = test->priv;
> +	struct kunit_resource *res;
> +	kunit_resource_free_t free = fake_resource_free;
> +
> +	res = kunit_alloc_resource(&ctx->test,
> +				   fake_resource_init,
> +				   fake_resource_free,
> +				   ctx);
> +

> +	KUNIT_ASSERT_NOT_ERR_OR_NULL(test, res);

	KUNIT_EXPECT_NOT_ERR_OR_NULL(test, res);

Thanks!
Masa

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ