mesa/tests: ensure that util_cpu_detect has been called

I think that this test was passing in some cases because of loader side
effects, that stop happening after classic is removed.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10153>
This commit is contained in:
Dylan Baker 2021-12-03 12:54:26 -08:00 committed by Marge Bot
parent 268fc8e5c1
commit 901e0d6a11
1 changed files with 22 additions and 12 deletions

View File

@ -35,13 +35,23 @@
#include "main/glformats.h"
#include "main/format_unpack.h"
#include "main/format_pack.h"
#include "util/u_cpu_detect.h"
// Test fixture for Format tests.
// Currently just ensures that util_cpu_detect() has been called
class MesaFormatsTest : public ::testing::Test {
protected:
MesaFormatsTest() {
util_cpu_detect();
}
};
/**
* 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)
TEST_F(MesaFormatsTest, FormatTypeAndComps)
{
for (int fi = MESA_FORMAT_NONE + 1; fi < MESA_FORMAT_COUNT; ++fi) {
mesa_format f = (mesa_format) fi;
@ -68,7 +78,7 @@ TEST(MesaFormatsTest, FormatTypeAndComps)
/**
* Do sanity checking of the format info table.
*/
TEST(MesaFormatsTest, FormatSanity)
TEST_F(MesaFormatsTest, FormatSanity)
{
for (int fi = 0; fi < MESA_FORMAT_COUNT; ++fi) {
mesa_format f = (mesa_format) fi;
@ -139,7 +149,7 @@ TEST(MesaFormatsTest, FormatSanity)
}
}
TEST(MesaFormatsTest, IntensityToRed)
TEST_F(MesaFormatsTest, IntensityToRed)
{
EXPECT_EQ(_mesa_get_intensity_format_red(MESA_FORMAT_I_UNORM8),
MESA_FORMAT_R_UNORM8);
@ -157,7 +167,7 @@ static mesa_format fffat_wrap(GLenum format, GLenum type)
return (mesa_format)f;
}
TEST(MesaFormatsTest, FormatFromFormatAndType)
TEST_F(MesaFormatsTest, FormatFromFormatAndType)
{
EXPECT_EQ(fffat_wrap(GL_RGBA, GL_SHORT),
MESA_FORMAT_RGBA_SNORM16);
@ -171,7 +181,7 @@ TEST(MesaFormatsTest, FormatFromFormatAndType)
GL_BYTE)));
}
TEST(MesaFormatsTest, FormatMatchesFormatAndType)
TEST_F(MesaFormatsTest, FormatMatchesFormatAndType)
{
EXPECT_TRUE(_mesa_format_matches_format_and_type(MESA_FORMAT_RGBA_UNORM16,
GL_RGBA,
@ -203,7 +213,7 @@ test_unpack_r32ui(uint32_t val)
return result[0];
}
TEST(MesaFormatsTest, UnpackRGBAUintRow)
TEST_F(MesaFormatsTest, UnpackRGBAUintRow)
{
EXPECT_EQ(test_unpack_r8i(0), 0);
EXPECT_EQ(test_unpack_r8i(1), 1);
@ -212,7 +222,7 @@ TEST(MesaFormatsTest, UnpackRGBAUintRow)
EXPECT_EQ(test_unpack_r32ui(0xffffffff), 0xffffffff);
}
TEST(MesaFormatsTest, UnpackRGBAUbyteRowRGBA32F)
TEST_F(MesaFormatsTest, UnpackRGBAUbyteRowRGBA32F)
{
float val[4] = {0, 0.5, -1, 2};
uint8_t result[4];
@ -223,7 +233,7 @@ TEST(MesaFormatsTest, UnpackRGBAUbyteRowRGBA32F)
EXPECT_EQ(result[3], 0xff);
}
TEST(MesaFormatsTest, UnpackRGBAUbyteRowRGBA4)
TEST_F(MesaFormatsTest, UnpackRGBAUbyteRowRGBA4)
{
uint16_t val = (1 << 0) | (0x3f << 5) | (0x10 << 11);
uint8_t result[4];
@ -242,7 +252,7 @@ test_unpack_floatz_z32f(float val)
return result;
}
TEST(MesaFormatsTest, UnpackFloatZRow)
TEST_F(MesaFormatsTest, UnpackFloatZRow)
{
EXPECT_EQ(test_unpack_floatz_z32f(0.5), 0.5);
EXPECT_EQ(test_unpack_floatz_z32f(-1.0), -1.0);
@ -257,7 +267,7 @@ test_unpack_uintz_z32f(float val)
return result;
}
TEST(MesaFormatsTest, UnpackUintZRow)
TEST_F(MesaFormatsTest, UnpackUintZRow)
{
EXPECT_EQ(test_unpack_uintz_z32f(0.5), 0x7fffffff);
EXPECT_EQ(test_unpack_uintz_z32f(-1.0), 0);
@ -265,7 +275,7 @@ TEST(MesaFormatsTest, UnpackUintZRow)
}
/* It's easy to have precision issues packing 32-bit floats to unorm. */
TEST(MesaFormatsTest, PackFloatZ)
TEST_F(MesaFormatsTest, PackFloatZ)
{
float val = 0.571428597f;
uint32_t result;
@ -273,7 +283,7 @@ TEST(MesaFormatsTest, PackFloatZ)
EXPECT_EQ(result, 0x924924ff);
}
TEST(MesaFormatsTest, PackUbyteRGBARounding)
TEST_F(MesaFormatsTest, PackUbyteRGBARounding)
{
for (int i = 0; i <= 255; i++) {
uint8_t val[4] = {(uint8_t)i, 0, 0, 0};