2012-11-01 16:19:01 +01:00
|
|
|
// Headless version of PPSSPP, for testing using http://code.google.com/p/pspautotests/ .
|
|
|
|
// See headless.txt.
|
|
|
|
// To build on non-windows systems, just run CMake in the SDL directory, it will build both a normal ppsspp and the headless version.
|
|
|
|
|
2013-09-16 08:36:10 -07:00
|
|
|
#include <cstdio>
|
|
|
|
#include <cstdlib>
|
|
|
|
#include <limits>
|
2012-11-01 16:19:01 +01:00
|
|
|
|
2014-03-25 00:49:03 -07:00
|
|
|
#include "file/zip_read.h"
|
2015-05-30 12:53:57 -07:00
|
|
|
#include "profiler/profiler.h"
|
2013-11-17 10:15:49 -08:00
|
|
|
#include "Common/FileUtil.h"
|
2013-02-18 23:25:06 +01:00
|
|
|
#include "Core/Config.h"
|
|
|
|
#include "Core/Core.h"
|
|
|
|
#include "Core/CoreTiming.h"
|
|
|
|
#include "Core/System.h"
|
2013-04-10 22:17:43 -07:00
|
|
|
#include "Core/HLE/sceUtility.h"
|
2013-02-18 23:25:06 +01:00
|
|
|
#include "Core/Host.h"
|
2014-03-25 00:46:21 -07:00
|
|
|
#include "Core/SaveState.h"
|
2012-11-01 16:19:01 +01:00
|
|
|
#include "Log.h"
|
|
|
|
#include "LogManager.h"
|
2013-09-04 12:07:42 +02:00
|
|
|
#include "base/NativeApp.h"
|
|
|
|
#include "input/input_state.h"
|
2013-09-16 08:36:10 -07:00
|
|
|
#include "base/timeutil.h"
|
2012-11-01 16:19:01 +01:00
|
|
|
|
2013-02-08 00:22:37 -08:00
|
|
|
#include "Compare.h"
|
2012-12-29 19:36:03 -08:00
|
|
|
#include "StubHost.h"
|
|
|
|
#ifdef _WIN32
|
|
|
|
#include "WindowsHeadlessHost.h"
|
|
|
|
#endif
|
2012-11-01 16:19:01 +01:00
|
|
|
|
2013-11-02 17:13:17 -07:00
|
|
|
// https://github.com/richq/android-ndk-profiler
|
|
|
|
#ifdef ANDROID_NDK_PROFILER
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include "android/android-ndk-profiler/prof.h"
|
|
|
|
#endif
|
|
|
|
|
2012-11-09 13:40:09 +01:00
|
|
|
class PrintfLogger : public LogListener
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
void Log(LogTypes::LOG_LEVELS level, const char *msg)
|
|
|
|
{
|
|
|
|
switch (level)
|
|
|
|
{
|
2013-03-10 22:31:47 -07:00
|
|
|
case LogTypes::LVERBOSE:
|
|
|
|
fprintf(stderr, "V %s", msg);
|
|
|
|
break;
|
2012-11-09 13:40:09 +01:00
|
|
|
case LogTypes::LDEBUG:
|
2012-12-29 20:49:45 -08:00
|
|
|
fprintf(stderr, "D %s", msg);
|
2012-11-09 13:40:09 +01:00
|
|
|
break;
|
|
|
|
case LogTypes::LINFO:
|
2012-12-29 20:49:45 -08:00
|
|
|
fprintf(stderr, "I %s", msg);
|
2012-11-09 13:40:09 +01:00
|
|
|
break;
|
|
|
|
case LogTypes::LERROR:
|
2012-12-29 20:49:45 -08:00
|
|
|
fprintf(stderr, "E %s", msg);
|
2012-11-09 13:40:09 +01:00
|
|
|
break;
|
|
|
|
case LogTypes::LWARNING:
|
2012-12-29 20:49:45 -08:00
|
|
|
fprintf(stderr, "W %s", msg);
|
2012-11-09 13:40:09 +01:00
|
|
|
break;
|
|
|
|
case LogTypes::LNOTICE:
|
|
|
|
default:
|
2012-12-29 20:49:45 -08:00
|
|
|
fprintf(stderr, "N %s", msg);
|
2012-11-09 13:40:09 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2013-03-29 18:50:08 +01:00
|
|
|
struct InputState;
|
2014-08-17 16:07:14 +02:00
|
|
|
// Temporary hacks around annoying linking errors.
|
|
|
|
void D3D9_SwapBuffers() { }
|
2013-02-18 23:25:06 +01:00
|
|
|
void GL_SwapBuffers() { }
|
2015-09-06 13:36:33 +02:00
|
|
|
void GL_SwapInterval(int) { }
|
2015-10-10 16:41:19 +02:00
|
|
|
void Vulkan_SwapBuffers() {}
|
2013-03-29 22:39:37 -07:00
|
|
|
void NativeUpdate(InputState &input_state) { }
|
2015-12-31 16:59:40 +01:00
|
|
|
void NativeRender(GraphicsContext *graphicsContext) { }
|
2014-02-10 15:14:45 +01:00
|
|
|
void NativeResized() { }
|
2015-02-01 18:04:06 +01:00
|
|
|
void NativeMessageReceived(const char *message, const char *value) {}
|
2013-03-29 22:39:37 -07:00
|
|
|
|
2013-09-04 12:07:42 +02:00
|
|
|
std::string System_GetProperty(SystemProperty prop) { return ""; }
|
2014-07-20 12:11:50 +02:00
|
|
|
int System_GetPropertyInt(SystemProperty prop) { return -1; }
|
2013-12-04 17:41:59 +01:00
|
|
|
void System_SendMessage(const char *command, const char *parameter) {}
|
2013-12-08 12:12:45 +01:00
|
|
|
bool System_InputBoxGetWString(const wchar_t *title, const std::wstring &defaultvalue, std::wstring &outvalue) { return false; }
|
2015-12-17 22:41:50 +01:00
|
|
|
void System_AskForPermission(SystemPermission permission) {}
|
|
|
|
PermissionStatus System_GetPermissionStatus(SystemPermission permission) { return PERMISSION_STATUS_GRANTED; }
|
2013-09-04 12:07:42 +02:00
|
|
|
|
2013-03-29 22:39:37 -07:00
|
|
|
InputState input_state;
|
2013-02-18 23:25:06 +01:00
|
|
|
|
2014-04-19 12:52:43 -07:00
|
|
|
int printUsage(const char *progname, const char *reason)
|
2012-11-01 16:19:01 +01:00
|
|
|
{
|
2012-11-24 21:45:32 -08:00
|
|
|
if (reason != NULL)
|
|
|
|
fprintf(stderr, "Error: %s\n\n", reason);
|
2012-11-01 16:19:01 +01:00
|
|
|
fprintf(stderr, "PPSSPP Headless\n");
|
2012-12-05 23:47:09 -08:00
|
|
|
fprintf(stderr, "This is primarily meant as a non-interactive test tool.\n\n");
|
2013-09-16 23:58:42 -07:00
|
|
|
fprintf(stderr, "Usage: %s file.elf... [options]\n\n", progname);
|
2012-11-24 21:45:32 -08:00
|
|
|
fprintf(stderr, "Options:\n");
|
2014-04-19 12:52:43 -07:00
|
|
|
fprintf(stderr, " -m, --mount umd.cso mount iso on umd1:\n");
|
|
|
|
fprintf(stderr, " -r, --root some/path mount path on host0: (elfs must be in here)\n");
|
2012-11-24 21:45:32 -08:00
|
|
|
fprintf(stderr, " -l, --log full log output, not just emulated printfs\n");
|
2012-12-29 21:01:13 -08:00
|
|
|
|
2014-08-30 09:57:56 -07:00
|
|
|
#if defined(HEADLESSHOST_CLASS)
|
2013-01-13 16:35:34 -08:00
|
|
|
{
|
2013-09-11 21:40:25 -07:00
|
|
|
fprintf(stderr, " --graphics=BACKEND use the full gpu backend (slower)\n");
|
|
|
|
fprintf(stderr, " options: gles, software, directx9\n");
|
2013-01-13 16:35:34 -08:00
|
|
|
fprintf(stderr, " --screenshot=FILE compare against a screenshot\n");
|
|
|
|
}
|
2013-10-14 02:35:29 -07:00
|
|
|
#endif
|
2013-09-16 08:36:10 -07:00
|
|
|
fprintf(stderr, " --timeout=SECONDS abort test it if takes longer than SECONDS\n");
|
2012-12-29 21:01:13 -08:00
|
|
|
|
2013-09-17 00:15:19 -07:00
|
|
|
fprintf(stderr, " -v, --verbose show the full passed/failed result\n");
|
2013-02-09 01:14:39 -08:00
|
|
|
fprintf(stderr, " -i use the interpreter\n");
|
|
|
|
fprintf(stderr, " -j use jit (default)\n");
|
2012-11-24 21:45:32 -08:00
|
|
|
fprintf(stderr, " -c, --compare compare with output in file.expected\n");
|
|
|
|
fprintf(stderr, "\nSee headless.txt for details.\n");
|
2014-04-19 12:52:43 -07:00
|
|
|
|
|
|
|
return 1;
|
2012-11-01 16:19:01 +01:00
|
|
|
}
|
|
|
|
|
2014-08-30 09:57:56 -07:00
|
|
|
static HeadlessHost *getHost(GPUCore gpuCore) {
|
|
|
|
switch (gpuCore) {
|
2016-04-10 10:21:48 +02:00
|
|
|
case GPUCORE_NULL:
|
2013-09-16 09:42:30 +02:00
|
|
|
return new HeadlessHost();
|
2014-08-30 09:57:56 -07:00
|
|
|
#ifdef HEADLESSHOST_CLASS
|
2013-09-16 09:42:30 +02:00
|
|
|
default:
|
|
|
|
return new HEADLESSHOST_CLASS();
|
2014-08-30 09:57:56 -07:00
|
|
|
#else
|
|
|
|
default:
|
|
|
|
return new HeadlessHost();
|
|
|
|
#endif
|
2013-09-16 09:42:30 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-09-17 00:15:19 -07:00
|
|
|
bool RunAutoTest(HeadlessHost *headlessHost, CoreParameter &coreParameter, bool autoCompare, bool verbose, double timeout)
|
2013-09-16 23:49:41 -07:00
|
|
|
{
|
|
|
|
if (teamCityMode) {
|
|
|
|
// Kinda ugly, trying to guesstimate the test name from filename...
|
2013-09-17 00:15:19 -07:00
|
|
|
teamCityName = GetTestName(coreParameter.fileToStart);
|
2013-09-16 23:49:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
std::string output;
|
|
|
|
if (autoCompare)
|
|
|
|
coreParameter.collectEmuLog = &output;
|
|
|
|
|
|
|
|
std::string error_string;
|
|
|
|
if (!PSP_Init(coreParameter, &error_string)) {
|
|
|
|
fprintf(stderr, "Failed to start %s. Error: %s\n", coreParameter.fileToStart.c_str(), error_string.c_str());
|
|
|
|
printf("TESTERROR\n");
|
|
|
|
TeamCityPrint("##teamcity[testIgnored name='%s' message='PRX/ELF missing']\n", teamCityName.c_str());
|
2013-09-18 00:17:30 -07:00
|
|
|
return false;
|
2013-09-16 23:49:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
TeamCityPrint("##teamcity[testStarted name='%s' captureStandardOutput='true']\n", teamCityName.c_str());
|
|
|
|
|
|
|
|
host->BootDone();
|
|
|
|
|
|
|
|
if (autoCompare)
|
|
|
|
headlessHost->SetComparisonScreenshot(ExpectedScreenshotFromFilename(coreParameter.fileToStart));
|
|
|
|
|
|
|
|
time_update();
|
|
|
|
bool passed = true;
|
2013-11-23 10:42:28 -08:00
|
|
|
// TODO: We must have some kind of stack overflow or we're not following the ABI right.
|
|
|
|
// This gets trashed if it's not static.
|
2013-12-06 21:18:26 -08:00
|
|
|
static double deadline;
|
|
|
|
deadline = time_now() + timeout;
|
2013-09-16 23:49:41 -07:00
|
|
|
|
|
|
|
coreState = CORE_RUNNING;
|
|
|
|
while (coreState == CORE_RUNNING)
|
|
|
|
{
|
|
|
|
int blockTicks = usToCycles(1000000 / 10);
|
|
|
|
PSP_RunLoopFor(blockTicks);
|
|
|
|
|
|
|
|
// If we were rendering, this might be a nice time to do something about it.
|
|
|
|
if (coreState == CORE_NEXTFRAME) {
|
|
|
|
coreState = CORE_RUNNING;
|
|
|
|
headlessHost->SwapBuffers();
|
|
|
|
}
|
|
|
|
time_update();
|
|
|
|
if (time_now_d() > deadline) {
|
|
|
|
// Don't compare, print the output at least up to this point, and bail.
|
|
|
|
printf("%s", output.c_str());
|
|
|
|
passed = false;
|
|
|
|
|
|
|
|
host->SendDebugOutput("TIMEOUT\n");
|
|
|
|
TeamCityPrint("##teamcity[testFailed name='%s' message='Test timeout']\n", teamCityName.c_str());
|
|
|
|
Core_Stop();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
PSP_Shutdown();
|
|
|
|
|
|
|
|
headlessHost->FlushDebugOutput();
|
|
|
|
|
|
|
|
if (autoCompare && passed)
|
2013-09-17 00:15:19 -07:00
|
|
|
passed = CompareOutput(coreParameter.fileToStart, output, verbose);
|
2013-09-16 23:49:41 -07:00
|
|
|
|
|
|
|
TeamCityPrint("##teamcity[testFinished name='%s']\n", teamCityName.c_str());
|
|
|
|
|
|
|
|
return passed;
|
|
|
|
}
|
|
|
|
|
2012-11-01 16:19:01 +01:00
|
|
|
int main(int argc, const char* argv[])
|
|
|
|
{
|
2015-05-30 12:53:57 -07:00
|
|
|
PROFILE_INIT();
|
|
|
|
|
2013-11-02 17:13:17 -07:00
|
|
|
#ifdef ANDROID_NDK_PROFILER
|
|
|
|
setenv("CPUPROFILE_FREQUENCY", "500", 1);
|
|
|
|
setenv("CPUPROFILE", "/sdcard/gmon.out", 1);
|
|
|
|
monstartup("ppsspp_headless");
|
|
|
|
#endif
|
|
|
|
|
2012-11-01 16:19:01 +01:00
|
|
|
bool fullLog = false;
|
|
|
|
bool autoCompare = false;
|
2013-09-17 00:15:19 -07:00
|
|
|
bool verbose = false;
|
2014-03-25 00:46:21 -07:00
|
|
|
const char *stateToLoad = 0;
|
2016-04-10 10:21:48 +02:00
|
|
|
GPUCore gpuCore = GPUCORE_NULL;
|
2016-05-08 01:43:27 +02:00
|
|
|
CPUCore cpuCore = CPU_CORE_JIT;
|
2012-11-01 16:19:01 +01:00
|
|
|
|
2013-09-16 23:58:42 -07:00
|
|
|
std::vector<std::string> testFilenames;
|
2012-11-01 16:19:01 +01:00
|
|
|
const char *mountIso = 0;
|
2014-04-19 12:52:43 -07:00
|
|
|
const char *mountRoot = 0;
|
2013-01-13 16:35:34 -08:00
|
|
|
const char *screenshotFilename = 0;
|
2013-09-16 23:17:34 -07:00
|
|
|
float timeout = std::numeric_limits<float>::infinity();
|
2012-11-01 16:19:01 +01:00
|
|
|
|
2012-11-24 21:45:32 -08:00
|
|
|
for (int i = 1; i < argc; i++)
|
2012-11-01 16:19:01 +01:00
|
|
|
{
|
2014-04-19 12:52:43 -07:00
|
|
|
if (!strcmp(argv[i], "-m") || !strcmp(argv[i], "--mount"))
|
2012-11-01 16:19:01 +01:00
|
|
|
{
|
2014-04-19 12:52:43 -07:00
|
|
|
if (++i >= argc)
|
|
|
|
return printUsage(argv[0], "Missing argument after -m");
|
2012-11-01 16:19:01 +01:00
|
|
|
mountIso = argv[i];
|
|
|
|
}
|
2014-04-19 12:52:43 -07:00
|
|
|
else if (!strcmp(argv[i], "-r") || !strcmp(argv[i], "--root"))
|
|
|
|
{
|
|
|
|
if (++i >= argc)
|
|
|
|
return printUsage(argv[0], "Missing argument after -r");
|
|
|
|
mountRoot = argv[i];
|
|
|
|
}
|
2012-11-24 21:45:32 -08:00
|
|
|
else if (!strcmp(argv[i], "-l") || !strcmp(argv[i], "--log"))
|
2012-11-01 16:19:01 +01:00
|
|
|
fullLog = true;
|
2013-02-09 01:14:39 -08:00
|
|
|
else if (!strcmp(argv[i], "-i"))
|
2016-05-08 01:43:27 +02:00
|
|
|
cpuCore = CPU_CORE_INTERPRETER;
|
2012-11-01 16:19:01 +01:00
|
|
|
else if (!strcmp(argv[i], "-j"))
|
2016-05-08 01:43:27 +02:00
|
|
|
cpuCore = CPU_CORE_JIT;
|
|
|
|
else if (!strcmp(argv[i], "-ir"))
|
|
|
|
cpuCore = CPU_CORE_IRJIT;
|
2012-11-24 21:45:32 -08:00
|
|
|
else if (!strcmp(argv[i], "-c") || !strcmp(argv[i], "--compare"))
|
2012-11-01 16:19:01 +01:00
|
|
|
autoCompare = true;
|
2013-09-17 00:15:19 -07:00
|
|
|
else if (!strcmp(argv[i], "-v") || !strcmp(argv[i], "--verbose"))
|
|
|
|
verbose = true;
|
2013-09-11 21:40:25 -07:00
|
|
|
else if (!strncmp(argv[i], "--graphics=", strlen("--graphics=")) && strlen(argv[i]) > strlen("--graphics="))
|
|
|
|
{
|
|
|
|
const char *gpuName = argv[i] + strlen("--graphics=");
|
|
|
|
if (!strcasecmp(gpuName, "gles"))
|
2016-04-10 10:21:48 +02:00
|
|
|
gpuCore = GPUCORE_GLES;
|
2013-09-11 21:40:25 -07:00
|
|
|
else if (!strcasecmp(gpuName, "software"))
|
2016-04-10 10:21:48 +02:00
|
|
|
gpuCore = GPUCORE_SOFTWARE;
|
2013-09-11 21:40:25 -07:00
|
|
|
else if (!strcasecmp(gpuName, "directx9"))
|
2016-04-10 10:21:48 +02:00
|
|
|
gpuCore = GPUCORE_DIRECTX9;
|
2016-03-13 11:23:46 -07:00
|
|
|
else if (!strcasecmp(gpuName, "vulkan"))
|
2016-04-10 10:21:48 +02:00
|
|
|
gpuCore = GPUCORE_VULKAN;
|
2013-09-11 21:40:25 -07:00
|
|
|
else if (!strcasecmp(gpuName, "null"))
|
2016-04-10 10:21:48 +02:00
|
|
|
gpuCore = GPUCORE_NULL;
|
2013-09-11 21:40:25 -07:00
|
|
|
else
|
2014-04-19 12:52:43 -07:00
|
|
|
return printUsage(argv[0], "Unknown gpu backend specified after --graphics=");
|
2013-09-11 21:40:25 -07:00
|
|
|
}
|
|
|
|
// Default to GLES if no value selected.
|
2012-12-29 21:01:13 -08:00
|
|
|
else if (!strcmp(argv[i], "--graphics"))
|
2016-04-10 10:21:48 +02:00
|
|
|
gpuCore = GPUCORE_GLES;
|
2013-01-13 16:35:34 -08:00
|
|
|
else if (!strncmp(argv[i], "--screenshot=", strlen("--screenshot=")) && strlen(argv[i]) > strlen("--screenshot="))
|
|
|
|
screenshotFilename = argv[i] + strlen("--screenshot=");
|
2013-09-16 08:36:10 -07:00
|
|
|
else if (!strncmp(argv[i], "--timeout=", strlen("--timeout=")) && strlen(argv[i]) > strlen("--timeout="))
|
|
|
|
timeout = strtod(argv[i] + strlen("--timeout="), NULL);
|
2013-09-16 08:15:59 -07:00
|
|
|
else if (!strcmp(argv[i], "--teamcity"))
|
|
|
|
teamCityMode = true;
|
2014-03-25 00:46:21 -07:00
|
|
|
else if (!strncmp(argv[i], "--state=", strlen("--state=")) && strlen(argv[i]) > strlen("--state="))
|
|
|
|
stateToLoad = argv[i] + strlen("--state=");
|
2013-09-16 23:58:42 -07:00
|
|
|
else if (!strcmp(argv[i], "--help") || !strcmp(argv[i], "-h"))
|
2014-04-19 12:52:43 -07:00
|
|
|
return printUsage(argv[0], NULL);
|
2013-09-16 23:58:42 -07:00
|
|
|
else
|
|
|
|
testFilenames.push_back(argv[i]);
|
2012-11-01 16:19:01 +01:00
|
|
|
}
|
|
|
|
|
2013-09-18 00:17:30 -07:00
|
|
|
// TODO: Allow a filename here?
|
|
|
|
if (testFilenames.size() == 1 && testFilenames[0] == "@-")
|
|
|
|
{
|
|
|
|
testFilenames.clear();
|
|
|
|
char temp[2048];
|
|
|
|
temp[2047] = '\0';
|
|
|
|
|
|
|
|
while (scanf("%2047s", temp) == 1)
|
|
|
|
testFilenames.push_back(temp);
|
|
|
|
}
|
|
|
|
|
2013-09-16 23:58:42 -07:00
|
|
|
if (testFilenames.empty())
|
2014-04-19 12:52:43 -07:00
|
|
|
return printUsage(argv[0], argc <= 1 ? NULL : "No executables specified");
|
2012-11-01 16:19:01 +01:00
|
|
|
|
2013-09-16 09:42:30 +02:00
|
|
|
HeadlessHost *headlessHost = getHost(gpuCore);
|
2016-03-13 11:23:46 -07:00
|
|
|
headlessHost->SetGraphicsCore(gpuCore);
|
2012-12-29 19:36:03 -08:00
|
|
|
host = headlessHost;
|
2013-03-10 23:08:57 +01:00
|
|
|
|
|
|
|
std::string error_string;
|
2015-12-31 16:59:40 +01:00
|
|
|
GraphicsContext *graphicsContext;
|
|
|
|
bool glWorking = host->InitGraphics(&error_string, &graphicsContext);
|
2012-11-01 16:19:01 +01:00
|
|
|
|
|
|
|
LogManager::Init();
|
|
|
|
LogManager *logman = LogManager::GetInstance();
|
|
|
|
|
2012-11-09 13:40:09 +01:00
|
|
|
PrintfLogger *printfLogger = new PrintfLogger();
|
|
|
|
|
2015-12-31 16:59:40 +01:00
|
|
|
for (int i = 0; i < LogTypes::NUMBER_OF_LOGS; i++) {
|
2012-11-01 16:19:01 +01:00
|
|
|
LogTypes::LOG_TYPE type = (LogTypes::LOG_TYPE)i;
|
|
|
|
logman->SetEnable(type, fullLog);
|
|
|
|
logman->SetLogLevel(type, LogTypes::LDEBUG);
|
2012-11-09 13:40:09 +01:00
|
|
|
logman->AddListener(type, printfLogger);
|
2012-11-01 16:19:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
CoreParameter coreParameter;
|
2016-05-08 01:43:27 +02:00
|
|
|
coreParameter.cpuCore = cpuCore;
|
2016-04-10 10:21:48 +02:00
|
|
|
coreParameter.gpuCore = glWorking ? gpuCore : GPUCORE_NULL;
|
2016-01-03 11:05:36 -08:00
|
|
|
coreParameter.graphicsContext = graphicsContext;
|
2012-11-01 16:19:01 +01:00
|
|
|
coreParameter.enableSound = false;
|
2013-04-10 22:17:43 -07:00
|
|
|
coreParameter.mountIso = mountIso ? mountIso : "";
|
2014-04-19 12:52:43 -07:00
|
|
|
coreParameter.mountRoot = mountRoot ? mountRoot : "";
|
2013-04-10 22:17:43 -07:00
|
|
|
coreParameter.startPaused = false;
|
2013-09-16 08:15:59 -07:00
|
|
|
coreParameter.printfEmuLog = !autoCompare;
|
2013-04-10 22:17:43 -07:00
|
|
|
coreParameter.headLess = true;
|
|
|
|
coreParameter.renderWidth = 480;
|
|
|
|
coreParameter.renderHeight = 272;
|
|
|
|
coreParameter.pixelWidth = 480;
|
|
|
|
coreParameter.pixelHeight = 272;
|
2013-05-20 08:28:07 -07:00
|
|
|
coreParameter.unthrottle = true;
|
2012-11-01 16:19:01 +01:00
|
|
|
|
2012-11-17 18:08:10 +01:00
|
|
|
g_Config.bEnableSound = false;
|
2012-11-05 13:36:12 +01:00
|
|
|
g_Config.bFirstRun = false;
|
|
|
|
g_Config.bIgnoreBadMemAccess = true;
|
2013-03-09 12:53:53 -08:00
|
|
|
// Never report from tests.
|
|
|
|
g_Config.sReportHost = "";
|
2013-04-10 22:17:43 -07:00
|
|
|
g_Config.bAutoSaveSymbolMap = false;
|
2014-06-14 08:44:14 -07:00
|
|
|
g_Config.iRenderingMode = 1;
|
2013-04-10 22:17:43 -07:00
|
|
|
g_Config.bHardwareTransform = true;
|
|
|
|
#ifdef USING_GLES2
|
|
|
|
g_Config.iAnisotropyLevel = 0;
|
|
|
|
#else
|
2016-03-17 21:56:04 -07:00
|
|
|
g_Config.iAnisotropyLevel = 4;
|
2013-04-10 22:17:43 -07:00
|
|
|
#endif
|
|
|
|
g_Config.bVertexCache = true;
|
|
|
|
g_Config.bTrueColor = true;
|
2013-09-16 18:08:09 -04:00
|
|
|
g_Config.iLanguage = PSP_SYSTEMPARAM_LANGUAGE_ENGLISH;
|
2013-06-19 13:08:29 +08:00
|
|
|
g_Config.iTimeFormat = PSP_SYSTEMPARAM_TIME_FORMAT_24HR;
|
2013-04-10 22:17:43 -07:00
|
|
|
g_Config.bEncryptSave = true;
|
2013-04-20 09:30:46 -07:00
|
|
|
g_Config.sNickName = "shadow";
|
|
|
|
g_Config.iTimeZone = 60;
|
|
|
|
g_Config.iDateFormat = PSP_SYSTEMPARAM_DATE_FORMAT_DDMMYYYY;
|
2013-06-19 13:08:29 +08:00
|
|
|
g_Config.iButtonPreference = PSP_SYSTEMPARAM_BUTTON_CROSS;
|
2013-04-20 09:30:46 -07:00
|
|
|
g_Config.iLockParentalLevel = 9;
|
2013-09-11 21:40:25 -07:00
|
|
|
g_Config.iInternalResolution = 1;
|
2013-09-19 00:29:19 -07:00
|
|
|
g_Config.bFrameSkipUnthrottle = false;
|
2013-11-17 10:15:13 -08:00
|
|
|
g_Config.bEnableLogging = fullLog;
|
2013-12-15 09:36:41 -08:00
|
|
|
g_Config.iNumWorkerThreads = 1;
|
2014-03-25 00:46:21 -07:00
|
|
|
g_Config.bSoftwareSkinning = true;
|
|
|
|
g_Config.bVertexDecoderJit = true;
|
2014-06-14 08:44:14 -07:00
|
|
|
g_Config.bBlockTransferGPU = true;
|
2016-04-09 21:10:41 -07:00
|
|
|
g_Config.iSplineBezierQuality = 2;
|
2012-11-05 13:36:12 +01:00
|
|
|
|
2013-10-25 11:45:41 +02:00
|
|
|
#ifdef _WIN32
|
2013-10-24 21:29:48 -07:00
|
|
|
InitSysDirectories();
|
2013-10-25 11:45:41 +02:00
|
|
|
#endif
|
|
|
|
|
2013-01-21 01:50:42 +01:00
|
|
|
#if defined(ANDROID)
|
|
|
|
#elif defined(BLACKBERRY) || defined(__SYMBIAN32__)
|
2013-01-21 22:46:53 -08:00
|
|
|
#elif !defined(_WIN32)
|
2014-10-19 23:20:51 +02:00
|
|
|
g_Config.memStickDirectory = std::string(getenv("HOME")) + "/.ppsspp/";
|
2013-01-21 01:50:42 +01:00
|
|
|
#endif
|
|
|
|
|
2013-11-17 10:15:49 -08:00
|
|
|
// Try to find the flash0 directory. Often this is from a subdirectory.
|
|
|
|
for (int i = 0; i < 3; ++i)
|
|
|
|
{
|
|
|
|
if (!File::Exists(g_Config.flash0Directory))
|
|
|
|
g_Config.flash0Directory += "../../flash0/";
|
|
|
|
}
|
|
|
|
// Or else, maybe in the executable's dir.
|
|
|
|
if (!File::Exists(g_Config.flash0Directory))
|
|
|
|
g_Config.flash0Directory = File::GetExeDirectory() + "flash0/";
|
|
|
|
|
2013-01-13 16:35:34 -08:00
|
|
|
if (screenshotFilename != 0)
|
|
|
|
headlessHost->SetComparisonScreenshot(screenshotFilename);
|
|
|
|
|
2014-03-25 00:49:03 -07:00
|
|
|
#ifdef ANDROID
|
|
|
|
// For some reason the debugger installs it with this name?
|
|
|
|
if (File::Exists("/data/app/org.ppsspp.ppsspp-2.apk")) {
|
|
|
|
VFSRegister("", new ZipAssetReader("/data/app/org.ppsspp.ppsspp-2.apk", "assets/"));
|
|
|
|
}
|
|
|
|
if (File::Exists("/data/app/org.ppsspp.ppsspp.apk")) {
|
|
|
|
VFSRegister("", new ZipAssetReader("/data/app/org.ppsspp.ppsspp.apk", "assets/"));
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2014-03-25 00:46:21 -07:00
|
|
|
if (stateToLoad != NULL)
|
|
|
|
SaveState::Load(stateToLoad);
|
|
|
|
|
2013-09-17 00:02:53 -07:00
|
|
|
std::vector<std::string> failedTests;
|
|
|
|
std::vector<std::string> passedTests;
|
2013-09-16 23:58:42 -07:00
|
|
|
for (size_t i = 0; i < testFilenames.size(); ++i)
|
|
|
|
{
|
|
|
|
coreParameter.fileToStart = testFilenames[i];
|
|
|
|
if (autoCompare)
|
|
|
|
printf("%s:\n", coreParameter.fileToStart.c_str());
|
2013-09-17 00:15:19 -07:00
|
|
|
bool passed = RunAutoTest(headlessHost, coreParameter, autoCompare, verbose, timeout);
|
2013-09-17 00:02:53 -07:00
|
|
|
if (autoCompare)
|
|
|
|
{
|
2013-09-17 00:15:19 -07:00
|
|
|
std::string testName = GetTestName(coreParameter.fileToStart);
|
2013-09-17 00:02:53 -07:00
|
|
|
if (passed)
|
|
|
|
{
|
|
|
|
passedTests.push_back(testName);
|
|
|
|
printf(" %s - passed!\n", testName.c_str());
|
|
|
|
}
|
|
|
|
else
|
|
|
|
failedTests.push_back(testName);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (autoCompare)
|
|
|
|
{
|
|
|
|
printf("%d tests passed, %d tests failed.\n", (int)passedTests.size(), (int)failedTests.size());
|
|
|
|
if (!failedTests.empty())
|
|
|
|
{
|
|
|
|
printf("Failed tests:\n");
|
2013-09-19 00:29:19 -07:00
|
|
|
for (size_t i = 0; i < failedTests.size(); ++i) {
|
2013-09-17 08:12:39 -07:00
|
|
|
printf(" %s\n", failedTests[i].c_str());
|
2013-09-17 00:02:53 -07:00
|
|
|
}
|
|
|
|
}
|
2013-09-16 23:58:42 -07:00
|
|
|
}
|
|
|
|
|
2014-09-20 21:55:58 +02:00
|
|
|
host->ShutdownGraphics();
|
2013-09-16 23:58:42 -07:00
|
|
|
delete host;
|
|
|
|
host = NULL;
|
|
|
|
headlessHost = NULL;
|
2012-11-01 16:19:01 +01:00
|
|
|
|
2013-11-02 17:13:17 -07:00
|
|
|
#ifdef ANDROID_NDK_PROFILER
|
|
|
|
moncleanup();
|
|
|
|
#endif
|
|
|
|
|
2012-11-01 16:19:01 +01:00
|
|
|
return 0;
|
|
|
|
}
|