mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-22 06:15:58 +00:00
Merge main and compile and target Android API 36
This commit is contained in:
commit
28a5423629
123 files changed
+2639
-335
No files matched your search
@@ -40,6 +40,27 @@ class AuthorshipTest(unittest.TestCase):
|
||||
def test_bot_pr_author_is_rejected(self):
|
||||
self.assertTrue(check.event_violations({"pull_request": {"user": {"login": "service", "type": "Bot"}}}))
|
||||
|
||||
def test_people_named_like_assistants_are_not_bots(self):
|
||||
for author in ("Claudemirovsky <63046606+Claudemirovsky@users.noreply.github.com>",
|
||||
"Claude Monet <claude@example.com>", "Devin Smith <devin@example.com>",
|
||||
"Cody Allen <cody@example.com>", "Gemini Patel <gp@example.com>"):
|
||||
with self.subTest(author=author):
|
||||
self.assertEqual([], check.commit_violations("abc", self.commit(author=author)))
|
||||
self.assertEqual([], check.event_violations({"pull_request": {"user": {"login": "Claudemirovsky", "type": "User"}}}))
|
||||
|
||||
def test_assistant_identities_are_still_bots(self):
|
||||
for author in ("Claude Opus 5.5 <noreply@anthropic.com>", "Claude Code <cc@example.com>",
|
||||
"Cursor Agent <cursoragent@cursor.com>",
|
||||
"Devin AI <devin-ai-integration[bot]@users.noreply.github.com>",
|
||||
"Gemini <gemini@example.com>", "GPT-5 <a@example.com>"):
|
||||
with self.subTest(author=author):
|
||||
self.assertTrue(check.commit_violations("abc", self.commit(author=author)))
|
||||
for login in ("chatgpt-codex-connector", "Copilot", "claude"):
|
||||
with self.subTest(login=login):
|
||||
self.assertTrue(check.event_violations({"pull_request": {"user": {"login": login, "type": "User"}}}))
|
||||
message = "Fix\n\nCo-authored-by: Claude Opus 5.5 <noreply@anthropic.com>\n"
|
||||
self.assertEqual(1, len(check.commit_violations("abc", self.commit(message=message))))
|
||||
|
||||
def test_missing_author_fails_closed(self):
|
||||
self.assertTrue(check.commit_violations("abc", b"tree 000\n\nmessage\n"))
|
||||
|
||||
|
||||
@@ -0,0 +1,139 @@
|
||||
import os
|
||||
from pathlib import Path
|
||||
import shutil
|
||||
import subprocess
|
||||
import tempfile
|
||||
import unittest
|
||||
|
||||
FASTPATH = Path(__file__).resolve().parents[1] / "proot/fastpath/fastpath.c"
|
||||
|
||||
PROGRAM = r"""
|
||||
#include "FASTPATH"
|
||||
|
||||
static long host_sys(long nr, long a, long b, long c, long d, long e, long f) {
|
||||
long r = syscall(nr, a, b, c, d, e, f);
|
||||
return r < 0 ? -errno : r;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
static char hosts[MAX_BINDS][PATH_MAX], guests[MAX_BINDS][512];
|
||||
fp_sys = host_sys;
|
||||
snprintf(root, sizeof root, "%s", argv[1]);
|
||||
rootlen = strlen(root);
|
||||
int i = 2;
|
||||
for (; i + 1 < argc && strcmp(argv[i], "--"); i += 2) {
|
||||
struct bind *bd = &binds[nbinds];
|
||||
bd->host = hosts[nbinds];
|
||||
bd->guest = guests[nbinds];
|
||||
snprintf(bd->host, PATH_MAX, "%s", argv[i]);
|
||||
snprintf(bd->guest, sizeof guests[0], "%s", argv[i + 1]);
|
||||
bd->hlen = strlen(bd->host);
|
||||
bd->glen = strlen(bd->guest);
|
||||
nbinds++;
|
||||
}
|
||||
pthread_once(&init_once, fp_init);
|
||||
fp_on = 1;
|
||||
for (i++; i < argc; i++) {
|
||||
char text[PATH_MAX];
|
||||
if (!strcmp(argv[i], "name")) {
|
||||
if (guest_text(argv[++i], text) < 0) strcpy(text, "SLOW");
|
||||
puts(text);
|
||||
} else if (!strcmp(argv[i], "link")) {
|
||||
snprintf(text, sizeof text, "%s", argv[i + 2]);
|
||||
if (detranslated(text, argv[i + 1]) == FP_SLOW) strcpy(text, "SLOW");
|
||||
i += 2;
|
||||
puts(text);
|
||||
} else if (!strcmp(argv[i], "lstat")) {
|
||||
struct stat st;
|
||||
long r = fstatat(AT_FDCWD, argv[++i], &st, AT_SYMLINK_NOFOLLOW);
|
||||
puts(r < 0 ? "error" : S_ISDIR(st.st_mode) ? "dir" : S_ISLNK(st.st_mode) ? "link" : "other");
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
"""
|
||||
|
||||
|
||||
class FastPathBindNamesTest(unittest.TestCase):
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
if shutil.which("gcc") is None:
|
||||
raise unittest.SkipTest("gcc is not available")
|
||||
cls.work = Path(tempfile.mkdtemp())
|
||||
source = cls.work / "names.c"
|
||||
source.write_text(PROGRAM.replace("FASTPATH", str(FASTPATH)))
|
||||
cls.program = cls.work / "names"
|
||||
subprocess.run(["gcc", "-O1", "-w", "-pthread", "-o", str(cls.program), str(source), "-ldl"], check=True)
|
||||
t = cls.work / "tree"
|
||||
for d in ["root/etc", "root/mnt", "root/opt", "root/d/real", "lib/common/game", "fonts", "a", "b"]:
|
||||
(t / d).mkdir(parents=True, exist_ok=True)
|
||||
for f in ["root/etc/x", "lib/f", "lib/common/game/f", "fonts/f", "a/f", "b/f"]:
|
||||
(t / f).touch()
|
||||
os.symlink(t / "lib/f", t / "lib/l2")
|
||||
os.symlink(t / "lib/common", t / "lib/l")
|
||||
os.symlink("real", t / "root/d/link")
|
||||
cls.tree = t
|
||||
cls.binds = [
|
||||
(t / "lib", "/mnt/droiddeck-sd"),
|
||||
(t / "lib", "/mnt/bannerlator-sd"),
|
||||
(t / "lib", "/mnt/DroidDeck-SD"),
|
||||
(t / "lib/common", "/opt/common"),
|
||||
(t / "fonts", "/usr/share/fonts/android"),
|
||||
(t / "a", "/opt/g"),
|
||||
(t / "b", "/opt/g"),
|
||||
(t / "fonts", "/mnt/x"),
|
||||
]
|
||||
|
||||
@classmethod
|
||||
def tearDownClass(cls):
|
||||
shutil.rmtree(cls.work, ignore_errors=True)
|
||||
|
||||
def ask(self, *queries):
|
||||
argv = [str(self.program), str(self.tree / "root")]
|
||||
for host, guest in self.binds:
|
||||
argv += [str(host), guest]
|
||||
argv.append("--")
|
||||
for q in queries:
|
||||
argv += [str(x) for x in q]
|
||||
out = subprocess.run(argv, capture_output=True, text=True, timeout=20, check=True).stdout
|
||||
return out.splitlines()
|
||||
|
||||
def test_a_host_file_takes_the_name_proot_gives_it(self):
|
||||
t = self.tree
|
||||
self.assertEqual(self.ask(
|
||||
("name", t / "lib/f"),
|
||||
("name", t / "lib/common/game/f"),
|
||||
("name", t / "fonts/f"),
|
||||
("name", t / "b/f"),
|
||||
("name", t / "a/f"),
|
||||
("name", t / "root/etc/x"),
|
||||
), [
|
||||
"/mnt/droiddeck-sd/f",
|
||||
"/opt/common/game/f",
|
||||
"/usr/share/fonts/android/f",
|
||||
"/opt/g/f",
|
||||
str(t / "a/f"),
|
||||
"/etc/x",
|
||||
])
|
||||
|
||||
def test_a_link_inside_a_library_reads_back_like_proot(self):
|
||||
t = self.tree
|
||||
self.assertEqual(self.ask(
|
||||
("link", t / "lib/l2", t / "lib/f"),
|
||||
("link", t / "lib/l", t / "lib/common"),
|
||||
), [
|
||||
"/mnt/droiddeck-sd/f",
|
||||
str(t / "lib/common"),
|
||||
])
|
||||
|
||||
def test_a_final_dot_follows_the_link(self):
|
||||
self.assertEqual(self.ask(
|
||||
("lstat", "/d/link"),
|
||||
("lstat", "/d/link/."),
|
||||
("lstat", "/d/link/./"),
|
||||
("lstat", "/d/link/"),
|
||||
), ["link", "dir", "dir", "dir"])
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
@@ -319,7 +319,7 @@ class FsyncPreloadTest(unittest.TestCase):
|
||||
source = base / "fsync-test.c"
|
||||
source.write_text(PROGRAM)
|
||||
subprocess.run(["cc", "-O2", "-Wall", "-fPIC", "-shared", "-pthread", "-o", str(cls.lib),
|
||||
str(PRELOAD / "fsync.c"), str(PRELOAD / "robust.c"), str(PRELOAD / "noexec.c"), "-ldl"], check=True)
|
||||
str(PRELOAD / "fsync.c"), str(PRELOAD / "robust.c"), str(PRELOAD / "noexec.c"), str(PRELOAD / "writewatch.c"), "-ldl"], check=True)
|
||||
subprocess.run(["cc", "-O2", "-Wall", "-pthread", "-o", str(cls.exe), str(source)], check=True)
|
||||
|
||||
@classmethod
|
||||
|
||||
@@ -43,7 +43,7 @@ class NoexecPreloadTest(unittest.TestCase):
|
||||
cls.tmp = Path(tempfile.mkdtemp())
|
||||
cls.lib = cls.tmp / "libnoexec.so"
|
||||
subprocess.run(["cc", "-O2", "-Wall", "-Werror", "-fPIC", "-shared", "-pthread", "-DNOEXEC_TEST", "-o", str(cls.lib),
|
||||
str(PRELOAD / "noexec.c"), str(PRELOAD / "fsync.c"), str(PRELOAD / "robust.c"), "-ldl"], check=True)
|
||||
str(PRELOAD / "noexec.c"), str(PRELOAD / "fsync.c"), str(PRELOAD / "robust.c"), str(PRELOAD / "writewatch.c"), "-ldl"], check=True)
|
||||
source = cls.tmp / "program.c"
|
||||
source.write_text(PROGRAM)
|
||||
for name in ("FEX", "game"):
|
||||
|
||||
@@ -230,7 +230,7 @@ class Openat2PreloadTest(unittest.TestCase):
|
||||
cls.tmp = Path(tempfile.mkdtemp())
|
||||
cls.lib = cls.tmp / "libopenat2.so"
|
||||
subprocess.run(["cc", "-O2", "-Wall", "-Werror", "-fPIC", "-shared", "-pthread", "-o", str(cls.lib),
|
||||
str(PRELOAD / "robust.c"), str(PRELOAD / "fsync.c"), str(PRELOAD / "noexec.c"), "-ldl"], check=True)
|
||||
str(PRELOAD / "robust.c"), str(PRELOAD / "fsync.c"), str(PRELOAD / "noexec.c"), str(PRELOAD / "writewatch.c"), "-ldl"], check=True)
|
||||
source = cls.tmp / "openat2.c"
|
||||
source.write_text(PROGRAM)
|
||||
subprocess.run(["cc", "-O2", "-Wall", "-Werror", "-o", str(cls.tmp / "openat2"), str(source), "-ldl"], check=True)
|
||||
|
||||
@@ -74,6 +74,36 @@ class PipeWireHelperTest(unittest.TestCase):
|
||||
self.assertIn('did not open', result.stderr)
|
||||
self.assertFalse((self.runtime / 'droiddeck-pipewire/pids').exists())
|
||||
|
||||
def test_clients_get_full_access_without_the_flatpak_check(self):
|
||||
self.pack('python3 -c "import socket,sys; s=socket.socket(socket.AF_UNIX); s.bind(sys.argv[1]); '
|
||||
'import time; time.sleep(30)" "$XDG_RUNTIME_DIR/pipewire-0"')
|
||||
for _ in range(2):
|
||||
result = self.run_helper('start')
|
||||
self.assertEqual(result.returncode, 0, result.stderr)
|
||||
daemon = (self.dir / 'share/pipewire/pipewire.conf.d/droiddeck-access.conf').read_text()
|
||||
self.assertIn('module.access = false', daemon)
|
||||
self.assertIn('name = libpipewire-module-access', daemon)
|
||||
self.assertIn('access.socket = { pipewire-0 = "unrestricted", pipewire-0-manager = "unrestricted" }',
|
||||
daemon)
|
||||
self.assertNotIn('access.legacy', daemon)
|
||||
manager = (self.dir / 'share/wireplumber/wireplumber.conf.d/droiddeck-access.conf').read_text()
|
||||
self.assertIn('matches = [ { pipewire.access = "unrestricted" } ]', manager)
|
||||
self.assertIn('default_permissions = "all"', manager)
|
||||
|
||||
def test_start_fails_cleanly_when_the_access_settings_cannot_be_written(self):
|
||||
self.pack('exec sleep 30')
|
||||
self.run_helper('start')
|
||||
self.run_helper('stop')
|
||||
conf = self.dir / 'share/pipewire/pipewire.conf.d'
|
||||
for child in conf.iterdir():
|
||||
child.unlink()
|
||||
conf.rmdir()
|
||||
conf.write_text('')
|
||||
result = self.run_helper('start')
|
||||
self.assertNotEqual(result.returncode, 0)
|
||||
self.assertIn('could not write the access settings', result.stderr)
|
||||
self.assertFalse((self.runtime / 'droiddeck-pipewire/pids').exists())
|
||||
|
||||
def test_unchanged_bundle_is_not_unpacked_again(self):
|
||||
self.pack('exec sleep 30')
|
||||
self.run_helper('start')
|
||||
|
||||
@@ -0,0 +1,154 @@
|
||||
import os
|
||||
from pathlib import Path
|
||||
import shutil
|
||||
import subprocess
|
||||
import tempfile
|
||||
import unittest
|
||||
|
||||
PRELOAD = Path(__file__).resolve().parents[1] / "linuxfs/preload"
|
||||
|
||||
NTDLL = r"""
|
||||
#define _GNU_SOURCE
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
__attribute__((noinline)) int ntdll_open(const char *path) {
|
||||
int fd = open(path, O_RDONLY | O_CLOEXEC);
|
||||
__asm__ volatile("" ::: "memory");
|
||||
return fd;
|
||||
}
|
||||
|
||||
__attribute__((noinline)) int ntdll_openat(const char *path) {
|
||||
int fd = openat(AT_FDCWD, path, O_RDONLY | O_CLOEXEC);
|
||||
__asm__ volatile("" ::: "memory");
|
||||
return fd;
|
||||
}
|
||||
|
||||
__attribute__((noinline)) FILE *ntdll_fopen(const char *path) {
|
||||
FILE *f = fopen(path, "r");
|
||||
__asm__ volatile("" ::: "memory");
|
||||
return f;
|
||||
}
|
||||
"""
|
||||
|
||||
PROGRAM = r"""
|
||||
#define _GNU_SOURCE
|
||||
#include <fcntl.h>
|
||||
#include <signal.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/ptrace.h>
|
||||
#include <sys/wait.h>
|
||||
#include <unistd.h>
|
||||
|
||||
int ntdll_open(const char *path);
|
||||
int ntdll_openat(const char *path);
|
||||
FILE *ntdll_fopen(const char *path);
|
||||
|
||||
static void report(const char *name, int fd) {
|
||||
char link[64], target[256] = "", text[16384], *field;
|
||||
ssize_t n;
|
||||
long tracer = -1;
|
||||
if (fd < 0) {
|
||||
printf("%s failed\n", name);
|
||||
return;
|
||||
}
|
||||
snprintf(link, sizeof(link), "/proc/self/fd/%d", fd);
|
||||
n = readlink(link, target, sizeof(target) - 1);
|
||||
target[n > 0 ? n : 0] = '\0';
|
||||
n = pread(fd, text, sizeof(text) - 1, 0);
|
||||
text[n > 0 ? n : 0] = '\0';
|
||||
if ((field = strstr(text, "\nTracerPid:\t")) != NULL) tracer = strtol(field + 12, NULL, 10);
|
||||
const char *kind = strncmp(target, "/proc/", 6) == 0 ? "proc"
|
||||
: strncmp(target, "/memfd:", 7) == 0 ? "memfd"
|
||||
: strncmp(target, "/tmp/.droiddeck-status-", 23) == 0 ? "copy" : target;
|
||||
printf("%s kind=%s tracer=%s rdonly=%d vm=%d\n", name, kind, tracer == 0 ? "hidden" : tracer > 0 ? "shown" : "missing",
|
||||
(fcntl(fd, F_GETFL) & O_ACCMODE) == O_RDONLY, strstr(text, "\nVmRSS:") != NULL);
|
||||
close(fd);
|
||||
}
|
||||
|
||||
static void report_stream(const char *name, FILE *f) {
|
||||
if (f == NULL) {
|
||||
printf("%s failed\n", name);
|
||||
return;
|
||||
}
|
||||
report(name, dup(fileno(f)));
|
||||
fclose(f);
|
||||
}
|
||||
|
||||
int main(void) {
|
||||
int ready[2];
|
||||
if (pipe(ready) != 0) return 1;
|
||||
pid_t child = fork();
|
||||
if (child == 0) {
|
||||
char ok = ptrace(PTRACE_TRACEME, 0, NULL, NULL) == 0;
|
||||
if (write(ready[1], &ok, 1) != 1) _exit(1);
|
||||
for (;;) pause();
|
||||
}
|
||||
char ok = 0;
|
||||
if (read(ready[0], &ok, 1) != 1 || !ok) {
|
||||
kill(child, SIGKILL);
|
||||
waitpid(child, NULL, 0);
|
||||
puts("no ptrace");
|
||||
return 0;
|
||||
}
|
||||
char other[64], self[64];
|
||||
snprintf(other, sizeof(other), "/proc/%d/status", (int)child);
|
||||
snprintf(self, sizeof(self), "/proc/%d/status", (int)getpid());
|
||||
report("main_other_open", open(other, O_RDONLY | O_CLOEXEC));
|
||||
report_stream("main_other_fopen", fopen(other, "r"));
|
||||
report("main_self_open", open("/proc/self/status", O_RDONLY | O_CLOEXEC));
|
||||
report("ntdll_other_open", ntdll_open(other));
|
||||
report("ntdll_other_openat", ntdll_openat(other));
|
||||
report_stream("ntdll_other_fopen", ntdll_fopen(other));
|
||||
report_stream("ntdll_self_fopen", ntdll_fopen(self));
|
||||
kill(child, SIGKILL);
|
||||
waitpid(child, NULL, 0);
|
||||
return 0;
|
||||
}
|
||||
"""
|
||||
|
||||
|
||||
class TracerPreloadTest(unittest.TestCase):
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
if not shutil.which("cc"):
|
||||
raise unittest.SkipTest("no compiler")
|
||||
cls.tmp = tempfile.TemporaryDirectory()
|
||||
tmp = Path(cls.tmp.name)
|
||||
(tmp / "ntdll.c").write_text(NTDLL)
|
||||
(tmp / "prog.c").write_text(PROGRAM)
|
||||
sources = sorted(str(p) for p in PRELOAD.glob("*.c"))
|
||||
subprocess.run(["cc", "-shared", "-fPIC", "-O2", "-Wall", "-pthread", "-o", str(tmp / "libblsession.so"), *sources, "-ldl"],
|
||||
check=True)
|
||||
subprocess.run(["cc", "-shared", "-fPIC", "-O2", "-o", str(tmp / "ntdll.so"), str(tmp / "ntdll.c")], check=True)
|
||||
subprocess.run(["cc", "-O1", "-o", str(tmp / "prog"), str(tmp / "prog.c"), str(tmp / "ntdll.so"), "-Wl,-rpath," + str(tmp)],
|
||||
check=True)
|
||||
env = dict(os.environ, LD_PRELOAD=str(tmp / "libblsession.so"))
|
||||
out = subprocess.run([str(tmp / "prog")], env=env, capture_output=True, text=True, timeout=60)
|
||||
if out.returncode != 0:
|
||||
raise AssertionError(out.stdout + out.stderr)
|
||||
if "no ptrace" in out.stdout:
|
||||
raise unittest.SkipTest("ptrace not allowed")
|
||||
cls.lines = dict(line.split(" ", 1) for line in out.stdout.splitlines())
|
||||
|
||||
@classmethod
|
||||
def tearDownClass(cls):
|
||||
cls.tmp.cleanup()
|
||||
|
||||
def test_other_programs_still_see_no_tracer(self):
|
||||
self.assertEqual(self.lines["main_other_open"], "kind=copy tracer=hidden rdonly=1 vm=1")
|
||||
self.assertEqual(self.lines["main_other_fopen"], "kind=copy tracer=hidden rdonly=1 vm=1")
|
||||
self.assertEqual(self.lines["main_self_open"], "kind=memfd tracer=hidden rdonly=0 vm=1")
|
||||
|
||||
def test_wine_reads_the_real_status_file(self):
|
||||
for name in ("ntdll_other_open", "ntdll_other_openat", "ntdll_other_fopen"):
|
||||
self.assertEqual(self.lines[name], "kind=proc tracer=shown rdonly=1 vm=1", name)
|
||||
self.assertEqual(self.lines["ntdll_self_fopen"], "kind=proc tracer=hidden rdonly=1 vm=1")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
@@ -0,0 +1,301 @@
|
||||
import ctypes
|
||||
import os
|
||||
from pathlib import Path
|
||||
import platform
|
||||
import shutil
|
||||
import subprocess
|
||||
import tempfile
|
||||
import unittest
|
||||
|
||||
PRELOAD = Path(__file__).resolve().parents[1] / "linuxfs/preload"
|
||||
|
||||
NTDLL = r"""
|
||||
#include <signal.h>
|
||||
__attribute__((noinline)) void syscall_dispatcher_return_slowpath(void) { raise(SIGUSR2); }
|
||||
void slowpath(void) {
|
||||
syscall_dispatcher_return_slowpath();
|
||||
__asm__ volatile("" ::: "memory");
|
||||
}
|
||||
void slowpath_other(int sig) {
|
||||
raise(sig);
|
||||
__asm__ volatile("" ::: "memory");
|
||||
}
|
||||
"""
|
||||
|
||||
PROGRAM = r"""
|
||||
#define _GNU_SOURCE
|
||||
#include <asm/sigcontext.h>
|
||||
#include <pthread.h>
|
||||
#include <setjmp.h>
|
||||
#include <signal.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <ucontext.h>
|
||||
#include <unistd.h>
|
||||
|
||||
void slowpath(void);
|
||||
void slowpath_other(int sig);
|
||||
|
||||
static char altstack[65536];
|
||||
static char landing_stack[65536] __attribute__((aligned(16)));
|
||||
static volatile int mode;
|
||||
static int calls;
|
||||
static volatile int on_alt, usr2_blocked, usr1_blocked, code_ok, stack_ok;
|
||||
static volatile long handler_sp;
|
||||
static jmp_buf back;
|
||||
static uint64_t saved[31];
|
||||
static unsigned __int128 saved_v[32];
|
||||
static uint32_t saved_fpsr;
|
||||
|
||||
void landing(void);
|
||||
__asm__(".text\n.globl landing\n.type landing, %function\nlanding:\n"
|
||||
" sub sp, sp, #784\n"
|
||||
" stp x0, x1, [sp, #0]\n stp x2, x3, [sp, #16]\n stp x4, x5, [sp, #32]\n stp x6, x7, [sp, #48]\n"
|
||||
" stp x8, x9, [sp, #64]\n stp x10, x11, [sp, #80]\n stp x12, x13, [sp, #96]\n stp x14, x15, [sp, #112]\n"
|
||||
" stp x16, x17, [sp, #128]\n stp x18, x19, [sp, #144]\n stp x20, x21, [sp, #160]\n stp x22, x23, [sp, #176]\n"
|
||||
" stp x24, x25, [sp, #192]\n stp x26, x27, [sp, #208]\n stp x28, x29, [sp, #224]\n str x30, [sp, #240]\n"
|
||||
" add x9, sp, #256\n"
|
||||
" stp q0, q1, [x9, #0]\n stp q2, q3, [x9, #32]\n stp q4, q5, [x9, #64]\n stp q6, q7, [x9, #96]\n"
|
||||
" stp q8, q9, [x9, #128]\n stp q10, q11, [x9, #160]\n stp q12, q13, [x9, #192]\n stp q14, q15, [x9, #224]\n"
|
||||
" stp q16, q17, [x9, #256]\n stp q18, q19, [x9, #288]\n stp q20, q21, [x9, #320]\n stp q22, q23, [x9, #352]\n"
|
||||
" stp q24, q25, [x9, #384]\n stp q26, q27, [x9, #416]\n stp q28, q29, [x9, #448]\n stp q30, q31, [x9, #480]\n"
|
||||
" mrs x10, fpsr\n str w10, [sp, #768]\n"
|
||||
" mov x0, sp\n bl landed\n brk #0\n");
|
||||
|
||||
void landed(uint64_t *regs) {
|
||||
memcpy(saved, regs, sizeof(saved));
|
||||
memcpy(saved_v, regs + 32, sizeof(saved_v));
|
||||
saved_fpsr = *(uint32_t *)(regs + 96);
|
||||
longjmp(back, 1);
|
||||
}
|
||||
|
||||
static struct fpsimd_context *fpsimd_of(ucontext_t *uc) {
|
||||
struct _aarch64_ctx *c = (struct _aarch64_ctx *)uc->uc_mcontext.__reserved;
|
||||
while (c->magic) {
|
||||
if (c->magic == FPSIMD_MAGIC) return (struct fpsimd_context *)c;
|
||||
c = (struct _aarch64_ctx *)((char *)c + c->size);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void handler(int sig, siginfo_t *info, void *ctx) {
|
||||
ucontext_t *uc = ctx;
|
||||
sigset_t now;
|
||||
long sp = (long)&now;
|
||||
__atomic_add_fetch(&calls, 1, __ATOMIC_RELAXED);
|
||||
handler_sp = sp;
|
||||
on_alt = sp >= (long)altstack && sp < (long)altstack + (long)sizeof(altstack);
|
||||
pthread_sigmask(SIG_BLOCK, NULL, &now);
|
||||
usr2_blocked = sigismember(&now, SIGUSR2);
|
||||
usr1_blocked = sigismember(&now, SIGUSR1);
|
||||
code_ok = sig == SIGUSR2 && info->si_signo == SIGUSR2 && info->si_code == SI_TKILL && info->si_pid == getpid();
|
||||
stack_ok = uc->uc_stack.ss_sp == altstack && uc->uc_stack.ss_size == sizeof(altstack) && !(uc->uc_stack.ss_flags & SS_DISABLE);
|
||||
if (mode == 1) {
|
||||
struct fpsimd_context *fp = fpsimd_of(uc);
|
||||
for (int i = 0; i <= 28; i++) uc->uc_mcontext.regs[i] = 0x1000 + i;
|
||||
uc->uc_mcontext.regs[29] = 0x2900;
|
||||
uc->uc_mcontext.regs[30] = 0x3000;
|
||||
uc->uc_mcontext.sp = (uint64_t)(landing_stack + sizeof(landing_stack));
|
||||
uc->uc_mcontext.pc = (uint64_t)landing;
|
||||
uc->uc_mcontext.pstate = 0x60000000;
|
||||
for (int i = 0; i < 32; i++) fp->vregs[i] = ((unsigned __int128)(0x7700 + i) << 64) | (0x5500 + i);
|
||||
fp->fpsr = 0x8;
|
||||
}
|
||||
}
|
||||
|
||||
static void usr1(int sig, siginfo_t *info, void *ctx) {
|
||||
(void)sig;
|
||||
(void)info;
|
||||
(void)ctx;
|
||||
}
|
||||
|
||||
uint64_t kept_x[10];
|
||||
double kept_d[8];
|
||||
|
||||
static int keep_callee_saved(void) {
|
||||
uint64_t *out = kept_x;
|
||||
double *d = kept_d;
|
||||
__asm__ volatile(
|
||||
"mov x19, #19\n mov x20, #20\n mov x21, #21\n mov x22, #22\n mov x23, #23\n"
|
||||
"mov x24, #24\n mov x25, #25\n mov x26, #26\n mov x27, #27\n mov x28, #28\n"
|
||||
"fmov d8, #1.0\n fmov d9, #2.0\n fmov d10, #3.0\n fmov d11, #4.0\n"
|
||||
"fmov d12, #5.0\n fmov d13, #6.0\n fmov d14, #7.0\n fmov d15, #8.0\n"
|
||||
"bl slowpath\n"
|
||||
"adrp x0, kept_x\n add x0, x0, :lo12:kept_x\n"
|
||||
"stp x19, x20, [x0, #0]\n stp x21, x22, [x0, #16]\n stp x23, x24, [x0, #32]\n"
|
||||
"stp x25, x26, [x0, #48]\n stp x27, x28, [x0, #64]\n"
|
||||
"adrp x0, kept_d\n add x0, x0, :lo12:kept_d\n"
|
||||
"stp d8, d9, [x0, #0]\n stp d10, d11, [x0, #16]\n stp d12, d13, [x0, #32]\n stp d14, d15, [x0, #48]\n"
|
||||
:
|
||||
:
|
||||
: "x0", "x1", "x2", "x3", "x4", "x5", "x6", "x7", "x8", "x9", "x10", "x11", "x12", "x13", "x14", "x15",
|
||||
"x16", "x17", "x19", "x20", "x21", "x22", "x23", "x24", "x25", "x26", "x27", "x28", "x30",
|
||||
"v0", "v1", "v2", "v3", "v4", "v5", "v6", "v7", "v8", "v9", "v10", "v11", "v12", "v13", "v14", "v15",
|
||||
"v16", "v17", "v18", "v19", "v20", "v21", "v22", "v23", "v24", "v25", "v26", "v27", "v28", "v29", "v30",
|
||||
"v31", "memory", "cc");
|
||||
for (int i = 0; i < 10; i++)
|
||||
if (out[i] != (uint64_t)(19 + i)) return 0;
|
||||
for (int i = 0; i < 8; i++)
|
||||
if (d[i] != (double)(i + 1)) return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void *stress(void *arg) {
|
||||
(void)arg;
|
||||
for (int i = 0; i < 2000; i++) slowpath();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
stack_t ss = {.ss_sp = altstack, .ss_size = sizeof(altstack), .ss_flags = 0};
|
||||
struct sigaction sa;
|
||||
sigset_t mask, now;
|
||||
sigaltstack(&ss, NULL);
|
||||
memset(&sa, 0, sizeof(sa));
|
||||
sa.sa_sigaction = handler;
|
||||
sa.sa_flags = SA_SIGINFO | SA_ONSTACK | SA_RESTART;
|
||||
sigemptyset(&sa.sa_mask);
|
||||
sigaddset(&sa.sa_mask, SIGUSR1);
|
||||
sigaction(SIGUSR2, &sa, NULL);
|
||||
sa.sa_sigaction = usr1;
|
||||
sigemptyset(&sa.sa_mask);
|
||||
sigaction(SIGUSR1, &sa, NULL);
|
||||
|
||||
if (argc > 1 && strcmp(argv[1], "bench") == 0) {
|
||||
int n = argc > 2 ? atoi(argv[2]) : 20000;
|
||||
struct timespec a, b;
|
||||
clock_gettime(CLOCK_MONOTONIC, &a);
|
||||
for (int i = 0; i < n; i++) slowpath();
|
||||
clock_gettime(CLOCK_MONOTONIC, &b);
|
||||
printf("%.2f us per raise, alt %d\n", ((b.tv_sec - a.tv_sec) * 1e9 + (b.tv_nsec - a.tv_nsec)) / 1e3 / n, on_alt);
|
||||
return 0;
|
||||
}
|
||||
|
||||
mode = 0;
|
||||
calls = 0;
|
||||
int kept = keep_callee_saved();
|
||||
pthread_sigmask(SIG_BLOCK, NULL, &now);
|
||||
printf("returned calls=%d kept=%d usr2_blocked=%d usr1_blocked=%d code=%d stack=%d after_usr2=%d after_usr1=%d\n",
|
||||
calls, kept, usr2_blocked, usr1_blocked, code_ok, stack_ok, sigismember(&now, SIGUSR2),
|
||||
sigismember(&now, SIGUSR1));
|
||||
printf("path %s\n", on_alt ? "kernel" : "inline");
|
||||
|
||||
mode = 1;
|
||||
calls = 0;
|
||||
if (!setjmp(back)) {
|
||||
slowpath();
|
||||
printf("redirect did not happen\n");
|
||||
} else {
|
||||
int ok = 1;
|
||||
for (int i = 0; i <= 28; i++)
|
||||
if (saved[i] != (uint64_t)(0x1000 + i)) ok = 0;
|
||||
if (saved[29] != 0x2900 || saved[30] != 0x3000) ok = 0;
|
||||
for (int i = 0; i < 32; i++)
|
||||
if (saved_v[i] != (((unsigned __int128)(0x7700 + i) << 64) | (0x5500 + i))) ok = 0;
|
||||
printf("redirect calls=%d regs=%d fpsr=%u\n", calls, ok, saved_fpsr & 0x8);
|
||||
}
|
||||
mode = 0;
|
||||
|
||||
sigemptyset(&mask);
|
||||
sigaddset(&mask, SIGUSR2);
|
||||
pthread_sigmask(SIG_BLOCK, &mask, NULL);
|
||||
calls = 0;
|
||||
slowpath();
|
||||
int while_blocked = calls;
|
||||
pthread_sigmask(SIG_UNBLOCK, &mask, NULL);
|
||||
printf("blocked during=%d after=%d\n", while_blocked, calls);
|
||||
|
||||
calls = 0;
|
||||
slowpath_other(SIGUSR1);
|
||||
raise(SIGUSR2);
|
||||
printf("other calls=%d main_path=%s\n", calls, on_alt ? "kernel" : "inline");
|
||||
|
||||
calls = 0;
|
||||
pthread_t t[4];
|
||||
for (int i = 0; i < 4; i++) pthread_create(&t[i], NULL, stress, NULL);
|
||||
for (int i = 0; i < 4; i++) pthread_join(t[i], NULL);
|
||||
printf("threads calls=%d\n", calls);
|
||||
return 0;
|
||||
}
|
||||
"""
|
||||
|
||||
|
||||
def has_gcs_hwcap():
|
||||
try:
|
||||
getauxval = ctypes.CDLL(None).getauxval
|
||||
except (AttributeError, OSError):
|
||||
return False
|
||||
getauxval.restype = ctypes.c_ulong
|
||||
getauxval.argtypes = [ctypes.c_ulong]
|
||||
return bool(getauxval(16) & (1 << 32))
|
||||
|
||||
|
||||
def runner():
|
||||
if platform.machine() in ("aarch64", "arm64") and shutil.which("gcc") and not has_gcs_hwcap():
|
||||
return "gcc", []
|
||||
if shutil.which("aarch64-linux-gnu-gcc") and shutil.which("qemu-aarch64") and Path("/usr/aarch64-linux-gnu").is_dir():
|
||||
return "aarch64-linux-gnu-gcc", ["qemu-aarch64", "-cpu", "neoverse-n1", "-L", "/usr/aarch64-linux-gnu"]
|
||||
return None, None
|
||||
|
||||
|
||||
class Usr2PreloadTest(unittest.TestCase):
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
cls.cc, cls.prefix = runner()
|
||||
if cls.cc is None:
|
||||
raise unittest.SkipTest("no aarch64 compiler and runner")
|
||||
cls.tmp = tempfile.TemporaryDirectory()
|
||||
tmp = Path(cls.tmp.name)
|
||||
(tmp / "ntdll.c").write_text(NTDLL)
|
||||
(tmp / "prog.c").write_text(PROGRAM)
|
||||
sources = sorted(str(p) for p in PRELOAD.glob("*.c"))
|
||||
subprocess.run([cls.cc, "-shared", "-fPIC", "-O2", "-Wall", "-pthread", "-o", str(tmp / "libblsession.so"),
|
||||
*sources, "-ldl"], check=True)
|
||||
subprocess.run([cls.cc, "-shared", "-fPIC", "-O2", "-o", str(tmp / "ntdll.so"), str(tmp / "ntdll.c")], check=True)
|
||||
subprocess.run([cls.cc, "-O1", "-U_FORTIFY_SOURCE", "-pthread", "-o", str(tmp / "prog"), str(tmp / "prog.c"), str(tmp / "ntdll.so"),
|
||||
"-Wl,-rpath," + str(tmp)], check=True)
|
||||
cls.program = tmp / "prog"
|
||||
cls.preload = tmp / "libblsession.so"
|
||||
|
||||
@classmethod
|
||||
def tearDownClass(cls):
|
||||
cls.tmp.cleanup()
|
||||
|
||||
def run_program(self, preload):
|
||||
env = dict(os.environ)
|
||||
env.pop("LD_PRELOAD", None)
|
||||
cmd = list(self.prefix) + [str(self.program)]
|
||||
if preload:
|
||||
if self.prefix:
|
||||
cmd = list(self.prefix) + ["-E", "LD_PRELOAD=" + str(self.preload), str(self.program)]
|
||||
else:
|
||||
env["LD_PRELOAD"] = str(self.preload)
|
||||
out = subprocess.run(cmd, env=env, capture_output=True, text=True, timeout=120)
|
||||
self.assertEqual(out.returncode, 0, out.stderr)
|
||||
return out.stdout.splitlines()
|
||||
|
||||
def test_a_ntdll_raise_runs_the_handler_without_a_kernel_signal(self):
|
||||
lines = self.run_program(True)
|
||||
self.assertIn("path inline", lines)
|
||||
self.assertIn("returned calls=1 kept=1 usr2_blocked=1 usr1_blocked=1 code=1 stack=1 after_usr2=0 after_usr1=0", lines)
|
||||
|
||||
def test_b_context_the_handler_writes_is_the_one_that_resumes(self):
|
||||
self.assertIn("redirect calls=1 regs=1 fpsr=8", self.run_program(True))
|
||||
|
||||
def test_c_behaves_like_the_kernel_signal(self):
|
||||
stock = [line for line in self.run_program(False) if not line.startswith("path ")]
|
||||
inline = [line for line in self.run_program(True) if not line.startswith("path ")]
|
||||
self.assertIn("returned calls=1 kept=1 usr2_blocked=1 usr1_blocked=1 code=1 stack=1 after_usr2=0 after_usr1=0", stock)
|
||||
self.assertEqual(stock, inline)
|
||||
|
||||
def test_d_blocked_other_signals_and_other_callers_use_the_kernel(self):
|
||||
lines = self.run_program(True)
|
||||
self.assertIn("blocked during=0 after=1", lines)
|
||||
self.assertIn("other calls=1 main_path=kernel", lines)
|
||||
self.assertIn("threads calls=8000", lines)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
@@ -32,6 +32,7 @@ int probe(void) {
|
||||
#include <assert.h>
|
||||
#include <dlfcn.h>
|
||||
int bl_fsync_syscall(long n, const long *a, long *r) { (void)n; (void)a; (void)r; return 0; }
|
||||
int bl_writewatch_syscall(long n, const long *a, long (*real)(long, ...), long *r) { (void)n; (void)a; (void)real; (void)r; return 0; }
|
||||
#include """ + '"' + robust.as_posix() + '"' + r"""
|
||||
int main(int argc, char **argv) {
|
||||
assert(argc == 3);
|
||||
|
||||
@@ -0,0 +1,119 @@
|
||||
from pathlib import Path
|
||||
import shutil
|
||||
import subprocess
|
||||
import tempfile
|
||||
import unittest
|
||||
|
||||
PRELOAD = Path(__file__).resolve().parents[1] / "linuxfs/preload"
|
||||
|
||||
PROGRAM = r"""
|
||||
#include "WRITEWATCH"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/mman.h>
|
||||
|
||||
#define PAGES 96
|
||||
|
||||
static int uffd, pagemap;
|
||||
static uint64_t page;
|
||||
|
||||
static char *region(void) {
|
||||
char *m = mmap(NULL, PAGES * page, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
|
||||
madvise(m, PAGES * page, MADV_NOHUGEPAGE);
|
||||
struct uffdio_register reg = { .range = { (uintptr_t)m, PAGES * page }, .mode = UFFDIO_REGISTER_MODE_WP };
|
||||
if (m == MAP_FAILED || ioctl(uffd, UFFDIO_REGISTER, ®)) exit(3);
|
||||
protect(uffd, (uintptr_t)m, (uintptr_t)m + PAGES * page);
|
||||
return m;
|
||||
}
|
||||
|
||||
static long scan(char *m, int emulated, uint64_t flags, uint64_t vec_len, uint64_t max_pages, uint64_t from, uint64_t to,
|
||||
struct page_region *vec, uint64_t *walk_end) {
|
||||
struct pm_scan_arg a = { .size = sizeof a, .flags = flags, .start = (uintptr_t)m + from * page, .end = (uintptr_t)m + to * page,
|
||||
.vec = vec_len ? (uintptr_t)vec : 0, .vec_len = vec_len, .max_pages = max_pages,
|
||||
.category_mask = PAGE_IS_WRITTEN, .return_mask = PAGE_IS_WRITTEN };
|
||||
long n = emulated ? emulate_scan(pagemap, uffd, &a) : ioctl(pagemap, PAGEMAP_SCAN, &a);
|
||||
*walk_end = (a.walk_end - (uintptr_t)m) / page;
|
||||
return n;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
page = (uint64_t)getpagesize();
|
||||
uffd = syscall(SYS_userfaultfd, O_CLOEXEC | O_NONBLOCK | UFFD_USER_MODE_ONLY);
|
||||
struct uffdio_api api = { .api = UFFD_API, .features = UFFD_FEATURE_WP_ASYNC | UFFD_FEATURE_WP_UNPOPULATED };
|
||||
pagemap = open("/proc/self/pagemap", O_RDONLY | O_CLOEXEC);
|
||||
if (uffd < 0 || ioctl(uffd, UFFDIO_API, &api) || pagemap < 0) { puts("unsupported"); return 0; }
|
||||
char *kernel = region(), *ours = region();
|
||||
struct page_region probe[1];
|
||||
uint64_t end;
|
||||
if (scan(kernel, 0, 0, 1, 0, 0, PAGES, probe, &end) < 0) { puts("unsupported"); return 0; }
|
||||
srand(atoi(argv[1]));
|
||||
int rounds = atoi(argv[2]), differing = 0;
|
||||
for (int r = 0; r < rounds; r++) {
|
||||
int writes = rand() % 24;
|
||||
for (int w = 0; w < writes; w++) {
|
||||
int p = rand() % PAGES;
|
||||
if (rand() % 4 == 0) {
|
||||
volatile char x = kernel[p * page] + ours[p * page];
|
||||
(void)x;
|
||||
continue;
|
||||
}
|
||||
kernel[p * page + rand() % page] = (char)r;
|
||||
ours[p * page + rand() % page] = (char)r;
|
||||
}
|
||||
uint64_t flags = rand() % 2 ? PM_SCAN_WP_MATCHING : 0;
|
||||
uint64_t vec_len = rand() % 3 == 0 ? 0 : 1 + rand() % 5;
|
||||
uint64_t max_pages = rand() % 3 == 0 ? 1 + rand() % 8 : 0;
|
||||
if (!vec_len) flags = PM_SCAN_WP_MATCHING, max_pages = 0;
|
||||
uint64_t from = rand() % PAGES, to = from + rand() % (PAGES - from + 1);
|
||||
struct page_region kv[8], ov[8];
|
||||
uint64_t kend, oend;
|
||||
long kn = scan(kernel, 0, flags, vec_len, max_pages, from, to, kv, &kend);
|
||||
long on = scan(ours, 1, flags, vec_len, max_pages, from, to, ov, &oend);
|
||||
int same = kn == on && (kn < 0 || kend == oend);
|
||||
for (long i = 0; same && i < kn; i++)
|
||||
same = kv[i].start - (uintptr_t)kernel == ov[i].start - (uintptr_t)ours
|
||||
&& kv[i].end - (uintptr_t)kernel == ov[i].end - (uintptr_t)ours && kv[i].categories == ov[i].categories;
|
||||
struct page_region kall[PAGES], oall[PAGES];
|
||||
long ka = scan(kernel, 0, 0, PAGES, 0, 0, PAGES, kall, &kend), oa = scan(ours, 1, 0, PAGES, 0, 0, PAGES, oall, &oend);
|
||||
same = same && ka == oa;
|
||||
for (long i = 0; same && i < ka; i++)
|
||||
same = kall[i].start - (uintptr_t)kernel == oall[i].start - (uintptr_t)ours && kall[i].end - (uintptr_t)kernel == oall[i].end - (uintptr_t)ours;
|
||||
if (!same) {
|
||||
differing++;
|
||||
printf("round %d flags %llu vec %llu max %llu range %llu-%llu: kernel %ld end %llu, ours %ld end %llu\n", r,
|
||||
(unsigned long long)flags, (unsigned long long)vec_len, (unsigned long long)max_pages, (unsigned long long)from,
|
||||
(unsigned long long)to, kn, (unsigned long long)kend, on, (unsigned long long)oend);
|
||||
}
|
||||
}
|
||||
printf("rounds %d differing %d\n", rounds, differing);
|
||||
return 0;
|
||||
}
|
||||
"""
|
||||
|
||||
|
||||
class WriteWatchPreloadTest(unittest.TestCase):
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
if shutil.which("gcc") is None:
|
||||
raise unittest.SkipTest("gcc is not available")
|
||||
cls.work = Path(tempfile.mkdtemp())
|
||||
source = cls.work / "writewatch.c"
|
||||
source.write_text(PROGRAM.replace("WRITEWATCH", str(PRELOAD / "writewatch.c")))
|
||||
cls.program = cls.work / "writewatch"
|
||||
subprocess.run(["gcc", "-O1", "-Wall", "-o", str(cls.program), str(source)], check=True)
|
||||
|
||||
@classmethod
|
||||
def tearDownClass(cls):
|
||||
shutil.rmtree(cls.work, ignore_errors=True)
|
||||
|
||||
def test_a_scan_android_refuses_answers_like_the_kernel_one(self):
|
||||
for seed in range(4):
|
||||
out = subprocess.run([str(self.program), str(seed), "400"], capture_output=True, text=True, timeout=60).stdout
|
||||
if out.strip() == "unsupported":
|
||||
self.skipTest("this kernel has no asynchronous userfaultfd write protection")
|
||||
self.assertTrue(out.rstrip().endswith("differing 0"), out)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
@@ -129,6 +129,8 @@ class ZramPreloadTest(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
self.ctl.write_text("0")
|
||||
for ack in self.dir.glob("ctl.ack.*"):
|
||||
ack.unlink()
|
||||
|
||||
def run_program(self, program=None, mb=48, cycles=1, *extra):
|
||||
environment = dict(os.environ, LD_PRELOAD=str(self.lib))
|
||||
@@ -140,9 +142,10 @@ class ZramPreloadTest(unittest.TestCase):
|
||||
out.setdefault(key, []).append(int(value))
|
||||
return out
|
||||
|
||||
def test_only_the_client_takes_the_signal(self):
|
||||
def test_every_process_takes_the_signal(self):
|
||||
self.assertEqual([1], self.run_program()["handler"])
|
||||
self.assertEqual([0], self.run_program(self.game)["handler"])
|
||||
self.assertEqual([1], self.run_program(self.game)["handler"])
|
||||
self.assertEqual(2, len(list(self.dir.glob("ctl.ack.*"))))
|
||||
|
||||
def test_nothing_is_installed_without_the_control_file(self):
|
||||
self.ctl.unlink()
|
||||
@@ -157,6 +160,7 @@ class ZramPreloadTest(unittest.TestCase):
|
||||
self.assertGreater(out["out"][0], 32 * 1024)
|
||||
self.assertLess(out["back"][0], out["out"][0] // 4)
|
||||
self.assertEqual([1], out["intact"])
|
||||
self.assertEqual(["1"], [ack.read_text() for ack in self.dir.glob("ctl.ack.*")])
|
||||
|
||||
@unittest.skipUnless(swap_total_kb() > 256 * 1024, "needs swap")
|
||||
def test_reads_back_what_the_kernel_swapped_elsewhere(self):
|
||||
|
||||
Reference in new issue
Block a user