146 lines
3.2 KiB
C++
146 lines
3.2 KiB
C++
// ----------------------------------------------------------------------------
|
|
// Main function for executing all unit tests
|
|
// ----------------------------------------------------------------------------
|
|
#ifdef ITF_WINDOWS
|
|
#include <tchar.h>
|
|
#endif // ITF_WINDOWS
|
|
|
|
#include "gmock/gmock.h"
|
|
#include "gtest/gtest.h"
|
|
|
|
#include "precompiled_core.h"
|
|
|
|
#include <ubiservices/ubiservices.h>
|
|
|
|
#ifdef ITF_ORBIS
|
|
|
|
#include "core/memory/memory_orbis.h"
|
|
|
|
// Be sure to first initialize the custom system heap before any allocation (ie. any global)
|
|
namespace ITF
|
|
{
|
|
class MemoryHeapInitializer
|
|
{
|
|
public:
|
|
MemoryHeapInitializer()
|
|
{
|
|
bool ret = createSystemHeap();
|
|
ITF_UNUSED(ret);
|
|
ITF_ASSERT_CRASH(ret, "FATAL ERROR: Could not create system heap!");
|
|
}
|
|
|
|
~MemoryHeapInitializer()
|
|
{
|
|
destroySystemHeap();
|
|
}
|
|
};
|
|
static MemoryHeapInitializer g_firstCalledMemoryHeapInitializer __attribute__((init_priority (200)));
|
|
}
|
|
|
|
size_t sceLibcHeapSize = SCE_LIBC_HEAP_SIZE_EXTENDED_ALLOC_NO_LIMIT;
|
|
unsigned int sceLibcHeapExtendedAlloc = 1;
|
|
|
|
#endif // ITF_ORBIS
|
|
|
|
#if defined(ITF_NX)
|
|
|
|
#include <nn/nn_Log.h>
|
|
|
|
#include "core/memory/memory_nx.h"
|
|
|
|
#ifdef ITF_NX_PROFILER
|
|
bool _ENABLE_GPU_PROFILE = false;
|
|
#endif // ITF_NX_PROFILER
|
|
|
|
extern "C" void nninitStartup()
|
|
{
|
|
/* NO C++ Initializers have been run yet here */
|
|
|
|
NN_LOG("********** nninitStartup **********\n");
|
|
|
|
ITF::CreateMemoryManager();
|
|
}
|
|
#endif // ITF_NX
|
|
|
|
#ifdef ITF_PROSPERO
|
|
|
|
#include "core/memory/memory_Prospero.h"
|
|
|
|
// Be sure to first initialize the custom system heap before any allocation (ie. any global)
|
|
namespace ITF
|
|
{
|
|
class MemoryHeapInitializer
|
|
{
|
|
public:
|
|
MemoryHeapInitializer()
|
|
{
|
|
bool ret = createSystemHeap();
|
|
ITF_UNUSED(ret);
|
|
ITF_ASSERT_CRASH(ret, "FATAL ERROR: Could not create system heap!");
|
|
}
|
|
|
|
~MemoryHeapInitializer()
|
|
{
|
|
destroySystemHeap();
|
|
}
|
|
};
|
|
static MemoryHeapInitializer g_firstCalledMemoryHeapInitializer __attribute__((init_priority(200)));
|
|
}
|
|
|
|
size_t sceLibcHeapSize = SCE_LIBC_HEAP_SIZE_EXTENDED_ALLOC_NO_LIMIT;
|
|
unsigned int sceLibcHeapExtendedAlloc = 1;
|
|
|
|
#endif // ITF_PROSPERO
|
|
|
|
namespace ITF
|
|
{
|
|
void InitializeUAF()
|
|
{
|
|
ThreadInfo::registerThreadEngineIndex(eThreadId_mainThread, Thread::getCurrentThreadId());
|
|
|
|
// display alert window when there is an assert
|
|
AssertManager::enableAsserts();
|
|
}
|
|
}
|
|
|
|
namespace
|
|
{
|
|
// Independent-platform main
|
|
template<typename T>
|
|
int commonMain(int argc, T *argv[])
|
|
{
|
|
::testing::InitGoogleMock(&argc, argv);
|
|
|
|
// Initialize the internal memory library of UbiServices
|
|
ubiservices::initializeSdk();
|
|
|
|
ITF::InitializeUAF();
|
|
|
|
int results = RUN_ALL_TESTS();
|
|
return results;
|
|
}
|
|
}
|
|
|
|
// Handle all platforms
|
|
#ifdef ITF_WINDOWS
|
|
|
|
int _tmain(int argc, _TCHAR * argv[])
|
|
{
|
|
return commonMain(argc, argv);
|
|
}
|
|
|
|
#elif defined(ITF_ORBIS) || defined(ITF_GGP) || defined(ITF_PROSPERO)
|
|
|
|
int main(int argc, char *argv[])
|
|
{
|
|
return commonMain(argc, argv);
|
|
}
|
|
|
|
#elif defined(ITF_NX)
|
|
|
|
extern "C" void nnMain()
|
|
{
|
|
commonMain(nn::os::GetHostArgc(), nn::os::GetHostArgv());
|
|
}
|
|
|
|
#endif // ITF_WINDOWS
|