mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-24 23:36:04 +00:00
Merge remote-tracking branch 'origin/main' into feat/lse-emu
This commit is contained in:
commit
08cb1fc75d
7 files changed
+87
-18
No files matched your search
@@ -695,6 +695,32 @@ jobs:
|
||||
if-no-files-found: ignore
|
||||
overwrite: true
|
||||
|
||||
- name: Resolve the Robolectric version
|
||||
id: robolectric
|
||||
run: |
|
||||
echo "version=$(grep -o "org.robolectric:robolectric:[0-9.]*" app/build.gradle | cut -d: -f3)" >> "$GITHUB_OUTPUT"
|
||||
# Robolectric downloads these from Maven Central on first use without retrying, and 429s fail whole test classes.
|
||||
# The cache path sits beside the workspace because runner homes are at different depths from it, and
|
||||
# actions/cache stores paths relative to the workspace. Runners that keep their own ~/.m2 skip the cache.
|
||||
- name: Place Robolectric's Android jars beside the workspace
|
||||
id: robolectric-jars
|
||||
run: |
|
||||
set -euo pipefail
|
||||
jars="$GITHUB_WORKSPACE/../robolectric-jars"
|
||||
m2="$HOME/.m2/repository/org/robolectric/android-all-instrumented"
|
||||
if [ -d "$m2" ] && [ ! -L "$m2" ]; then
|
||||
echo "cache=false" >> "$GITHUB_OUTPUT"
|
||||
else
|
||||
mkdir -p "$jars" "$(dirname "$m2")"
|
||||
ln -sfn "$(cd "$jars" && pwd)" "$m2"
|
||||
echo "cache=true" >> "$GITHUB_OUTPUT"
|
||||
fi
|
||||
- name: Cache Robolectric's Android jars
|
||||
if: steps.robolectric-jars.outputs.cache == 'true'
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: ../robolectric-jars
|
||||
key: robolectric-android-all-v2-${{ steps.robolectric.outputs.version }}
|
||||
- name: Unit tests
|
||||
id: unit-tests
|
||||
env:
|
||||
|
||||
@@ -27,7 +27,7 @@ internal object DeveloperTools {
|
||||
internal object NavTabs {
|
||||
const val MORE = "more"
|
||||
val ALL = listOf("steam", "desktop", "games", "downloads", "setup", "updates", "stores", "soundtracks", "components", "storage", "sync", "decky", "boot-movies", "android-apps", "agent")
|
||||
val DEFAULT_SHELVED = setOf("stores", "soundtracks", "components", "storage", "sync", "decky", "boot-movies", "android-apps", "agent")
|
||||
val DEFAULT_SHELVED = setOf("soundtracks", "components", "storage", "sync", "decky", "boot-movies", "android-apps", "agent")
|
||||
val DEFAULT_HIDDEN = setOf("android-apps", "agent")
|
||||
private val SHELVED_WHEN_NEW = setOf("storage", "sync", "decky", "boot-movies", "android-apps", "agent")
|
||||
private val OLD_ORDER = listOf("steam", "games", "soundtracks", "stores", "downloads", "desktop", "agent", "components", "android-apps", "storage", "sync", "setup", "updates")
|
||||
|
||||
@@ -40,8 +40,8 @@ class NavTabsTest {
|
||||
}
|
||||
|
||||
@Test fun aFreshInstallShowsTheDefaultBarMoreAndHiddenTabs() {
|
||||
assertEquals(listOf("steam", "desktop", "games", "downloads", "setup", "updates", NavTabs.MORE), navigationKeys(state()))
|
||||
assertEquals(listOf("stores", "soundtracks", "components", "storage", "sync", "decky", "boot-movies"), NavTabs.more(state()))
|
||||
assertEquals(listOf("steam", "desktop", "games", "downloads", "setup", "updates", "stores", NavTabs.MORE), navigationKeys(state()))
|
||||
assertEquals(listOf("soundtracks", "components", "storage", "sync", "decky", "boot-movies"), NavTabs.more(state()))
|
||||
assertEquals(TabPlace.HIDDEN, NavTabs.place(state(), "android-apps"))
|
||||
assertEquals(TabPlace.HIDDEN, NavTabs.place(state(), "agent"))
|
||||
assertFalse(com.droiddeck.launcher.agent.AgentTab.shown)
|
||||
@@ -51,13 +51,13 @@ class NavTabsTest {
|
||||
@Test fun showingMusicOnceKeepsItShownAfterReload() {
|
||||
place("soundtracks", TabPlace.BAR)
|
||||
NavTabs.load(ctx)
|
||||
assertEquals(listOf("steam", "desktop", "games", "downloads", "setup", "updates", "soundtracks", NavTabs.MORE), navigationKeys(state()))
|
||||
assertEquals(listOf("steam", "desktop", "games", "downloads", "setup", "updates", "stores", "soundtracks", NavTabs.MORE), navigationKeys(state()))
|
||||
}
|
||||
|
||||
@Test fun shelvedTabsLeaveTheBarAndAddMoreAtTheEnd() {
|
||||
place("desktop", TabPlace.MORE)
|
||||
val s = state()
|
||||
assertEquals(listOf("desktop", "stores", "soundtracks", "components", "storage", "sync", "decky", "boot-movies"), NavTabs.more(s))
|
||||
assertEquals(listOf("desktop", "soundtracks", "components", "storage", "sync", "decky", "boot-movies"), NavTabs.more(s))
|
||||
assertEquals(NavTabs.MORE, navigationKeys(s).last())
|
||||
assertFalse("desktop" in navigationKeys(s))
|
||||
}
|
||||
@@ -70,14 +70,14 @@ class NavTabsTest {
|
||||
}
|
||||
|
||||
@Test fun resettingPutsBackTheDefaultLayout() {
|
||||
place("stores", TabPlace.BAR)
|
||||
place("stores", TabPlace.MORE)
|
||||
place("updates", TabPlace.HIDDEN)
|
||||
moveTab("downloads", -1)
|
||||
assertFalse(NavTabs.isDefault())
|
||||
NavTabs.reset(ctx)
|
||||
NavTabs.load(ctx)
|
||||
assertTrue(NavTabs.isDefault())
|
||||
assertEquals(listOf("steam", "desktop", "games", "downloads", "setup", "updates", NavTabs.MORE), navigationKeys(state()))
|
||||
assertEquals(listOf("steam", "desktop", "games", "downloads", "setup", "updates", "stores", NavTabs.MORE), navigationKeys(state()))
|
||||
}
|
||||
|
||||
@Test fun anOldLayoutKeepsWhatItsSwitchesShowed() {
|
||||
|
||||
@@ -10,6 +10,13 @@
|
||||
// PT_INTERP) literally and failed with "bad interpreter: No such file or directory".
|
||||
// getcwd() is not virtualised, so cwd + path is a real path that starts with DDNATV_ROOT.
|
||||
static const char *absolutize_exec_path(const char *path, char *buffer, size_t bufsize) {
|
||||
if (is_proc_self_exe(path)) {
|
||||
ssize_t n = handle_proc_self_exe(buffer, bufsize - 1);
|
||||
if (n > 0 && buffer[0] == '/') {
|
||||
buffer[n] = '\0';
|
||||
return buffer;
|
||||
}
|
||||
}
|
||||
if (!path || path[0] == '\0' || path[0] == '/') return path;
|
||||
char cwd[PATH_MAX];
|
||||
static char *(*real_getcwd)(char *, size_t) = NULL;
|
||||
|
||||
@@ -203,15 +203,10 @@ static void exe_from_cmdline(const char *cmdline_path, char *out, size_t outsz)
|
||||
}
|
||||
|
||||
static ssize_t copy_guest_exe(const char *real_exe, char *buf, size_t bufsiz) {
|
||||
const char *out_path = real_exe;
|
||||
if (g_ddnatv_root[0] != '\0') {
|
||||
size_t rlen = g_ddnatv_root_len;
|
||||
if (strncmp(real_exe, g_ddnatv_root, rlen) == 0 &&
|
||||
(real_exe[rlen] == '/' || real_exe[rlen] == '\0')) {
|
||||
out_path = real_exe + rlen;
|
||||
if (out_path[0] == '\0') out_path = "/";
|
||||
}
|
||||
}
|
||||
char guest[PATH_MAX];
|
||||
char back[PATH_MAX];
|
||||
const char *out_path = guest_path_of_host_dir(real_exe, guest, sizeof(guest));
|
||||
if (!out_path || strcmp(rewrite_path_in_root(out_path, back, sizeof(back)), real_exe) != 0) out_path = real_exe;
|
||||
size_t len = strlen(out_path);
|
||||
size_t copy_len = (len < bufsiz) ? len : bufsiz;
|
||||
memcpy(buf, out_path, copy_len);
|
||||
|
||||
@@ -124,10 +124,12 @@ class NativeHookLdsoSpawnTest(unittest.TestCase):
|
||||
def tearDownClass(cls):
|
||||
cls.tmp.cleanup()
|
||||
|
||||
def call(self, how, *argv, binds=None):
|
||||
def call(self, how, *argv, binds=None, real_exe=None):
|
||||
hook_env = {"DDNATV_ROOT": str(self.root), "LD_PRELOAD": f"{self.hook}:{self.recorder}"}
|
||||
if binds:
|
||||
hook_env["DDNATV_BINDS"] = binds
|
||||
if real_exe:
|
||||
hook_env["DDNATV_REAL_EXE"] = real_exe
|
||||
env = {k: v for k, v in os.environ.items() if k not in ("LD_PRELOAD", "DDNATV_EXEC", "LD_LIBRARY_PATH")}
|
||||
if self.prefix:
|
||||
cmd = list(self.prefix) + [arg for key, value in hook_env.items() for arg in ("-E", f"{key}={value}")]
|
||||
@@ -177,6 +179,22 @@ class NativeHookLdsoSpawnTest(unittest.TestCase):
|
||||
self.call(how, GUEST_LDSO, "--list", GUEST_TOOL)
|
||||
self.assertEqual([], self.library_paths)
|
||||
|
||||
def test_a_program_from_a_bind_starts_itself_again_through_proc_self_exe(self):
|
||||
bash = str(self.runtime / "bash")
|
||||
for how in ("exec", "spawn"):
|
||||
with self.subTest(how=how):
|
||||
call = self.call(how, "/proc/self/exe", "x", binds=f"/proc:/proc|{self.runtime}:{BOUND_DIR}", real_exe=bash)
|
||||
self.assertEqual(str(self.root / GUEST_LDSO.lstrip("/")), call[0])
|
||||
self.assertEqual([bash, "x"], call[-2:])
|
||||
|
||||
def test_a_rootfs_program_starts_itself_again_through_proc_self_exe(self):
|
||||
tool = str(self.root / GUEST_TOOL.lstrip("/"))
|
||||
for how in ("exec", "spawn"):
|
||||
with self.subTest(how=how):
|
||||
call = self.call(how, "/proc/self/exe", "x", binds="/proc:/proc", real_exe=tool)
|
||||
self.assertEqual(str(self.root / GUEST_LDSO.lstrip("/")), call[0])
|
||||
self.assertEqual([tool, "x"], call[-2:])
|
||||
|
||||
def test_a_script_interpreter_from_a_bind_runs_as_a_guest_program(self):
|
||||
for how in ("exec", "spawn"):
|
||||
with self.subTest(how=how):
|
||||
|
||||
@@ -57,6 +57,16 @@ class NativeHookProcExeTest(unittest.TestCase):
|
||||
(cls.root / "usr/bin").mkdir(parents=True)
|
||||
cls.kwin = cls.root / "usr/bin/kwin_wayland"
|
||||
shutil.copy(tmp / "sleeper", cls.kwin)
|
||||
cls.runtime = tmp / "runtime"
|
||||
cls.runtime.mkdir()
|
||||
cls.bound = cls.runtime / "chrome"
|
||||
shutil.copy(tmp / "sleeper", cls.bound)
|
||||
cls.shadowed = cls.runtime / "bin/chrome"
|
||||
cls.shadowed.parent.mkdir()
|
||||
shutil.copy(tmp / "sleeper", cls.shadowed)
|
||||
cls.override = tmp / "override"
|
||||
cls.override.mkdir()
|
||||
shutil.copy(tmp / "sleeper", cls.override / "chrome")
|
||||
# The child's /proc/<pid>/exe must name the loader, as DroidDeck's libddexec.so does.
|
||||
cls.loader = tmp / "lib/libddexec.so"
|
||||
cls.loader.parent.mkdir()
|
||||
@@ -85,8 +95,10 @@ class NativeHookProcExeTest(unittest.TestCase):
|
||||
self.assertEqual("ready", child.stdout.readline().strip())
|
||||
return child.pid
|
||||
|
||||
def readlink(self, *paths):
|
||||
def readlink(self, *paths, binds=None):
|
||||
hook_env = {"DDNATV_ROOT": str(self.root), "LD_PRELOAD": str(self.hook)}
|
||||
if binds:
|
||||
hook_env["DDNATV_BINDS"] = binds
|
||||
env = {k: v for k, v in os.environ.items() if k != "LD_PRELOAD"}
|
||||
if self.prefix:
|
||||
cmd = list(self.prefix) + [arg for key, value in hook_env.items() for arg in ("-E", f"{key}={value}")]
|
||||
@@ -108,6 +120,17 @@ class NativeHookProcExeTest(unittest.TestCase):
|
||||
at = f"at:/proc/{pid}"
|
||||
self.assertEqual("/usr/bin/kwin_wayland", self.readlink(at)[at])
|
||||
|
||||
def test_a_guest_program_from_a_bind_is_named_by_its_guest_path(self):
|
||||
pid = self.start(loader=True, real_exe=str(self.bound), program=self.bound)
|
||||
link = f"/proc/{pid}/exe"
|
||||
self.assertEqual("/app/extra/chrome", self.readlink(link, binds=f"/proc:/proc|{self.runtime}:/app/extra")[link])
|
||||
|
||||
def test_a_guest_program_shadowed_by_a_nested_bind_keeps_its_own_path(self):
|
||||
pid = self.start(loader=True, real_exe=str(self.shadowed), program=self.shadowed)
|
||||
link = f"/proc/{pid}/exe"
|
||||
binds = f"/proc:/proc|{self.runtime}:/app|{self.override}:/app/bin"
|
||||
self.assertEqual(str(self.shadowed), self.readlink(link, binds=binds)[link])
|
||||
|
||||
def test_a_program_named_only_in_the_environment_is_not_believed(self):
|
||||
pid = self.start(loader=True, real_exe=str(self.kwin))
|
||||
link = f"/proc/{pid}/exe"
|
||||
|
||||
Reference in new issue
Block a user