Git Product home page Git Product logo

pspautotests's Introduction

pspautotests

A repository of PSP programs performing several tests on the PSP platform.

  • It will allow people to see how to use some obscure-newly-discovered APIs and features
  • It will allow PSP emulators to avoid some regressions while performing refactorings and to have a reference while implementing APIs

The main idea behind this is having several files per test unit:

  • _file_*.expected* - File with the expected Kprintf's output, preferably from a real PSP
  • _file_*.prx* - The program that will call Kprintf syscall in order to generate an output
  • _file_*.input* - Optional file specifying automated actions that should simulate user interaction: pressing a key, releasing a key, selecting a file on the save selector, waiting for a function (for example a vsync) to call before continuing...

How to build and use

If you just want to run the tests, you just need to run your emulator on the PRX files and compare with the .expected files. PPSSPP has a convenient script for this called test.py.

If you want to change tests, you'll need to read the rest. This tutorial is focused on Windows but can probably be used on Linux and Mac too, you just don't need to install the driver there.

Prerequisites

The rest of this tutorial will assume that you installed the PSPSDK in C:\pspsdk.

Step 1: Install PSPLink on your PSP

  • Copy the OE version of PSPLink (C:\pspsdk\psplink\psp\oe\psplink) to PSP/GAME on the PSP.
  • Run it on your PSP from the game menu.

Step 2: Prepare the PC

Tip: If you see PSP Type A, you've connected the PSP in "USB mode". Disconnect, and run the PSPLINK game instead.

Windows 7 and later

  • Plug the PSP into your PC via USB while PSPLINK is running.
  • Use Zadig to install the libusbK (on Windows 11, at least) or libusb-win32 driver.
  • Make sure it says PSP Type B in Zadig and click Install Driver.

Windows XP / Vista / etc.

  • If you are on Vista x64, you may need to press F8 during boot up and select "Disable driver signing verification". You'll have to do this each boot on Vista x64.
  • After boot, plug the PSP into your PC via USB while PSPLINK is running.
  • Go into Device Manager and select the PSP Type B device in the list.
  • Right click on "PSP Type B" -> Properties.
  • Select Update Driver and select "I have my own driver".
  • For the path, use C:\pspsdk\bin\driver or C:\pspsdk\bin\driver_x64 depending on your OS install.

Mac OS X

Linux

Step 3: Add pspsdk to PATH

  • Add C:\pspsdk\bin (or equivalent) to your PATH if you haven't already got it.
  • Go to pspautotests\common and run make (might need to start a new cmd shell)

You are now ready to roll!

Running tests

In a standard "cmd" command prompt in the directory that you want the PSP software to regard as "host0:/" (normally pspautotests/) if it tries to read files over the cable, type the following:

> cd pspautotests
> usbhostfs_pc -b 3000

Then in a separate command prompt:

> pspsh -p 3000

If you now don't see a host0:/ prompt, something is wrong. Most likely the driver has not loaded correctly. If the port 3000 happened to be taken (usbhostfs_pc would have complained), try another port number.

Now you have full access to the PSP from this prompt.

You can exit it and use gentest.py (which will start the same prompt) to run tests (e.g. gentest.py misc/testgp) and update the .expected files.

You can run executables on the PSP that reside on the PC directly from within this the pspsh shell, just cd to the directory and run ./my_program.prx.

Note that you CAN'T run ELF files on modern firmware, you MUST build as .PRX. To do this, set BUILD_PRX = 1 in your makefile.

Also, somewhere in your program, add the following line to get a proper heap size:

unsigned int sce_newlib_heap_kb_size = -1;

For some probably historical reason, by default PSPSDK assumes that you want a 64k heap when you build a PRX.

TODO

Maybe join .expected and .input file in a single .test file?

Random Ideas for .test file:

EXPECTED:CALL(sceDisplay.sceDisplayWaitVblank)
ACTION:BUTTON_PRESS(CROSS)
EXPECTED:OUTPUT('CROSS Pressed')
EXPECTED:CALL(sceDisplay.sceDisplayWaitVblank)
ACTION:BUTTON_RELEASE(CROSS)

pspautotests's People

Contributors

achurch avatar artart78 avatar coestergaard avatar elsonlee avatar homersp avatar hrydgard avatar orphis avatar shenweip avatar soywiz avatar tmaul avatar unknownbrackets avatar xele02 avatar xyzz avatar ydamigos avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pspautotests's Issues

Kernel mode tests

If we ever want to implement / allow cfw plugins, certain translation patches, maybe some kernel-mode modules without HLE'ing, etc. we will need to support kernel mode.

Also, there are a couple funcs which might be useful for testing (ctrl emulation, have not tried it yet, partition and module info, etc.) which are only available under kernel mode.

I had problems before but I think I missed something simple. I'm able now to make working kernel-mode tests using:

diff --git a/common/Makefile b/common/Makefile
index ce2bd26..92f9ab6 100644
--- a/common/Makefile
+++ b/common/Makefile
@@ -1,5 +1,7 @@
 TARGET_LIB = libcommon.a
+EXTRA_TARGETS = libcommon_kernel.a
 OBJS = common.o vram.o sysmem-imports.o
+KERNEL_OBJS = common_kernel.o vram.o sysmem-imports.o

 INCDIR =
 CFLAGS = -O0 -G 0 -g -Wall
@@ -11,3 +13,13 @@ LDFLAGS = -G0

 PSPSDK=$(shell psp-config --pspsdk-path)
 include $(PSPSDK)/lib/build.mak
+
+%.o: %.S
+  $(AS) $(ASFLAGS) -c -o $@ $<
+
+common_kernel.o: common.c
+  $(CC) $(CFLAGS) -DCOMMON_KERNEL=1 -c -o $@ $<
+
+libcommon_kernel.a: $(KERNEL_OBJS)
+  $(AR) cru $@ $(KERNEL_OBJS)
+  $(RANLIB) $@
diff --git a/common/common.c b/common/common.c
index d7ed0bf..ba79d79 100644
--- a/common/common.c
+++ b/common/common.c
@@ -43,9 +43,13 @@ enum PspModuleInfoAttr
 };
 */

+#ifdef COMMON_KERNEL
+PSP_MODULE_INFO("TESTMODULE", PSP_MODULE_KERNEL, 1, 0);
+PSP_MAIN_THREAD_ATTR(PSP_THREAD_ATTR_VFPU);
+#else
 PSP_MODULE_INFO("TESTMODULE", PSP_MODULE_USER, 1, 0);
 PSP_MAIN_THREAD_ATTR(PSP_THREAD_ATTR_USER | PSP_THREAD_ATTR_VFPU);
-//PSP_MAIN_THREAD_ATTR(PSP_THREAD_ATTR_USER);
+#endif

 #define EMULATOR_DEVCTL__GET_HAS_DISPLAY 0x00000001
 #define EMULATOR_DEVCTL__SEND_OUTPUT     0x00000002
diff --git a/common/common.mk b/common/common.mk
index 857bceb..0006cdf 100644
--- a/common/common.mk
+++ b/common/common.mk
@@ -26,8 +26,12 @@ LDFLAGS = -G0
 endif

 ifndef LIBS
+ifdef COMMON_KERNEL
+LIBS = -lpspgu -lpsprtc -lpspctrl -lpspmath -lcommon_kernel -lc -lm
+else
 LIBS = -lpspgu -lpsprtc -lpspctrl -lpspmath -lcommon -lc -lm
 endif
+endif
 ifdef EXTRA_LIBS
 LIBS := $(LIBS) $(EXTRA_LIBS)
 endif
diff --git a/common/sysmem-imports.S b/common/sysmem-imports.S
index 25e1811..0c5c14c 100644
--- a/common/sysmem-imports.S
+++ b/common/sysmem-imports.S
@@ -38,4 +38,4 @@ IMPORT_FUNC  "SysMemUserForUser",0x358CA1BB,sceKernelSetCompil
 IMPORT_FUNC  "SysMemUserForUser",0xA6848DF8,sceKernelSetUsersystemLibWork
 IMPORT_FUNC  "SysMemUserForUser",0xACBD88CA,sceKernelTotalMemSize
 IMPORT_FUNC  "SysMemUserForUser",0xD8DE5C1E,SysMemUserForUser_D8DE5C1E
-IMPORT_FUNC  "SysMemUserForUser",0x945E45DA,SysMemUserForUser_945E45DA
\ No newline at end of file
+IMPORT_FUNC  "SysMemUserForUser",0x945E45DA,SysMemUserForUser_945E45DA

The only problem is, this means creating duplicates of some tests if we want to run them. Another potential option is automatically building a "kernel version" of each test as TESTNAME_kernel.prx or something.

Not sure what's best.

-[Unknown]

Questions about using psplink

I have tried to follow the "How to build and use" mini tutorial in the README file. But since I never used psplink I have some questions, and probably would be a good idea to provide something a bit more straightforward.

Question1: How should I install psplink? I thought psplink was a kernel module that had to be installed as a plugin or something. I have looked at pspsdk\psplink\psp\oe\psplink and copied the contents to ms0:/PSP/GAME/psplink because I have seen that there is an eboot.
But as far as I know that executes psplink as a user module. Right? It will work that way?

Question2: I don't know what I have to install on host. I have Windows 8 x64. I thought I had to install libusb: http://sourceforge.net/apps/trac/libusb-win32/wiki
I have seen that since 1.2 they have a signed certificate, so maybe we don't need to do the hack of disabling the certificate signature? I ended here: http://sourceforge.net/projects/libusb-win32/files/libusb-win32-releases/1.2.6.0/ and downloaded libusb-win32-bin-1.2.6.0.zip and libusb-win32-devel-filter-1.2.6.0.exe what should I install? the filter one? I have installed that and executed:

on the psp, psplink (it seems that it is freezed or something. Home button doesn't work). But for example I can press LT+RT+Square and perform memory dumping, so it seems that at least it didn't crash.

on the computer:
usbhostfs_pc -b 3000
USBHostFS (c) TyRaNiD 2k6
Built Mar 26 2009 16:26:00 - $Revision: 2368 $
sh> Accepting async connection (0) from 127.0.0.1
Accepting async connection (2) from 127.0.0.1

then in another console:

pspsh -p 3000

I have tried writting help and trying some commands. For example: "power" command, but when I type that nothing else occurs.
Also usbhostfs didn't told me to install anything (no driver at all), so I think I missed something.
Could you provide some more n00bfriendly information about how to use that ? That would help a lot and will save me a lot of time.

Thanks in advance!

Avoid printf rescheduling

I have seend that there are a lot of problems with printf doing a thread reschedule. I was thinking about that.
What about disabling thread switching on printf?

Maybe with a macro that replaces printf, and calls the real printf. Something like:

#define printf(...) \
    sceKernelCpuSuspendIntr(); \
    real_printf(__VA_ARGS__); \
    sceKernelCpuResumeIntr();

Figure out how to run tests on each SDK ver

Eventually we need to run these tests against different SDK versions so we can see what differences they produce.

Possibly just calling the memory/SDK/etc. functions, but not sure if they work correctly through psplink or if the build settings need to be changed or something...

Not a priority right now imho, just a todo.

-[Unknown]

Running audio/atrac/resetting failed on build

Hi,

I am trying to run the audio/atrac/resetting test but it fails to build.

python2 gentest.py audio/atrac/resetting
Running test audio/atrac/resetting on the PSP...
psp-g++ -I. -I../../../common -I. -I/opt/pspsdk/psp/sdk/include -g -G0 -Wall -O0 -fno-strict-aliasing -I. -I../../../common -I. -I/opt/pspsdk/psp/sdk/include -g -G0 -Wall -O0 -fno-strict-aliasing -fno-exceptions -fno-rtti  -D_PSP_FW_VERSION=500   -c -o shared.o shared.cpp
In file included from shared.h:2,
                 from shared.cpp:1:
atrac.h:18: error: declaration of C function 'int sceAtracGetAtracID(int)' conflicts with
/opt/pspsdk/psp/sdk/include/pspatrac3.h:70: error: previous declaration 'int sceAtracGetAtracID(uint)' here
atrac.h:20: error: declaration of C function 'int sceAtracSetData(int, void*, SceSize)' conflicts with
/opt/pspsdk/psp/sdk/include/pspatrac3.h:202: error: previous declaration 'int sceAtracSetData(int, u8*, u32)' here
atrac.h:21: error: declaration of C function 'int sceAtracResetPlayPosition(int, int, int, int)' conflicts with
/opt/pspsdk/psp/sdk/include/pspatrac3.h:200: error: previous declaration 'int sceAtracResetPlayPosition(int, u32, u32, u32)' here
atrac.h:23: error: declaration of C function 'int sceAtracSetHalfwayBufferAndGetID(void*, int, int)' conflicts with
/opt/pspsdk/psp/sdk/include/pspatrac3.h:206: error: previous declaration 'int sceAtracSetHalfwayBufferAndGetID(u8*, u32, u32)' here
shared.cpp: In destructor 'Atrac3File::~Atrac3File()':
shared.cpp:26: warning: deleting 'void*' is undefined
shared.cpp: In member function 'void Atrac3File::Reload(const char*)':
shared.cpp:31: warning: deleting 'void*' is undefined
<builtin>: recipe for target 'shared.o' failed
make: *** [shared.o] Error 1

My machine runs Archlinux x64.

I made some public domain audio assets for the PPSSPP autotests (for those who missed them on the forum)

Original forum post: http://forums.ppsspp.org/showthread.php?tid=3914

Original MP3 file: https://dl.dropboxusercontent.com/u/13594612/prototype-platformer/sounds/Music.mp3

atrac3+ stereo: https://dl.dropboxusercontent.com/u/13594612/prototype-platformer/sounds/music.oma

atrac3 stereo: https://dl.dropboxusercontent.com/u/13594612/prototype-platformer/sounds/music.at3

VAG stereo: https://dl.dropboxusercontent.com/u/13594612/prototype-platformer/sounds/music.vag

Feel free to use the files or distribute them in any way you want. I will update this issue if I find a way to convert the files to more formats (like atrac3 mono).

Compile without prblems, but running with error

Hello, I was trying to use this complied codes for running a game, but I am facing an error(you can find it in the attachment). Could you help me with it?
 C LNMSQ J BN TI 90Y9W
The specification of my computer:
Operating System: Windows 8 Pro 64-bit (6.2, Build 9200) (9200.win8_gdr.121119-1606)
Language: English (Regional Setting: English)
System Manufacturer: Dell Inc.
System Model: Dell System XPS L502X
BIOS: Default System BIOS
Processor: Intel(R) Core(TM) i7-2670QM CPU @ 2.20GHz (8 CPUs), ~2.2GHz
Memory: 6144MB RAM
Available OS Memory: 6038MB RAM
Page File: 4839MB used, 7342MB available
Windows Dir: C:\WINDOWS
DirectX Version: DirectX 11
DX Setup Parameters: Not found
User DPI Setting: Using System DPI
System DPI Setting: 120 DPI (125 percent)
DWM DPI Scaling: Disabled
DxDiag Version: 6.02.9200.16384 64bit Unicode
Two graphic cards:

  1. integrated one in the chip
  2. Nvidia GT540M(default one)

Thanks so much!

sltiu (cpu test)

This is the second time (first in cspspemu, now in jspspemu) that I have some issues with that cpu instruction. But I didn't have a simple test that tested it and didn't know that that was the source of problems.

This sentence: printf("%f\n", -20000.5);
Outputs: "-20000.4CCD00"
when implemented bad.

This was the change:
jspspemu/jspspemu@4a6a88d

-       sltiu(i: Instruction) { return assignGpr(i.rt, call('state.sltu', [gpr(i.rs), u_imm32(i.u_imm16)])); }
+       sltiu(i: Instruction) { return assignGpr(i.rt, call('state.sltu', [gpr(i.rs), u_imm32(i.imm16)])); }

I create the issue here in order to add a sltiu test in "cpu.c" file and don't forget about that.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.