mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-22 14:26:00 +00:00
fix: avoid incompatible Turnip selection and explain Steam startup failures (#1380)
This commit is contained in:
16 files changed
+504
-7
No files matched your search
@@ -0,0 +1,121 @@
|
||||
package com.droiddeck.launcher.session
|
||||
|
||||
import android.app.Application
|
||||
import com.droiddeck.launcher.R
|
||||
import com.droiddeck.launcher.SessionActivity
|
||||
import com.droiddeck.launcher.gpu.GpuInfo
|
||||
import org.junit.After
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertNotNull
|
||||
import org.junit.Assert.assertNull
|
||||
import org.junit.Before
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
import org.junit.rules.TemporaryFolder
|
||||
import org.junit.runner.RunWith
|
||||
import org.robolectric.Robolectric
|
||||
import org.robolectric.RobolectricTestRunner
|
||||
import org.robolectric.annotation.Config
|
||||
import org.robolectric.annotation.Implementation
|
||||
import org.robolectric.annotation.Implements
|
||||
import org.robolectric.util.ReflectionHelpers
|
||||
import java.io.File
|
||||
|
||||
@RunWith(RobolectricTestRunner::class)
|
||||
@Config(
|
||||
sdk = [33], application = Application::class, qualifiers = "en-rUS",
|
||||
instrumentedPackages = ["com.droiddeck.launcher.gpu.GpuInfo"],
|
||||
shadows = [SessionEndHintTest.DetectedGpu::class],
|
||||
)
|
||||
class SessionEndHintTest {
|
||||
@get:Rule val temporary = TemporaryFolder()
|
||||
private lateinit var activity: SessionActivity
|
||||
private var previousArchitecture: String? = null
|
||||
|
||||
@Before
|
||||
fun setUp() {
|
||||
previousArchitecture = SessionState.steamClientArch
|
||||
DetectedGpu.family = GpuInfo.Family.NOT_ADRENO
|
||||
activity = Robolectric.buildActivity(SessionActivity::class.java).get()
|
||||
SessionState.steamClientArch = "arm64"
|
||||
}
|
||||
|
||||
@After
|
||||
fun tearDown() {
|
||||
SessionState.steamClientArch = previousArchitecture
|
||||
DetectedGpu.family = GpuInfo.Family.NOT_ADRENO
|
||||
}
|
||||
|
||||
@Test
|
||||
fun sigillOnArm64IncludesTheExperimentalX64Fallback() {
|
||||
SessionState.steamClientArch = "arm64"
|
||||
|
||||
assertEquals(
|
||||
activity.getString(R.string.session_end_steam_sigill) + "\n" + activity.getString(R.string.session_end_steam_try_x64),
|
||||
hintText(sigillLog()),
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun sigillOnX86_64DoesNotSuggestSwitchingToItself() {
|
||||
SessionState.steamClientArch = "x86_64"
|
||||
|
||||
assertEquals(activity.getString(R.string.session_end_steam_sigill), hintText(sigillLog()))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun sigillWithUnknownArchitectureDoesNotAssumeArm64() {
|
||||
SessionState.steamClientArch = null
|
||||
|
||||
assertEquals(activity.getString(R.string.session_end_steam_sigill), hintText(sigillLog()))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun vulkanFailureOnAdrenoSelectsTheDriverHint() {
|
||||
for (family in listOf(GpuInfo.Family.A6XX, GpuInfo.Family.ADRENO_UNKNOWN)) {
|
||||
DetectedGpu.family = family
|
||||
|
||||
assertEquals(family.name, activity.getString(R.string.session_end_vulkan_device), hintText(vulkanLog()))
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun vulkanFailureOnNonAdrenoExplainsTheMissingLinuxDriver() {
|
||||
DetectedGpu.family = GpuInfo.Family.NOT_ADRENO
|
||||
|
||||
assertEquals(activity.getString(R.string.session_end_gpu_unsupported), hintText(vulkanLog()))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun missingEmptyAndUnrelatedLogsHaveNoHint() {
|
||||
assertNull(hint(null))
|
||||
assertNull(hint(File(temporary.root, "missing.log")))
|
||||
assertNull(hint(log("")))
|
||||
assertNull(hint(log("game: Illegal instruction\n== steam exited rc=132")))
|
||||
}
|
||||
|
||||
private fun sigillLog() = log("== STEP 12:00:00 starting the Steam client\n== steam exited rc=132\n")
|
||||
|
||||
private fun vulkanLog() = log("[gamescope] [Error] vulkan: failed to find physical device\n")
|
||||
|
||||
private fun log(text: String): File = temporary.newFile().apply { writeText(text) }
|
||||
|
||||
private fun hint(log: File?): Any? = SessionActivity::class.java
|
||||
.getDeclaredMethod("sessionEndHint", File::class.java).apply { isAccessible = true }.invoke(activity, log)
|
||||
|
||||
private fun hintText(log: File): String {
|
||||
val result = hint(log)
|
||||
assertNotNull(result)
|
||||
return ReflectionHelpers.getField(result, "text")
|
||||
}
|
||||
|
||||
@Implements(value = GpuInfo.Companion::class, isInAndroidSdk = false)
|
||||
class DetectedGpu {
|
||||
@Implementation
|
||||
fun detect(): GpuInfo = GpuInfo("test GPU", if (family == GpuInfo.Family.A6XX) 610 else 0, family, "", false)
|
||||
|
||||
companion object {
|
||||
var family = GpuInfo.Family.NOT_ADRENO
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package com.droiddeck.launcher.session
|
||||
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertNull
|
||||
import org.junit.Test
|
||||
|
||||
class SessionLaunchFailureTest {
|
||||
private fun find(vararg lines: String) = SessionLaunchFailure.find(lines.asSequence())
|
||||
|
||||
@Test fun installedSteamThatExitsWithSigillHasACpuFailureHint() {
|
||||
assertEquals(SessionLaunchFailure.STEAM_ILLEGAL_INSTRUCTION, find(
|
||||
"== STEP 06:35:36.987 Steam client ready",
|
||||
"== STEP 06:35:41.058 starting the Steam client",
|
||||
"/usr/local/bin/droiddeck-session: line 309: 1192 Illegal instruction steam",
|
||||
"== steam exited rc=132",
|
||||
"(EE) failed to read Wayland events: Broken pipe",
|
||||
))
|
||||
}
|
||||
|
||||
@Test fun gamescopeWithoutAPhysicalDeviceHasAGraphicsFailureHint() {
|
||||
assertEquals(SessionLaunchFailure.VULKAN_DEVICE_MISSING, find(
|
||||
"[gamescope] [\u001b[0;31mError\u001b[0m] \u001b[0;37mvulkan:\u001b[0m failed to find physical device",
|
||||
"SDL_Vulkan_CreateSurface failed: VK_KHR_wayland_surface extension is not enabled in the Vulkan instance.Failed to create backend.",
|
||||
))
|
||||
}
|
||||
|
||||
@Test fun unrelatedIllegalInstructionsAndExitCodesAreNotBlamedOnSteam() {
|
||||
assertNull(find("game: Illegal instruction", "== steam exited rc=132"))
|
||||
assertNull(find("== STEP 12:00:00 starting the Steam client", "== steam exited rc=139"))
|
||||
assertNull(find("== STEP 12:00:00 starting the Steam client", "== steam exited rc=1320"))
|
||||
assertNull(find("== STEP 12:00:00 starting the Steam client", "== steam exited rc=0"))
|
||||
}
|
||||
|
||||
@Test fun onlyTheLatestClientAttemptCounts() {
|
||||
assertNull(find(
|
||||
"== STEP 12:00:00 starting the Steam client", "== steam exited rc=132",
|
||||
"== STEP 12:01:00 starting the Steam client", "== steam exited rc=0",
|
||||
))
|
||||
}
|
||||
|
||||
@Test fun aLaterSuccessfulDeviceSelectionClearsTheGraphicsFailure() {
|
||||
assertNull(find(
|
||||
"[gamescope] [Error] vulkan: failed to find physical device",
|
||||
"[gamescope] [Info] vulkan: selecting physical device 'Turnip Adreno (TM) 610': queue family 0",
|
||||
))
|
||||
}
|
||||
|
||||
@Test fun aNewSessionDoesNotReuseAnOldFailure() {
|
||||
assertNull(find(
|
||||
"== STEP 12:00:00 starting the Steam client", "== steam exited rc=132",
|
||||
"== droiddeck-session Fri Oct 23 12:01:00 mode=steam",
|
||||
))
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user