Upgrade to mgba_rom_test for faster testing (#175)

It's a 0.10 new platform, which is lighter than mgba-sdl, and also allows automatically closing the emulator when the tests end.
Helps making both the actions and the user-side docker testing faster
This commit is contained in:
Lorenzooone 2022-07-09 18:08:31 +02:00 committed by GitHub
parent 7c9408ec44
commit 1f03f27ac5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 53 additions and 18 deletions

View File

@ -1,7 +1,7 @@
FROM mcr.microsoft.com/powershell:ubuntu-20.04 AS builder
RUN echo "------------------Updating System------------------"
RUN apt update
RUN apt upgrade
RUN apt update -y
RUN apt upgrade -y
RUN apt install -y wget gcc-arm-none-eabi cmake build-essential tar git
RUN echo "------------------Installing dotnet core------------------"
RUN mkdir -p /opt/dep
@ -37,7 +37,7 @@ CMD /home/m2gba/src/docker-scripts/docker-build-patch-script
#---------------------- Building mgba ------------------------
FROM builder AS mgba_builder
USER root
RUN apt-get update && \
RUN apt-get update -y && \
apt-get install -y --no-install-recommends build-essential ccache cmake \
git libavcodec-dev libavfilter-dev libavformat-dev libavresample-dev \
libavutil-dev libcmocka-dev libedit-dev libelf-dev libpng-dev \
@ -47,17 +47,17 @@ RUN apt-get update && \
WORKDIR /home/m2gba
USER m2gba
RUN git clone https://github.com/mgba-emu/mgba.git
RUN cd mgba && mkdir build && cd build && cmake -DCMAKE_INSTALL_PREFIX:PATH=/usr .. && make
RUN cd mgba && mkdir build && cd build && cmake -DBUILD_ROM_TEST:BOOL=ON -DBUILD_QT:BOOL=OFF -DBUILD_SDL:BOOL=OFF -DCMAKE_INSTALL_PREFIX:PATH=/usr .. && make
#------------------- Building the Tester ---------------------
FROM builder AS tester
USER root
RUN apt-get update && \
apt-get install -y --no-install-recommends pulseaudio alsa-utils libsdl2-dev \
RUN apt-get update -y && \
apt-get install -y --no-install-recommends libgl1-mesa-glx \
libzip-dev libavcodec-dev libavfilter-dev && \
apt-get autoremove -y && apt-get clean
WORKDIR /opt/src
USER m2gba
COPY --from=mgba_builder /home/m2gba/mgba/build/sdl/mgba ./bin/mgba-sdl
COPY --from=mgba_builder /home/m2gba/mgba/build/test/mgba-rom-test ./bin/mgba-rom-test
COPY --from=mgba_builder /home/m2gba/mgba/build/libmgba* ./
CMD /home/m2gba/src/docker-scripts/docker-test-rom-script

View File

@ -1,10 +1,6 @@
#!/bin/pwsh
"Starting Dummy services"
$Env:SDL_VIDEODRIVER = "dummy"
pulseaudio -D --exit-idle-time=-1
pactl load-module module-null-sink sink_name=SpeakerOutput sink_properties=device.description="Dummy_Output"
$Env:LD_LIBRARY_PATH += "/opt/src"
$Env:PATH += ":/home/m2gba/.dotnet:/home/m2gba/.dotnet/tools"
Copy-Item -Path "\home\m2gba\src\*" -Destination "\opt\src" -Recurse -Force
@ -13,7 +9,7 @@ Copy-Item -Path "\home\m2gba\src\*" -Destination "\opt\src" -Recurse -Force
if ($LASTEXITCODE -ne 0) { exit -1 }
"Starting to build test rom"
./test.ps1
./test-fast.ps1
$LAST_VAL = $LASTEXITCODE
"Copying test log to output"

View File

@ -1,6 +1,7 @@
#include "window.h"
void __attribute__((naked)) m12_first_function() {}
void __attribute__((naked)) stop(int param) {}
void __attribute__((naked)) cpufastset(void *source, void *dest, int mode) {}
void __attribute__((naked)) cpuset(void *source, void *dest, int mode) {}
byte* __attribute__((naked)) m2_strlookup(int *offset_table, byte *strings, int index) {}
@ -39,4 +40,4 @@ void __attribute__((naked)) m2_title_teardown() {}
void __attribute__((naked)) vblank() {}
int __attribute__((naked)) m2_set_equippables(WINDOW* window, unsigned short choice, byte* index_list) {}
void __attribute__((naked)) reg_ram_reset(int flag) {}
void __attribute__((naked)) m2_printnextch(WINDOW* window) {}
void __attribute__((naked)) m2_printnextch(WINDOW* window) {}

View File

@ -12,6 +12,5 @@ void start_tests()
end_session();
while(1)
vblank();
}
stop(0);
}

View File

@ -2,4 +2,4 @@
void start_tests();
extern void vblank();
extern void stop(int);

View File

@ -1,3 +1,7 @@
cpufastset:
swi 0xC
bx lr
stop:
swi 0x3
bx lr

35
test-fast.ps1 Executable file
View File

@ -0,0 +1,35 @@
$test_rom_file = "bin/m12test.gba"
$log_file = "bin/test.log"
$sleep_time = 300
$failure_text = "FAIL"
$end_text = "Done!"
$mgba_name = "mgba-rom-test"
If ($IsWindows) { $mgba_cmd = "bin/$mgba_name.exe" }
ElseIf ($IsLinux -or $IsMacOS) { $mgba_cmd = "bin/$mgba_name" }
"Building the test ROM..."
.\build.ps1 -t
if ($LASTEXITCODE -ne 0) { exit -1 }
Remove-Item -Path $log_file
"Starting the emulator... And closing it after $sleep_time seconds if it hasn't finished by then"
& timeout --preserve-status $sleep_time $mgba_cmd -l 16 -C logLevel.gba.bios=0 -C logToStdout=0 -C logToFile=1 -C logFile=$log_file $test_rom_file
if ($LASTEXITCODE -ne 0) { exit -1 }
$fails = Select-String -Path $log_file -Pattern $failure_text
if ($fails.count -ne 0) {
"Test failures:"
$fails
exit -1
}
$end_session = Select-String -Path $log_file -Pattern $end_text
if ($end_session.count -eq 0) {
"The tests did not run to completion!"
exit -1
}
"No failures!"
exit 0

0
test.ps1 Normal file → Executable file
View File