diff mbox series

[v5,8/9] drm/selftest: Refactor test-drm_plane_helper

Message ID 20181019105752.17741-9-alexandru-cosmin.gheorghe@arm.com (mailing list archive)
State New, archived
Headers show
Series Add method to describe tile/bit_level_packed formats | expand

Commit Message

Alexandru-Cosmin Gheorghe Oct. 19, 2018, 10:57 a.m. UTC
The idea is to split test implementations in different compilation
units, but have one single place where we define the list of tests,
in this case(drm_modeset_selftests.h).

Signed-off-by: Alexandru Gheorghe <alexandru-cosmin.gheorghe@arm.com>
---
 ...er_selftests.h => drm_modeset_selftests.h} |  0
 .../drm/selftests/test-drm_modeset_common.c   | 11 ++++++++++-
 .../drm/selftests/test-drm_modeset_common.h   |  2 +-
 .../gpu/drm/selftests/test-drm_plane_helper.c | 19 +------------------
 4 files changed, 12 insertions(+), 20 deletions(-)
 rename drivers/gpu/drm/selftests/{drm_plane_helper_selftests.h => drm_modeset_selftests.h} (100%)

Comments

Daniel Vetter Oct. 19, 2018, 3:14 p.m. UTC | #1
On Fri, Oct 19, 2018 at 11:57:51AM +0100, Alexandru Gheorghe wrote:
> The idea is to split test implementations in different compilation
> units, but have one single place where we define the list of tests,
> in this case(drm_modeset_selftests.h).
> 
> Signed-off-by: Alexandru Gheorghe <alexandru-cosmin.gheorghe@arm.com>
> ---
>  ...er_selftests.h => drm_modeset_selftests.h} |  0
>  .../drm/selftests/test-drm_modeset_common.c   | 11 ++++++++++-
>  .../drm/selftests/test-drm_modeset_common.h   |  2 +-
>  .../gpu/drm/selftests/test-drm_plane_helper.c | 19 +------------------
>  4 files changed, 12 insertions(+), 20 deletions(-)
>  rename drivers/gpu/drm/selftests/{drm_plane_helper_selftests.h => drm_modeset_selftests.h} (100%)
> 
> diff --git a/drivers/gpu/drm/selftests/drm_plane_helper_selftests.h b/drivers/gpu/drm/selftests/drm_modeset_selftests.h
> similarity index 100%
> rename from drivers/gpu/drm/selftests/drm_plane_helper_selftests.h
> rename to drivers/gpu/drm/selftests/drm_modeset_selftests.h
> diff --git a/drivers/gpu/drm/selftests/test-drm_modeset_common.c b/drivers/gpu/drm/selftests/test-drm_modeset_common.c
> index fad5209043f1..2a7f93774006 100644
> --- a/drivers/gpu/drm/selftests/test-drm_modeset_common.c
> +++ b/drivers/gpu/drm/selftests/test-drm_modeset_common.c
> @@ -7,9 +7,18 @@
>  
>  #include "test-drm_modeset_common.h"
>  
> +#define TESTS "drm_modeset_selftests.h"
> +#include "drm_selftest.h"
> +
> +#include "drm_selftest.c"
> +
>  static int __init test_drm_modeset_init(void)
>  {
> -	return test_drm_plane_helper();
> +	int err;
> +
> +	err = run_selftests(selftests, ARRAY_SIZE(selftests), NULL);
> +
> +	return err > 0 ? 0 : err;
>  }
>  
>  static void __exit test_drm_modeset_exit(void)
> diff --git a/drivers/gpu/drm/selftests/test-drm_modeset_common.h b/drivers/gpu/drm/selftests/test-drm_modeset_common.h
> index bdeba264661f..b0065a2eb067 100644
> --- a/drivers/gpu/drm/selftests/test-drm_modeset_common.h
> +++ b/drivers/gpu/drm/selftests/test-drm_modeset_common.h
> @@ -13,6 +13,6 @@
>  
>  #define FAIL_ON(x) FAIL((x), "%s", "FAIL_ON(" __stringify(x) ")\n")
>  
> -int test_drm_plane_helper(void);
> +int igt_check_plane_state(void *ignored);

I wonder whether we can't do some macro trickery to also generate these
here from the selftest.h file. But that's probably for when we're drowning
in these, which we're definitely not yet :-)

Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>

>  
>  #endif
> diff --git a/drivers/gpu/drm/selftests/test-drm_plane_helper.c b/drivers/gpu/drm/selftests/test-drm_plane_helper.c
> index 0dad2f812a27..0a9553f51796 100644
> --- a/drivers/gpu/drm/selftests/test-drm_plane_helper.c
> +++ b/drivers/gpu/drm/selftests/test-drm_plane_helper.c
> @@ -11,9 +11,6 @@
>  
>  #include "test-drm_modeset_common.h"
>  
> -#define TESTS "drm_plane_helper_selftests.h"
> -#include "drm_selftest.h"
> -
>  static void set_src(struct drm_plane_state *plane_state,
>  		    unsigned src_x, unsigned src_y,
>  		    unsigned src_w, unsigned src_h)
> @@ -76,7 +73,7 @@ static bool check_crtc_eq(struct drm_plane_state *plane_state,
>  	return true;
>  }
>  
> -static int igt_check_plane_state(void *ignored)
> +int igt_check_plane_state(void *ignored)

>  {
>  	int ret;
>  
> @@ -220,17 +217,3 @@ static int igt_check_plane_state(void *ignored)
>  
>  	return 0;
>  }
> -
> -#include "drm_selftest.c"
> -
> -/**
> - * test_drm_plane_helper - Run drm plane helper selftests.
> - */
> -int test_drm_plane_helper(void)
> -{
> -	int err;
> -
> -	err = run_selftests(selftests, ARRAY_SIZE(selftests), NULL);
> -
> -	return err > 0 ? 0 : err;
> -}
> -- 
> 2.18.0
>
Alexandru-Cosmin Gheorghe Oct. 22, 2018, 9:40 a.m. UTC | #2
Hi Daniel,

On Fri, Oct 19, 2018 at 05:14:51PM +0200, Daniel Vetter wrote:
> On Fri, Oct 19, 2018 at 11:57:51AM +0100, Alexandru Gheorghe wrote:
> > The idea is to split test implementations in different compilation
> > units, but have one single place where we define the list of tests,
> > in this case(drm_modeset_selftests.h).
> > 
> > Signed-off-by: Alexandru Gheorghe <alexandru-cosmin.gheorghe@arm.com>
> > ---
> >  ...er_selftests.h => drm_modeset_selftests.h} |  0
> >  .../drm/selftests/test-drm_modeset_common.c   | 11 ++++++++++-
> >  .../drm/selftests/test-drm_modeset_common.h   |  2 +-
> >  .../gpu/drm/selftests/test-drm_plane_helper.c | 19 +------------------
> >  4 files changed, 12 insertions(+), 20 deletions(-)
> >  rename drivers/gpu/drm/selftests/{drm_plane_helper_selftests.h => drm_modeset_selftests.h} (100%)
> > 
> > diff --git a/drivers/gpu/drm/selftests/drm_plane_helper_selftests.h b/drivers/gpu/drm/selftests/drm_modeset_selftests.h
> > similarity index 100%
> > rename from drivers/gpu/drm/selftests/drm_plane_helper_selftests.h
> > rename to drivers/gpu/drm/selftests/drm_modeset_selftests.h
> > diff --git a/drivers/gpu/drm/selftests/test-drm_modeset_common.c b/drivers/gpu/drm/selftests/test-drm_modeset_common.c
> > index fad5209043f1..2a7f93774006 100644
> > --- a/drivers/gpu/drm/selftests/test-drm_modeset_common.c
> > +++ b/drivers/gpu/drm/selftests/test-drm_modeset_common.c
> > @@ -7,9 +7,18 @@
> >  
> >  #include "test-drm_modeset_common.h"
> >  
> > +#define TESTS "drm_modeset_selftests.h"
> > +#include "drm_selftest.h"
> > +
> > +#include "drm_selftest.c"
> > +
> >  static int __init test_drm_modeset_init(void)
> >  {
> > -	return test_drm_plane_helper();
> > +	int err;
> > +
> > +	err = run_selftests(selftests, ARRAY_SIZE(selftests), NULL);
> > +
> > +	return err > 0 ? 0 : err;
> >  }
> >  
> >  static void __exit test_drm_modeset_exit(void)
> > diff --git a/drivers/gpu/drm/selftests/test-drm_modeset_common.h b/drivers/gpu/drm/selftests/test-drm_modeset_common.h
> > index bdeba264661f..b0065a2eb067 100644
> > --- a/drivers/gpu/drm/selftests/test-drm_modeset_common.h
> > +++ b/drivers/gpu/drm/selftests/test-drm_modeset_common.h
> > @@ -13,6 +13,6 @@
> >  
> >  #define FAIL_ON(x) FAIL((x), "%s", "FAIL_ON(" __stringify(x) ")\n")
> >  
> > -int test_drm_plane_helper(void);
> > +int igt_check_plane_state(void *ignored);
> 
> I wonder whether we can't do some macro trickery to also generate these
> here from the selftest.h file. But that's probably for when we're drowning
> in these, which we're definitely not yet :-)

I agree.

> 
> Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>

Pushed the patch to drm-misc-next. 
Thanks for the review.

> 
> >  
> >  #endif
> > diff --git a/drivers/gpu/drm/selftests/test-drm_plane_helper.c b/drivers/gpu/drm/selftests/test-drm_plane_helper.c
> > index 0dad2f812a27..0a9553f51796 100644
> > --- a/drivers/gpu/drm/selftests/test-drm_plane_helper.c
> > +++ b/drivers/gpu/drm/selftests/test-drm_plane_helper.c
> > @@ -11,9 +11,6 @@
> >  
> >  #include "test-drm_modeset_common.h"
> >  
> > -#define TESTS "drm_plane_helper_selftests.h"
> > -#include "drm_selftest.h"
> > -
> >  static void set_src(struct drm_plane_state *plane_state,
> >  		    unsigned src_x, unsigned src_y,
> >  		    unsigned src_w, unsigned src_h)
> > @@ -76,7 +73,7 @@ static bool check_crtc_eq(struct drm_plane_state *plane_state,
> >  	return true;
> >  }
> >  
> > -static int igt_check_plane_state(void *ignored)
> > +int igt_check_plane_state(void *ignored)
> 
> >  {
> >  	int ret;
> >  
> > @@ -220,17 +217,3 @@ static int igt_check_plane_state(void *ignored)
> >  
> >  	return 0;
> >  }
> > -
> > -#include "drm_selftest.c"
> > -
> > -/**
> > - * test_drm_plane_helper - Run drm plane helper selftests.
> > - */
> > -int test_drm_plane_helper(void)
> > -{
> > -	int err;
> > -
> > -	err = run_selftests(selftests, ARRAY_SIZE(selftests), NULL);
> > -
> > -	return err > 0 ? 0 : err;
> > -}
> > -- 
> > 2.18.0
> > 
> 
> -- 
> Daniel Vetter
> Software Engineer, Intel Corporation
> http://blog.ffwll.ch
diff mbox series

Patch

diff --git a/drivers/gpu/drm/selftests/drm_plane_helper_selftests.h b/drivers/gpu/drm/selftests/drm_modeset_selftests.h
similarity index 100%
rename from drivers/gpu/drm/selftests/drm_plane_helper_selftests.h
rename to drivers/gpu/drm/selftests/drm_modeset_selftests.h
diff --git a/drivers/gpu/drm/selftests/test-drm_modeset_common.c b/drivers/gpu/drm/selftests/test-drm_modeset_common.c
index fad5209043f1..2a7f93774006 100644
--- a/drivers/gpu/drm/selftests/test-drm_modeset_common.c
+++ b/drivers/gpu/drm/selftests/test-drm_modeset_common.c
@@ -7,9 +7,18 @@ 
 
 #include "test-drm_modeset_common.h"
 
+#define TESTS "drm_modeset_selftests.h"
+#include "drm_selftest.h"
+
+#include "drm_selftest.c"
+
 static int __init test_drm_modeset_init(void)
 {
-	return test_drm_plane_helper();
+	int err;
+
+	err = run_selftests(selftests, ARRAY_SIZE(selftests), NULL);
+
+	return err > 0 ? 0 : err;
 }
 
 static void __exit test_drm_modeset_exit(void)
diff --git a/drivers/gpu/drm/selftests/test-drm_modeset_common.h b/drivers/gpu/drm/selftests/test-drm_modeset_common.h
index bdeba264661f..b0065a2eb067 100644
--- a/drivers/gpu/drm/selftests/test-drm_modeset_common.h
+++ b/drivers/gpu/drm/selftests/test-drm_modeset_common.h
@@ -13,6 +13,6 @@ 
 
 #define FAIL_ON(x) FAIL((x), "%s", "FAIL_ON(" __stringify(x) ")\n")
 
-int test_drm_plane_helper(void);
+int igt_check_plane_state(void *ignored);
 
 #endif
diff --git a/drivers/gpu/drm/selftests/test-drm_plane_helper.c b/drivers/gpu/drm/selftests/test-drm_plane_helper.c
index 0dad2f812a27..0a9553f51796 100644
--- a/drivers/gpu/drm/selftests/test-drm_plane_helper.c
+++ b/drivers/gpu/drm/selftests/test-drm_plane_helper.c
@@ -11,9 +11,6 @@ 
 
 #include "test-drm_modeset_common.h"
 
-#define TESTS "drm_plane_helper_selftests.h"
-#include "drm_selftest.h"
-
 static void set_src(struct drm_plane_state *plane_state,
 		    unsigned src_x, unsigned src_y,
 		    unsigned src_w, unsigned src_h)
@@ -76,7 +73,7 @@  static bool check_crtc_eq(struct drm_plane_state *plane_state,
 	return true;
 }
 
-static int igt_check_plane_state(void *ignored)
+int igt_check_plane_state(void *ignored)
 {
 	int ret;
 
@@ -220,17 +217,3 @@  static int igt_check_plane_state(void *ignored)
 
 	return 0;
 }
-
-#include "drm_selftest.c"
-
-/**
- * test_drm_plane_helper - Run drm plane helper selftests.
- */
-int test_drm_plane_helper(void)
-{
-	int err;
-
-	err = run_selftests(selftests, ARRAY_SIZE(selftests), NULL);
-
-	return err > 0 ? 0 : err;
-}