8000 test(loader): Add script to check mm_DetermineBackendS1 on all games. by tschumann · Pull Request #219 · alliedmodders/metamod-source · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

test(loader): Add script to check mm_DetermineBackendS1 on all games. #219

New issue

Have a question about this project? Sign up for a free GitHub acco 8000 unt to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 27 additions & 27 deletions loader/loader.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,33 +81,33 @@ typedef void * HMODULE;
enum MetamodBackend
{
MMBackend_Episode1 = 0,
MMBackend_DarkMessiah,
MMBackend_Episode2,
MMBackend_BloodyGoodTime,
MMBackend_EYE,
MMBackend_CSS,
MMBackend_Episode2Valve_OBSOLETE,
MMBackend_Left4Dead,
MMBackend_Left4Dead2,
MMBackend_AlienSwarm,
MMBackend_Portal2,
MMBackend_CSGO,
MMBackend_DOTA,
MMBackend_HL2DM,
MMBackend_DODS,
MMBackend_TF2,
MMBackend_NuclearDawn,
MMBackend_SDK2013,
MMBackend_Blade,
MMBackend_Insurgency,
MMBackend_Contagion,
MMBackend_BMS,
MMBackend_DOI,
MMBackend_Mock,
MMBackend_PVKII,
MMBackend_MCV,
MMBackend_CS2,
MMBackend_Deadlock,
MMBackend_DarkMessiah = 1,
MMBackend_Episode2 = 2,
MMBackend_BloodyGoodTime = 3,
MMBackend_EYE = 4,
MMBackend_CSS = 5,
MMBackend_Episode2Valve_OBSOLETE = 6,
MMBackend_Left4Dead = 7,
MMBackend_Left4Dead2 = 8,
MMBackend_AlienSwarm = 9,
MMBackend_Portal2 = 10,
MMBackend_CSGO = 11,
MMBackend_DOTA = 12,
MMBackend_HL2DM = 13,
MMBackend_DODS = 14,
MMBackend_TF2 = 15,
MMBackend_NuclearDawn = 16,
MMBackend_SDK2013 = 17,
MMBackend_Blade = 18,
MMBackend_Insurgency = 19,
MMBackend_Contagion = 20,
MMBackend_BMS = 21,
MMBackend_DOI = 22,
MMBackend_Mock = 23,
MMBackend_PVKII = 24,
MMBackend_MCV = 25,
MMBackend_CS2 = 26,
MMBackend_Deadlock = 27,
MMBackend_UNKNOWN
};

Expand Down
18 changes: 6 additions & 12 deletions loader/test/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,23 +26,17 @@ Using GitBash:
```
PATH="C:\Program Files (x86)\Steam\steamapps\common\Black Mesa\bin":"C:\Program Files (x86)\Steam\steamapps\common\Black Mesa\bms\bin":$PATH loader/test/test_loader/windows-x86/test_loader.exe -testdbs1 -gamedir bms -expectedbackend 21

PATH="C:\Program Files (x86)\Steam\steamapps\common\Counter-Strike Global Offensive\bin":"C:\Program Files (x86)\Steam\steamapps\common\Counter-Strike Global Offensive\csgo\bin":$PATH loader/test/test_loader/windows-x86/test_loader.exe -testdbs1 -gamedir csgo -expectedbackend 11

PATH="C:\Program Files (x86)\Steam\steamapps\common\Counter-Strike Source\bin\x64":"C:\Program Files (x86)\Steam\steamapps\common\Counter-Strike Source\cstrike\bin\x64":$PATH loader/test/test_loader/windows-x86_64/test_loader.exe -testdbs1 -gamedir cstrike -expectedbackend 5

PATH="C:\Program Files (x86)\Steam\steamapps\common\Half-Life 2 Deathmatch\bin\x64":"C:\Program Files (x86)\Steam\steamapps\common\Half-Life 2 Deathmatch\hl2mp\bin\x64":$PATH loader/test/test_loader/windows-x86_64/test_loader.exe -testdbs1 -gamedir hl2mp -expectedbackend 13

PATH="C:\Program Files (x86)\Steam\steamapps\common\Military Conflict - Vietnam\bin\win64":"C:\Program Files (x86)\Steam\steamapps\common\Military Conflict - Vietnam\vietnam\bin\win64":$PATH loader/test/test_loader/windows-x86_64/test_loader.exe -testdbs1 -gamedir vietnam -expectedbackend 25

# NOTE: use Insurgency because server.dll in episodic/ doesn't load
PATH="C:\Program Files (x86)\Steam\steamapps\common\Source SDK Base":"C:\Program Files (x86)\Steam\steamapps\common\Source SDK Base\bin":"C:\Program Files (x86)\Steam\steamapps\common\Source SDK Base\insurgency\bin":$PATH loader/test/test_loader/windows-x86/test_loader.exe -testdbs1 -gamedir insurgency -expectedbackend 0

PATH="C:\Program Files (x86)\Steam\steamapps\common\Team Fortress 2\bin\x64":"C:\Program Files (x86)\Steam\steamapps\common\Team Fortress 2\tf\bin\x64":$PATH loader/test/test_loader/windows-x86_64/test_loader.exe -testdbs1 -gamedir tf -expectedbackend 15
```

Using PowerShell:
```
powershell -Command { $env:Path="C:\Program Files (x86)\Steam\steamapps\common\Black Mesa\bin;" + "C:\Program Files (x86)\Steam\steamapps\common\Black Mesa\bms\bin;" + $env:Path; .\loader\test\test_loader\windows-x86\test_loader.exe -testdbs1 -gamedir bms -expectedbackend 21 }

powershell -Command { $env:Path="C:\Program Files (x86)\Steam\steamapps\common\Counter-Strike Source\bin\x64;" + "C:\Program Files (x86)\Steam\steamapps\common\Counter-Strike Source\cstrike\bin\x64;" + $env:Path; .\loader\test\test_loader\windows-x86_64\test_loader.exe -testdbs1 -gamedir cstrike -expectedbackend 5 }
```
```

You can run the following to test all supported games in Steam:
```
.\loader\test\test_determinebackends1.ps1 "C:\Program Files (x86)\Steam"
```
5 changes: 4 additions & 1 deletion loader/test/determinebackends1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#define ENGINE_LIB_NAME "engine" LIB_SUFFIX
#endif

bool DetermineBackendS1(char *gameDir, int expectedBackend)
bool DetermineBackendS1(const char *gameDir, int expectedBackend)
{
char errorBuffer[128];
void *serverLib = nullptr;
Expand Down Expand Up @@ -57,6 +57,9 @@ bool DetermineBackendS1(char *gameDir, int expectedBackend)

MetamodBackend actualBackend = mm_DetermineBackendS1(engineQvi, serverQvi, gameDir);

mm_UnloadLibrary(engineLib);
mm_UnloadLibrary(serverLib);

if (actualBackend != expectedBackend)
{
std::cout << "Got MetamodBackend " << actualBackend << " instead of expected " << expectedBackend << std::endl;
Expand Down
4 changes: 2 additions & 2 deletions loader/test/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
} \


bool DetermineBackendS1(char *gameDir, int expectedBackend);
bool DetermineBackendS1(const char *gameDir, int expectedBackend);
DECL_TEST(TrimComments);

int main(int argc, char *argv[])
Expand All @@ -47,7 +47,7 @@ int main(int argc, char *argv[])

if (testDetermineBackendS1)
{
bool success = DetermineBackendS1(gameDirectory, expectedMetamodBackend);
bool success = DetermineBackendS1(gameDirectory ? gameDirectory : "", expectedMetamodBackend);
// invert it because return code from main has 0 as success
return success != true;
}
Expand Down
142 changes: 142 additions & 0 deletions loader/test/test_determinebackends1.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
Set-StrictMode -Version 3.0

$ErrorActionPreference = "Stop"
$PSNativeCommandUserErrorActionPerference = $true

# get the location of this file
$scriptpath = $MyInvocation.MyCommand.Path
# get the directory path to this file
$wd = Split-Path $scriptpath
# set the working directory as this file's directory
Push-Location $wd

class SteamGame {
[string]$Name
[string]$EnginePath
[string]$GamePath
[string]$GameDir
[string]$Architecture
[bool]$IsDedicatedServer
[int]$ExpectedBackend
[bool]$Skip

SteamGame([string]$name, [string]$enginePath, [string]$gamePath, [string]$gameDir, [string]$architecture, [bool]$isDedicatedServer, [int]$expectedBackend, [bool]$skip) {
$this.Name = $name
$this.EnginePath = $enginePath
$this.GamePath = $gamePath
$this.GameDir = $gameDir
$this.Architecture = $architecture
$this.IsDedicatedServer = $isDedicatedServer
$this.ExpectedBackend = $expectedBackend
$this.Skip = $skip
}
}

if ($args.Count -ge 1)
{
$steamPath = $args[0]
}

$global:failureCount = 0

$gamesToTest = @{
alienswarm = [SteamGame]::new("Alien Swarm", "common\Alien Swarm\bin", "common\Alien Swarm\swarm\bin", "swarm", "x86", $false, 9, $true)
blackmesa = [SteamGame]::new("Black Mesa", "common\Black Mesa\bin", "common\Black Mesa\bms\bin", "bms", "x86", $false, 21, $false)
bladesymphony_32 = [SteamGame]::new("Blade Symphony (x86)", "common\Blade Symphony\bin\win32", "", "berimbau", "x86", $false, 18, $false)
bladesymphony_64 = [SteamGame]::new("Blade Symphony (x64)", "common\Blade Symphony\bin\win64", "", "berimbau", "x64", $false, 6D47 18, $false)
bloodygoodtime = [SteamGame]::new("Bloody Good Time", "common\Bloody Good Time\bin", "common\Bloody Good Time\pm\bin", "pm", "x86", $false, 3, $true)
bloodygoodtime_ds = [SteamGame]::new("Bloody Good Time Dedicated Server", "common\Bloody Good Time Dedicated Server\bin", "common\Bloody Good Time Dedicated Server\pm\bin", "pm", "x86", $false, 3, $true)
contagion = [SteamGame]::new("Contagion", "common\Contagion\engine", "common\Contagion\bin", "contagion", "x64", $false, 18, $false)
counterstrikeglobaloffensive = [SteamGame]::new("Counter-Strike Global Offensive", "common\Counter-Strike Global Offensive\bin", "common\Counter-Strike Global Offensive\csgo\bin", "csgo", "x86", $false, 11, $false)
counterstrikesource = [SteamGame]::new("Counter-Strike Source", "common\Counter-Strike Source\bin\x64", "common\Counter-Strike Source\cstrike\bin\x64", "cstrike", "x64", $false, 5, $false)
darkmessiahofmightandmagic = [SteamGame]::new("Dark Messiah of Might and Magic", "common\Dark Messiah Might and Magic Multi-Player\bin", "", "", "x86", $false, 1, $true)
darkmessiahofmightandmagic_ds = [SteamGame]::new("Dark Messiah of Might and Magic Dedicated Server", "common\Dark Messiah Might and Magic Dedicated Server\bin", "", "", "x86", $false, 1, $true)
dayofdefeatsource = [SteamGame]::new("Day of Defeat Source", "common\Day of Defeat Source\bin\x64", "common\Day of Defeat Source\dod\bin\x64", "dod", "x64", $false, 14, $false)
# NOTE: fails because libogg.dll and libvorbis.dll both link MSVCR100.dll
dayofinfamy_32 = [SteamGame]::new("Day of Infamy (x86)", "common\dayofinfamy\bin", "common\dayofinfamy\doi\bin", "doi", "x86", $false, 22, $true)
dayofinfamy_64 = [SteamGame]::new("Day of Infamy (x64)", "common\dayofinfamy\bin\x64", "common\dayofinfamy\doi\bin\x64", "doi", "x64", $false, 22, $false)
eyedivinecybermancy = [SteamGame]::new("E.Y.E: Divine Cybermancy", "common\EYE\bin", "common\EYE\EYE\bin", "EYE", "x86", $false, 4, $true)
fistfuloffrags = [SteamGame]::new("Fistful of Frags", "common\Fistful of Frags\sdk\bin", "common\Fistful of Frags\fof\bin", "fof", "x86", $false, 17, $false)
garrysmod = [SteamGame]::new("Garry's Mod", "common\GarrysMod\bin", "common\GarrysMod\garrysmod\bin", "garrysmod", "x86", $false, 17, $true)
halflifesourcedeathmatch = [SteamGame]::new("Half-Life Source Deathmatch", "common\Half-Life 1 Source Deathmatch\bin\x64", "common\Half-Life 1 Source Deathmatch\hl1mp\bin\x64", "hl1mp", "x64", $false, 13, $false)
halflifesourcedeathmatch_ds = [SteamGame]::new("Half-Life Source Deathmatch Dedicated Server", "common\Half-Life Deathmatch Source Dedicated Server\bin\x64", "common\Half-Life Deathmatch Source Dedicated Server\hl1mp\bin\x64", "hl1mp", "x64", $false, 13, $false)
halflife2deathmatch = [SteamGame]::new("Half-Life 2 Deathmatch", "common\Half-Life 2 Deathmatch\bin\x64", "common\Half-Life 2 Deathmatch\hl2mp\bin\x64", "hl2mp", "x64", $false, 13, $false)
# NOTE: fails because libogg.dll and libvorbis.dll both link MSVCR100.dll
insurgency_32 = [SteamGame]::new("Insurgency (x86)", "common\insurgency2\bin", "common\insurgency2\insurgency\bin", "insurgency", "x86", $false, 19, $true)
insurgency_64 = [SteamGame]::new("Insurgency (x64)", "common\insurgency2\bin\x64", "common\insurgency2\insurgency\bin\x64", "insurgency", "x64", $false, 19, $false)
jabronibrawlepisode3 = [SteamGame]::new("Jabroni Brawl Episode 3", "common\Jabroni Brawl Episode 3\bin\win32", "common\Jabroni Brawl Episode 3\jbep3\bin\win32", "jbep3", "x86", $false, 11, $true)
left4dead = [SteamGame]::new("Left 4 Dead", "common\left 4 dead\bin", "common\left 4 dead\left4dead\bin", "left4dead", "x86", $false, 7, $true)
left4dead2 = [SteamGame]::new("Left 4 Dead 2", "common\Left 4 Dead 2\bin", "common\Left 4 Dead 2\left4dead2\bin", "left4dead2", "x86", $false, 8, $true)
militaryconflictvietnam = [SteamGame]::new("Military Conflict Vietnam", "common\Military Conflict - Vietnam\bin\win64", "common\Military Conflict - Vietnam\vietnam\bin\win64", "vietnam", "x64", $false, 25, $false)
nucleardawn = [SteamGame]::new("Nuclear Dawn", "common\Nuclear Dawn\bin", "common\Nuclear Dawn\nucleardawn\bin", "nucleardawn", "x86", $false, 16, $true)
piratesvikingsandknightsii = [SteamGame]::new("Pirates, Vikings and Knights II", "common\pirates, vikings and knights ii\sdkbase_pvkii\bin", "common\pirates, vikings and knights ii\pvkii\bin", "pvkii", "x86", $false, 24, $false)
portal2 = [SteamGame]::new("Portal 2", "common\Portal 2\bin", "common\Portal 2\portal2\bin", "portal2", "x86", $false, 10, $true)
revelations2012 = [SteamGame]::new("Revelations 2012", "common\Revelations 2012\bin", "common\Revelations 2012\revelations\bin", "revelations", "x86", $false, 8, $true)
sdk2006_insurgency = [SteamGame]::new("Source SDK Base 2006 (Insurgency)", "common\Source SDK Base\bin", "common\Source SDK Base\insurgency\bin", "insurgency", "x86", $false, 0, $false)
sdk2007_ageofchivalry = [SteamGame]::new("Source SDK Base 2007 (Age of Chivalry)", "common\Source SDK Base 2007\bin", "common\Source SDK Base 2007\ageofchivalry\bin", "ageofchivalry", "x86", $false, 2, $true)
teamfortress2 = [SteamGame]::new("Team Fortress 2", "common\Team Fortress 2\bin\x64", "common\Team Fortress 2\tf\bin\x64", "tf", "x64", $false, 15, $false)
treason = [SteamGame]::new("Treason", "common\Treason\bin", "common\Treason\treason\bin", "treason", "x86", $false, 17, $false)
theship = [SteamGame]::new("The Ship", "common\The Ship\bin", "common\The Ship\ship\bin", "ship", "x86", $false, 0, $true)
theship_ds = [SteamGame]::new("The Ship Dedicated Server", "common\The Ship Dedicated Server\bin", "common\The Ship Dedicated Server\ship\bin", "ship", "x86", $false, 0, $true)
zombiepanicsource = [SteamGame]::new("Zombie Panic Source", "common\Zombie Panic Source\bin", "common\Zombie Panic Source\zps\bin", "zps", "x86", $false, 17, $false)
}

function testGame([SteamGame]$game)
{
Write-Host @("Testing", $game.Name) -ForegroundColor yellow

$steamappsPath = "${steamPath}\steamapps"
$enginePath = "${steamappsPath}\" + $game.EnginePath
$gamePath = "${steamappsPath}\" + $game.GamePath

if (!(Test-Path -Path $enginePath))
{
Write-Host "Skipped - game not found at ${enginePath}`n" -ForegroundColor DarkYellow

Return
}

if ($gamePath -ne "" -And !(Test-Path -Path $gamePath))
{
Write-Host "Skipped - game not found at ${gamePath}`n" -ForegroundColor DarkYellow

Return
}

# make gamedir the last parameter as something weird is going on where if it's "" then PowerShell is collapsing it and the next argument gets passed as gamedir
if ($game.Architecture -eq "x86")
{
$env:Path=$enginePath + ";" + $gamePath + ";" + $env:Path; ..\..\build\loader\test\test_loader\windows-x86\test_loader.exe -testdbs1 -expectedbackend $game.ExpectedBackend -gamedir $game.GameDir
}
else
{
$env:Path=$enginePath + ";" + $gamePath + ";" + $env:Path; ..\..\build\loader\test\test_loader\windows-x86_64\test_loader.exe -testdbs1 -expectedbackend $game.ExpectedBackend -gamedir $game.GameDir
}

# some games don't seem to do the right thing when not initialised through the engine, so skip the known failures
if ($game.Skip -eq $true)
{
Write-Host "Skipped - invalid result`n" -ForegroundColor DarkYellow

Return
}

if ($LastExitCode -eq 0)
{
Write-Host "Passed`n" -ForegroundColor Green
}
else
{
Write-Host "Failed`n" -ForegroundColor Red
$global:failureCount++
}
}

foreach ($game in $gamesToTest.Keys | Sort-Object)
{
testGame $gamesToTest[$game]
}

Write-Host "There were ${global:failureCount} failures"

Pop-Location
Loading
0