Skip to content

Commit

Permalink
Update Windows github action to use winpcap and run test of axpbox rom
Browse files Browse the repository at this point in the history
  • Loading branch information
Remy van Elst committed May 1, 2024
1 parent f3bd6f4 commit 53182e3
Show file tree
Hide file tree
Showing 7 changed files with 83 additions and 3 deletions.
20 changes: 17 additions & 3 deletions .github/workflows/build-test-and-artifact.yml
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,15 @@ jobs:
steps:
- uses: actions/checkout@v2

- name: Install winpcap
working-directory: ${{runner.workspace}}\axpbox\winpcap
run: ${{runner.workspace}}\axpbox\winpcap\install.ps1

- name: Choco install
uses: crazy-max/ghaction-chocolatey@v3
with:
args: install netcat

- name: Get current date
id: date
run: echo "::set-output name=date::$(date +'%Y-%m-%dT%H%M')"
Expand All @@ -149,8 +158,8 @@ jobs:
- name: Configure CMake
shell: bash
working-directory: ${{runner.workspace}}/build
run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=Release
run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=Release

- name: Build
working-directory: ${{runner.workspace}}/build
shell: bash
Expand All @@ -162,13 +171,18 @@ jobs:
working-directory: ${{runner.workspace}}/build
run: ${{runner.workspace}}\build\Release\axpbox.exe

- name: Run rom tests script
working-directory: ${{runner.workspace}}\axpbox\test\rom\
run: ${{runner.workspace}}\axpbox\test\rom\test.ps1


- name: Upload AXPbox Binary
uses: actions/upload-artifact@v1
with:
name: AXPbox-windows-x86-msvc-${{ env.BUILD_DATE }}.exe
path: ${{runner.workspace}}\build\Release\axpbox.exe
env:
BUILD_DATE: ${{ steps.date.outputs.date }}
BUILD_DATE: ${{ steps.date.outputs.date }}

osx-x86-appleclang:
runs-on: "macos-12"
Expand Down
46 changes: 46 additions & 0 deletions test/rom/test.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Download the firmware
Invoke-WebRequest -Uri 'http://raymii.org/s/inc/downloads/es40-srmon/cl67srmrom.exe' -OutFile 'cl67srmrom.exe'

# Start AXPbox
Start-Process '..\..\..\build\Release\axpbox' -ArgumentList 'run' -NoNewWindow -RedirectStandardOutput stdout.txt -RedirectStandardError stderr.txt

# Wait for AXPbox to start
Start-Sleep -Seconds 5

# Connect to terminal
Start-Process -FilePath 'nc' -ArgumentList '-t', '127.0.0.1', '21000' -NoNewWindow -RedirectStandardOutput 'axp.log'

# Wait for the last line of log to become P00>>>
$timeout = 600
while ($true) {
if ($timeout -eq 0) {
Write-Host "waiting for SRM prompt timed out" -ForegroundColor Red
exit 1
}

echo "=== start axp.log ==="
Get-Content -Path 'axp.log' -Raw
echo "=== end axp.log ==="

$content = Get-Content -Path 'axp.log' -Raw
$contentWithoutNullBytes = $content -replace '\0', ''

if ($contentWithoutNullBytes -match "P00>>>") {
break
}

Start-Sleep -Seconds 1
$timeout--
}

Stop-Process -Name 'nc'

# Diff logs
Write-Host -NoNewline -ForegroundColor DarkRed ""
Compare-Object -ReferenceObject (Get-Content 'axp_correct.log') -DifferenceObject (Get-Content 'axp.log') | Format-Table
Write-Host -NoNewline -ForegroundColor DarkGreen "diff clean"
$result = $LASTEXITCODE
Write-Host -NoNewline -ForegroundColor White ""

Remove-Item -Path 'axp.log', 'cl67*', '*.rom'
exit $result
Binary file added winpcap/Packet.dll
Binary file not shown.
20 changes: 20 additions & 0 deletions winpcap/install.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# via: https://github.com/3gstudent/Winpcap_Install

Set-Location -Path $PSScriptRoot

if ($env:PROCESSOR_ARCHITECTURE -eq "x86") {
Move-Item -Path "npf_x86.sys" -Destination "$env:SystemRoot\system32\drivers\npf.sys"
} elseif ($env:PROCESSOR_ARCHITECTURE -eq "AMD64") {
Move-Item -Path "npf_x64.sys" -Destination "$env:SystemRoot\system32\drivers\npf.sys"
}

if (Test-Path "$env:SystemRoot\system32\drivers\npf.sys") {
Write-Host "Move success!"
} else {
Write-Host "Move error!"
exit 1
}

New-Service -Name "npf" -BinaryPathName "$env:SystemRoot\system32\drivers\npf.sys" -StartupType "Automatic" -DisplayName "NetGroup Packet Filter Driver" | Out-Null

Start-Service -Name "npf"
Binary file added winpcap/npf_x64.sys
Binary file not shown.
Binary file added winpcap/npf_x86.sys
Binary file not shown.
Binary file added winpcap/wpcap.dll
Binary file not shown.

0 comments on commit 53182e3

Please sign in to comment.