[v1,1/2] piglit-framework-gl: add possibility to deinit test

Submitted by Sergii Romantsov on Nov. 21, 2018, 10:18 a.m.

Details

Message ID 1542795533-19793-1-git-send-email-sergii.romantsov@globallogic.com
State New
Headers show
Series "Series without cover letter" ( rev: 1 ) in Piglit

Not browsing as part of any series.

Commit Message

Sergii Romantsov Nov. 21, 2018, 10:18 a.m.
Each test can be initialized ('init') and displayed ('dipslay').
During initialization can be allocated resources.
But there is no common unified mechanism to free resources on test
finishing, except, probably, registaration of callabck with 'atexit'.

To the piglit-configuration added callback-function 'deinit' that
will be called on the test end.

CC: Brian Paul <brianp@vmware.com>
CC: Timothy Arceri <tarceri@itsqueeze.com>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=108819
Signed-off-by: Sergii Romantsov <sergii.romantsov@globallogic.com>
---
 tests/util/piglit-framework-gl.h                     | 3 +++
 tests/util/piglit-framework-gl/piglit_gl_framework.c | 2 ++
 2 files changed, 5 insertions(+)

Patch hide | download patch | download mbox

diff --git a/tests/util/piglit-framework-gl.h b/tests/util/piglit-framework-gl.h
index a4ecddb..2dfbad2 100644
--- a/tests/util/piglit-framework-gl.h
+++ b/tests/util/piglit-framework-gl.h
@@ -192,6 +192,9 @@  struct piglit_gl_test_config {
 	enum piglit_result
 	(*display)(void);
 
+	void
+	(*deinit)(void);
+
 	/**
 	 * List of subtests supported by this test case
 	 *
diff --git a/tests/util/piglit-framework-gl/piglit_gl_framework.c b/tests/util/piglit-framework-gl/piglit_gl_framework.c
index 37c0677..bdb9dbd 100644
--- a/tests/util/piglit-framework-gl/piglit_gl_framework.c
+++ b/tests/util/piglit-framework-gl/piglit_gl_framework.c
@@ -116,5 +116,7 @@  piglit_gl_framework_init(struct piglit_gl_framework *gl_fw,
 void
 piglit_gl_framework_teardown(struct piglit_gl_framework *gl_fw)
 {
+	if (gl_fw->test_config->deinit)
+		gl_fw->test_config->deinit();
 	return;
 }

Comments

Hello,
is there any chance to get review?
In the goal is idea to get a simple mechanism to control resources freeing
(any extra memory allocations, files etc.) of any piglit-test on the exit.

On Wed, Nov 21, 2018 at 12:18 PM Sergii Romantsov <
sergii.romantsov@gmail.com> wrote:

> Each test can be initialized ('init') and displayed ('dipslay').
> During initialization can be allocated resources.
> But there is no common unified mechanism to free resources on test
> finishing, except, probably, registaration of callabck with 'atexit'.
>
> To the piglit-configuration added callback-function 'deinit' that
> will be called on the test end.
>
> CC: Brian Paul <brianp@vmware.com>
> CC: Timothy Arceri <tarceri@itsqueeze.com>
> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=108819
> Signed-off-by: Sergii Romantsov <sergii.romantsov@globallogic.com>
> ---
>  tests/util/piglit-framework-gl.h                     | 3 +++
>  tests/util/piglit-framework-gl/piglit_gl_framework.c | 2 ++
>  2 files changed, 5 insertions(+)
>
> diff --git a/tests/util/piglit-framework-gl.h
> b/tests/util/piglit-framework-gl.h
> index a4ecddb..2dfbad2 100644
> --- a/tests/util/piglit-framework-gl.h
> +++ b/tests/util/piglit-framework-gl.h
> @@ -192,6 +192,9 @@ struct piglit_gl_test_config {
>         enum piglit_result
>         (*display)(void);
>
> +       void
> +       (*deinit)(void);
> +
>         /**
>          * List of subtests supported by this test case
>          *
> diff --git a/tests/util/piglit-framework-gl/piglit_gl_framework.c
> b/tests/util/piglit-framework-gl/piglit_gl_framework.c
> index 37c0677..bdb9dbd 100644
> --- a/tests/util/piglit-framework-gl/piglit_gl_framework.c
> +++ b/tests/util/piglit-framework-gl/piglit_gl_framework.c
> @@ -116,5 +116,7 @@ piglit_gl_framework_init(struct piglit_gl_framework
> *gl_fw,
>  void
>  piglit_gl_framework_teardown(struct piglit_gl_framework *gl_fw)
>  {
> +       if (gl_fw->test_config->deinit)
> +               gl_fw->test_config->deinit();
>         return;
>  }
> --
> 2.7.4
>
>
Sergii Romantsov <sergii.romantsov@gmail.com> writes:

> Hello,
> is there any chance to get review?
> In the goal is idea to get a simple mechanism to control resources freeing
> (any extra memory allocations, files etc.) of any piglit-test on the exit.

I gave some feedback, and I haven't seen a new version.
Hello, Eric.
Yes, and i also answered with some explanation:

> And, in general, I would recommend just freeing data after usage,> rather than having a deinit function.

Looks like it may complicate a logic and code of test. Test may exit with
any call to 'piglit_report_result' and it can happens on any stage of
execution. In proposed mechanism we shouldn't care when and why exit is
done, so we can be sure that all resources will be freed.

But if it is not an argument - will update on this week like you have
suggested.

On Thu, Jan 3, 2019 at 8:42 PM Eric Anholt <eric@anholt.net> wrote:

> Sergii Romantsov <sergii.romantsov@gmail.com> writes:
>
> > Hello,
> > is there any chance to get review?
> > In the goal is idea to get a simple mechanism to control resources
> freeing
> > (any extra memory allocations, files etc.) of any piglit-test on the
> exit.
>
> I gave some feedback, and I haven't seen a new version.
>