This repository has been archived by the owner on Dec 18, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 319
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Tests: Added command line utility to run all tests on multiple thread…
…s at once (No GUI) to speed up test runs
- Loading branch information
Showing
4 changed files
with
357 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,161 @@ | ||
#if _WIN64 || __x86_64__ || __ppc64__ | ||
#define ENVIRONMENT64 | ||
#else | ||
#define ENVIRONMENT32 | ||
#endif | ||
|
||
#ifdef ENVIRONMENT32 | ||
#ifdef _DEBUG | ||
#define MESEN_LIBRARY_PATH "../bin/x86/Debug/" | ||
#else | ||
#define MESEN_LIBRARY_PATH "../bin/x86/Release/" | ||
#endif | ||
#else | ||
#ifdef _DEBUG | ||
#define MESEN_LIBRARY_PATH "../bin/x64/Debug/" | ||
#else | ||
#define MESEN_LIBRARY_PATH "../bin/x64/Release/" | ||
#endif | ||
#endif | ||
|
||
#pragma comment(lib, MESEN_LIBRARY_PATH"Utilities.lib") | ||
|
||
#include <Windows.h> | ||
#include <Shlobj.h> | ||
#include <iostream> | ||
#include <thread> | ||
#include <vector> | ||
#include <string> | ||
#include <thread> | ||
#include "../Utilities/FolderUtilities.h" | ||
#include "../Utilities/SimpleLock.h" | ||
#include "../Utilities/Timer.h" | ||
#include "../Core/MessageManager.h" | ||
|
||
typedef void (__stdcall *NotificationListenerCallback)(ConsoleNotificationType); | ||
|
||
class InteropNotificationListener : public INotificationListener | ||
{ | ||
NotificationListenerCallback _callback; | ||
public: | ||
InteropNotificationListener(NotificationListenerCallback callback) | ||
{ | ||
_callback = callback; | ||
} | ||
|
||
void ProcessNotification(ConsoleNotificationType type, void* parameter) | ||
{ | ||
_callback((ConsoleNotificationType)type); | ||
} | ||
}; | ||
|
||
extern "C" { | ||
void __stdcall InitializeEmu(char* homeFolder, void*, void*); | ||
int __stdcall RomTestRun(char* filename); | ||
void __stdcall LoadROM(char* filename); | ||
void __stdcall Run(); | ||
void __stdcall Stop(); | ||
INotificationListener* __stdcall RegisterNotificationCallback(NotificationListenerCallback callback); | ||
} | ||
|
||
std::thread *runThread = nullptr; | ||
std::atomic<int> testIndex; | ||
vector<string> testFilenames; | ||
vector<string> failedTests; | ||
SimpleLock lock; | ||
Timer timer; | ||
|
||
void OnNotificationReceived(ConsoleNotificationType type) | ||
{ | ||
if(type == ConsoleNotificationType::GameLoaded) { | ||
runThread = new std::thread(Run); | ||
} | ||
} | ||
|
||
void RunEmu() | ||
{ | ||
Run(); | ||
} | ||
|
||
void RunTest() | ||
{ | ||
while(true) { | ||
lock.Acquire(); | ||
int index = testIndex++; | ||
lock.Release(); | ||
|
||
if(index < testFilenames.size()) { | ||
string filepath = testFilenames[index]; | ||
string filename = FolderUtilities::GetFilename(filepath, false); | ||
string command = "TestHelper.exe /testrom \"" + filepath + "\""; | ||
|
||
lock.Acquire(); | ||
std::cout << std::to_string(index) << ") " << filename << std::endl; | ||
lock.Release(); | ||
|
||
if(std::system(command.c_str()) != 1) { | ||
//Test failed | ||
lock.Acquire(); | ||
failedTests.push_back(filename); | ||
std::cout << " **** " << std::to_string(index) << ") " << filename << " failed" << std::endl; | ||
lock.Release(); | ||
} | ||
} else { | ||
break; | ||
} | ||
} | ||
} | ||
|
||
int main(int argc, char* argv[]) | ||
{ | ||
using namespace std; | ||
if(argc <= 2) { | ||
string testFolder; | ||
if(argc == 1) { | ||
wchar_t path[MAX_PATH]; | ||
SHGetFolderPath(NULL, CSIDL_MYDOCUMENTS, NULL, SHGFP_TYPE_CURRENT, path); | ||
testFolder = utf8::utf8::encode(path) + "\\Mesen\\Tests"; | ||
} else { | ||
testFolder = argv[1]; | ||
} | ||
|
||
vector<std::thread*> testThreads; | ||
testFilenames = FolderUtilities::GetFilesInFolder(testFolder, "*.mtp", true); | ||
testIndex = 0; | ||
|
||
timer.Reset(); | ||
|
||
for(int i = 0; i < 4; i++) { | ||
std::thread *testThread = new std::thread(RunTest); | ||
testThreads.push_back(testThread); | ||
} | ||
|
||
for(int i = 0; i < 4; i++) { | ||
testThreads[i]->join(); | ||
delete testThreads[i]; | ||
} | ||
|
||
std::cout << std::endl << std::endl; | ||
std::cout << "------------" << std::endl; | ||
std::cout << "Failed tests" << std::endl; | ||
std::cout << "------------" << std::endl; | ||
for(string failedTest : failedTests) { | ||
std::cout << failedTest << std::endl; | ||
} | ||
std::cout << std::endl << std::endl << "Elapsed time: " << (timer.GetElapsedMS() / 1000) << " seconds"; | ||
|
||
std::getchar(); | ||
} else if(argc == 3) { | ||
char* testFilename = argv[2]; | ||
RegisterNotificationCallback((NotificationListenerCallback)OnNotificationReceived); | ||
InitializeEmu("C:\\Windows\\Temp\\Mesen", nullptr, nullptr); | ||
int result = RomTestRun(testFilename); | ||
if(runThread != nullptr) { | ||
runThread->join(); | ||
delete runThread; | ||
} | ||
return result; | ||
} | ||
return 0; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,169 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<ItemGroup Label="ProjectConfigurations"> | ||
<ProjectConfiguration Include="Debug|Win32"> | ||
<Configuration>Debug</Configuration> | ||
<Platform>Win32</Platform> | ||
</ProjectConfiguration> | ||
<ProjectConfiguration Include="Debug|x64"> | ||
<Configuration>Debug</Configuration> | ||
<Platform>x64</Platform> | ||
</ProjectConfiguration> | ||
<ProjectConfiguration Include="Release|Win32"> | ||
<Configuration>Release</Configuration> | ||
<Platform>Win32</Platform> | ||
</ProjectConfiguration> | ||
<ProjectConfiguration Include="Release|x64"> | ||
<Configuration>Release</Configuration> | ||
<Platform>x64</Platform> | ||
</ProjectConfiguration> | ||
</ItemGroup> | ||
<PropertyGroup Label="Globals"> | ||
<ProjectGuid>{2A607369-8B5D-494A-9E40-C5DC8D821AA3}</ProjectGuid> | ||
<Keyword>Win32Proj</Keyword> | ||
<RootNamespace>TestHelper</RootNamespace> | ||
</PropertyGroup> | ||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> | ||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> | ||
<ConfigurationType>Application</ConfigurationType> | ||
<UseDebugLibraries>true</UseDebugLibraries> | ||
<PlatformToolset>v120</PlatformToolset> | ||
<CharacterSet>Unicode</CharacterSet> | ||
</PropertyGroup> | ||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration"> | ||
<ConfigurationType>Application</ConfigurationType> | ||
<UseDebugLibraries>true</UseDebugLibraries> | ||
<PlatformToolset>v120</PlatformToolset> | ||
<CharacterSet>Unicode</CharacterSet> | ||
</PropertyGroup> | ||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> | ||
<ConfigurationType>Application</ConfigurationType> | ||
<UseDebugLibraries>false</UseDebugLibraries> | ||
<PlatformToolset>v120</PlatformToolset> | ||
<WholeProgramOptimization>true</WholeProgramOptimization> | ||
<CharacterSet>Unicode</CharacterSet> | ||
</PropertyGroup> | ||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration"> | ||
<ConfigurationType>Application</ConfigurationType> | ||
<UseDebugLibraries>false</UseDebugLibraries> | ||
<PlatformToolset>v120</PlatformToolset> | ||
<WholeProgramOptimization>true</WholeProgramOptimization> | ||
<CharacterSet>Unicode</CharacterSet> | ||
</PropertyGroup> | ||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> | ||
<ImportGroup Label="ExtensionSettings"> | ||
</ImportGroup> | ||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> | ||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> | ||
</ImportGroup> | ||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets"> | ||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> | ||
</ImportGroup> | ||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> | ||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> | ||
</ImportGroup> | ||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets"> | ||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> | ||
</ImportGroup> | ||
<PropertyGroup Label="UserMacros" /> | ||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> | ||
<LinkIncremental>true</LinkIncremental> | ||
<OutDir>$(SolutionDir)\bin\$(PlatformTarget)\$(Configuration)\</OutDir> | ||
<IntDir>obj\$(Platform)\$(Configuration)\</IntDir> | ||
</PropertyGroup> | ||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> | ||
<IntDir>obj\$(Platform)\$(Configuration)\</IntDir> | ||
<LinkIncremental>true</LinkIncremental> | ||
<OutDir>$(SolutionDir)\bin\$(PlatformTarget)\$(Configuration)\</OutDir> | ||
</PropertyGroup> | ||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> | ||
<LinkIncremental>false</LinkIncremental> | ||
<OutDir>$(SolutionDir)\bin\$(PlatformTarget)\$(Configuration)\</OutDir> | ||
<IntDir>obj\$(Platform)\$(Configuration)\</IntDir> | ||
</PropertyGroup> | ||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> | ||
<IntDir>obj\$(Platform)\$(Configuration)\</IntDir> | ||
<LinkIncremental>false</LinkIncremental> | ||
<OutDir>$(SolutionDir)\bin\$(PlatformTarget)\$(Configuration)\</OutDir> | ||
</PropertyGroup> | ||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> | ||
<ClCompile> | ||
<PrecompiledHeader> | ||
</PrecompiledHeader> | ||
<WarningLevel>Level3</WarningLevel> | ||
<Optimization>Disabled</Optimization> | ||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions> | ||
<SDLCheck>true</SDLCheck> | ||
</ClCompile> | ||
<Link> | ||
<SubSystem>Console</SubSystem> | ||
<GenerateDebugInformation>true</GenerateDebugInformation> | ||
</Link> | ||
</ItemDefinitionGroup> | ||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> | ||
<ClCompile> | ||
<PrecompiledHeader> | ||
</PrecompiledHeader> | ||
<WarningLevel>Level3</WarningLevel> | ||
<Optimization>Disabled</Optimization> | ||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions> | ||
<SDLCheck>true</SDLCheck> | ||
</ClCompile> | ||
<Link> | ||
<SubSystem>Console</SubSystem> | ||
<GenerateDebugInformation>true</GenerateDebugInformation> | ||
</Link> | ||
</ItemDefinitionGroup> | ||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> | ||
<ClCompile> | ||
<WarningLevel>Level3</WarningLevel> | ||
<PrecompiledHeader> | ||
</PrecompiledHeader> | ||
<Optimization>MaxSpeed</Optimization> | ||
<FunctionLevelLinking>true</FunctionLevelLinking> | ||
<IntrinsicFunctions>true</IntrinsicFunctions> | ||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions> | ||
<SDLCheck>true</SDLCheck> | ||
</ClCompile> | ||
<Link> | ||
<SubSystem>Console</SubSystem> | ||
<GenerateDebugInformation>true</GenerateDebugInformation> | ||
<EnableCOMDATFolding>true</EnableCOMDATFolding> | ||
<OptimizeReferences>true</OptimizeReferences> | ||
</Link> | ||
</ItemDefinitionGroup> | ||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> | ||
<ClCompile> | ||
<WarningLevel>Level3</WarningLevel> | ||
<PrecompiledHeader> | ||
</PrecompiledHeader> | ||
<Optimization>MaxSpeed</Optimization> | ||
<FunctionLevelLinking>true</FunctionLevelLinking> | ||
<IntrinsicFunctions>true</IntrinsicFunctions> | ||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions> | ||
<SDLCheck>true</SDLCheck> | ||
</ClCompile> | ||
<Link> | ||
<SubSystem>Console</SubSystem> | ||
<GenerateDebugInformation>true</GenerateDebugInformation> | ||
<EnableCOMDATFolding>true</EnableCOMDATFolding> | ||
<OptimizeReferences>true</OptimizeReferences> | ||
</Link> | ||
</ItemDefinitionGroup> | ||
<ItemGroup> | ||
<ClCompile Include="TestHelper.cpp" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ProjectReference Include="..\InteropDLL\InteropDLL.vcxproj"> | ||
<Project>{37749bb2-fa78-4ec9-8990-5628fc0bba19}</Project> | ||
<Private>false</Private> | ||
<ReferenceOutputAssembly>true</ReferenceOutputAssembly> | ||
<CopyLocalSatelliteAssemblies>false</CopyLocalSatelliteAssemblies> | ||
<LinkLibraryDependencies>true</LinkLibraryDependencies> | ||
<UseLibraryDependencyInputs>true</UseLibraryDependencyInputs> | ||
</ProjectReference> | ||
</ItemGroup> | ||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> | ||
<ImportGroup Label="ExtensionTargets"> | ||
</ImportGroup> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<ItemGroup> | ||
<Filter Include="Source Files"> | ||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier> | ||
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions> | ||
</Filter> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ClCompile Include="TestHelper.cpp"> | ||
<Filter>Source Files</Filter> | ||
</ClCompile> | ||
</ItemGroup> | ||
</Project> |