mirror of
https://github.com/mihawk-99/PS5_RetroArch.git
synced 2026-10-18 23:09:29 -05:00
Create and repair all seven managed directories to the owner-authorized 0777,
including existing folders and restrictive umasks. Console 0775 modes still
denied every FTP upload; 0777 passed upload, byte-for-byte readback and cleanup
in each folder. Preserve user file modes and configuration contents.
Validation: tools/verify.sh (all five gates, 35 tests, 16 evidence records).
Console: tools/run-title.sh --no-build --watch 30; python3 tools/check-ftp-write.py.
Evidence: evidence/ftp-directory-permissions/{capture,expectation}.json.
Build: 347655429cf4a60f3d7608c3ba4e46ec1c1972f81704cbea9f9e654c9942cfed.
Thirty seconds alive, script-closed; no GPU refusals/API errors. PS5_Vulkan unchanged.
75 lines
3.3 KiB
Python
75 lines
3.3 KiB
Python
"""Native platform setup with isolated filesystem and menu-entry capture."""
|
|
from pathlib import Path
|
|
import subprocess
|
|
import tempfile
|
|
import unittest
|
|
|
|
ROOT = Path(__file__).resolve().parent.parent
|
|
|
|
|
|
class PlatformPaths(unittest.TestCase):
|
|
def test_config_and_browser_roots(self):
|
|
with tempfile.TemporaryDirectory() as td:
|
|
binary = str(Path(td) / 'paths-test')
|
|
functions = ['fopen', 'stat', 'mkdir', 'chmod', 'rename', 'remove']
|
|
subprocess.run(['c++', '-std=c++17', '-O2', '-Wall', '-Wextra', '-Werror',
|
|
'-Ivendor/retroarch', '-Ivendor/retroarch/libretro-common/include',
|
|
'tests/frontend_ps5_test.cpp', '-o', binary,
|
|
*[f'-Wl,--wrap={name}' for name in functions]], cwd=ROOT, check=True)
|
|
subprocess.run([binary, str(Path(td) / 'filesystem')], cwd=ROOT,
|
|
check=True, timeout=10)
|
|
|
|
def test_native_directory_records(self):
|
|
with tempfile.TemporaryDirectory() as td:
|
|
binary = str(Path(td) / 'directory-test')
|
|
subprocess.run(['c++', '-std=c++17', '-O2', '-Wall', '-Wextra', '-Werror',
|
|
'tests/ps5_directory_test.cpp', '-o', binary,
|
|
'-Wl,--wrap=open', '-Wl,--wrap=close'], cwd=ROOT, check=True)
|
|
subprocess.run([binary], cwd=ROOT, check=True, timeout=10)
|
|
|
|
def test_application_path_avoids_procfs(self):
|
|
import importlib.util
|
|
import re
|
|
spec = importlib.util.spec_from_file_location('patches', ROOT / 'tools/apply-port-patches.py')
|
|
patches = importlib.util.module_from_spec(spec)
|
|
spec.loader.exec_module(patches)
|
|
source = (ROOT / 'vendor/retroarch/libretro-common/file/file_path.c').read_text()
|
|
for path, anchor, replacement, marker in patches.EDITS:
|
|
if path == 'libretro-common/file/file_path.c' and marker not in source:
|
|
self.assertIn(anchor, source)
|
|
source = source.replace(anchor, replacement, 1)
|
|
body = re.search(r'size_t fill_pathname_application_path\(char \*s, size_t len\)\n\{.*?\n\}',
|
|
source, re.S)[0]
|
|
program = r'''
|
|
#include <assert.h>
|
|
#include <string.h>
|
|
#include <stdio.h>
|
|
#include <unistd.h>
|
|
#include <stdlib.h>
|
|
#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
|
|
pid_t getpid(void) { abort(); }
|
|
ssize_t readlink(const char *p, char *b, size_t n) { abort(); }
|
|
size_t strlcpy(char *s, const char *p, size_t n) {
|
|
size_t len = strlen(p);
|
|
if (n) { size_t copied = len < n - 1 ? len : n - 1;
|
|
memcpy(s, p, copied); s[copied] = 0; }
|
|
return len;
|
|
}
|
|
''' + body + r'''
|
|
int main(void) {
|
|
char buffer[64];
|
|
assert(fill_pathname_application_path(buffer, sizeof(buffer)) == strlen("/app0/eboot.bin"));
|
|
assert(strcmp(buffer, "/app0/eboot.bin") == 0);
|
|
assert(fill_pathname_application_path(NULL, 0) == 0);
|
|
char small[4];
|
|
fill_pathname_application_path(small, sizeof(small));
|
|
assert(strcmp(small, "/ap") == 0);
|
|
}
|
|
'''
|
|
with tempfile.TemporaryDirectory() as td:
|
|
path = Path(td) / 'executable.c'
|
|
path.write_text(program)
|
|
binary = str(Path(td) / 'executable-test')
|
|
subprocess.run(['cc', '-std=gnu11', '-O2', str(path), '-o', binary], check=True)
|
|
subprocess.run([binary], check=True)
|