diff options
author | Lorenzo Colitti <lorenzo@google.com> | 2023-09-06 17:01:19 +0900 |
---|---|---|
committer | Cherrypicker Worker <android-build-cherrypicker-worker@google.com> | 2023-09-07 01:57:06 +0000 |
commit | d0a655296ad0e167e9b598ab074adde91e78eb59 (patch) | |
tree | 24293b3319db9c50dfe2cd45b3bd97dde4032a07 | |
parent | 861d32d0e01b0db8209167aa346f40424e64c7f6 (diff) | |
download | Connectivity-d0a655296ad0e167e9b598ab074adde91e78eb59.tar.gz |
Convert ProcNetTest to JUnit4.
This allows using assumptions to skip tests.
Test: atest CtsHostsideNetworkTests
(cherry picked from https://android-review.googlesource.com/q/commit:9ae344b81ad53269f8b7c7d305fbf8f87c6d7ccc)
Merged-In: Ic1fc41c1ca0c30b6b7350c413d710d959b9a5013
Change-Id: Ic1fc41c1ca0c30b6b7350c413d710d959b9a5013
-rw-r--r-- | tests/cts/hostside/src/com/android/cts/net/ProcNetTest.java | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/tests/cts/hostside/src/com/android/cts/net/ProcNetTest.java b/tests/cts/hostside/src/com/android/cts/net/ProcNetTest.java index b4964c1d62..e45ff82a17 100644 --- a/tests/cts/hostside/src/com/android/cts/net/ProcNetTest.java +++ b/tests/cts/hostside/src/com/android/cts/net/ProcNetTest.java @@ -16,11 +16,19 @@ package android.security.cts; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + import com.android.tradefed.build.IBuildInfo; import com.android.tradefed.device.ITestDevice; -import com.android.tradefed.testtype.DeviceTestCase; +import com.android.tradefed.testtype.DeviceJUnit4ClassRunner; import com.android.tradefed.testtype.IBuildReceiver; import com.android.tradefed.testtype.IDeviceTest; +import com.android.tradefed.testtype.junit4.BaseHostJUnit4Test; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; import java.util.ArrayList; import java.util.Arrays; @@ -31,7 +39,8 @@ import java.util.List; * * These tests analyze /proc/net to verify that certain networking properties are correct. */ -public class ProcNetTest extends DeviceTestCase implements IBuildReceiver, IDeviceTest { +@RunWith(DeviceJUnit4ClassRunner.class) +public class ProcNetTest extends BaseHostJUnit4Test implements IBuildReceiver, IDeviceTest { private static final String SPI_TIMEOUT_SYSCTL = "/proc/sys/net/core/xfrm_acq_expires"; private static final int MIN_ACQ_EXPIRES = 3600; // Global sysctls. Must be present and set to 1. @@ -70,13 +79,12 @@ public class ProcNetTest extends DeviceTestCase implements IBuildReceiver, IDevi */ @Override public void setDevice(ITestDevice device) { - super.setDevice(device); mDevice = device; } - @Override - protected void setUp() throws Exception { - super.setUp(); + /** Run before each test case. */ + @Before + public void setUp() throws Exception { mSysctlDirs = getSysctlDirs(); } @@ -111,6 +119,7 @@ public class ProcNetTest extends DeviceTestCase implements IBuildReceiver, IDevi /** * Checks that SPI default timeouts are overridden, and set to a reasonable length of time */ + @Test public void testMinAcqExpires() throws Exception { int value = readIntFromPath(SPI_TIMEOUT_SYSCTL); assertAtLeast(SPI_TIMEOUT_SYSCTL, value, MIN_ACQ_EXPIRES); @@ -120,6 +129,7 @@ public class ProcNetTest extends DeviceTestCase implements IBuildReceiver, IDevi * Checks that the sysctls for multinetwork kernel features are present and * enabled. */ + @Test public void testProcSysctls() throws Exception { for (String sysctl : GLOBAL_SYSCTLS) { int value = readIntFromPath(sysctl); @@ -136,6 +146,7 @@ public class ProcNetTest extends DeviceTestCase implements IBuildReceiver, IDevi /** * Verify that accept_ra_rt_info_{min,max}_plen exists and is set to the expected value */ + @Test public void testAcceptRaRtInfoMinMaxPlen() throws Exception { for (String interfaceDir : mSysctlDirs) { String path = IPV6_SYSCTL_DIR + "/" + interfaceDir + "/" + "accept_ra_rt_info_min_plen"; @@ -151,6 +162,7 @@ public class ProcNetTest extends DeviceTestCase implements IBuildReceiver, IDevi * Verify that router_solicitations exists and is set to the expected value * and verify that router_solicitation_max_interval exists and is in an acceptable interval. */ + @Test public void testRouterSolicitations() throws Exception { for (String interfaceDir : mSysctlDirs) { String path = IPV6_SYSCTL_DIR + "/" + interfaceDir + "/" + "router_solicitations"; @@ -170,6 +182,7 @@ public class ProcNetTest extends DeviceTestCase implements IBuildReceiver, IDevi * (This repeats the VTS test, and is here for good performance of the internet as a whole.) * TODO: revisit this once a better CC algorithm like BBR2 is available. */ + @Test public void testCongestionControl() throws Exception { String path = "/proc/sys/net/ipv4/tcp_congestion_control"; String value = mDevice.executeAdbCommand("shell", "cat", path).trim(); |