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 3302eb4
Show file tree
Hide file tree
Showing 5 changed files with 114 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\winpcap-nmap-4.02.exe /S

- 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
8 changes: 8 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@ if (CMAKE_GENERATOR MATCHES "Visual Studio")
add_definitions(/wd4099 /wd4146 /wd4267 /wd4305 /wd4307)
add_definitions(/wd4715 /wd4722 /wd4723 /wd4838 /wd4309 /wd4334)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP")

find_package(WinPcap)
if(WINPCAP_FOUND)
message(STATUS "winpcap found. Networking support enabled")
include_directories(${WINPCAP_INCLUDE_DIRS})
target_link_libraries(axpbox ${WINPCAP_LIBRARIES})
endif()
endif()

find_package(Threads REQUIRED)
Expand Down Expand Up @@ -123,6 +130,7 @@ AXPBOX_TEST_LARGE_FILES(HAVE_LARGE_FILES)




if (DISABLE_PCAP STREQUAL "yes")
set(HAVE_PCAP 0)
endif()
Expand Down
43 changes: 43 additions & 0 deletions cmake/FindWinPcap.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# - Try to find WinPcap
#
# Sets the following variables:
#
# WINPCAP_FOUND - if package found
# WINPCAP_INCLUDE_DIRS - include directories
# WINPCAP_LIBRARIES - libraries
#

find_path(WINPCAP_INCLUDE_DIR NAMES pcap.h
PATH_SUFFIXES
WpdPack/Include
winpcap/WpdPack/Include
)

find_library(WINPCAP_LIBRARY_PACKET Packet
PATH_SUFFIXES
WpdPack/Lib
winpcap/WpdPack/Lib
)

find_library(WINPCAP_LIBRARY_WPCAP wpcap
PATH_SUFFIXES
WpdPack/Lib
winpcap/WpdPack/Lib
)

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(WinPcap DEFAULT_MSG
WINPCAP_INCLUDE_DIR
WINPCAP_LIBRARY_PACKET
WINPCAP_LIBRARY_WPCAP
)

if(WINPCAP_FOUND)
set(WINPCAP_INCLUDE_DIRS ${WINPCAP_INCLUDE_DIR})
set(WINPCAP_LIBRARIES ${WINPCAP_LIBRARY_PACKET} ${WINPCAP_LIBRARY_WPCAP})
else()
set(WINPCAP_INCLUDE_DIRS)
set(WINPCAP_LIBRARIES)
endif()

mark_as_advanced(WINPCAP_LIBRARIES WINPCAP_INCLUDE_DIRS)
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/winpcap-nmap-4.02.exe
Binary file not shown.

0 comments on commit 3302eb4

Please sign in to comment.