Add uninstaller.sh test

This commit is contained in:
topjohnwu
2025-08-04 20:20:53 -07:00
committed by John Wu
parent bf4ed295da
commit 7df4a9d74f
2 changed files with 15 additions and 4 deletions

View File

@@ -136,5 +136,9 @@ class AdditionalTest : BaseTest {
@Test @Test
fun testRemoveModule() { fun testRemoveModule() {
assertNull("$REMOVE_TEST should be removed", modules.find { it.id == REMOVE_TEST }) assertNull("$REMOVE_TEST should be removed", modules.find { it.id == REMOVE_TEST })
assertTrue(
"Uninstaller of $REMOVE_TEST should be run",
RootUtils.fs.getFile(Environment.REMOVE_TEST_MARKER).exists()
)
} }
} }

View File

@@ -58,11 +58,13 @@ class Environment : BaseTest {
return Build.VERSION.SDK_INT >= 27 return Build.VERSION.SDK_INT >= 27
} }
private const val MODULE_UPDATE_PATH = "/data/adb/modules_update"
private const val MODULE_ERROR = "Module zip processing incorrect" private const val MODULE_ERROR = "Module zip processing incorrect"
const val MOUNT_TEST = "mount_test" const val MOUNT_TEST = "mount_test"
const val SEPOLICY_RULE = "sepolicy_rule" const val SEPOLICY_RULE = "sepolicy_rule"
const val INVALID_ZYGISK = "invalid_zygisk" const val INVALID_ZYGISK = "invalid_zygisk"
const val REMOVE_TEST = "remove_test" const val REMOVE_TEST = "remove_test"
const val REMOVE_TEST_MARKER = "/dev/.remove_test_removed"
const val EMPTY_ZYGISK = "empty_zygisk" const val EMPTY_ZYGISK = "empty_zygisk"
} }
@@ -170,6 +172,10 @@ class Environment : BaseTest {
// Create a new module but mark is as "remove" // Create a new module but mark is as "remove"
val module = LocalModule(path) val module = LocalModule(path)
assertTrue(error, path.mkdirs()) assertTrue(error, path.mkdirs())
// Create uninstaller script
path.getChildFile("uninstall.sh").newOutputStream().writer().use {
it.write("touch $REMOVE_TEST_MARKER")
}
assertTrue(error, path.getChildFile("service.sh").createNewFile()) assertTrue(error, path.getChildFile("service.sh").createNewFile())
module.remove = true module.remove = true
@@ -220,11 +226,12 @@ class Environment : BaseTest {
} }
val root = RootUtils.fs.getFile(Const.MODULE_PATH) val root = RootUtils.fs.getFile(Const.MODULE_PATH)
if (mount()) { setupMountTest(root) } val update = RootUtils.fs.getFile(MODULE_UPDATE_PATH)
if (preinit()) { setupSepolicyRuleModule(root) } if (mount()) { setupMountTest(update) }
if (preinit()) { setupSepolicyRuleModule(update) }
setupSystemlessHost() setupSystemlessHost()
setupEmptyZygiskModule(root) setupEmptyZygiskModule(update)
setupInvalidZygiskModule(root) setupInvalidZygiskModule(update)
setupRemoveModule(root) setupRemoveModule(root)
} }