mirror of https://github.com/xemu-project/xemu.git
tests/mcpx/dsp: Add basic test
This commit is contained in:
parent
9d1e7f9713
commit
eb36b8919e
|
@ -86,3 +86,4 @@ subdir('qapi-schema')
|
||||||
subdir('qtest')
|
subdir('qtest')
|
||||||
subdir('migration')
|
subdir('migration')
|
||||||
subdir('functional')
|
subdir('functional')
|
||||||
|
subdir('xbox')
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
all: basic
|
||||||
|
|
||||||
|
%: %.a56
|
||||||
|
a56 -o $@ $<
|
|
@ -0,0 +1,12 @@
|
||||||
|
P 0000 0C0040
|
||||||
|
P 0040 0AF080
|
||||||
|
P 0041 000042
|
||||||
|
P 0042 56F400
|
||||||
|
P 0043 123456
|
||||||
|
P 0044 567000
|
||||||
|
P 0045 000003
|
||||||
|
P 0046 08F484
|
||||||
|
P 0047 000001
|
||||||
|
P 0048 0C0042
|
||||||
|
I 000040 start
|
||||||
|
I 000042 mainloop
|
|
@ -0,0 +1,12 @@
|
||||||
|
org p:$0000
|
||||||
|
jmp <start
|
||||||
|
|
||||||
|
org p:$40
|
||||||
|
start
|
||||||
|
jmp mainloop
|
||||||
|
|
||||||
|
mainloop
|
||||||
|
move #$123456,A
|
||||||
|
move A,X:3
|
||||||
|
movep #$000001,x:$ffffc4
|
||||||
|
jmp <mainloop
|
|
@ -0,0 +1,13 @@
|
||||||
|
test_env = environment()
|
||||||
|
test_env.set('G_TEST_SRCDIR', meson.current_source_dir())
|
||||||
|
test_env.set('G_TEST_BUILDDIR', meson.current_build_dir())
|
||||||
|
|
||||||
|
exe = executable('test-xbox-mcpx-dsp',
|
||||||
|
sources: files('test-dsp.c'),
|
||||||
|
dependencies: [qemuutil, dsp, glib])
|
||||||
|
|
||||||
|
test('xbox-mcpx-dsp', exe,
|
||||||
|
env: test_env,
|
||||||
|
args: ['--tap', '-k'],
|
||||||
|
protocol: 'tap',
|
||||||
|
suite: ['xbox', 'xbox-mcpx', 'xbox-mcpx-dsp'])
|
|
@ -0,0 +1,84 @@
|
||||||
|
/*
|
||||||
|
* DSP tests.
|
||||||
|
*
|
||||||
|
* Copyright (c) 2025 Matt Borgerson
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
* License as published by the Free Software Foundation; either
|
||||||
|
* version 2 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This library is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
|
* License along with this library; if not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "qemu/osdep.h"
|
||||||
|
#include "hw/xbox/mcpx/dsp/dsp.h"
|
||||||
|
|
||||||
|
static void scratch_rw(void *opaque, uint8_t *ptr, uint32_t addr, size_t len, bool dir)
|
||||||
|
{
|
||||||
|
assert(!"Not implemented");
|
||||||
|
}
|
||||||
|
|
||||||
|
static void fifo_rw(void *opaque, uint8_t *ptr, unsigned int index, size_t len, bool dir)
|
||||||
|
{
|
||||||
|
assert(!"Not implemented");
|
||||||
|
}
|
||||||
|
|
||||||
|
static void load_prog(DSPState *s, const char *path)
|
||||||
|
{
|
||||||
|
FILE *file = fopen(path, "r");
|
||||||
|
assert(file && "Error opening file");
|
||||||
|
|
||||||
|
char type, line[100], arg1[20], arg2[20];
|
||||||
|
int addr, value;
|
||||||
|
|
||||||
|
while (fgets(line, sizeof(line), file)) {
|
||||||
|
if (sscanf(line, "%c %s %s", &type, arg1, arg2) >= 2) {
|
||||||
|
switch (type) {
|
||||||
|
case 'P':
|
||||||
|
case 'X':
|
||||||
|
case 'Y': {
|
||||||
|
assert(sscanf(arg1, "%x", &addr) == 1);
|
||||||
|
assert(sscanf(arg2, "%x", &value) == 1);
|
||||||
|
dsp_write_memory(s, type, addr, value);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
printf("Invalid line: %s\n", line);
|
||||||
|
assert(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fclose(file);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void test_dsp_basic(void)
|
||||||
|
{
|
||||||
|
g_autofree gchar *path = g_test_build_filename(G_TEST_DIST, "data", "basic", NULL);
|
||||||
|
|
||||||
|
DSPState *s = dsp_init(NULL, scratch_rw, fifo_rw);
|
||||||
|
|
||||||
|
load_prog(s, path);
|
||||||
|
dsp_run(s, 1000);
|
||||||
|
|
||||||
|
uint32_t v = dsp_read_memory(s, 'X', 3);
|
||||||
|
g_assert_cmphex(v, ==, 0x123456);
|
||||||
|
|
||||||
|
dsp_destroy(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int argc, char **argv)
|
||||||
|
{
|
||||||
|
g_test_init(&argc, &argv, NULL);
|
||||||
|
|
||||||
|
g_test_add_func("/basic", test_dsp_basic);
|
||||||
|
|
||||||
|
return g_test_run();
|
||||||
|
}
|
|
@ -0,0 +1 @@
|
||||||
|
subdir('dsp')
|
Loading…
Reference in New Issue