Add Quest 3/3S compatibility to the standard APK (#642)

This commit is contained in:
Jagger15 authored and GitHub committed 2026-10-12 17:13:07 -04:00
1 parent 8f36eb7f54
commit 6c35297dba
25 files changed
+659 -12

No files matched your search

+1
View File
@@ -320,6 +320,7 @@ else
fi
cd "${repo_root}"
python3 tools/quest/build-driver.py "${NDK}"
bash tools/comet/build-local.sh
python3 tools/release/runtime_inputs.py record
./gradlew "${gradle_task}" --console=plain -PndkVersion="${ndk_version}" ${gradle_rust_arg}
@@ -20,7 +20,7 @@ import socket
import struct
import sys
SOCKET = "\0com.droiddeck.launcher.bwrap"
SOCKET = "\0" + os.environ.get("DROIDDECK_BWRAP_SOCKET", "com.droiddeck.launcher.bwrap")
VERSION = "bubblewrap 0.11.0 (droiddeck)"
# Options and how many arguments each takes; bwrap(1).
+2 -1
View File
@@ -421,6 +421,7 @@ static int is_link_query(unsigned long request) {
}
void bl_kgsl_chip_id_fixup(unsigned long request, void *arg, int rc); /* kgslid.c */
#include "../../quest/kgsl_compat.h"
int bl_kgsl_poll(int (*real)(int, unsigned long, void *), int fd, unsigned long request,
void *arg, int *rc) __attribute__((visibility("hidden")));
int bl_ntsync_ioctl(int fd, unsigned long request, void *arg, int *rc) __attribute__((visibility("hidden")));
@@ -440,7 +441,7 @@ int ioctl(int fd, unsigned long request, ...) {
if (bl_ntsync_ioctl(fd, request, arg, &rc)) return rc;
if (bl_drm_gem_close(fd, request, arg, &rc)) return rc;
if (real == NULL) real = (ioctl_fn) dlsym(RTLD_NEXT, "ioctl");
if (!bl_kgsl_poll(real, fd, request, arg, &rc)) rc = real(fd, request, arg);
if (!bl_kgsl_poll(real, fd, request, arg, &rc)) rc = quest_kgsl_ioctl(real, fd, request, arg);
bl_kgsl_chip_id_fixup(request, arg, rc);
if (arg == NULL || !is_link_query(request)) return rc;
int saved = errno;
+3
View File
@@ -0,0 +1,3 @@
/* SPDX-License-Identifier: GPL-3.0-or-later */
/* Shared with the Android driver wrapper so the two translation paths cannot drift. */
#include "../../quest/kgsl_compat.c"
+26
View File
@@ -0,0 +1,26 @@
/* SPDX-License-Identifier: GPL-3.0-or-later
* Loaded as the AdrenoTools driver; DT_NEEDED points to the original Turnip.
* Vulkan/HAL symbols are resolved from that dependency. Its ioctl calls resolve here.
*/
#define _GNU_SOURCE
#include "kgsl_compat.h"
#include <dlfcn.h>
#include <pthread.h>
#include <stdarg.h>
#include <sys/syscall.h>
#include <unistd.h>
static int (*next_ioctl)(int, int, ...);
static pthread_once_t once = PTHREAD_ONCE_INIT;
static void resolve_ioctl(void) { next_ioctl = dlsym(RTLD_NEXT, "ioctl"); }
static int forward(int fd, unsigned long request, void *arg) {
pthread_once(&once, resolve_ioctl);
return next_ioctl ? next_ioctl(fd, (int)request, arg) : (int)syscall(SYS_ioctl, fd, request, arg);
}
__attribute__((visibility("default"))) int ioctl(int fd, int request, ...) {
va_list ap;
va_start(ap, request);
void *arg = va_arg(ap, void *);
va_end(ap);
return quest_kgsl_ioctl(forward, fd, (unsigned int)request, arg);
}
+60
View File
@@ -0,0 +1,60 @@
#!/usr/bin/env python3
"""Build the Quest allocation adapter around the unchanged bundled Android Turnip."""
import io
import json
from pathlib import Path
import subprocess
import sys
import tarfile
import tempfile
ROOT = Path(__file__).resolve().parents[2]
OUTPUT = ROOT / 'app/build/prepared-assets/graphics_driver/adrenotools-turnip25.1.0-quest1.tzst'
def build(ndk, output=OUTPUT):
hosts = list((Path(ndk) / 'toolchains/llvm/prebuilt').glob('*'))
if len(hosts) != 1:
raise ValueError('Expected one NDK host toolchain')
llvm = hosts[0] / 'bin'
original = ROOT / 'app/src/main/assets/graphics_driver/adrenotools-turnip25.1.0.tzst'
data = subprocess.run(['zstd', '-dc', str(original)], capture_output=True, check=True).stdout
with tempfile.TemporaryDirectory(prefix='quest-driver-') as folder:
work = Path(folder)
with tarfile.open(fileobj=io.BytesIO(data)) as archive:
# Only read the known driver entry; no archive paths are extracted.
driver = archive.extractfile('vulkan.ad07xx.so').read()
(work / 'vulkan.ad07xx.so').write_bytes(driver)
wrapper = work / 'libquest_turnip.so'
subprocess.run([
str(llvm / 'aarch64-linux-android26-clang'), '-shared', '-fPIC', '-O2',
'-Wall', '-Wextra', '-Werror', '-fvisibility=hidden',
'-Wl,-z,max-page-size=16384', '-Wl,-soname,libquest_turnip.so',
'-Wl,--no-as-needed', str(work / 'vulkan.ad07xx.so'), '-Wl,--as-needed',
str(ROOT / 'tools/quest/android_wrapper.c'), str(ROOT / 'tools/quest/kgsl_compat.c'),
'-ldl', '-llog', '-o', str(wrapper),
], check=True)
subprocess.run([str(llvm / 'llvm-strip'), '--strip-unneeded', str(wrapper)], check=True)
metadata = json.dumps({
'libraryName': 'libquest_turnip.so',
'name': 'Turnip Adreno 7xx - Quest GPUOBJ experimental',
'description': 'Bundled A7xx driver with the experimental Quest 3/3S allocation adapter.',
'driverVersion': 'Bundled Mesa + Quest GPUOBJ v1',
}, indent=2).encode() + b'\n'
stream = io.BytesIO()
with tarfile.open(fileobj=stream, mode='w', format=tarfile.USTAR_FORMAT) as archive:
for name, content in [('meta.json', metadata), ('libquest_turnip.so', wrapper.read_bytes()),
('vulkan.ad07xx.so', driver)]:
entry = tarfile.TarInfo(name)
entry.size = len(content)
entry.mode = 0o644
archive.addfile(entry, io.BytesIO(content))
compressed = subprocess.run(['zstd', '-q', '-19', '-c'], input=stream.getvalue(),
capture_output=True, check=True).stdout
output.parent.mkdir(parents=True, exist_ok=True)
output.write_bytes(compressed)
print(output)
if __name__ == '__main__':
build(sys.argv[1])
+78
View File
@@ -0,0 +1,78 @@
/* SPDX-License-Identifier: GPL-3.0-or-later
* Quest experimental build, 2026-10-11.
* Horizon permits GPUOBJ allocation, but rejects the legacy GPUMEM alloc/free calls.
* Retry only those two calls after EACCES/EPERM. No change to device permissions.
*/
#include "kgsl_compat.h"
#include <errno.h>
#include <limits.h>
#include <stdint.h>
#include <stdio.h>
#ifdef __ANDROID__
#include <android/log.h>
#endif
#if __SIZEOF_POINTER__ == 8
_Static_assert(sizeof(struct kgsl_gpumem_alloc_id) == 48, "KGSL alloc ABI");
_Static_assert(sizeof(struct kgsl_gpuobj_alloc) == 48, "GPUOBJ alloc ABI");
_Static_assert(sizeof(struct kgsl_gpuobj_free) == 32, "GPUOBJ free ABI");
_Static_assert(sizeof(struct kgsl_gpuobj_info) == 48, "GPUOBJ info ABI");
#endif
static void report(const char *operation, int error) {
static unsigned successes, failures;
unsigned *counter = error ? &failures : &successes;
/* Log the first success and at most eight failures per process. */
if (__atomic_fetch_add(counter, 1, __ATOMIC_RELAXED) >= (error ? 8u : 1u)) return;
int saved = errno;
#ifdef __ANDROID__
__android_log_print(error ? ANDROID_LOG_ERROR : ANDROID_LOG_INFO, "QuestKGSL",
"%s: GPUOBJ compatibility path, errno=%d", operation, error);
#else
fprintf(stderr, "[QuestKGSL] %s: GPUOBJ compatibility path, errno=%d\n", operation, error);
#endif
errno = saved;
}
int quest_kgsl_ioctl(quest_ioctl_fn real, int fd, unsigned long request, void *arg) {
int rc = real(fd, request, arg);
if (rc != -1 || (errno != EACCES && errno != EPERM) || arg == NULL) return rc;
if (request == IOCTL_KGSL_GPUMEM_ALLOC_ID) {
struct kgsl_gpumem_alloc_id *old = arg;
struct kgsl_gpuobj_alloc alloc = {.size = old->size, .flags = old->flags};
rc = real(fd, IOCTL_KGSL_GPUOBJ_ALLOC, &alloc);
if (rc != 0) { report("alloc failed", errno); return rc; }
struct kgsl_gpuobj_info info = {.id = alloc.id};
rc = real(fd, IOCTL_KGSL_GPUOBJ_INFO, &info);
int error = errno;
if (rc == 0 && (info.size > SIZE_MAX || alloc.mmapsize > SIZE_MAX ||
info.gpuaddr > ULONG_MAX || info.flags > UINT_MAX)) {
rc = -1;
error = EOVERFLOW;
}
if (rc != 0) {
/* The caller never receives this allocation, so clean it up on an INFO failure. */
struct kgsl_gpuobj_free release = {.id = alloc.id};
if (real(fd, IOCTL_KGSL_GPUOBJ_FREE, &release) != 0)
report("cleanup failed", errno);
errno = error;
report("info failed", error);
return rc;
}
old->id = alloc.id;
old->flags = (unsigned int)info.flags;
old->size = info.size;
old->mmapsize = alloc.mmapsize;
old->gpuaddr = info.gpuaddr;
report("allocation succeeded", 0);
return 0;
}
if (request == IOCTL_KGSL_GPUMEM_FREE_ID) {
const struct kgsl_gpumem_free_id *old = arg;
struct kgsl_gpuobj_free release = {.id = old->id};
rc = real(fd, IOCTL_KGSL_GPUOBJ_FREE, &release);
if (rc != 0) report("free failed", errno);
}
return rc;
}
+15
View File
@@ -0,0 +1,15 @@
/* SPDX-License-Identifier: GPL-3.0-or-later */
#ifndef DROIDDECK_QUEST_KGSL_COMPAT_H
#define DROIDDECK_QUEST_KGSL_COMPAT_H
/* Use the vendored Qualcomm UAPI, including its architecture-dependent ioctl sizes. */
#ifndef __user
#define __user
#endif
#include "../../app/src/main/cpp/adrenotools/src/hook/kgsl.h"
typedef int (*quest_ioctl_fn)(int, unsigned long, void *);
__attribute__((visibility("hidden")))
int quest_kgsl_ioctl(quest_ioctl_fn real, int fd, unsigned long request, void *arg);
#endif
+77
View File
@@ -0,0 +1,77 @@
/* SPDX-License-Identifier: GPL-3.0-or-later */
#include "kgsl_compat.h"
#include <assert.h>
#include <errno.h>
#include <stdio.h>
#include <string.h>
static unsigned long calls[8];
static int count, old_error, alloc_error, info_error, free_error;
static unsigned long address;
static int mock(int fd, unsigned long request, void *arg) {
assert(fd == 42 && count < 8);
calls[count++] = request;
if (request == IOCTL_KGSL_GPUMEM_ALLOC_ID || request == IOCTL_KGSL_GPUMEM_FREE_ID) {
if (old_error) { errno = old_error; return -1; }
return 0;
}
if (request == IOCTL_KGSL_GPUOBJ_ALLOC) {
if (alloc_error) { errno = alloc_error; return -1; }
struct kgsl_gpuobj_alloc *p = arg;
assert(p->size == 123 && p->flags == 0x10000 && !p->metadata && !p->metadata_len);
p->id = 77; p->size = 4096; p->mmapsize = 8192;
return 0;
}
if (request == IOCTL_KGSL_GPUOBJ_INFO) {
struct kgsl_gpuobj_info *p = arg;
assert(p->id == 77);
if (info_error) { errno = info_error; return -1; }
p->gpuaddr = address; p->flags = 0x20000; p->size = 4096;
return 0;
}
if (request == IOCTL_KGSL_GPUOBJ_FREE) {
struct kgsl_gpuobj_free *p = arg;
assert(p->id == 77 && !p->flags && !p->priv && !p->type && !p->len);
if (free_error) { errno = free_error; return -1; }
return 0;
}
errno = EACCES;
return -1;
}
static struct kgsl_gpumem_alloc_id reset(void) {
count = old_error = alloc_error = info_error = free_error = 0;
address = 0x100000;
return (struct kgsl_gpumem_alloc_id){.size = 123, .flags = 0x10000};
}
int main(void) {
struct kgsl_gpumem_alloc_id p = reset();
assert(quest_kgsl_ioctl(mock, 42, IOCTL_KGSL_GPUMEM_ALLOC_ID, &p) == 0 && count == 1);
p = reset(); old_error = EACCES;
assert(quest_kgsl_ioctl(mock, 42, IOCTL_KGSL_GPUMEM_ALLOC_ID, &p) == 0);
assert(count == 3 && p.id == 77 && p.size == 4096 && p.mmapsize == 8192);
assert(p.flags == 0x20000 && p.gpuaddr == address);
p = reset(); old_error = EPERM; address = 0;
assert(quest_kgsl_ioctl(mock, 42, IOCTL_KGSL_GPUMEM_ALLOC_ID, &p) == 0 && p.gpuaddr == 0);
p = reset(); old_error = ENOMEM;
assert(quest_kgsl_ioctl(mock, 42, IOCTL_KGSL_GPUMEM_ALLOC_ID, &p) == -1 && errno == ENOMEM && count == 1);
p = reset(); old_error = EACCES; alloc_error = ENOMEM;
assert(quest_kgsl_ioctl(mock, 42, IOCTL_KGSL_GPUMEM_ALLOC_ID, &p) == -1 && errno == ENOMEM && count == 2);
assert(p.id == 0 && p.size == 123);
p = reset(); old_error = EACCES; info_error = EIO;
assert(quest_kgsl_ioctl(mock, 42, IOCTL_KGSL_GPUMEM_ALLOC_ID, &p) == -1 && errno == EIO);
assert(count == 4 && calls[3] == IOCTL_KGSL_GPUOBJ_FREE && p.id == 0);
p = reset(); old_error = EACCES; info_error = EIO; free_error = ENOSPC;
assert(quest_kgsl_ioctl(mock, 42, IOCTL_KGSL_GPUMEM_ALLOC_ID, &p) == -1 && errno == EIO && count == 4);
p = reset(); old_error = EACCES;
assert(quest_kgsl_ioctl(mock, 42, IOCTL_KGSL_GPUMEM_ALLOC_ID, NULL) == -1 && count == 1);
p = reset(); old_error = EACCES;
assert(quest_kgsl_ioctl(mock, 42, 0x1234, &p) == -1 && errno == EACCES && count == 1);
struct kgsl_gpumem_free_id release = {.id = 77};
reset(); old_error = EACCES;
assert(quest_kgsl_ioctl(mock, 42, IOCTL_KGSL_GPUMEM_FREE_ID, &release) == 0 && count == 2);
reset(); old_error = EPERM; free_error = EIO;
assert(quest_kgsl_ioctl(mock, 42, IOCTL_KGSL_GPUMEM_FREE_ID, &release) == -1 && errno == EIO && count == 2);
reset();
assert(quest_kgsl_ioctl(mock, 42, IOCTL_KGSL_GPUMEM_FREE_ID, &release) == 0 && count == 1);
puts("PASS: 12 GPUOBJ translation, passthrough, failure and cleanup scenarios");
}
+7 -2
View File
@@ -16,7 +16,9 @@ SOURCE_PATHS = ['app/build.gradle', 'app/src/main/cpp/fakeinput_steam.cpp', 'app
'tools/linuxfs', 'tools/proot', 'tools/aaudio-sink', 'tools/directaudio',
'tools/gamescope/release.env', 'tools/droiddeck-esync/release.env',
'tools/mangoapp', 'tools/msitools', 'tools/comet', 'tools/build_local.sh',
'tools/release/runtime_inputs.py', 'app/src/main/assets/desktop-removal']
'tools/release/runtime_inputs.py', 'app/src/main/assets/desktop-removal',
'tools/quest', 'app/src/main/cpp/adrenotools/src/hook/kgsl.h',
'app/src/main/assets/graphics_driver/adrenotools-turnip25.1.0.tzst']
def digest(path):
@@ -48,11 +50,14 @@ def outputs(root):
for library in ['libproot.so', 'libproot-loader.so', 'libdirectaudiorelay.so']:
result['lib/arm64-v8a/' + library] = 'app/src/main/jniLibs/arm64-v8a/' + library
result['assets/pulseaudio.tzst'] = 'app/build/prepared-assets/pulseaudio.tzst'
result['assets/graphics_driver/adrenotools-turnip25.1.0-quest1.tzst'] = \
'app/build/prepared-assets/graphics_driver/adrenotools-turnip25.1.0-quest1.tzst'
return result
def required():
paths = ['assets/linuxfs/' + name for name in ['libfakeinput.so', 'libblsession.so',
paths = ['assets/graphics_driver/adrenotools-turnip25.1.0-quest1.tzst']
paths += ['assets/linuxfs/' + name for name in ['libfakeinput.so', 'libblsession.so',
'libblfastpath.so', 'libssbs.so', 'usr/local/bin/droiddeck-clipboard',
'usr/local/bin/gamescope', 'usr/local/lib/droiddeck/uruntime']]
for arch in ['x86_64', 'i386']:
+84
View File
@@ -0,0 +1,84 @@
import os
from pathlib import Path
import shutil
import subprocess
import sys
import tempfile
import unittest
SOURCE = Path(__file__).resolve().parents[2] / "app/src/main/cpp/fakeinput_steam.cpp"
PROGRAM = r"""
#include <assert.h>
#include <errno.h>
#include <stdarg.h>
#include <sys/ioctl.h>
#include <termios.h>
#include <unistd.h>
#ifdef BACKEND
int ioctl(int fd, unsigned long request, ...) {
va_list ap;
va_start(ap, request);
int *value = va_arg(ap, int *);
va_end(ap);
assert(fd == -1 && request == 0x12345678 && value);
*value = 0x51;
errno = EACCES;
return -1;
}
#else
int main(int argc, char **argv) {
if (argc > 1) {
int value = 0;
assert(ioctl(-1, 0x12345678, &value) == -1);
assert(value == 0x51 && errno == EACCES);
} else {
int fds[2];
assert(pipe(fds) == 0);
struct termios term;
assert(ioctl(fds[0], TCGETS, &term) == -1 && errno == ENOTTY);
close(fds[0]);
close(fds[1]);
}
return 0;
}
#endif
"""
@unittest.skipUnless(sys.platform == "linux" and shutil.which("gcc") and shutil.which("g++"),
"needs Linux, gcc and g++")
class FakeinputIoctlTest(unittest.TestCase):
@classmethod
def setUpClass(cls):
cls.tmp = tempfile.TemporaryDirectory()
cls.addClassCleanup(cls.tmp.cleanup)
cls.path = Path(cls.tmp.name)
source = cls.path / "program.c"
source.write_text(PROGRAM)
subprocess.run(["gcc", "-o", str(cls.path / "program"), str(source)], check=True)
subprocess.run(["gcc", "-shared", "-fPIC", "-DBACKEND", "-o",
str(cls.path / "backend.so"), str(source)], check=True)
subprocess.run(["g++", "-shared", "-fPIC", "-O2", "-Wno-attributes", "-pthread",
"-std=c++17", "-static-libstdc++", "-static-libgcc",
"-Wl,--exclude-libs,ALL", "-o", str(cls.path / "libfakeinput.so"),
str(SOURCE), "-ldl"], check=True)
def run_program(self, backend=False):
preload = str(self.path / "libfakeinput.so")
args = [str(self.path / "program")]
if backend:
preload += ":" + str(self.path / "backend.so")
args.append("backend")
subprocess.run(args, env=dict(os.environ, LD_PRELOAD=preload), check=True, timeout=10)
def test_later_interposer_receives_arguments_and_returns_errno(self):
self.run_program(backend=True)
def test_libc_passthrough_retains_kernel_error(self):
self.run_program()
if __name__ == "__main__":
unittest.main()
+23
View File
@@ -0,0 +1,23 @@
from pathlib import Path
import shutil
import subprocess
import sys
import tempfile
import unittest
QUEST = Path(__file__).resolve().parents[1] / 'quest'
@unittest.skipUnless(sys.platform == 'linux' and shutil.which('gcc'), 'needs Linux and gcc')
class QuestKgslTest(unittest.TestCase):
def test_allocation_passthrough_translation_and_cleanup(self):
with tempfile.TemporaryDirectory() as folder:
binary = str(Path(folder) / 'test-kgsl')
subprocess.run(['gcc', '-Wall', '-Wextra', '-Werror', '-O2', '-o', binary,
str(QUEST / 'test_kgsl_compat.c'), str(QUEST / 'kgsl_compat.c')], check=True)
result = subprocess.run([binary], capture_output=True, text=True, check=True, timeout=10)
self.assertIn('PASS: 12 GPUOBJ', result.stdout)
if __name__ == '__main__':
unittest.main()
+14
View File
@@ -55,6 +55,20 @@ class RuntimeInputsTest(unittest.TestCase):
with self.assertRaisesRegex(ValueError, 'sources changed'):
runtime.verify(self.root)
def test_changed_quest_source_rejects_old_outputs(self):
source = self.root / 'tools/quest/kgsl_compat.c'
source.parent.mkdir(parents=True)
source.write_text('old compatibility code')
runtime.record(self.root)
source.write_text('new compatibility code')
with self.assertRaisesRegex(ValueError, 'sources changed'):
runtime.verify(self.root)
def test_missing_quest_driver_cannot_be_attested(self):
(self.root / 'app/build/prepared-assets/graphics_driver/adrenotools-turnip25.1.0-quest1.tzst').unlink()
with self.assertRaisesRegex(ValueError, 'quest1.tzst'):
runtime.record(self.root)
def test_modified_prebuilt_binary_is_rejected(self):
runtime.record(self.root)
(self.root / 'app/src/main/jniLibs/arm64-v8a/libproot.so').write_bytes(b'old APK binary')
+67
View File
@@ -0,0 +1,67 @@
"""Exercise the literal launch prefix from SessionService without an Android runtime.
This is a focused source/exec regression check, not a Kotlin or PRoot integration
test. PRoot executes the first guest argument directly; KEY=VALUE is meaningful
only after /usr/bin/env. Read the production prefix rather than duplicate it.
"""
import json
from pathlib import Path
import re
import subprocess
import unittest
SERVICE = Path(__file__).resolve().parents[2] / (
"app/src/main/java/com/droiddeck/launcher/session/SessionService.kt")
VARIANTS = Path(__file__).resolve().parents[1] / "release/variants.txt"
PACKAGES = [line.split()[1] for line in VARIANTS.read_text().splitlines()
if line.strip() and not line.startswith("#")]
def guest_prefix(package):
source = SERVICE.read_text()
before_environment = source.split("val guest = ArrayList<String>()", 1)[1].split(
"addClientEnvironment(guest, steamHere)", 1)[0]
environment = source.split("private fun addClientEnvironment(", 1)[1].split(
'guest.add("HOME=/root")', 1)[0]
prefix = []
for line in (before_environment + environment).splitlines():
line = line.strip()
if not line.startswith("guest.add("):
continue
expression = line[len("guest.add("):-1]
match = re.fullmatch(r'("[^"\\]*")(?: \+ (.+))?', expression)
if match is None:
raise AssertionError("Launch prefix changed; update its regression harness: " + line)
value = json.loads(match[1])
if match[2]:
if match[2] != "com.droiddeck.launcher.runtime.BwrapSpawner.socket(this)":
raise AssertionError("Unexpected dynamic launch-prefix argument: " + line)
value += package + ".bwrap"
prefix.append(value)
return prefix
class SessionGuestCommandTest(unittest.TestCase):
def test_env_is_the_executable_for_every_package(self):
for package in PACKAGES:
with self.subTest(package=package):
self.assertEqual(["/usr/bin/env", "-i"], guest_prefix(package)[:2])
@unittest.skipUnless(Path("/usr/bin/env").is_file(), "needs /usr/bin/env")
def test_child_receives_its_package_socket_after_environment_is_cleared(self):
for package in PACKAGES:
with self.subTest(package=package):
# env with no command prints the environment it would pass to the
# session. A misplaced assignment fails at exec, before it runs.
result = subprocess.run(
guest_prefix(package), capture_output=True, text=True, check=True,
timeout=5, env={"DROIDDECK_BWRAP_SOCKET": "wrong.bwrap", "STALE_HOST": "1"})
self.assertEqual(
["DROIDDECK_BWRAP_SOCKET=" + package + ".bwrap"],
result.stdout.splitlines())
if __name__ == "__main__":
unittest.main()