Skip to content

Socket "testing"#14

Draft
StevenMiller123 wants to merge 11 commits intops4emulation:mainfrom
StevenMiller123:net-tests
Draft

Socket "testing"#14
StevenMiller123 wants to merge 11 commits intops4emulation:mainfrom
StevenMiller123:net-tests

Conversation

@StevenMiller123
Copy link
Collaborator

@StevenMiller123 StevenMiller123 commented Jan 29, 2026

This homebrew uses a variety of socket-related behaviors to visually test how sockets are functioning.
The primary test code is a basic test of non-blocking socket communication, and I've baked in a couple socket-based logging backends to ensure multiple sockets can communicate simultaneously, and give a visual indicator of sockets functioning.

I've run these tests on a PS4 with no internet, and they run to completion without logging any errors.

<94> EXEC /app0/eboot.bin [user], vm#1, dmem#1  <4681043 msec>
 +++ num clients 2
<118>**** Base Mode ****
<118>[SceShellCore] Best effort threads use 2 CPU cores.
<118>Main: Running first round of tests
<118>Main: Running second round of tests
<118>Server: socket(AF_INET, SOCK_STREAM, 0) returns 0x0000000f
<118>Server: setsockopt(SOL_SOCKET, SO_REUSEADDR) returns 0x00000000
<118>Server: setsockopt(SOL_SOCKET, SO_REUSEPORT) returns 0x00000000
<118>Server: bind returns 0x00000000
<118>Server: listen returns 0x00000000
<118>Client: socket(AF_INET, SOCK_STREAM, 0) returns 0x00000011
<118>Client: inet_pton(ORBIS_NET_AF_INET) returns 0x00000001
<118>Client: connect returns 0x00000000
<118>Server: accept returns 0x0000000e
<118>Server: send returns 0x0000002d
<118>Client: recv returns 0x0000002d
<118>Client: send returns 0x0000002d
<118>Server: recv returns 0x0000002d
<118>Server: epoll_create returns 0x00000010
<118>Server: epoll_ctl returns 0x00000000
<118>Server: epoll_wait returns 0x00000000
<118>Client: send returns 0x0000002d
<118>Client: socket_close returns 0x00000000
<118>Server: epoll_wait returns 0x00000001
<118>Server: recv returns 0x0000002d
<118>Server: epoll_destroy returns 0x00000000
<118>Server: socket_close returns 0x00000000
<118>Server: socket_close returns 0x00000000
<118>Main: Running third round of tests
<118>Server: socket(AF_INET, SOCK_STREAM, 0) returns 0x0000000e
<118>Server: setsockopt(SOL_SOCKET, SO_REUSEADDR) returns 0x00000000
<118>Server: setsockopt(SOL_SOCKET, SO_REUSEPORT) returns 0x00000000
<118>Server: bind returns 0x00000000
<118>Server: listen returns 0x00000000
<118>Client: socket(AF_INET, SOCK_STREAM, 0) returns 0x00000010
<118>Client: inet_pton(ORBIS_NET_AF_INET) returns 0x00000001
<118>Client: connect returns 0x00000000
<118>Server: accept returns 0x0000000f
<118>Server: send returns 0x0000002d
<118>Client: recv returns 0x0000002d
<118>Client: send returns 0x0000002d
<118>Server: recv returns 0x0000002d
<118>Server: epoll_create returns 0x00000011
<118>Server: epoll_ctl returns 0x00000000
<118>Server: epoll_wait returns 0x00000000
<118>Client: send returns 0x0000002d
<118>Server: epoll_wait returns 0x00000001
<118>Client: socket_close returns 0x00000000
<118>Server: recv returns 0x0000002d
<118>Server: epoll_destroy returns 0x00000000
<118>Server: socket_close returns 0x00000000
<118>Server: socket_close returns 0x00000000
<118>Main: Running fourth round of tests
<118>Server: socket(AF_INET, SOCK_STREAM, 0) returns 0x0000000e
<118>Server: setsockopt(SOL_SOCKET, SO_REUSEADDR) returns 0x00000000
<118>Server: setsockopt(SOL_SOCKET, SO_REUSEPORT) returns 0x00000000
<118>Server: bind returns 0x00000000
<118>Server: listen returns 0x00000000
<118>Client: socket(AF_INET, SOCK_STREAM, 0) returns 0x00000017
<118>Client: inet_pton(ORBIS_NET_AF_INET) returns 0x00000001
<118>Client: connect returns 0x00000000
<118>Server: accept returns 0x00000014
<118>Server: send returns 0x0000002d
<118>Client: recv returns 0x0000002d
<118>Client: send returns 0x0000002d
<118>Server: recv returns 0x0000002d
<118>Server: epoll_create returns 0x00000011
<118>Server: epoll_ctl returns 0x00000000
<118>Server: epoll_wait returns 0x00000000
<118>Client: send returns 0x0000002d
<118>Client: socket_close returns 0x00000000
<118>Server: epoll_wait returns 0x00000001
<118>Server: recv returns 0x0000002d
<118>Server: epoll_destroy returns 0x00000000
<118>Main: Test suite completed
<118>.
<118>OK (1 tests, 1 ran, 107 checks, 0 ignored, 0 filtered out, 2724 ms)
<118>

I plan to continue increasing the scope of these tests over time, so I've marked this as a draft for now.

The actual test part of the test is fairly basic, but the logging serves as a somewhat more advanced test.
… more complicated

The goal is going to be to have separate "logger" classes to go with each test, serving as a "real-world" use case for the features being tested.
Also made this non-blocking logger support asynchronous logging, to make it even harder to run. Probably going to work in separate tests for running as sync and async, but for now I've just got it set to run async.
Need to copy log result, otherwise it can change on the fly.
A far more simplistic logging backend, where blocking IO saves us from needing to mess with epolls, and we don't need to deal with the various errors coming from incomplete connections or messages.
Now the loggers are actually relevant to the tests.
The "first" round of tests runs with no logging backend, perfect for ensuring basic behavior works. The second round runs with the blocking sockets logging backend, third round with the non-blocking sync logging, and finally the last round uses non-blocking async logging.
Didn't cause issues too often on PS4, but was an issue that could occur.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant