Skip to content
Snippets Groups Projects
Commit 1bd33c6c authored by Maciej Żenczykowski's avatar Maciej Żenczykowski Committed by Gerrit Code Review
Browse files

Merge "Add test for cgroup bpf program status" into main

parents 118c2646 54e84ab0
No related branches found
No related tags found
No related merge requests found
......@@ -45,6 +45,7 @@ android_test {
// order-dependent setup.
"NetworkStackApiStableLib",
"androidx.test.ext.junit",
"compatibility-device-util-axt",
"frameworks-net-integration-testutils",
"kotlin-reflect",
"mockito-target-extended-minus-junit4",
......
......@@ -40,11 +40,14 @@ import android.os.ConditionVariable
import android.os.IBinder
import android.os.SystemConfigManager
import android.os.UserHandle
import android.os.VintfRuntimeInfo
import android.testing.TestableContext
import android.util.Log
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.platform.app.InstrumentationRegistry
import com.android.compatibility.common.util.SystemUtil
import com.android.connectivity.resources.R
import com.android.net.module.util.BpfUtils
import com.android.server.BpfNetMaps
import com.android.server.ConnectivityService
import com.android.server.NetworkAgentWrapper
......@@ -53,6 +56,7 @@ import com.android.server.connectivity.ConnectivityResources
import com.android.server.connectivity.MockableSystemProperties
import com.android.server.connectivity.MultinetworkPolicyTracker
import com.android.server.connectivity.ProxyTracker
import com.android.testutils.DeviceInfoUtils
import com.android.testutils.RecorderCallback.CallbackEntry.LinkPropertiesChanged
import com.android.testutils.TestableNetworkCallback
import kotlin.test.assertEquals
......@@ -60,6 +64,7 @@ import kotlin.test.assertNotNull
import kotlin.test.assertTrue
import kotlin.test.fail
import org.junit.After
import org.junit.Assume
import org.junit.Before
import org.junit.BeforeClass
import org.junit.Test
......@@ -302,4 +307,25 @@ class ConnectivityServiceIntegrationTest {
!it.hasCapability(NET_CAPABILITY_VALIDATED)
}
}
private fun isBpfGetCgroupProgramIdSupportedByKernel(): Boolean {
val kVersionString = VintfRuntimeInfo.getKernelVersion()
return DeviceInfoUtils.compareMajorMinorVersion(kVersionString, "4.19") >= 0
}
@Test
fun testBpfProgramAttachStatus() {
Assume.assumeTrue(isBpfGetCgroupProgramIdSupportedByKernel())
listOf(
BpfUtils.BPF_CGROUP_INET_INGRESS,
BpfUtils.BPF_CGROUP_INET_EGRESS,
BpfUtils.BPF_CGROUP_INET_SOCK_CREATE
).forEach {
val ret = SystemUtil.runShellCommand(InstrumentationRegistry.getInstrumentation(),
"cmd connectivity bpf-get-cgroup-program-id $it").trim()
assertTrue(Integer.parseInt(ret) > 0, "Unexpected output $ret for type $it")
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment