mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-10-28 02:42:07 +00:00
Add sepolicy.rule patching tests
This commit is contained in:
@@ -7,6 +7,7 @@ import androidx.test.uiautomator.By
|
||||
import androidx.test.uiautomator.Until
|
||||
import com.topjohnwu.magisk.core.model.module.LocalModule
|
||||
import com.topjohnwu.magisk.core.utils.RootUtils
|
||||
import com.topjohnwu.superuser.Shell
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import org.junit.After
|
||||
import org.junit.Assert.assertEquals
|
||||
@@ -96,6 +97,10 @@ class AdditionalTest : BaseTest {
|
||||
"/system/app/EasterEgg should be empty",
|
||||
egg.isEmpty()
|
||||
)
|
||||
assertTrue(
|
||||
"Module sepolicy.rule is not applied",
|
||||
Shell.cmd("magiskpolicy --print-rules | grep -q magisk_test").exec().isSuccess
|
||||
)
|
||||
module!!
|
||||
assertTrue("test_01 should be zygisk unloaded", module.zygiskUnloaded)
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@ import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import timber.log.Timber
|
||||
import java.io.File
|
||||
import java.io.PrintStream
|
||||
|
||||
@Keep
|
||||
@RunWith(AndroidJUnit4::class)
|
||||
@@ -106,7 +107,15 @@ class Environment : BaseTest {
|
||||
val module = LocalModule(path)
|
||||
assertTrue(error, module.zygiskFolder.mkdir())
|
||||
|
||||
assertTrue(error, Shell.cmd("set_default_perm $path").exec().isSuccess)
|
||||
// Add sepolicy patch
|
||||
PrintStream(path.getChildFile("sepolicy.rule").newOutputStream()).use {
|
||||
it.println("type magisk_test domain")
|
||||
}
|
||||
|
||||
assertTrue(error, Shell.cmd(
|
||||
"set_default_perm $path",
|
||||
"copy_preinit_files"
|
||||
).exec().isSuccess)
|
||||
}
|
||||
|
||||
private fun setupModule02(root: ExtendedFile) {
|
||||
|
||||
Reference in New Issue
Block a user