Files
MoHadiShibli 4331ec79fd Cleanup: drop the diagnostic spike, one version source, public tests
The staged spike that worked out the VDA call order is no longer part of the
build. It is kept at tag spike-final.

- src/main.c is the service only: instance lock, credentials, MBus and pad
  init, then the web service. src/server.c and include/c4f_server.h are gone
  with stage 8, and so are the stage-only helpers in src/vda.c: the MBus bind
  and holds, the assignment and button-map probes, and the GoldHEN klog stream
  path. The service reads /dev/klog, which is what works.
- VERSION holds the only version number. Both Makefiles pass it in, the
  packager reads it for param.sfo and the package name, and the build and
  deploy scripts read it for the file they look for.
- The payload's log is /data/control4free/control4free.log, not spike.log.
- The page drops the protocol 1 branches: the payload has always answered 2.
  A console slot is a "controller" and a pad plugged into the phone or PC is a
  "gamepad", so the two no longer read as the same word.
- The host tests move to tests/, with tests/run.py to run all four suites. They
  build the real sources with the PS4 calls stubbed, so they need no console.
  klog_test now covers the device path only, and asserts that nothing ever
  connects to GoldHEN's klog server.
2026-10-05 01:53:11 +03:00

38 lines
1.2 KiB
C

/* Link-time syscall fault injection; never linked into the payload. */
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/select.h>
#include <sys/socket.h>
#include <unistd.h>
static int fault(const char *wanted)
{
const char *path = getenv("C4F_TEST_FAULT");
char value[32] = {0};
FILE *file = path ? fopen(path, "r") : NULL;
if (!file) return 0;
(void)fgets(value, sizeof(value), file); fclose(file);
if (strcmp(value, wanted)) return 0;
unlink(path); errno = ENETDOWN; return 1;
}
int __real_select(int, fd_set *, fd_set *, fd_set *, struct timeval *);
int __wrap_select(int n, fd_set *r, fd_set *w, fd_set *e, struct timeval *t)
{
if (fault("select")) { errno = EBADF; return -1; }
return __real_select(n, r, w, e, t);
}
int __real_accept(int, struct sockaddr *, socklen_t *);
int __wrap_accept(int fd, struct sockaddr *a, socklen_t *n)
{
if (fault("accept")) return -1;
return __real_accept(fd, a, n);
}
int __real_getsockopt(int, int, int, void *, socklen_t *);
int __wrap_getsockopt(int fd, int level, int opt, void *out, socklen_t *size)
{
if (opt == SO_ERROR && fault("socket")) { *(int *)out = ECONNRESET; return 0; }
return __real_getsockopt(fd, level, opt, out, size);
}