Commit bdf2b720 by Nicolas Capens Committed by Nicolas Capens

Avoid ignoring unsuccessful routine creation

Unsuccessful routine creation is a bug that must be caught instead of being silently ignored. Bug: b/148295813 Change-Id: Ic718f0420d6833362944c96a3d172813eba3c207 Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/40568Tested-by: 's avatarNicolas Capens <nicolascapens@google.com> Kokoro-Presubmit: kokoro <noreply+kokoro@google.com> Reviewed-by: 's avatarAntonio Maiorano <amaiorano@google.com>
parent 133b87d6
......@@ -131,12 +131,9 @@ TEST(ReactorUnitTests, Sample)
auto routine = function("one");
if(routine)
{
int one[2] = { 1, 0 };
int result = routine(&one[1], 2);
EXPECT_EQ(result, reference(&one[1], 2));
}
}
TEST(ReactorUnitTests, Uninitialized)
......@@ -162,11 +159,8 @@ TEST(ReactorUnitTests, Uninitialized)
auto routine = function("one");
if(routine)
{
int result = routine();
EXPECT_EQ(result, result); // Anything is fine, just don't crash
}
}
TEST(ReactorUnitTests, Unreachable)
......@@ -186,11 +180,8 @@ TEST(ReactorUnitTests, Unreachable)
auto routine = function("one");
if(routine)
{
int result = routine(16);
EXPECT_EQ(result, 20);
}
}
TEST(ReactorUnitTests, VariableAddress)
......@@ -207,11 +198,8 @@ TEST(ReactorUnitTests, VariableAddress)
auto routine = function("one");
if(routine)
{
int result = routine(16);
EXPECT_EQ(result, 20);
}
}
TEST(ReactorUnitTests, SubVectorLoadStore)
......@@ -232,8 +220,6 @@ TEST(ReactorUnitTests, SubVectorLoadStore)
auto routine = function("one");
if(routine)
{
int8_t in[16 * 5] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
17, 18, 19, 20, 21, 22, 23, 24, 0, 0, 0, 0, 0, 0, 0, 0,
25, 26, 27, 28, 29, 30, 31, 32, 0, 0, 0, 0, 0, 0, 0, 0,
......@@ -264,7 +250,6 @@ TEST(ReactorUnitTests, SubVectorLoadStore)
}
}
}
}
}
TEST(ReactorUnitTests, VectorConstant)
......@@ -283,8 +268,6 @@ TEST(ReactorUnitTests, VectorConstant)
auto routine = function("one");
if(routine)
{
int8_t out[16 * 4] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
......@@ -306,7 +289,6 @@ TEST(ReactorUnitTests, VectorConstant)
EXPECT_EQ(out[i], exp[i]);
}
}
}
}
TEST(ReactorUnitTests, Concatenate)
......@@ -323,8 +305,6 @@ TEST(ReactorUnitTests, Concatenate)
auto routine = function("one");
if(routine)
{
int8_t ref[16 * 5] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 };
......@@ -342,7 +322,6 @@ TEST(ReactorUnitTests, Concatenate)
EXPECT_EQ(out[i], ref[i]) << "Row " << row << " column " << col << " not equal to reference.";
}
}
}
}
TEST(ReactorUnitTests, Cast)
......@@ -360,8 +339,6 @@ TEST(ReactorUnitTests, Cast)
auto routine = function("one");
if(routine)
{
int out[2][4];
memset(&out, 0, sizeof(out));
......@@ -374,7 +351,6 @@ TEST(ReactorUnitTests, Cast)
EXPECT_EQ(out[1][0], 0x16120804);
EXPECT_EQ(out[1][1], 0x01020304);
EXPECT_EQ(out[1][2], 0x06080204);
}
}
static uint16_t swizzleCode4(int i)
......@@ -424,8 +400,6 @@ TEST(ReactorUnitTests, Swizzle4)
auto routine = function("one");
if(routine)
{
struct
{
float f[256 + 256 + 2][4];
......@@ -501,7 +475,6 @@ TEST(ReactorUnitTests, Swizzle4)
EXPECT_EQ(out.i[132 + i][2], ((i >> 4) & 0x03) + 1);
EXPECT_EQ(out.i[132 + i][3], ((i >> 6) & 0x03) + 1);
}
}
}
TEST(ReactorUnitTests, Swizzle)
......@@ -518,8 +491,6 @@ TEST(ReactorUnitTests, Swizzle)
auto routine = function("one");
if(routine)
{
int out[3][4];
memset(&out, 0, sizeof(out));
......@@ -538,12 +509,10 @@ TEST(ReactorUnitTests, Swizzle)
EXPECT_EQ(out[2][1], 0x11120910);
EXPECT_EQ(out[2][2], 0x07080506);
EXPECT_EQ(out[2][3], 0x03040102);
}
}
TEST(ReactorUnitTests, Shuffle)
{
{
// |select| is [0aaa:0bbb:0ccc:0ddd] where |aaa|, |bbb|, |ccc|
// and |ddd| are 7-bit selection indices. For a total (1 << 12)
// possibilities.
......@@ -599,8 +568,6 @@ TEST(ReactorUnitTests, Shuffle)
auto routine = function("one");
if(routine)
{
struct
{
float f[kSelectRange][4];
......@@ -635,8 +602,6 @@ TEST(ReactorUnitTests, Shuffle)
EXPECT_EQ(out.u[i][2], unsigned(100 + ((i >> 6) & 7)));
EXPECT_EQ(out.u[i][3], unsigned(100 + ((i >> 9) & 7)));
}
}
}
}
TEST(ReactorUnitTests, Branching)
......@@ -688,12 +653,9 @@ TEST(ReactorUnitTests, Branching)
auto routine = function("one");
if(routine)
{
int result = routine();
EXPECT_EQ(result, 1000402222);
}
}
TEST(ReactorUnitTests, MinMax)
......@@ -720,8 +682,6 @@ TEST(ReactorUnitTests, MinMax)
auto routine = function("one");
if(routine)
{
unsigned int out[10][4];
memset(&out, 0, sizeof(out));
......@@ -777,7 +737,6 @@ TEST(ReactorUnitTests, MinMax)
EXPECT_EQ(out[9][1], 0x0000FFFFu);
EXPECT_EQ(out[9][2], 0x00000000u);
EXPECT_EQ(out[9][3], 0x00000000u);
}
}
TEST(ReactorUnitTests, NotNeg)
......@@ -803,8 +762,6 @@ TEST(ReactorUnitTests, NotNeg)
auto routine = function("one");
if(routine)
{
unsigned int out[10][4];
memset(&out, 0, sizeof(out));
......@@ -855,7 +812,6 @@ TEST(ReactorUnitTests, NotNeg)
EXPECT_EQ(out[8][1], 0x3F800000u);
EXPECT_EQ(out[8][2], 0x80000000u);
EXPECT_EQ(out[8][3], 0x00000000u);
}
}
TEST(ReactorUnitTests, FPtoUI)
......@@ -876,8 +832,6 @@ TEST(ReactorUnitTests, FPtoUI)
auto routine = function("one");
if(routine)
{
unsigned int out[2][4];
memset(&out, 0, sizeof(out));
......@@ -893,7 +847,6 @@ TEST(ReactorUnitTests, FPtoUI)
EXPECT_EQ(out[1][1], 0x80000000u);
EXPECT_EQ(out[1][2], 0x00000000u);
EXPECT_EQ(out[1][3], 0xCCCC0000u);
}
}
TEST(ReactorUnitTests, VectorCompare)
......@@ -915,8 +868,6 @@ TEST(ReactorUnitTests, VectorCompare)
auto routine = function("one");
if(routine)
{
unsigned int out[6][4];
memset(&out, 0, sizeof(out));
......@@ -948,7 +899,6 @@ TEST(ReactorUnitTests, VectorCompare)
EXPECT_EQ(out[5][0], 0x00000000u);
EXPECT_EQ(out[5][1], 0xFFFFFFFFu);
}
}
TEST(ReactorUnitTests, SaturatedAddAndSubtract)
......@@ -1005,8 +955,6 @@ TEST(ReactorUnitTests, SaturatedAddAndSubtract)
auto routine = function("one");
if(routine)
{
unsigned int out[14][2];
memset(&out, 0, sizeof(out));
......@@ -1054,7 +1002,6 @@ TEST(ReactorUnitTests, SaturatedAddAndSubtract)
EXPECT_EQ(out[13][0], 0x00000000u);
EXPECT_EQ(out[13][1], 0x00040002u);
}
}
TEST(ReactorUnitTests, Unpack)
......@@ -1077,8 +1024,6 @@ TEST(ReactorUnitTests, Unpack)
auto routine = function("one");
if(routine)
{
unsigned int in[1][2];
unsigned int out[2][2];
......@@ -1094,7 +1039,6 @@ TEST(ReactorUnitTests, Unpack)
EXPECT_EQ(out[1][0], 0xEFEF1212u);
EXPECT_EQ(out[1][1], 0xABABCDCDu);
}
}
TEST(ReactorUnitTests, Pack)
......@@ -1124,8 +1068,6 @@ TEST(ReactorUnitTests, Pack)
auto routine = function("one");
if(routine)
{
unsigned int out[6][2];
memset(&out, 0, sizeof(out));
......@@ -1149,7 +1091,6 @@ TEST(ReactorUnitTests, Pack)
EXPECT_EQ(out[5][0], 0x00040003u);
EXPECT_EQ(out[5][1], 0x00000000u);
}
}
TEST(ReactorUnitTests, MulHigh)
......@@ -1186,8 +1127,6 @@ TEST(ReactorUnitTests, MulHigh)
auto routine = function("one");
if(routine)
{
unsigned int out[6][4];
memset(&out, 0, sizeof(out));
......@@ -1219,7 +1158,6 @@ TEST(ReactorUnitTests, MulHigh)
EXPECT_EQ(out[5][1], 0x3FFFFFFFu);
EXPECT_EQ(out[5][2], 0x40008000u);
EXPECT_EQ(out[5][3], 0xFFFFFFFEu);
}
}
TEST(ReactorUnitTests, MulAdd)
......@@ -1238,8 +1176,6 @@ TEST(ReactorUnitTests, MulAdd)
auto routine = function("one");
if(routine)
{
unsigned int out[1][2];
memset(&out, 0, sizeof(out));
......@@ -1248,7 +1184,6 @@ TEST(ReactorUnitTests, MulAdd)
EXPECT_EQ(out[0][0], 0x000AE34Au);
EXPECT_EQ(out[0][1], 0x009D5254u);
}
}
TEST(ReactorUnitTests, PointersEqual)
......@@ -1501,12 +1436,9 @@ TEST(ReactorUnitTests, Call_Args4)
auto routine = function("one");
if(routine)
{
int res = routine();
EXPECT_EQ(res, 1 + 2 + 3 + 4);
}
}
}
TEST(ReactorUnitTests, Call_Args5)
......@@ -1528,12 +1460,9 @@ TEST(ReactorUnitTests, Call_Args5)
auto routine = function("one");
if(routine)
{
int res = routine();
EXPECT_EQ(res, 1 + 2 + 3 + 4 + 5);
}
}
}
TEST(ReactorUnitTests, Call_ArgsMany)
......@@ -1555,12 +1484,9 @@ TEST(ReactorUnitTests, Call_ArgsMany)
auto routine = function("one");
if(routine)
{
int res = routine();
EXPECT_EQ(res, 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8);
}
}
}
TEST(ReactorUnitTests, Call_ArgsMixed)
......@@ -1586,12 +1512,9 @@ TEST(ReactorUnitTests, Call_ArgsMixed)
auto routine = function("one");
if(routine)
{
int res = routine();
EXPECT_EQ(res, 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8);
}
}
}
TEST(ReactorUnitTests, Call_ArgsPointer)
......@@ -1614,12 +1537,9 @@ TEST(ReactorUnitTests, Call_ArgsPointer)
auto routine = function("one");
if(routine)
{
int res = routine();
EXPECT_EQ(res, 12345);
}
}
}
TEST(ReactorUnitTests, CallExternalCallRoutine)
......@@ -1781,13 +1701,10 @@ TYPED_TEST(CToReactorTCastTest, Casts)
routine = function("one");
if(routine)
{
auto callable = (int (*)(CType))routine->getEntry();
CType in = {};
EXPECT_EQ(callable(in), 1);
}
}
}
template<typename T>
......@@ -1847,8 +1764,6 @@ TYPED_TEST(GEPTest, PtrOffsets)
routine = function("one");
if(routine)
{
auto callable = (CType * (*)(CType *, unsigned int)) routine->getEntry();
union PtrInt
......@@ -1874,7 +1789,6 @@ TYPED_TEST(GEPTest, PtrOffsets)
EXPECT_EQ(got, expect) << "i:" << i;
}
}
}
}
TEST(ReactorUnitTests, Coroutines_Fibonacci)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment