Compare commits

..
Author SHA1 Message Date
Kurt Himebauch f4daf49097 Merge branch 'main' into fix/swapped-red-blue 2026-11-24 17:51:11 -05:00
The412Banner 0764d7365a fix(gamescope): compose into an RGBA surface on every offscreen copy path
Patch 0923 picked the RGBA SDR surface only on PowerVR. Xclipse's system
driver takes the same copy path, so gamescope picked BGRA there and the
rgba8 composite shader wrote through a BGRA view: red and blue swapped in
Steam and every game on the Galaxy Z Flip7.
2026-11-23 20:41:10 +00:00
13 changed files with 37 additions and 220 deletions

No files matched your search

@@ -626,7 +626,6 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
private var cardboard by mutableStateOf(Cardboard.OFF)
private var headTracker: HeadTracker? = null
private var steamVrStatus by mutableStateOf<SteamVr.Status?>(null)
private var steamVrPercent by mutableStateOf<Int?>(null)
private var steamVrSwitchedPicture by mutableStateOf(false)
private var steamVrSeenRunning = false
private val steamVrRecovery by lazy { com.droiddeck.launcher.gpu.SteamVrRecovery(this) {
@@ -1391,12 +1390,9 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
val request = steamVrRequestGeneration
val session = SessionState.sessionId
val now = kotlinx.coroutines.withContext(kotlinx.coroutines.Dispatchers.IO) {
SteamVr.report(this@SessionActivity)
}
if (request == steamVrRequestGeneration && session == SessionState.sessionId) {
steamVrPercent = now.percent
onSteamVrStatus(now.status)
SteamVr.status(this@SessionActivity)
}
if (request == steamVrRequestGeneration && session == SessionState.sessionId) onSteamVrStatus(now)
kotlinx.coroutines.delay(3000)
}
}
@@ -1509,7 +1505,6 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
com.droiddeck.launcher.glasses.GlassesMenuMirror.recenter()
},
steamVr = steamVrStatus,
steamVrPercent = steamVrPercent,
immersiveSteamVr = com.droiddeck.launcher.session.QuestExperimental.isSupported(),
onSteamVr = { action -> steamVrAction(action) },
textureAnisotropy = if (drawerGameProfileId == null) textureAnisotropy else drawerTextureAnisotropy,
@@ -32,21 +32,9 @@ object SteamVr {
}
}
data class Report(val status: Status, val percent: Int? = null)
fun status(context: Context): Status = report(context).status
fun report(context: Context): Report = runCatching {
report(AgentGuest.call(context, JSONObject().put("kind", "vr").put("action", "status"), STATUS_TIMEOUT_MS))
}.getOrDefault(Report(Status.UNAVAILABLE))
fun report(answer: JSONObject): Report {
val status = parse(answer)
val size = answer.optLong("size", 0L)
val done = answer.optLong("downloaded", -1L)
val percent = if (status == Status.INSTALLING && size > 0 && done in 0 until size) (done * 100 / size).toInt() else null
return Report(status, percent)
}
fun status(context: Context): Status = runCatching {
parse(AgentGuest.call(context, JSONObject().put("kind", "vr").put("action", "status"), STATUS_TIMEOUT_MS))
}.getOrDefault(Status.UNAVAILABLE)
fun run(context: Context, action: String): Boolean = runCatching {
require(action in setOf("install", "start", "stop"))
@@ -948,7 +948,7 @@ internal object EnhancedSessionLogShare {
"droiddeck", "droiddeck-esync", "session.log", "app.log", "wayland.log", "audio.log",
"device.txt", "network.txt", "events.jsonl", "memory.csv", "capture.json", "crash.log",
"frame-trace.log", "process-trace.log", "game-lifecycle.log", "launches.log", "tools.tsv", "wanted.tsv", "prefixes.json",
"battlenet.log", "spawned.log", "flatpak-install.log", "droiddeck-steamvr-install.log", "cef_log.txt", "cef_log.previous.txt",
"battlenet.log", "spawned.log", "flatpak-install.log", "cef_log.txt", "cef_log.previous.txt",
"console_log.txt", "webhelper_js.txt", "controller_support.txt", "systemperfmanager.txt",
"rpcs3", "RPCS3.log",
)
@@ -265,7 +265,6 @@ class DrawerActions(
val cardboard: Cardboard = Cardboard.OFF,
val cardboardSensor: Boolean = false,
val steamVr: SteamVr.Status? = null,
val steamVrPercent: Int? = null,
val glassesPresent: Boolean = false,
val glassesOutput: Boolean = false,
val immersiveSteamVr: Boolean = false,
@@ -1403,7 +1402,7 @@ private fun SteamVrGroup(a: DrawerActions, track: (String) -> Modifier) {
}
when (a.steamVr) {
SteamVr.Status.NOT_INSTALLED -> button(vrLabel, stringResource(R.string.cardboard_steamvr_install), "install")
SteamVr.Status.INSTALLING -> SteamVrInstalling(vrLabel, a.steamVrPercent)
SteamVr.Status.INSTALLING -> SettingsRow(vrLabel, stringResource(R.string.cardboard_steamvr_installing)) {}
SteamVr.Status.READY -> button(vrLabel, enterLabel, "start")
SteamVr.Status.RUNNING -> {
if (a.immersiveSteamVr) button(vrLabel, enterLabel, "start")
@@ -1418,19 +1417,12 @@ private fun SteamVrGroup(a: DrawerActions, track: (String) -> Modifier) {
}
}
@Composable
private fun SteamVrInstalling(label: String, percent: Int?) {
SettingsRow(label, stringResource(R.string.cardboard_steamvr_installing)) {
if (percent != null) Text(stringResource(R.string.ctrl_percent, percent), fontSize = 13.sp, color = MaterialTheme.colorScheme.onSurfaceVariant)
}
}
@Composable
private fun SteamVrRow(a: DrawerActions) {
val vrLabel = stringResource(R.string.cardboard_steamvr)
when (a.steamVr) {
SteamVr.Status.NOT_INSTALLED -> ActionRow(vrLabel, null, stringResource(R.string.cardboard_steamvr_install), { a.onSteamVr("install") })
SteamVr.Status.INSTALLING -> SteamVrInstalling(vrLabel, a.steamVrPercent)
SteamVr.Status.INSTALLING -> SettingsRow(vrLabel, stringResource(R.string.cardboard_steamvr_installing)) {}
SteamVr.Status.READY -> ActionRow(vrLabel, null, stringResource(R.string.cardboard_steamvr_start), { a.onSteamVr("start") })
SteamVr.Status.RUNNING -> ActionRow(vrLabel, null, stringResource(R.string.cardboard_steamvr_stop), { a.onSteamVr("stop") })
SteamVr.Status.UNAVAILABLE -> SettingsRow(vrLabel, stringResource(R.string.cardboard_steamvr_unavailable)) {}
@@ -64,22 +64,6 @@ class CardboardTest {
SteamVr.parse(answer("ok" to true, "installed" to true, "driver" to true).put("exitCode", 1)))
}
@Test fun steamVrReportsDownloadPercentOnlyWhileInstalling() {
fun answer(installing: Boolean, downloaded: Long?, size: Long?) = JSONObject().apply {
put("ok", true)
put("installing", installing)
put("driver", true)
downloaded?.let { put("downloaded", it) }
size?.let { put("size", it) }
}
assertEquals(SteamVr.Report(SteamVr.Status.INSTALLING, 0), SteamVr.report(answer(true, 0, 571_309_057)))
assertEquals(SteamVr.Report(SteamVr.Status.INSTALLING, 49), SteamVr.report(answer(true, 285_654_528, 571_309_057)))
assertEquals(SteamVr.Report(SteamVr.Status.INSTALLING, 99), SteamVr.report(answer(true, 571_309_056, 571_309_057)))
assertEquals(SteamVr.Report(SteamVr.Status.INSTALLING, null), SteamVr.report(answer(true, 571_309_057, 571_309_057)))
assertEquals(SteamVr.Report(SteamVr.Status.INSTALLING, null), SteamVr.report(answer(true, null, null)))
assertEquals(SteamVr.Report(SteamVr.Status.NOT_INSTALLED, null), SteamVr.report(answer(false, 1_000, 571_309_057)))
}
@Test fun steamVrActionsSucceedOnlyWhenTheHelperDid() {
fun answer(ok: Boolean, exitCode: Int? = null, started: Boolean? = null) = JSONObject().apply {
put("ok", ok)
+1 -4
View File
@@ -55,10 +55,7 @@ the lens exactly.
Valve's ARM64 SteamVR, the build the Steam Frame runs, comes from Valve's public SteamOS package
server (`deckard-steamvr`, pinned by version and SHA-256 in `droiddeck-steamvr`; the same hash
[steam-frame-nixos](https://github.com/y0usaf/steam-frame-nixos) pins). `droiddeck-steamvr install`
unpacks it to `/opt/steamvr`. The drawer's **Install** button runs that (571 MB) and shows the
download percentage. A download that stays under 1 KB/s for 60 seconds is stopped and resumed, up to
five tries without progress; each step is written to Steam's logs as `droiddeck-steamvr-install.log`,
which the session log share includes. **Start** then
unpacks it to `/opt/steamvr`. The drawer's **Install** button runs that (571 MB). **Start** then
switches the picture to side-by-side and runs SteamVR with three DroidDeck pieces (`tools/vr`):
1. **`driver_droiddeck.so`**, an OpenVR driver with one HMD:
+4 -2
View File
@@ -76,8 +76,10 @@ The system PowerVR driver uses the existing SDL/Wayland swapchain backend. Its a
- `0922-powervr-linear-dmabuf-import.patch`: retain the explicit linear layout when PowerVR
rejects the mutable-format query, and intersect imported-image and FD memory-type masks.
- `0923-powervr-rgba-copy-surface.patch`: require an advertised RGBA SDR copy surface matching
the shader's `rgba8` storage view. The tested workaround leaves other vendors, HDR and direct
composition unchanged; it does not restrict game-facing BGRA formats.
the shader's `rgba8` storage view, on every GPU that composes offscreen and copies. Writing
through a BGRA view of that image swapped red and blue on PowerVR and on the Xclipse 950's
system driver; libhybris always offers RGBA next to BGRA. HDR and direct composition keep the
existing selector; it does not restrict game-facing BGRA formats.
- `0924-sdl-preserve-explicit-refresh.patch` and `0925-sdl-wait-before-present.patch`: preserve
configured refresh across SDL events and finish composition before presenting without a
render-finished semaphore. The build runs the focused capability, format and refresh tests.
@@ -2,24 +2,18 @@ diff --git a/src/nested_surface_format.hpp b/src/nested_surface_format.hpp
new file mode 100644
--- /dev/null
+++ b/src/nested_surface_format.hpp
@@ -0,0 +1,31 @@
@@ -0,0 +1,25 @@
+#pragma once
+
+#include <vulkan/vulkan_core.h>
+
+namespace gamescope
+{
+// The SDR composition shader declares rgba8, which requires an R8G8B8A8_UNORM
+// storage view. Binding a BGRA view is a format mismatch; a same-format copy
+// cannot correct it. Keep the workaround scoped to the PowerVR SDR copy path
+// where the channel reversal was reproduced, not game-facing texture formats.
+// On success, formatCount means the existing selector should choose the format.
+// On failure, no matching RGBA SDR surface was advertised for this scoped path.
+inline bool ChooseNestedSDRCopySurfaceFormat( uint32_t vendorId, bool copy, bool hdr,
+inline bool ChooseNestedSDRCopySurfaceFormat( bool copy, bool hdr,
+ const VkSurfaceFormatKHR *formats, uint32_t formatCount, uint32_t &surfaceFormat )
+{
+ surfaceFormat = formatCount;
+ if ( vendorId != 0x1010 || !copy || hdr )
+ if ( !copy || hdr )
+ return true;
+
+ for ( uint32_t i = 0; i < formatCount; ++i )
@@ -49,10 +43,10 @@ diff --git a/src/rendervulkan.cpp b/src/rendervulkan.cpp
uint32_t surfaceFormat = formatCount;
VkColorSpaceKHR preferredColorSpace = g_bOutputHDREnabled ? VK_COLOR_SPACE_HDR10_ST2084_EXT : VK_COLOR_SPACE_SRGB_NONLINEAR_KHR;
+ if ( !gamescope::ChooseNestedSDRCopySurfaceFormat( g_device.vendorID(), config.copy,
+ if ( !gamescope::ChooseNestedSDRCopySurfaceFormat( config.copy,
+ g_bOutputHDREnabled, pOutput->surfaceFormats.data(), formatCount, surfaceFormat ) )
+ {
+ vk_log.errorf( "PowerVR copy composition requires an RGBA SDR surface" );
+ vk_log.errorf( "Copy composition requires an RGBA SDR surface" );
+ return false;
+ }
+
+10 -16
View File
@@ -70,53 +70,47 @@ int main()
VK_FORMAT_B8G8R8A8_UNORM, VK_COLOR_SPACE_SRGB_NONLINEAR_KHR};
uint32_t surfaceFormat = UINT32_MAX;
// PowerVR SDR copy output needs the RGBA view matching the rgba8 shader.
const VkSurfaceFormatKHR bgraFirst[] = {bgra, rgba, rgba};
assert(ChooseNestedSDRCopySurfaceFormat(0x1010, true, false,
assert(ChooseNestedSDRCopySurfaceFormat(true, false,
bgraFirst, 3, surfaceFormat));
assert(surfaceFormat == 1);
const VkSurfaceFormatKHR rgbaFirst[] = {rgba, bgra};
assert(ChooseNestedSDRCopySurfaceFormat(0x1010, true, false,
assert(ChooseNestedSDRCopySurfaceFormat(true, false,
rgbaFirst, 2, surfaceFormat));
assert(surfaceFormat == 0);
assert(ChooseNestedSDRCopySurfaceFormat(0x1010, true, false,
assert(ChooseNestedSDRCopySurfaceFormat(true, false,
&rgba, 1, surfaceFormat));
assert(surfaceFormat == 0);
// Reusing a successful index must not hide a missing compatible format.
assert(!ChooseNestedSDRCopySurfaceFormat(0x1010, true, false,
assert(!ChooseNestedSDRCopySurfaceFormat(true, false,
&bgra, 1, surfaceFormat));
assert(surfaceFormat == 1);
const VkSurfaceFormatKHR wrongColorSpace = {
VK_FORMAT_R8G8B8A8_UNORM, VK_COLOR_SPACE_DISPLAY_P3_NONLINEAR_EXT};
assert(!ChooseNestedSDRCopySurfaceFormat(0x1010, true, false,
assert(!ChooseNestedSDRCopySurfaceFormat(true, false,
&wrongColorSpace, 1, surfaceFormat));
assert(surfaceFormat == 1);
const VkSurfaceFormatKHR srgbFormat = {
VK_FORMAT_R8G8B8A8_SRGB, VK_COLOR_SPACE_SRGB_NONLINEAR_KHR};
assert(!ChooseNestedSDRCopySurfaceFormat(0x1010, true, false,
assert(!ChooseNestedSDRCopySurfaceFormat(true, false,
&srgbFormat, 1, surfaceFormat));
assert(surfaceFormat == 1);
const VkSurfaceFormatKHR compatibleLast[] = {wrongColorSpace, srgbFormat, rgba};
assert(ChooseNestedSDRCopySurfaceFormat(0x1010, true, false,
assert(ChooseNestedSDRCopySurfaceFormat(true, false,
compatibleLast, 3, surfaceFormat));
assert(surfaceFormat == 2);
assert(!ChooseNestedSDRCopySurfaceFormat(0x1010, true, false,
assert(!ChooseNestedSDRCopySurfaceFormat(true, false,
nullptr, 0, surfaceFormat));
assert(surfaceFormat == 0);
// The existing selector still owns HDR, direct output, and other vendors.
// Each call clears a stale index even when BGRA is the only advertised format.
surfaceFormat = 0;
assert(ChooseNestedSDRCopySurfaceFormat(0x1010, true, true,
assert(ChooseNestedSDRCopySurfaceFormat(true, true,
&bgra, 1, surfaceFormat));
assert(surfaceFormat == 1);
surfaceFormat = 0;
assert(ChooseNestedSDRCopySurfaceFormat(0x1010, false, false,
&bgra, 1, surfaceFormat));
assert(surfaceFormat == 1);
surfaceFormat = 0;
assert(ChooseNestedSDRCopySurfaceFormat(0x5143, true, false,
assert(ChooseNestedSDRCopySurfaceFormat(false, false,
&bgra, 1, surfaceFormat));
assert(surfaceFormat == 1);
@@ -1082,8 +1082,6 @@ def steamvr(req):
key, _, value = part.partition("=")
if key in ("installed", "running", "installing", "driver"):
result[key] = value == "1"
elif key in ("downloaded", "size") and value.isdigit():
result[key] = int(value)
return result
@@ -13,15 +13,6 @@ chmod 700 "$state"
PKG_URL=https://steamdeck-packages.steamos.cloud/archlinux-deckard-hotfixes/release/0.3.x/deckard-steamvr-rel-r25358740%2B28b72a4f-1-aarch64.pkg.tar.zst
PKG_SHA256=90a600775eb3e8856dc475f83166a93a290a0b1f3b4e82a69c8e2a8f06b9ddc9
PKG_SIZE=571309057
pkg=$HOME/.cache/droiddeck-vr/steamvr.pkg.tar.zst
install_log=$logs/droiddeck-steamvr-install.log
bytes() { stat -c %s "$1" 2>/dev/null || echo 0; }
note() {
mkdir -p "$logs"
printf '%s %s\n' "$(date '+%Y-%m-%d %H:%M:%S')" "$*" | tee -a "$install_log"
}
running() { pgrep -x vrserver >/dev/null 2>&1; }
installed() { [ -x "$steamvr/bin/linuxarm64/vrstartup" ]; }
@@ -99,7 +90,7 @@ status)
if idle; then unregister; fi
n=0; [ -f "$state/installing" ] && n=1
d=0; [ -f "$driver/bin/linuxarm64/driver_droiddeck.so" ] && [ -f "$layer/libVkLayer_droiddeck_vr.so" ] && d=1
echo "installed=$i running=$r installing=$n driver=$d downloaded=$(bytes "$pkg") size=$PKG_SIZE"
echo "installed=$i running=$r installing=$n driver=$d"
;;
install)
exec 7>"$state/install.lock"
@@ -107,30 +98,18 @@ install)
installed && { echo "SteamVR is already in $steamvr"; exit 0; }
: > "$state/installing"
trap 'rm -f "$state/installing"' EXIT
cache=$(dirname "$pkg")
cache=$HOME/.cache/droiddeck-vr
mkdir -p "$cache"
attempt=1
while [ "$(bytes "$pkg")" -lt "$PKG_SIZE" ]; do
before=$(bytes "$pkg")
note "downloading SteamVR from Valve's package server: attempt $attempt, $before of $PKG_SIZE bytes"
curl -fsSL --connect-timeout 30 --speed-limit 1024 --speed-time 60 -C - -o "$pkg" "$PKG_URL" 2>>"$install_log"
code=$?
note "curl exited $code with $(bytes "$pkg") of $PKG_SIZE bytes"
[ "$code" = 0 ] && break
[ "$(bytes "$pkg")" -gt "$before" ] && attempt=0
[ "$attempt" -lt 5 ] || { note "download failed"; exit 1; }
attempt=$((attempt + 1))
sleep 5
done
note "checking sha256"
echo "$PKG_SHA256 $pkg" | sha256sum -c - >/dev/null 2>&1 || { note "checksum mismatch: removing the download"; rm -f "$pkg"; exit 1; }
pkg=$cache/steamvr.pkg.tar.zst
echo "downloading SteamVR (571 MB) from Valve's package server"
curl -fsSL --retry 5 -C - -o "$pkg" "$PKG_URL" || { echo "download failed"; exit 1; }
echo "$PKG_SHA256 $pkg" | sha256sum -c - >/dev/null 2>&1 || { echo "checksum mismatch: removing the download"; rm -f "$pkg"; exit 1; }
tmp=$cache/extract
rm -rf "$tmp" && mkdir -p "$tmp"
note "unpacking SteamVR"
zstd -dc "$pkg" 2>>"$install_log" | tar -x -C "$tmp" opt/steamvr 2>>"$install_log" || { note "extract failed"; rm -rf "$tmp"; exit 1; }
zstd -dc "$pkg" | tar -x -C "$tmp" opt/steamvr || { echo "extract failed"; rm -rf "$tmp"; exit 1; }
mkdir -p "$(dirname "$steamvr")"
rm -rf "$steamvr" && mv "$tmp/opt/steamvr" "$steamvr" && rm -rf "$tmp" "$pkg" || { note "could not move SteamVR into $steamvr"; exit 1; }
note "SteamVR installed in $steamvr"
rm -rf "$steamvr" && mv "$tmp/opt/steamvr" "$steamvr" && rm -rf "$tmp" "$pkg"
echo "SteamVR installed in $steamvr"
;;
stop)
stop || exit 1
-5
View File
@@ -179,11 +179,6 @@ class AgentTest(unittest.TestCase):
self.assertEqual((True, False, False, True),
(answer["installed"], answer["running"], answer["installing"], answer["driver"]))
def test_vr_status_reports_download_progress(self):
self.vr_helper('echo "installed=0 running=0 installing=1 driver=1 downloaded=1234 size=571309057"\n')
answer = self.ask({"kind": "vr", "action": "status"})
self.assertEqual((True, 1234, 571309057), (answer["installing"], answer["downloaded"], answer["size"]))
def test_vr_runs_only_its_own_actions(self):
log = self.dir / "args"
self.vr_helper('echo "$@" > %s\n' % log)
-101
View File
@@ -1,13 +1,9 @@
import hashlib
import io
import os
import json
import shlex
import shutil
import socket
import subprocess
import sys
import tarfile
import tempfile
import time
import unittest
@@ -253,102 +249,5 @@ class SteamVrHelperTest(unittest.TestCase):
self.assertTrue(xr.is_symlink())
def package(self):
payload = io.BytesIO()
with tarfile.open(fileobj=payload, mode='w') as archive:
body = b'#!/bin/sh\n' + os.urandom(6000).hex().encode() + b'\n'
entry = tarfile.TarInfo('opt/steamvr/bin/linuxarm64/vrstartup')
entry.size = len(body)
entry.mode = 0o755
archive.addfile(entry, io.BytesIO(body))
data = payload.getvalue()
source = self.root / 'package'
source.write_bytes(data)
text = self.helper.read_text()
for old, new in (('PKG_SIZE=571309057', 'PKG_SIZE=%d' % len(data)),
('PKG_SHA256=90a600775eb3e8856dc475f83166a93a290a0b1f3b4e82a69c8e2a8f06b9ddc9',
'PKG_SHA256=' + hashlib.sha256(data).hexdigest())):
self.assertIn(old, text)
text = text.replace(old, new)
self.helper.write_text(text, encoding='utf-8')
self.executable(self.commands / 'zstd', 'exec cat "$2"')
self.environment['STEAMVR'] = str(self.root / 'fresh/steamvr')
return source, len(data)
def fake_curl(self, source, chunk, exit_code):
self.executable(self.commands / 'curl', '\n'.join((
'out=; previous=',
'for argument in "$@"; do [ "$previous" = -o ] && out=$argument; previous=$argument; done',
'echo "$*" >> %s' % shlex.quote(str(self.root / 'curl-calls')),
'have=$(stat -c %s "$out" 2>/dev/null || echo 0)',
'tail -c +$((have + 1)) %s | head -c %d >> "$out"' % (shlex.quote(str(source)), chunk),
'[ "$(stat -c %%s "$out")" -lt "$(stat -c %%s %s)" ] || exit 0' % shlex.quote(str(source)),
'echo "curl: (28) Operation too slow" >&2',
'exit %d' % exit_code,
)))
def install(self):
return subprocess.run(['sh', str(self.helper), 'install'], env=self.environment,
capture_output=True, text=True, timeout=30)
def install_log(self):
return (self.home / '.local/share/Steam/logs/droiddeck-steamvr-install.log').read_text()
def test_install_resumes_a_stalled_download_and_logs_each_step(self):
source, size = self.package()
self.fake_curl(source, size // 8 + 1, 28)
result = self.install()
self.assertEqual(result.returncode, 0, result.stdout + result.stderr)
self.assertTrue((self.root / 'fresh/steamvr/bin/linuxarm64/vrstartup').is_file())
calls = (self.root / 'curl-calls').read_text().splitlines()
self.assertEqual(len(calls), 8)
for call in calls:
self.assertIn('--speed-limit 1024 --speed-time 60', call)
self.assertIn('--connect-timeout 30', call)
self.assertIn('-C -', call)
log = self.install_log()
self.assertIn('curl exited 28', log)
self.assertIn('curl: (28) Operation too slow', log)
self.assertIn('curl exited 0 with %d of %d bytes' % (size, size), log)
self.assertIn('checking sha256', log)
self.assertIn('unpacking SteamVR', log)
self.assertIn('SteamVR installed in', log)
self.assertFalse((self.runtime / 'droiddeck-steamvr/installing').exists())
self.assertFalse((self.home / '.cache/droiddeck-vr/steamvr.pkg.tar.zst').exists())
def test_install_gives_up_when_the_download_makes_no_progress(self):
source, size = self.package()
self.fake_curl(source, 0, 28)
result = self.install()
self.assertEqual(result.returncode, 1)
self.assertEqual(len((self.root / 'curl-calls').read_text().splitlines()), 5)
self.assertIn('download failed', self.install_log())
self.assertFalse((self.runtime / 'droiddeck-steamvr/installing').exists())
self.assertFalse((self.root / 'fresh/steamvr').exists())
def test_install_removes_a_corrupt_download(self):
source, size = self.package()
self.fake_curl(source, size, 0)
corrupt = self.home / '.cache/droiddeck-vr/steamvr.pkg.tar.zst'
corrupt.parent.mkdir(parents=True)
corrupt.write_bytes(b'x' * size)
result = self.install()
self.assertEqual(result.returncode, 1)
self.assertFalse((self.root / 'curl-calls').exists())
self.assertIn('checksum mismatch', self.install_log())
self.assertFalse(corrupt.exists())
def test_status_reports_download_progress(self):
partial = self.home / '.cache/droiddeck-vr/steamvr.pkg.tar.zst'
partial.parent.mkdir(parents=True)
partial.write_bytes(b'x' * 1234)
result = subprocess.run(['sh', str(self.helper), 'status'], env=self.environment,
capture_output=True, text=True, timeout=5, check=True)
self.assertIn('downloaded=1234 size=571309057', result.stdout)
partial.unlink()
result = subprocess.run(['sh', str(self.helper), 'status'], env=self.environment,
capture_output=True, text=True, timeout=5, check=True)
self.assertIn('downloaded=0 size=571309057', result.stdout)
if __name__ == '__main__':
unittest.main()