Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
platform_packages_modules_Connectivity
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
LMODroid
platform_packages_modules_Connectivity
Commits
cc2e593d
Commit
cc2e593d
authored
1 year ago
by
Remi NGUYEN VAN
Committed by
Gerrit Code Review
1 year ago
Browse files
Options
Downloads
Plain Diff
Merge "Use async private DNS resolution for privdns CTS" into main
parents
505b5ce4
5450f5e3
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
tests/cts/net/src/android/net/cts/DnsResolverTest.java
+26
-0
26 additions, 0 deletions
tests/cts/net/src/android/net/cts/DnsResolverTest.java
tests/cts/net/src/android/net/cts/MultinetworkApiTest.java
+48
-15
48 additions, 15 deletions
tests/cts/net/src/android/net/cts/MultinetworkApiTest.java
with
74 additions
and
15 deletions
tests/cts/net/src/android/net/cts/DnsResolverTest.java
+
26
−
0
View file @
cc2e593d
...
...
@@ -23,6 +23,7 @@ import static android.net.DnsResolver.TYPE_A;
import
static
android
.
net
.
DnsResolver
.
TYPE_AAAA
;
import
static
android
.
net
.
NetworkCapabilities
.
TRANSPORT_CELLULAR
;
import
static
android
.
net
.
cts
.
util
.
CtsNetUtils
.
TestNetworkCallback
;
import
static
android
.
provider
.
DeviceConfig
.
NAMESPACE_CONNECTIVITY
;
import
static
android
.
system
.
OsConstants
.
ETIMEDOUT
;
import
static
com
.
android
.
testutils
.
DevSdkIgnoreRuleKt
.
SC_V2
;
...
...
@@ -59,11 +60,14 @@ import androidx.test.runner.AndroidJUnit4;
import
com.android.net.module.util.DnsPacket
;
import
com.android.testutils.DevSdkIgnoreRule
;
import
com.android.testutils.DevSdkIgnoreRule.IgnoreUpTo
;
import
com.android.testutils.DeviceConfigRule
;
import
com.android.testutils.DnsResolverModuleTest
;
import
com.android.testutils.SkipPresubmit
;
import
org.junit.After
;
import
org.junit.Before
;
import
org.junit.BeforeClass
;
import
org.junit.ClassRule
;
import
org.junit.Rule
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
...
...
@@ -80,6 +84,8 @@ import java.util.concurrent.TimeUnit;
@AppModeFull
(
reason
=
"WRITE_SECURE_SETTINGS permission can't be granted to instant apps"
)
@RunWith
(
AndroidJUnit4
.
class
)
public
class
DnsResolverTest
{
@ClassRule
public
static
final
DeviceConfigRule
DEVICE_CONFIG_CLASS_RULE
=
new
DeviceConfigRule
();
@Rule
public
final
DevSdkIgnoreRule
ignoreRule
=
new
DevSdkIgnoreRule
();
...
...
@@ -123,6 +129,20 @@ public class DnsResolverTest {
private
TestNetworkCallback
mWifiRequestCallback
=
null
;
/**
* @see BeforeClass
*/
@BeforeClass
public
static
void
beforeClass
()
throws
Exception
{
// Use async private DNS resolution to avoid flakes due to races applying the setting
DEVICE_CONFIG_CLASS_RULE
.
setConfig
(
NAMESPACE_CONNECTIVITY
,
"networkmonitor_async_privdns_resolution"
,
"1"
);
// Make sure NetworkMonitor is restarted before and after the test so the flag is applied
// and cleaned up.
maybeToggleWifiAndCell
();
DEVICE_CONFIG_CLASS_RULE
.
runAfterNextCleanup
(
DnsResolverTest:
:
maybeToggleWifiAndCell
);
}
@Before
public
void
setUp
()
throws
Exception
{
mContext
=
InstrumentationRegistry
.
getContext
();
...
...
@@ -144,6 +164,12 @@ public class DnsResolverTest {
}
}
private
static
void
maybeToggleWifiAndCell
()
throws
Exception
{
final
CtsNetUtils
utils
=
new
CtsNetUtils
(
InstrumentationRegistry
.
getContext
());
utils
.
reconnectWifiIfSupported
();
utils
.
reconnectCellIfSupported
();
}
private
static
String
byteArrayToHexString
(
byte
[]
bytes
)
{
char
[]
hexChars
=
new
char
[
bytes
.
length
*
2
];
for
(
int
i
=
0
;
i
<
bytes
.
length
;
++
i
)
{
...
...
This diff is collapsed.
Click to expand it.
tests/cts/net/src/android/net/cts/MultinetworkApiTest.java
+
48
−
15
View file @
cc2e593d
...
...
@@ -17,6 +17,12 @@
package
android.net.cts
;
import
static
android
.
net
.
NetworkCapabilities
.
TRANSPORT_CELLULAR
;
import
static
android
.
provider
.
DeviceConfig
.
NAMESPACE_CONNECTIVITY
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertNotNull
;
import
static
org
.
junit
.
Assert
.
assertNull
;
import
static
org
.
junit
.
Assert
.
fail
;
import
android.content.ContentResolver
;
import
android.content.Context
;
...
...
@@ -28,9 +34,21 @@ import android.net.cts.util.CtsNetUtils;
import
android.platform.test.annotations.AppModeFull
;
import
android.system.ErrnoException
;
import
android.system.OsConstants
;
import
android.test.AndroidTestCase
;
public
class
MultinetworkApiTest
extends
AndroidTestCase
{
import
androidx.test.ext.junit.runners.AndroidJUnit4
;
import
androidx.test.platform.app.InstrumentationRegistry
;
import
com.android.testutils.DeviceConfigRule
;
import
org.junit.Before
;
import
org.junit.Rule
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
@RunWith
(
AndroidJUnit4
.
class
)
public
class
MultinetworkApiTest
{
@Rule
public
final
DeviceConfigRule
mDeviceConfigRule
=
new
DeviceConfigRule
();
static
{
System
.
loadLibrary
(
"nativemultinetwork_jni"
);
...
...
@@ -58,20 +76,17 @@ public class MultinetworkApiTest extends AndroidTestCase {
private
CtsNetUtils
mCtsNetUtils
;
private
String
mOldMode
;
private
String
mOldDnsSpecifier
;
@Override
protected
void
setUp
()
throws
Exception
{
super
.
setUp
();
mCM
=
(
ConnectivityManager
)
getContext
().
getSystemService
(
Context
.
CONNECTIVITY_SERVICE
);
mCR
=
getContext
().
getContentResolver
();
mCtsNetUtils
=
new
CtsNetUtils
(
getContext
());
}
@Override
protected
void
tearDown
()
throws
Exception
{
super
.
tearDown
();
private
Context
mContext
;
@Before
public
void
setUp
()
throws
Exception
{
mContext
=
InstrumentationRegistry
.
getInstrumentation
().
getContext
();
mCM
=
mContext
.
getSystemService
(
ConnectivityManager
.
class
);
mCR
=
mContext
.
getContentResolver
();
mCtsNetUtils
=
new
CtsNetUtils
(
mContext
);
}
@Test
public
void
testGetaddrinfo
()
throws
ErrnoException
{
for
(
Network
network
:
mCtsNetUtils
.
getTestableNetworks
())
{
int
errno
=
runGetaddrinfoCheck
(
network
.
getNetworkHandle
());
...
...
@@ -82,6 +97,7 @@ public class MultinetworkApiTest extends AndroidTestCase {
}
}
@Test
@AppModeFull
(
reason
=
"CHANGE_NETWORK_STATE permission can't be granted to instant apps"
)
public
void
testSetprocnetwork
()
throws
ErrnoException
{
// Hopefully no prior test in this process space has set a default network.
...
...
@@ -125,6 +141,7 @@ public class MultinetworkApiTest extends AndroidTestCase {
}
}
@Test
@AppModeFull
(
reason
=
"CHANGE_NETWORK_STATE permission can't be granted to instant apps"
)
public
void
testSetsocknetwork
()
throws
ErrnoException
{
for
(
Network
network
:
mCtsNetUtils
.
getTestableNetworks
())
{
...
...
@@ -136,6 +153,7 @@ public class MultinetworkApiTest extends AndroidTestCase {
}
}
@Test
public
void
testNativeDatagramTransmission
()
throws
ErrnoException
{
for
(
Network
network
:
mCtsNetUtils
.
getTestableNetworks
())
{
int
errno
=
runDatagramCheck
(
network
.
getNetworkHandle
());
...
...
@@ -146,6 +164,7 @@ public class MultinetworkApiTest extends AndroidTestCase {
}
}
@Test
public
void
testNoSuchNetwork
()
{
final
Network
eNoNet
=
new
Network
(
54321
);
assertNull
(
mCM
.
getNetworkInfo
(
eNoNet
));
...
...
@@ -158,6 +177,7 @@ public class MultinetworkApiTest extends AndroidTestCase {
// assertEquals(-OsConstants.ENONET, runGetaddrinfoCheck(eNoNetHandle));
}
@Test
public
void
testNetworkHandle
()
{
// Test Network -> NetworkHandle -> Network results in the same Network.
for
(
Network
network
:
mCtsNetUtils
.
getTestableNetworks
())
{
...
...
@@ -181,6 +201,7 @@ public class MultinetworkApiTest extends AndroidTestCase {
}
catch
(
IllegalArgumentException
e
)
{}
}
@Test
public
void
testResNApi
()
throws
Exception
{
final
Network
[]
testNetworks
=
mCtsNetUtils
.
getTestableNetworks
();
...
...
@@ -201,9 +222,21 @@ public class MultinetworkApiTest extends AndroidTestCase {
}
}
@Test
@AppModeFull
(
reason
=
"WRITE_SECURE_SETTINGS permission can't be granted to instant apps"
)
public
void
testResNApiNXDomainPrivateDns
()
throws
InterruptedException
{
public
void
testResNApiNXDomainPrivateDns
()
throws
Exception
{
// Use async private DNS resolution to avoid flakes due to races applying the setting
mDeviceConfigRule
.
setConfig
(
NAMESPACE_CONNECTIVITY
,
"networkmonitor_async_privdns_resolution"
,
"1"
);
mCtsNetUtils
.
reconnectWifiIfSupported
();
mCtsNetUtils
.
reconnectCellIfSupported
();
mCtsNetUtils
.
storePrivateDnsSetting
();
mDeviceConfigRule
.
runAfterNextCleanup
(()
->
{
mCtsNetUtils
.
reconnectWifiIfSupported
();
mCtsNetUtils
.
reconnectCellIfSupported
();
});
// Enable private DNS strict mode and set server to dns.google before doing NxDomain test.
// b/144521720
try
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment