mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-08-11 12:57:27 +00:00
Add uninstaller.sh test
This commit is contained in:
@@ -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()
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -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)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user