1
0

Merge pull request #3281 from cuberite/FixRasPiBuild

Fixed RasPi builds of unit tests.
This commit is contained in:
Mattes D 2016-08-04 21:04:03 +02:00 committed by GitHub
commit ad9fc17673
15 changed files with 97 additions and 44 deletions

View File

@ -1703,42 +1703,42 @@ bool cLuaState::CopyTableFrom(cLuaState & a_SrcLuaState, int a_SrcStackIdx, int
lua_pushnil(a_SrcLuaState); // SRC: <table> <key> lua_pushnil(a_SrcLuaState); // SRC: <table> <key>
while (lua_next(a_SrcLuaState, -2) != 0) // SRC: <table> <key> <value> while (lua_next(a_SrcLuaState, -2) != 0) // SRC: <table> <key> <value>
{ {
assert(lua_gettop(a_SrcLuaState) == srcTop + 3); ASSERT(lua_gettop(a_SrcLuaState) == srcTop + 3);
assert(lua_gettop(m_LuaState) == dstTop + 1); ASSERT(lua_gettop(m_LuaState) == dstTop + 1);
// Copy the key: // Copy the key:
if (!CopySingleValueFrom(a_SrcLuaState, -2, a_NumAllowedNestingLevels)) // DST: <table> <key> if (!CopySingleValueFrom(a_SrcLuaState, -2, a_NumAllowedNestingLevels)) // DST: <table> <key>
{ {
lua_pop(m_LuaState, 1); lua_pop(m_LuaState, 1);
lua_pop(a_SrcLuaState, 3); lua_pop(a_SrcLuaState, 3);
assert(lua_gettop(a_SrcLuaState) == srcTop); ASSERT(lua_gettop(a_SrcLuaState) == srcTop);
assert(lua_gettop(m_LuaState) == dstTop); ASSERT(lua_gettop(m_LuaState) == dstTop);
return false; return false;
} }
assert(lua_gettop(a_SrcLuaState) == srcTop + 3); ASSERT(lua_gettop(a_SrcLuaState) == srcTop + 3);
assert(lua_gettop(m_LuaState) == dstTop + 2); ASSERT(lua_gettop(m_LuaState) == dstTop + 2);
// Copy the value: // Copy the value:
if (!CopySingleValueFrom(a_SrcLuaState, -1, a_NumAllowedNestingLevels - 1)) // DST: <table> <key> <value> if (!CopySingleValueFrom(a_SrcLuaState, -1, a_NumAllowedNestingLevels - 1)) // DST: <table> <key> <value>
{ {
lua_pop(m_LuaState, 2); // DST: empty lua_pop(m_LuaState, 2); // DST: empty
lua_pop(a_SrcLuaState, 3); // SRC: empty lua_pop(a_SrcLuaState, 3); // SRC: empty
assert(lua_gettop(a_SrcLuaState) == srcTop); ASSERT(lua_gettop(a_SrcLuaState) == srcTop);
assert(lua_gettop(m_LuaState) == dstTop); ASSERT(lua_gettop(m_LuaState) == dstTop);
return false; return false;
} }
assert(lua_gettop(a_SrcLuaState) == srcTop + 3); ASSERT(lua_gettop(a_SrcLuaState) == srcTop + 3);
assert(lua_gettop(m_LuaState) == dstTop + 3); ASSERT(lua_gettop(m_LuaState) == dstTop + 3);
// Set the value and fix up stacks: // Set the value and fix up stacks:
lua_rawset(m_LuaState, -3); // DST: <table> lua_rawset(m_LuaState, -3); // DST: <table>
lua_pop(a_SrcLuaState, 1); // SRC: <table> <key> lua_pop(a_SrcLuaState, 1); // SRC: <table> <key>
assert(lua_gettop(a_SrcLuaState) == srcTop + 2); ASSERT(lua_gettop(a_SrcLuaState) == srcTop + 2);
assert(lua_gettop(m_LuaState) == dstTop + 1); ASSERT(lua_gettop(m_LuaState) == dstTop + 1);
} }
lua_pop(a_SrcLuaState, 1); // SRC: empty lua_pop(a_SrcLuaState, 1); // SRC: empty
assert(lua_gettop(a_SrcLuaState) == srcTop); ASSERT(lua_gettop(a_SrcLuaState) == srcTop);
assert(lua_gettop(m_LuaState) == dstTop + 1); ASSERT(lua_gettop(m_LuaState) == dstTop + 1);
return true; return true;
} }

View File

@ -256,8 +256,7 @@ public:
{ {
if (m_LuaState != nullptr) if (m_LuaState != nullptr)
{ {
auto top = lua_gettop(m_LuaState); ASSERT(m_StackLen == lua_gettop(m_LuaState));
ASSERT(m_StackLen == top);
lua_pop(m_LuaState, 1); lua_pop(m_LuaState, 1);
} }
} }

View File

@ -392,7 +392,9 @@ AString DamageTypeToString(eDamageType a_DamageType)
// Unknown damage type: // Unknown damage type:
ASSERT(!"Unknown DamageType"); ASSERT(!"Unknown DamageType");
return Printf("dtUnknown_%d", static_cast<int>(a_DamageType)); #ifndef __clang__
return Printf("dtUnknown_%d", static_cast<int>(a_DamageType));
#endif
} }

View File

@ -135,7 +135,9 @@ bool cByteBuffer::Write(const void * a_Bytes, size_t a_Count)
// Store the current free space for a check after writing: // Store the current free space for a check after writing:
size_t CurFreeSpace = GetFreeSpace(); size_t CurFreeSpace = GetFreeSpace();
size_t CurReadableSpace = GetReadableSpace(); #ifdef _DEBUG
size_t CurReadableSpace = GetReadableSpace();
#endif
size_t WrittenBytes = 0; size_t WrittenBytes = 0;
if (CurFreeSpace < a_Count) if (CurFreeSpace < a_Count)

View File

@ -238,7 +238,9 @@ AString cClientHandle::FormatMessageType(bool ShouldAppendChatPrefixes, eMessage
} }
} }
ASSERT(!"Unhandled chat prefix type!"); ASSERT(!"Unhandled chat prefix type!");
return ""; #ifndef __clang__
return "";
#endif
} }

View File

@ -284,7 +284,9 @@ cLogger::eLogLevel cCompositeChat::MessageTypeToLogLevel(eMessageType a_MessageT
case mtLeave: return cLogger::llRegular; case mtLeave: return cLogger::llRegular;
} }
ASSERT(!"Unhandled MessageType"); ASSERT(!"Unhandled MessageType");
return cLogger::llError; #ifndef __clang__
return cLogger::llError;
#endif
} }

View File

@ -203,7 +203,7 @@ enum eMobHeadRotation
inline const char * ClickActionToString(eClickAction a_ClickAction) inline const char * ClickActionToString(int a_ClickAction)
{ {
switch (a_ClickAction) switch (a_ClickAction)
{ {

View File

@ -67,7 +67,9 @@ bool cArrowEntity::CanPickup(const cPlayer & a_Player) const
case psInCreative: return a_Player.IsGameModeCreative(); case psInCreative: return a_Player.IsGameModeCreative();
} }
ASSERT(!"Unhandled pickup state"); ASSERT(!"Unhandled pickup state");
return false; #ifndef __clang__
return false;
#endif
} }

View File

@ -741,7 +741,9 @@ bool cEntity::ArmorCoversAgainst(eDamageType a_DamageType)
} }
} }
ASSERT(!"Invalid damage type!"); ASSERT(!"Invalid damage type!");
return false; #ifndef __clang__
return false;
#endif
} }

View File

@ -217,7 +217,9 @@ cEntityEffect * cEntityEffect::CreateEntityEffect(cEntityEffect::eType a_EffectT
} }
ASSERT(!"Unhandled entity effect type!"); ASSERT(!"Unhandled entity effect type!");
return nullptr; #ifndef __clang__
return nullptr;
#endif
} }

View File

@ -357,7 +357,9 @@ AString cProjectileEntity::GetMCAClassName(void) const
case pkFishingFloat: return ""; // Unknown, perhaps MC doesn't save this? case pkFishingFloat: return ""; // Unknown, perhaps MC doesn't save this?
} }
ASSERT(!"Unhandled projectile entity kind!"); ASSERT(!"Unhandled projectile entity kind!");
return ""; #ifndef __clang__
return "";
#endif
} }

View File

@ -370,15 +370,22 @@ template class SizeChecker<UInt8, 1>;
fflush(stdout); \ fflush(stdout); \
} }
#endif #endif
#define ASSERT(x) do { if (!(x)) { throw cAssertFailure();} } while (0)
#define testassert(x) do { if (!(x)) { REPORT_ERROR("Test failure: %s, file %s, line %d\n", #x, __FILE__, __LINE__); exit(1); } } while (0) #ifdef _DEBUG
#define CheckAsserts(x) do { try {x} catch (cAssertFailure) { break; } REPORT_ERROR("Test failure: assert didn't fire for %s, file %s, line %d\n", #x, __FILE__, __LINE__); exit(1); } while (0) #define ASSERT(x) do { if (!(x)) { throw cAssertFailure();} } while (0)
#define testassert(x) do { if (!(x)) { REPORT_ERROR("Test failure: %s, file %s, line %d\n", #x, __FILE__, __LINE__); exit(1); } } while (0)
#define CheckAsserts(x) do { try {x} catch (cAssertFailure) { break; } REPORT_ERROR("Test failure: assert didn't fire for %s, file %s, line %d\n", #x, __FILE__, __LINE__); exit(1); } while (0)
#else
#define ASSERT(...)
#define testassert(...)
#define CheckAsserts(...) LOG("Assert checking is disabled in Release-mode executables (file %s, line %d)", __FILE__, __LINE__)
#endif
#else #else
#ifdef _DEBUG #ifdef _DEBUG
#define ASSERT( x) ( !!(x) || ( LOGERROR("Assertion failed: %s, file %s, line %i", #x, __FILE__, __LINE__), PrintStackTrace(), assert(0), 0)) #define ASSERT(x) ( !!(x) || ( LOGERROR("Assertion failed: %s, file %s, line %i", #x, __FILE__, __LINE__), PrintStackTrace(), assert(0), 0))
#else #else
#define ASSERT(x) ((void)(x)) #define ASSERT(x)
#endif #endif
#endif #endif

View File

@ -405,7 +405,9 @@ bool cNameValueParser::Finish(void)
} }
} }
ASSERT(!"Unhandled parser state!"); ASSERT(!"Unhandled parser state!");
return false; #ifndef __clang__
return false;
#endif
} }

View File

@ -118,7 +118,9 @@ template <typename TYPE> void LinearUpscale2DArray(
// Interpolate each XY cell: // Interpolate each XY cell:
int DstSizeX = (a_SrcSizeX - 1) * a_UpscaleX + 1; int DstSizeX = (a_SrcSizeX - 1) * a_UpscaleX + 1;
int DstSizeY = (a_SrcSizeY - 1) * a_UpscaleY + 1; #ifdef _DEBUG
int DstSizeY = (a_SrcSizeY - 1) * a_UpscaleY + 1;
#endif
for (int y = 0; y < (a_SrcSizeY - 1); y++) for (int y = 0; y < (a_SrcSizeY - 1); y++)
{ {
int DstY = y * a_UpscaleY; int DstY = y * a_UpscaleY;
@ -198,7 +200,9 @@ template <typename TYPE> void LinearUpscale3DArray(
// Interpolate each XYZ cell: // Interpolate each XYZ cell:
int DstSizeX = (a_SrcSizeX - 1) * a_UpscaleX + 1; int DstSizeX = (a_SrcSizeX - 1) * a_UpscaleX + 1;
int DstSizeY = (a_SrcSizeY - 1) * a_UpscaleY + 1; int DstSizeY = (a_SrcSizeY - 1) * a_UpscaleY + 1;
int DstSizeZ = (a_SrcSizeZ - 1) * a_UpscaleZ + 1; #ifdef _DEBUG
int DstSizeZ = (a_SrcSizeZ - 1) * a_UpscaleZ + 1;
#endif
for (int z = 0; z < (a_SrcSizeZ - 1); z++) for (int z = 0; z < (a_SrcSizeZ - 1); z++)
{ {
int DstZ = z * a_UpscaleZ; int DstZ = z * a_UpscaleZ;

View File

@ -53,20 +53,45 @@ private:
struct sValue struct sValue
{ {
sValue(AString value) : m_Type(eType::String), m_stringValue (value) {} sValue(AString value):
sValue(Int64 value) : m_Type(eType::Int64), m_intValue(value) {} #ifdef _DEBUG
sValue(bool value) : m_Type(eType::Bool), m_boolValue(value) {} m_Type(eType::String),
#endif
m_stringValue (value)
{
}
sValue(Int64 value):
#ifdef _DEBUG
m_Type(eType::Int64),
#endif
m_intValue(value)
{
}
sValue(bool value):
#ifdef _DEBUG
m_Type(eType::Bool),
#endif
m_boolValue(value)
{
}
AString getStringValue() const { ASSERT(m_Type == eType::String); return m_stringValue; } AString getStringValue() const { ASSERT(m_Type == eType::String); return m_stringValue; }
Int64 getIntValue() const { ASSERT(m_Type == eType::Int64); return m_intValue; } Int64 getIntValue() const { ASSERT(m_Type == eType::Int64); return m_intValue; }
bool getBoolValue() const { ASSERT(m_Type == eType::Bool); return m_boolValue; } bool getBoolValue() const { ASSERT(m_Type == eType::Bool); return m_boolValue; }
private:
enum class eType private:
{
String, #ifdef _DEBUG
Int64, enum class eType
Bool {
} m_Type; String,
Int64,
Bool
} m_Type;
#endif
AString m_stringValue; AString m_stringValue;
union union
{ {