diff --git a/Common/Common.vcxproj b/Common/Common.vcxproj index 4c8a256ba4..b722d52fb0 100644 --- a/Common/Common.vcxproj +++ b/Common/Common.vcxproj @@ -140,12 +140,7 @@ - - true - true - true - true - + @@ -195,12 +190,7 @@ true true - - true - true - true - true - + diff --git a/Windows/PPSSPP.sln b/Windows/PPSSPP.sln index 4a53f1e91e..6f2586afda 100644 --- a/Windows/PPSSPP.sln +++ b/Windows/PPSSPP.sln @@ -1,5 +1,5 @@ -Microsoft Visual Studio Solution File, Format Version 11.00 -# Visual Studio Express 2012 for Windows Desktop +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2012 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PPSSPPWindows", "PPSSPP.vcxproj", "{567AF8DB-42C1-4D08-96CD-D70A2DFEFC6B}" ProjectSection(ProjectDependencies) = postProject {533F1D30-D04D-47CC-AD71-20F658907E36} = {533F1D30-D04D-47CC-AD71-20F658907E36} @@ -40,6 +40,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PPSSPPHeadless", "..\headle EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libkirk", "..\ext\libkirk\libkirk.vcxproj", "{3BAAE095-E0AB-4B0E-B5DF-CE39C8AE31DE}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "UnitTest", "..\unittest\UnitTests.vcxproj", "{37CBC214-7CE7-4655-B619-F7CEE16E3313}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 @@ -112,6 +114,14 @@ Global {3BAAE095-E0AB-4B0E-B5DF-CE39C8AE31DE}.Release|Win32.Build.0 = Release|Win32 {3BAAE095-E0AB-4B0E-B5DF-CE39C8AE31DE}.Release|x64.ActiveCfg = Release|x64 {3BAAE095-E0AB-4B0E-B5DF-CE39C8AE31DE}.Release|x64.Build.0 = Release|x64 + {37CBC214-7CE7-4655-B619-F7CEE16E3313}.Debug|Win32.ActiveCfg = Debug|Win32 + {37CBC214-7CE7-4655-B619-F7CEE16E3313}.Debug|Win32.Build.0 = Debug|Win32 + {37CBC214-7CE7-4655-B619-F7CEE16E3313}.Debug|x64.ActiveCfg = Debug|x64 + {37CBC214-7CE7-4655-B619-F7CEE16E3313}.Debug|x64.Build.0 = Debug|x64 + {37CBC214-7CE7-4655-B619-F7CEE16E3313}.Release|Win32.ActiveCfg = Release|Win32 + {37CBC214-7CE7-4655-B619-F7CEE16E3313}.Release|Win32.Build.0 = Release|Win32 + {37CBC214-7CE7-4655-B619-F7CEE16E3313}.Release|x64.ActiveCfg = Release|x64 + {37CBC214-7CE7-4655-B619-F7CEE16E3313}.Release|x64.Build.0 = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/ext/disarm.cpp b/ext/disarm.cpp index f2f7ffc193..f17d1856f1 100644 --- a/ext/disarm.cpp +++ b/ext/disarm.cpp @@ -310,7 +310,7 @@ instr_disassemble(word instr, address addr, pDisOptions opts) { result.undefined = result.badbits = - result.oddbits = + result.oddbits = 0; result.is_SWI = 0; result.target_type = target_None; result.offset = 0x80000000; @@ -947,6 +947,7 @@ const char *ArmRegName(int r) { } void ArmDis(unsigned int addr, unsigned int w, char *output) { pInstruction instr = instr_disassemble(w, addr, &options); + char temp[256]; sprintf(output, "%08x\t%s", w, instr->text); if (instr->undefined || instr->badbits || instr->oddbits) { if (instr->undefined) sprintf(output, " [undefined instr %08x]", w); @@ -954,7 +955,7 @@ void ArmDis(unsigned int addr, unsigned int w, char *output) { // HUH? LDR and STR gets this a lot // strcat(output, " ? (extra bits)"); - // if (instr->oddbits) sprintf(output, " [unexpected bits %08x]", w); + if (instr->oddbits) sprintf(temp, " [unexpected bits %08x]", w), strcat(output, temp); } // zap tabs while (*output) { diff --git a/unittest/UnitTest.cpp b/unittest/UnitTest.cpp new file mode 100644 index 0000000000..7a28f86115 --- /dev/null +++ b/unittest/UnitTest.cpp @@ -0,0 +1,58 @@ +// Copyright (c) 2012- PPSSPP Project. + +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, version 2.0 or later versions. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License 2.0 for more details. + +// A copy of the GPL 2.0 should have been included with the program. +// If not, see http://www.gnu.org/licenses/ + +// Official git repository and contact information can be found at +// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/. + +// UnitTests +// +// This is a program to directly test various functions, without going +// through a PSP. Especially useful for things like opcode emitters, +// hashes, and various data conversion utility function. +// +// TODO: Make a test of nice unittest asserts and count successes etc. +// Or just integrate with an existing testing framework. + + +#include +#include +#include + +#include "Common/ArmEmitter.h" +#include "ext/disarm.h" + +#define EXPECT_EQ_STR(a, b) if ((a) != (b)) { printf(__FUNCTION__ ": Test Fail\n%s\nvs\n%s\n", a.c_str(), b.c_str()); return false; } + +bool TestArmEmitter() { + using namespace ArmGen; + + u32 code[512]; + ARMXEmitter emitter((u8 *)code); + emitter.LDR(R3, R7); + + char disasm[512]; + ArmDis(0, code[0] & 0xFFFFFFFF, disasm); + std::string dis(disasm); + EXPECT_EQ_STR(dis, std::string("e4973000 LDR r3, [r7], #0")); + + printf("TestArmEmitter: Success\n"); + + return true; +} + +int main(int argc, const char *argv[]) +{ + TestArmEmitter(); + return 0; +} \ No newline at end of file diff --git a/unittest/UnitTests.vcxproj b/unittest/UnitTests.vcxproj new file mode 100644 index 0000000000..ca9cb9312e --- /dev/null +++ b/unittest/UnitTests.vcxproj @@ -0,0 +1,164 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {37CBC214-7CE7-4655-B619-F7CEE16E3313} + Win32Proj + UnitTests + UnitTest + + + + Application + true + v100 + MultiByte + + + Application + true + v100 + MultiByte + + + Application + false + v100 + true + MultiByte + + + Application + false + v100 + true + MultiByte + + + + + + + + + + + + + + + + + + + true + + + true + + + false + + + false + + + + + + Level3 + Disabled + WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) + ../common;..;../native;../native/ext/glew;../ext/zlib + + + Console + true + winmm.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) + ../common;..;../native;../native/ext/glew;../ext/zlib + + + Console + true + winmm.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + + + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) + ../common;..;../native;../native/ext/glew;../ext/zlib + + + Console + true + true + true + winmm.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + + + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) + ../common;..;../native;../native/ext/glew;../ext/zlib + + + Console + true + true + true + winmm.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + + + + + + + + {3fcdbae2-5103-4350-9a8e-848ce9c73195} + + + {533f1d30-d04d-47cc-ad71-20f658907e36} + + + + + + \ No newline at end of file diff --git a/unittest/UnitTests.vcxproj.filters b/unittest/UnitTests.vcxproj.filters new file mode 100644 index 0000000000..73adfc62f5 --- /dev/null +++ b/unittest/UnitTests.vcxproj.filters @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file