Merge branch 'main' into fix/gog-native-installer-extract

This commit is contained in:
Moroni Granja authored and GitHub committed 2026-10-20 09:54:16 -03:00
commit 38c72c6304
5 files changed
+101 -4

No files matched your search

@@ -187,10 +187,15 @@ public final class LinuxRuntime {
} catch (java.io.IOException e) {
}
}
File fileMax = new File(fakeProc, "file-max");
if (!fileMax.isFile()) {
String[][] seeded = {
{"file-max", "9223372036854775807\n"},
{"overcommit_memory", "0\n"},
};
for (String[] entry : seeded) {
File fake = new File(fakeProc, entry[0]);
if (fake.isFile()) continue;
try {
Files.write(fileMax.toPath(), "9223372036854775807\n".getBytes(StandardCharsets.US_ASCII));
Files.write(fake.toPath(), entry[1].getBytes(StandardCharsets.US_ASCII));
} catch (IOException e) {
}
}
@@ -205,6 +210,7 @@ public final class LinuxRuntime {
{"overflowuid", "/proc/sys/kernel/overflowuid"},
{"overflowgid", "/proc/sys/kernel/overflowgid"},
{"file-max", "/proc/sys/fs/file-max"},
{"overcommit_memory", "/proc/sys/vm/overcommit_memory"},
};
for (String[] entry : procFiles) {
File fake = new File(fakeProc, entry[0]);
@@ -0,0 +1,38 @@
package com.droiddeck.launcher.runtime
import android.content.ContextWrapper
import java.io.File
import java.nio.file.Files
import org.junit.After
import org.junit.Assert.assertEquals
import org.junit.Test
import org.junit.runner.RunWith
import org.robolectric.RobolectricTestRunner
import org.robolectric.RuntimeEnvironment
@RunWith(RobolectricTestRunner::class)
class LinuxRuntimeProcFilesTest {
private val root = Files.createTempDirectory("guest-proc-files").toFile()
private val context = object : ContextWrapper(RuntimeEnvironment.getApplication()) {
override fun getFilesDir() = File(root, "files").apply { mkdirs() }
override fun getCacheDir() = File(root, "cache").apply { mkdirs() }
override fun getNoBackupFilesDir() = File(root, "no_backup").apply { mkdirs() }
}
private val fakeProc get() = File(LinuxRuntime.rootDir(context), "etc/droiddeck/proc")
@After fun tearDown() {
root.deleteRecursively()
}
@Test fun theGuestGetsAnOvercommitPolicyItCanRead() {
LinuxRuntime.binds(context, null, null, null, null)
assertEquals("0\n", File(fakeProc, "overcommit_memory").readText())
assertEquals("9223372036854775807\n", File(fakeProc, "file-max").readText())
}
@Test fun aSeededFileIsKept() {
File(fakeProc, "overcommit_memory").apply { parentFile!!.mkdirs(); writeText("1\n") }
LinuxRuntime.binds(context, null, null, null, null)
assertEquals("1\n", File(fakeProc, "overcommit_memory").readText())
}
}