mirror of
https://github.com/grumpycoders/pcsx-redux.git
synced 2024-06-01 02:38:33 -04:00
Starting to handle mips unit testing.
This commit is contained in:
parent
d373bd4ccf
commit
82efaf9e26
3
.gitmodules
vendored
3
.gitmodules
vendored
|
@ -34,3 +34,6 @@
|
|||
[submodule "third_party/http-parser"]
|
||||
path = third_party/http-parser
|
||||
url = https://github.com/nodejs/http-parser.git
|
||||
[submodule "third_party/libcester"]
|
||||
path = third_party/libcester
|
||||
url = https://github.com/exoticlibraries/libcester.git
|
||||
|
|
22
.vscode/launch.json
vendored
22
.vscode/launch.json
vendored
|
@ -26,6 +26,28 @@
|
|||
"valuesFormatting": "parseText"
|
||||
},
|
||||
|
||||
{
|
||||
"type": "gdb",
|
||||
"request": "launch",
|
||||
"name": "(gdb) Launch Basic Test",
|
||||
"target": "./src/mips/tests/basic/basic.elf",
|
||||
"gdbpath": "/usr/bin/gdb-multiarch",
|
||||
"windows": {
|
||||
"gdbpath": "C:/gdb-multiarch/bin/gdb.exe",
|
||||
},
|
||||
"cwd": "${workspaceRoot}",
|
||||
"autorun": [
|
||||
"target remote localhost:3333",
|
||||
"symbol-file ./src/mips/tests/basic/basic.elf",
|
||||
"set substitute-path /project .",
|
||||
"load ./src/mips/tests/basic/basic.elf",
|
||||
"monitor reset halt",
|
||||
"tbreak main",
|
||||
"continue",
|
||||
],
|
||||
"valuesFormatting": "parseText"
|
||||
},
|
||||
|
||||
{
|
||||
"name": "(gdb) Launch PCSX-Redux",
|
||||
"type": "cppdbg",
|
||||
|
|
|
@ -8,9 +8,14 @@ CC = $(PREFIX)-gcc
|
|||
TYPE ?= cpe
|
||||
LDSCRIPT ?= $(ROOTDIR)/$(TYPE).ld
|
||||
|
||||
USE_FUNCTION_SECTIONS ?= true
|
||||
|
||||
ARCHFLAGS = -march=mips1 -mabi=32 -EL -fno-pic -mno-shared -mno-abicalls -mfp32
|
||||
ARCHFLAGS += -fno-stack-protector -nostdlib -ffreestanding
|
||||
CPPFLAGS += -mno-gpopt -fomit-frame-pointer -ffunction-sections
|
||||
ifeq ($(USE_FUNCTION_SECTIONS),true)
|
||||
CPPFLAGS += -ffunction-sections
|
||||
endif
|
||||
CPPFLAGS += -mno-gpopt -fomit-frame-pointer
|
||||
CPPFLAGS += -fno-builtin -fno-strict-aliasing -Wno-attributes
|
||||
CPPFLAGS += $(ARCHFLAGS)
|
||||
CPPFLAGS += -I$(ROOTDIR)
|
||||
|
|
46
src/mips/common/crt0/uC-sdk-crt0.s
Normal file
46
src/mips/common/crt0/uC-sdk-crt0.s
Normal file
|
@ -0,0 +1,46 @@
|
|||
/*
|
||||
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2020 PCSX-Redux authors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
||||
*/
|
||||
|
||||
.section .start, "ax", @progbits
|
||||
.align 2
|
||||
.global _ucsdk_start
|
||||
.global _start
|
||||
.type _start, @function
|
||||
|
||||
_start:
|
||||
la $t0, __bss_start
|
||||
la $t1, __bss_end
|
||||
|
||||
beq $t0, $t1, bss_init_skip
|
||||
|
||||
bss_init:
|
||||
sw $0, 0($t0)
|
||||
addiu $t0, 4
|
||||
bne $t0, $t1, bss_init
|
||||
|
||||
bss_init_skip:
|
||||
|
||||
j _ucsdk_start
|
|
@ -1,8 +1,45 @@
|
|||
TARGET = basic
|
||||
USE_FUNCTION_SECTIONS = false
|
||||
TYPE = ps-exe
|
||||
|
||||
SRCS = \
|
||||
../uC-sdk-glue/BoardConsole.c \
|
||||
../uC-sdk-glue/BoardInit.c \
|
||||
../uC-sdk-glue/init.c \
|
||||
\
|
||||
../../../../third_party/uC-sdk/libc/src/cxx-glue.c \
|
||||
../../../../third_party/uC-sdk/libc/src/errno.c \
|
||||
../../../../third_party/uC-sdk/libc/src/initfini.c \
|
||||
../../../../third_party/uC-sdk/libc/src/malloc.c \
|
||||
../../../../third_party/uC-sdk/libc/src/qsort.c \
|
||||
../../../../third_party/uC-sdk/libc/src/rand.c \
|
||||
../../../../third_party/uC-sdk/libc/src/reent.c \
|
||||
../../../../third_party/uC-sdk/libc/src/stdio.c \
|
||||
../../../../third_party/uC-sdk/libc/src/strto.c \
|
||||
../../../../third_party/uC-sdk/libc/src/unistd.c \
|
||||
../../../../third_party/uC-sdk/libc/src/xprintf.c \
|
||||
../../../../third_party/uC-sdk/libc/src/xscanf.c \
|
||||
../../../../third_party/uC-sdk/libc/src/yscanf.c \
|
||||
../../../../third_party/uC-sdk/os/src/devfs.c \
|
||||
../../../../third_party/uC-sdk/os/src/filesystem.c \
|
||||
../../../../third_party/uC-sdk/os/src/fio.c \
|
||||
../../../../third_party/uC-sdk/os/src/hash-djb2.c \
|
||||
../../../../third_party/uC-sdk/os/src/init.c \
|
||||
../../../../third_party/uC-sdk/os/src/osdebug.c \
|
||||
../../../../third_party/uC-sdk/os/src/romfs.c \
|
||||
../../../../third_party/uC-sdk/os/src/sbrk.c \
|
||||
|
||||
|
||||
CPPFLAGS = -DNOFLOATINGPOINT
|
||||
CPPFLAGS += -I.
|
||||
CPPFLAGS += -I../../../../third_party/uC-sdk/libc/include
|
||||
CPPFLAGS += -I../../../../third_party/uC-sdk/os/include
|
||||
CPPFLAGS += -I../../../../third_party/libcester/include
|
||||
CPPFLAGS += -I../../openbios/uC-sdk-glue
|
||||
|
||||
SRCS += \
|
||||
../../common/syscalls/printf.s \
|
||||
../../common/crt0/crt0.s \
|
||||
../../common/crt0/uC-sdk-crt0.s \
|
||||
basic.c \
|
||||
|
||||
include ../../common.mk
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2019 PCSX-Redux authors
|
||||
Copyright (c) 2020 PCSX-Redux authors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
@ -24,11 +24,16 @@ SOFTWARE.
|
|||
|
||||
*/
|
||||
|
||||
#include "common/hardware/pcsxhw.h"
|
||||
#include "common/syscalls/syscalls.h"
|
||||
|
||||
int main() {
|
||||
#undef unix
|
||||
#define CESTER_NO_SIGNAL
|
||||
#define CESTER_NO_TIME
|
||||
#define EXIT_SUCCESS 0
|
||||
#define EXIT_FAILURE 1
|
||||
#include "exotic/cester.h"
|
||||
|
||||
CESTER_TEST(test1, test_instance,
|
||||
ramsyscall_printf("Hello world\n");
|
||||
pcsx_exit(0);
|
||||
while (1);
|
||||
}
|
||||
cester_assert_equal(NULL, NULL);
|
||||
)
|
||||
|
|
58
src/mips/tests/uC-sdk-glue/BoardConsole.c
Normal file
58
src/mips/tests/uC-sdk-glue/BoardConsole.c
Normal file
|
@ -0,0 +1,58 @@
|
|||
/*
|
||||
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2019 PCSX-Redux authors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
||||
*/
|
||||
|
||||
#include "BoardConsole.h"
|
||||
|
||||
#include "common/syscalls/syscalls.h"
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
|
||||
void BoardConsoleInit() {}
|
||||
|
||||
void BoardConsolePuts(const char * str) {
|
||||
char c;
|
||||
while ((c = *str++)) BoardConsolePutc(c);
|
||||
}
|
||||
|
||||
void BoardConsolePutc(int c) {
|
||||
syscall_putchar(c);
|
||||
}
|
||||
|
||||
static void xprintfCallback(const char * str, int strsize, void * opaque0) {
|
||||
while (strsize--)
|
||||
BoardConsolePutc(*str++);
|
||||
}
|
||||
|
||||
void BoardConsolePrintf(const char * fmt, ...) {
|
||||
va_list ap;
|
||||
va_start(ap, fmt);
|
||||
BoardConsoleVPrintf(fmt, ap);
|
||||
va_end(ap);}
|
||||
|
||||
void BoardConsoleVPrintf(const char * fmt, va_list ap) {
|
||||
vxprintf(xprintfCallback, NULL, fmt, ap);
|
||||
}
|
35
src/mips/tests/uC-sdk-glue/BoardConsole.h
Normal file
35
src/mips/tests/uC-sdk-glue/BoardConsole.h
Normal file
|
@ -0,0 +1,35 @@
|
|||
/*
|
||||
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2019 PCSX-Redux authors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdarg.h>
|
||||
|
||||
void BoardConsoleInit();
|
||||
void BoardConsolePuts(const char * str);
|
||||
void BoardConsolePutc(int);
|
||||
void BoardConsolePrintf(const char * fmt, ...) __attribute__ ((format(printf, 1, 2)));
|
||||
void BoardConsoleVPrintf(const char * fmt, va_list ap);
|
44
src/mips/tests/uC-sdk-glue/BoardInit.c
Normal file
44
src/mips/tests/uC-sdk-glue/BoardInit.c
Normal file
|
@ -0,0 +1,44 @@
|
|||
/*
|
||||
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2019 PCSX-Redux authors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
||||
*/
|
||||
|
||||
#include "common/hardware/pcsxhw.h"
|
||||
|
||||
void BoardEarlyInit() {
|
||||
}
|
||||
|
||||
void BoardInit() {
|
||||
}
|
||||
|
||||
void BoardLateInit() {
|
||||
}
|
||||
|
||||
void BoardShutdown() {
|
||||
pcsx_exit(0);
|
||||
}
|
||||
|
||||
void BoardExceptionHandler(int code) {
|
||||
pcsx_exit(code);
|
||||
}
|
28
src/mips/tests/uC-sdk-glue/FreeRTOS.h
Normal file
28
src/mips/tests/uC-sdk-glue/FreeRTOS.h
Normal file
|
@ -0,0 +1,28 @@
|
|||
/*
|
||||
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2019 PCSX-Redux authors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
34
src/mips/tests/uC-sdk-glue/init.c
Normal file
34
src/mips/tests/uC-sdk-glue/init.c
Normal file
|
@ -0,0 +1,34 @@
|
|||
/*
|
||||
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2019 PCSX-Redux authors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
||||
*/
|
||||
|
||||
void cpu_early_init() {
|
||||
}
|
||||
|
||||
void cpu_init() {
|
||||
}
|
||||
|
||||
void cpu_late_init() {
|
||||
}
|
36
src/mips/tests/uC-sdk-glue/semphr.h
Normal file
36
src/mips/tests/uC-sdk-glue/semphr.h
Normal file
|
@ -0,0 +1,36 @@
|
|||
/*
|
||||
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2019 PCSX-Redux authors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#define portMAX_DELAY 0
|
||||
|
||||
typedef void * xSemaphoreHandle;
|
||||
static __inline void * xSemaphoreCreateMutex() { return NULL; }
|
||||
static __inline void xSemaphoreTake(void * semaphore, unsigned timeout) {}
|
||||
static __inline void xSemaphoreGive(void * semaphore) {}
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
TEST(Basic, Meta) {
|
||||
MainInvoker invoker("-run", "-bios", "src/mips/openbios/openbios.bin", "-loadexe",
|
||||
"src/mips/tests/basic/basic.cpe");
|
||||
"src/mips/tests/basic/basic.ps-exe");
|
||||
int ret = invoker.invoke();
|
||||
EXPECT_EQ(ret, 0);
|
||||
}
|
||||
|
|
1
third_party/libcester
vendored
Submodule
1
third_party/libcester
vendored
Submodule
|
@ -0,0 +1 @@
|
|||
Subproject commit 0e0c97dfbad6b256646d62ce32824836d87eebb9
|
Loading…
Reference in a new issue