Skip LinkAddress tests that are R-specific on Q
Address lifetime was added in R so tests for it should not be run on Q.
Test: CtsNetTestCasesLatestSdk:android.net.LinkAddressTest on both
devices
Bug: 150918852
Merged-In: I98b14727eabcf569829eee8df34afc057eba6f93
(cherry picked from commit 4e00259d220590acf781382de0542cbae75ec16f)
Change-Id: I9599afa8ae64bb13c93d5f26ebedf3f8dedff6d9
This commit is contained in:
committed by
Remi NGUYEN VAN
parent
e34d090bce
commit
890f021f5a
@@ -28,8 +28,8 @@ import static android.system.OsConstants.RT_SCOPE_SITE;
|
|||||||
import static android.system.OsConstants.RT_SCOPE_UNIVERSE;
|
import static android.system.OsConstants.RT_SCOPE_UNIVERSE;
|
||||||
|
|
||||||
import static com.android.testutils.MiscAssertsKt.assertEqualBothWays;
|
import static com.android.testutils.MiscAssertsKt.assertEqualBothWays;
|
||||||
|
import static com.android.testutils.MiscAssertsKt.assertFieldCountEquals;
|
||||||
import static com.android.testutils.MiscAssertsKt.assertNotEqualEitherWay;
|
import static com.android.testutils.MiscAssertsKt.assertNotEqualEitherWay;
|
||||||
import static com.android.testutils.ParcelUtilsKt.assertParcelSane;
|
|
||||||
import static com.android.testutils.ParcelUtilsKt.assertParcelingIsLossless;
|
import static com.android.testutils.ParcelUtilsKt.assertParcelingIsLossless;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
@@ -38,11 +38,17 @@ import static org.junit.Assert.assertNotEquals;
|
|||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
import static org.junit.Assert.fail;
|
import static org.junit.Assert.fail;
|
||||||
|
|
||||||
|
import android.os.Build;
|
||||||
import android.os.SystemClock;
|
import android.os.SystemClock;
|
||||||
|
|
||||||
import androidx.test.filters.SmallTest;
|
import androidx.test.filters.SmallTest;
|
||||||
import androidx.test.runner.AndroidJUnit4;
|
import androidx.test.runner.AndroidJUnit4;
|
||||||
|
|
||||||
|
import com.android.testutils.DevSdkIgnoreRule;
|
||||||
|
import com.android.testutils.DevSdkIgnoreRule.IgnoreAfter;
|
||||||
|
import com.android.testutils.DevSdkIgnoreRule.IgnoreUpTo;
|
||||||
|
|
||||||
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
|
|
||||||
@@ -57,6 +63,8 @@ import java.util.List;
|
|||||||
@RunWith(AndroidJUnit4.class)
|
@RunWith(AndroidJUnit4.class)
|
||||||
@SmallTest
|
@SmallTest
|
||||||
public class LinkAddressTest {
|
public class LinkAddressTest {
|
||||||
|
@Rule
|
||||||
|
public final DevSdkIgnoreRule ignoreRule = new DevSdkIgnoreRule();
|
||||||
|
|
||||||
private static final String V4 = "192.0.2.1";
|
private static final String V4 = "192.0.2.1";
|
||||||
private static final String V6 = "2001:db8::1";
|
private static final String V6 = "2001:db8::1";
|
||||||
@@ -318,15 +326,29 @@ public class LinkAddressTest {
|
|||||||
|
|
||||||
l = new LinkAddress(V6_ADDRESS, 64, 123, 456);
|
l = new LinkAddress(V6_ADDRESS, 64, 123, 456);
|
||||||
assertParcelingIsLossless(l);
|
assertParcelingIsLossless(l);
|
||||||
l = new LinkAddress(V6_ADDRESS, 64, 123, 456,
|
|
||||||
1L, 3600000L);
|
|
||||||
assertParcelingIsLossless(l);
|
|
||||||
|
|
||||||
l = new LinkAddress(V4 + "/28", IFA_F_PERMANENT, RT_SCOPE_LINK);
|
l = new LinkAddress(V4 + "/28", IFA_F_PERMANENT, RT_SCOPE_LINK);
|
||||||
assertParcelSane(l, 6);
|
assertParcelingIsLossless(l);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test @IgnoreUpTo(Build.VERSION_CODES.Q)
|
||||||
|
public void testLifetimeParceling() {
|
||||||
|
final LinkAddress l = new LinkAddress(V6_ADDRESS, 64, 123, 456, 1L, 3600000L);
|
||||||
|
assertParcelingIsLossless(l);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test @IgnoreAfter(Build.VERSION_CODES.Q)
|
||||||
|
public void testFieldCount_Q() {
|
||||||
|
assertFieldCountEquals(4, LinkAddress.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test @IgnoreUpTo(Build.VERSION_CODES.Q)
|
||||||
|
public void testFieldCount() {
|
||||||
|
// Make sure any new field is covered by the above parceling tests when changing this number
|
||||||
|
assertFieldCountEquals(6, LinkAddress.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test @IgnoreUpTo(Build.VERSION_CODES.Q)
|
||||||
public void testDeprecationTime() {
|
public void testDeprecationTime() {
|
||||||
try {
|
try {
|
||||||
new LinkAddress(V6_ADDRESS, 64, 0, 456,
|
new LinkAddress(V6_ADDRESS, 64, 0, 456,
|
||||||
@@ -347,7 +369,7 @@ public class LinkAddressTest {
|
|||||||
} catch (IllegalArgumentException expected) { }
|
} catch (IllegalArgumentException expected) { }
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test @IgnoreUpTo(Build.VERSION_CODES.Q)
|
||||||
public void testExpirationTime() {
|
public void testExpirationTime() {
|
||||||
try {
|
try {
|
||||||
new LinkAddress(V6_ADDRESS, 64, 0, 456,
|
new LinkAddress(V6_ADDRESS, 64, 0, 456,
|
||||||
@@ -366,10 +388,13 @@ public class LinkAddressTest {
|
|||||||
public void testGetFlags() {
|
public void testGetFlags() {
|
||||||
LinkAddress l = new LinkAddress(V6_ADDRESS, 64, 123, RT_SCOPE_HOST);
|
LinkAddress l = new LinkAddress(V6_ADDRESS, 64, 123, RT_SCOPE_HOST);
|
||||||
assertEquals(123, l.getFlags());
|
assertEquals(123, l.getFlags());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test @IgnoreUpTo(Build.VERSION_CODES.Q)
|
||||||
|
public void testGetFlags_Deprecation() {
|
||||||
// Test if deprecated bit was added/remove automatically based on the provided deprecation
|
// Test if deprecated bit was added/remove automatically based on the provided deprecation
|
||||||
// time
|
// time
|
||||||
l = new LinkAddress(V6_ADDRESS, 64, 0, RT_SCOPE_HOST,
|
LinkAddress l = new LinkAddress(V6_ADDRESS, 64, 0, RT_SCOPE_HOST,
|
||||||
1L, LinkAddress.LIFETIME_PERMANENT);
|
1L, LinkAddress.LIFETIME_PERMANENT);
|
||||||
// Check if the flag is added automatically.
|
// Check if the flag is added automatically.
|
||||||
assertTrue((l.getFlags() & IFA_F_DEPRECATED) != 0);
|
assertTrue((l.getFlags() & IFA_F_DEPRECATED) != 0);
|
||||||
@@ -458,8 +483,11 @@ public class LinkAddressTest {
|
|||||||
(IFA_F_TEMPORARY|IFA_F_TENTATIVE|IFA_F_OPTIMISTIC),
|
(IFA_F_TEMPORARY|IFA_F_TENTATIVE|IFA_F_OPTIMISTIC),
|
||||||
RT_SCOPE_UNIVERSE);
|
RT_SCOPE_UNIVERSE);
|
||||||
assertGlobalPreferred(l, "v6,global,tempaddr+optimistic");
|
assertGlobalPreferred(l, "v6,global,tempaddr+optimistic");
|
||||||
|
}
|
||||||
|
|
||||||
l = new LinkAddress(V6_ADDRESS, 64, IFA_F_DEPRECATED,
|
@Test @IgnoreUpTo(Build.VERSION_CODES.Q)
|
||||||
|
public void testIsGlobalPreferred_DeprecatedInFuture() {
|
||||||
|
final LinkAddress l = new LinkAddress(V6_ADDRESS, 64, IFA_F_DEPRECATED,
|
||||||
RT_SCOPE_UNIVERSE, SystemClock.elapsedRealtime() + 100000,
|
RT_SCOPE_UNIVERSE, SystemClock.elapsedRealtime() + 100000,
|
||||||
SystemClock.elapsedRealtime() + 200000);
|
SystemClock.elapsedRealtime() + 200000);
|
||||||
// Although the deprecated bit is set, but the deprecation time is in the future, test
|
// Although the deprecated bit is set, but the deprecation time is in the future, test
|
||||||
|
|||||||
Reference in New Issue
Block a user