fbo-fragcoord2: Convert asserts to failure reports.

Submitted by Vinson Lee on March 30, 2016, 11:58 p.m.

Details

Message ID 1459382296-19975-1-git-send-email-vlee@freedesktop.org
State New
Headers show
Series "fbo-fragcoord2: Convert asserts to failure reports." ( rev: 2 ) in Piglit

Not browsing as part of any series.

Commit Message

Vinson Lee March 30, 2016, 11:58 p.m.
Signed-off-by: Vinson Lee <vlee@freedesktop.org>
---
 tests/fbo/fbo-fragcoord2.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

Patch hide | download patch | download mbox

diff --git a/tests/fbo/fbo-fragcoord2.c b/tests/fbo/fbo-fragcoord2.c
index 34a5c6cf7802..e816a9800cd6 100644
--- a/tests/fbo/fbo-fragcoord2.c
+++ b/tests/fbo/fbo-fragcoord2.c
@@ -220,11 +220,17 @@  piglit_init(int argc, char**argv)
    piglit_ortho_projection(piglit_width, piglit_height, GL_FALSE);
 
    vs = piglit_compile_shader_text(GL_VERTEX_SHADER, VertShaderText);
-   assert(vs);
+   if (!vs) {
+      piglit_report_result(PIGLIT_FAIL);
+   }
 
    fs = piglit_compile_shader_text(GL_FRAGMENT_SHADER, FragShaderText);
-   assert(fs);
+   if (!fs) {
+      piglit_report_result(PIGLIT_FAIL);
+   }
 
    prog = piglit_link_simple_program(vs, fs);
-   assert(prog);
+   if (!prog) {
+      piglit_report_result(PIGLIT_FAIL);
+   }
 }

Comments

On 03/30/2016 05:58 PM, Vinson Lee wrote:
> Signed-off-by: Vinson Lee <vlee@freedesktop.org>
> ---
>   tests/fbo/fbo-fragcoord2.c | 12 +++++++++---
>   1 file changed, 9 insertions(+), 3 deletions(-)
>
> diff --git a/tests/fbo/fbo-fragcoord2.c b/tests/fbo/fbo-fragcoord2.c
> index 34a5c6cf7802..e816a9800cd6 100644
> --- a/tests/fbo/fbo-fragcoord2.c
> +++ b/tests/fbo/fbo-fragcoord2.c
> @@ -220,11 +220,17 @@ piglit_init(int argc, char**argv)
>      piglit_ortho_projection(piglit_width, piglit_height, GL_FALSE);
>
>      vs = piglit_compile_shader_text(GL_VERTEX_SHADER, VertShaderText);
> -   assert(vs);
> +   if (!vs) {
> +      piglit_report_result(PIGLIT_FAIL);
> +   }
>
>      fs = piglit_compile_shader_text(GL_FRAGMENT_SHADER, FragShaderText);
> -   assert(fs);
> +   if (!fs) {
> +      piglit_report_result(PIGLIT_FAIL);
> +   }
>
>      prog = piglit_link_simple_program(vs, fs);
> -   assert(prog);
> +   if (!prog) {
> +      piglit_report_result(PIGLIT_FAIL);
> +   }
>   }
>

Actually that whole section could be simplified with:

prog = piglit_build_simple_program(VertShaderText, FragShaderText);

That function will check if linking fails and call 
piglit_report_result(PIGLIT_FAIL) so need to check the return value.

-Brian
Quoting Brian Paul (2016-03-30 18:03:37)
> On 03/30/2016 05:58 PM, Vinson Lee wrote:
> > Signed-off-by: Vinson Lee <vlee@freedesktop.org>
> > ---
> >   tests/fbo/fbo-fragcoord2.c | 12 +++++++++---
> >   1 file changed, 9 insertions(+), 3 deletions(-)
> >
> > diff --git a/tests/fbo/fbo-fragcoord2.c b/tests/fbo/fbo-fragcoord2.c
> > index 34a5c6cf7802..e816a9800cd6 100644
> > --- a/tests/fbo/fbo-fragcoord2.c
> > +++ b/tests/fbo/fbo-fragcoord2.c
> > @@ -220,11 +220,17 @@ piglit_init(int argc, char**argv)
> >      piglit_ortho_projection(piglit_width, piglit_height, GL_FALSE);
> >
> >      vs = piglit_compile_shader_text(GL_VERTEX_SHADER, VertShaderText);
> > -   assert(vs);
> > +   if (!vs) {
> > +      piglit_report_result(PIGLIT_FAIL);
> > +   }
> >
> >      fs = piglit_compile_shader_text(GL_FRAGMENT_SHADER, FragShaderText);
> > -   assert(fs);
> > +   if (!fs) {
> > +      piglit_report_result(PIGLIT_FAIL);
> > +   }
> >
> >      prog = piglit_link_simple_program(vs, fs);
> > -   assert(prog);
> > +   if (!prog) {
> > +      piglit_report_result(PIGLIT_FAIL);
> > +   }
> >   }
> >
> 
> Actually that whole section could be simplified with:
> 
> prog = piglit_build_simple_program(VertShaderText, FragShaderText);
> 
> That function will check if linking fails and call 
> piglit_report_result(PIGLIT_FAIL) so need to check the return value.
> 
> -Brian
> 
> 
> _______________________________________________
> Piglit mailing list
> Piglit@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/piglit

I've seen this pattern a few times, maybe this could be added to the
TODO file as a good beginner project?