+- ps: >-
+ $env:Path = "C:\ProxSpace\msys\bin;$env:Path"
+
+ cd c:\ProxSpace\pm3
+
+
+ $global:TestsPassed=$true
+
+
+ Function ExecTest($Name, $File, $Cmd, $CheckResult) {
+
+ #--- begin Job
+
+ $Job = Start-Job -ScriptBlock {
+ [bool]$res=$false
+ $TestTime=[System.Environment]::TickCount
+ $env:Path = "C:\ProxSpace\msys\bin;$env:Path"
+ Set-Location $using:PWD
+
+ $sb=[scriptblock]::Create("$using:Cmd")
+ #execute scriptblock
+ Write-host "Test [$using:Name] job: $using:Cmd"
+ $Cond=&$sb
+
+ if ($Cond -eq $null){
+ } ElseIf($using:CheckResult -ne $null) {
+ [String]$searchstr=""
+ if ($Cond -is [Object]){
+ ForEach($line in $Cond){
+ Write-host $line -ForegroundColor Gray
+ $searchstr += $line
+ }
+ }else{
+ Write-host "$Cond" -ForegroundColor Gray
+ $searchstr = $Cond
+ }
+ If($searchstr -like "*$using:CheckResult*") {
+ $res=$true
+ }
+ $Cond="*$using:CheckResult*"
+ } Else {
+ If (!($Cond -is [bool] -or $Cond -is [byte] -or $Cond -is [int16] -or $Cond -is [int32] -or $Cond -is [int64] -or $Cond -is [float])){
+ if ($Cond -is "String" -and $Cond -like "*passed*"){
+ $res= $true
+ }
+ if ($Cond -is "String" -and $Cond -like "*true*"){
+ $res= $true
+ }
+ } Else {
+ $res=$Cond
+ }
+ }
+
+ If ($res) {
+ Write-host "Result[$using:Name]: $Cond" -ForegroundColor Green
+ Add-AppveyorTest -Name "$using:Name" -Framework NUnit -Filename "$using:File" -Outcome Passed -Duration "$([System.Environment]::TickCount-$TestTime)"
+ }Else {
+ Write-host "Result[$using:Name]: $Cond" -ForegroundColor Red
+ Add-AppveyorTest -Name "$using:Name" -Framework NUnit -Filename "$using:File" -Outcome Failed -Duration "$([System.Environment]::TickCount-$TestTime)" -ErrorMessage "command:$using:Cmd`nresult:$Cond"
+ }
+ return $res
+ }
+
+ #--- end Job
+
+ [bool]$res=$false
+ # Wait 40 sec timeout for Job
+ if(Wait-Job $Job -Timeout 40){
+ $Results = $Job | Receive-Job
+ if($Results -like "true"){
+ $res=$true
+ }
+ } else {
+ Write-host "Test [$Name] timeout" -ForegroundColor Red
+ Add-AppveyorTest -Name "$Name" -Framework NUnit -Filename "$File" -Outcome Failed -Duration 40000 -ErrorMessage "timeout"
+ }
+ Remove-Job -Force $Job
+
+ if(!$res){
+ $global:TestsPassed=$false
+ }
+ }
+
+
+ Write-Host "Running tests..." -ForegroundColor Yellow
+
+
+ #file test
+
+ ExecTest "proxmark3 exists" "proxmark3.exe" {Test-Path C:\ProxSpace\Release\proxmark3.exe}
+
+ ExecTest "arm image exists" "\arm\fullimage1.elf" {Test-Path C:\ProxSpace\Release\arm\fullimage.elf}
+
+ ExecTest "bootrom exists" "bootrom.elf" {Test-Path C:\ProxSpace\Release\arm\bootrom.elf}
+
+ ExecTest "hardnested tables exists" "hardnested" {Test-Path C:\ProxSpace\Release\hardnested\tables\*.z}
+
+ ExecTest "release exists" "release.zip" {Test-Path C:\ProxSpace\release.zip}
+
+
+ #proxmark logic tests
+
+ ExecTest "proxmark help" "proxmark3 -h" {bash -lc 'cd ~/client;proxmark3 -h | grep -q Execute && echo Passed || echo Failed'}
+
+ ExecTest "proxmark help hardnested" "proxmark3 -h" {bash -lc 'cd ~/client;proxmark3 -h | grep -q hardnested && echo Passed || echo Failed'}
+
+
+ ExecTest "hf mf offline text" "hf mf" {bash -lc "cd ~/client;proxmark3 comx -c 'hf mf'"} "at_enc"
+
+ ExecTest "hf mf hardnested" "hf mf hardnested" {bash -lc "cd ~/client;proxmark3 comx -c 'hf mf hardnested t 1 000000000000'"} "found:"
+
+
+ if ($global:TestsPassed) {
+ Write-Host "Tests [ OK ]" -ForegroundColor Green
+ } else {
+ Write-Host "Tests [ ERROR ]" -ForegroundColor Red
+ throw "Tests error."
+ }