diff --git a/docker-scripts/build-dockers/Dockerfile b/docker-scripts/build-dockers/Dockerfile index b3b70c4..38e8c03 100644 --- a/docker-scripts/build-dockers/Dockerfile +++ b/docker-scripts/build-dockers/Dockerfile @@ -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 diff --git a/docker-scripts/docker-test-rom-script b/docker-scripts/docker-test-rom-script index d4435e5..3dc2436 100755 --- a/docker-scripts/docker-test-rom-script +++ b/docker-scripts/docker-test-rom-script @@ -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" diff --git a/src/c/ext.c b/src/c/ext.c index afe187f..cbd07c1 100644 --- a/src/c/ext.c +++ b/src/c/ext.c @@ -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) {} \ No newline at end of file +void __attribute__((naked)) m2_printnextch(WINDOW* window) {} diff --git a/src/c/tests/main_test.c b/src/c/tests/main_test.c index 6123c15..62c46ee 100644 --- a/src/c/tests/main_test.c +++ b/src/c/tests/main_test.c @@ -12,6 +12,5 @@ void start_tests() end_session(); - while(1) - vblank(); -} \ No newline at end of file + stop(0); +} diff --git a/src/c/tests/main_test.h b/src/c/tests/main_test.h index 36df6f2..8d48df3 100644 --- a/src/c/tests/main_test.h +++ b/src/c/tests/main_test.h @@ -2,4 +2,4 @@ void start_tests(); -extern void vblank(); \ No newline at end of file +extern void stop(int); diff --git a/src/syscalls.asm b/src/syscalls.asm index a290973..68f75c3 100644 --- a/src/syscalls.asm +++ b/src/syscalls.asm @@ -1,3 +1,7 @@ cpufastset: swi 0xC bx lr + +stop: +swi 0x3 +bx lr diff --git a/test-fast.ps1 b/test-fast.ps1 new file mode 100755 index 0000000..1c7aa36 --- /dev/null +++ b/test-fast.ps1 @@ -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 diff --git a/test.ps1 b/test.ps1 old mode 100644 new mode 100755