[Mesa-dev] [PATCH 2/2] mesa/formats: make format testing a gtest

Chad Versace chad.versace at intel.com
Tue Aug 25 14:50:16 PDT 2015


On Mon 24 Aug 2015, Nanley Chery wrote:
> On Fri, Aug 21, 2015 at 2:12 PM, Chad Versace <chad.versace at intel.com>
> wrote:
> 
> > On Wed 19 Aug 2015, Nanley Chery wrote:
> > > From: Nanley Chery <nanley.g.chery at intel.com>
> > >
> > > We currently check that our format info table is sane during context
> > > initialization in debug builds. Perform this check during
> > > `make check` instead. This enables format testing in release builds
> > > and removes the requirement of an exhuastive switch for
> > > _mesa_uncompressed_format_to_type_and_comps().
> > >
> > > Signed-off-by: Nanley Chery <nanley.g.chery at intel.com>
> > > ---
> > >  src/mesa/main/context.c              |   4 -
> > >  src/mesa/main/formats.c              | 157
> > ++---------------------------------
> > >  src/mesa/main/tests/Makefile.am      |   1 +
> > >  src/mesa/main/tests/mesa_formats.cpp | 130 +++++++++++++++++++++++++++++
> > >  4 files changed, 137 insertions(+), 155 deletions(-)
> > >  create mode 100644 src/mesa/main/tests/mesa_formats.cpp
> >



> > > +/**
> > > + * Debug/test: check that all uncompressed formats are handled in the
> > > + * _mesa_uncompressed_format_to_type_and_comps() function. When new
> > pixel
> > > + * formats are added to Mesa, that function needs to be updated.
> > > + */
> > > +TEST(MesaFormatsTest, FormatTypeAndComps)
> > > +{
> > > +   for (int fi = MESA_FORMAT_NONE + 1; fi < MESA_FORMAT_COUNT; ++fi) {
> > > +      mesa_format f = (mesa_format) fi;
> > > +
> > > +      /* This function will emit a problem/warning if the format is
> > > +       * not handled.
> > > +       */
> > > +      if (!_mesa_is_format_compressed(f)) {
> > > +         GLenum datatype = 0;
> > > +         GLuint comps = 0;
> > > +         _mesa_uncompressed_format_to_type_and_comps(f, &datatype,
> > &comps);
> > > +
> > > +         /* If the datatype is zero, the format was not handled */
> > > +         ASSERT_NE(datatype, (GLenum)0);
> >
> > I think the test should also assert that comps >= 1.
> >
> > In the failure scenario for this function, comps will be set equal to 1.

> It can also be set equal to 1 for certain valid formats as well.

Right. I retract my comment. Since GLenum is unsigned, it doesn't matter
whether we check for != 0 or >= 1.

But my other comments in the previous email still hold.


More information about the mesa-dev mailing list