Exclude testGetNeighborsQuery from NetworkStackCoverageTests.

sepolicy gates RTM_GETNEIGH{TBL} with a new permission nlmsg_getneigh
and block access from untrusted_apps, but NetworkStackCoverageTests
uses the same UID with NetworkStack module, so it still has the
permission to send RTM_GETNEIGH(context: u:r:network_stack:s0<00>),
which causes the test always fails. Add the same assumeFalse check
for tests with network_stack context.

Bug: 283346574
Test: atest NetworkStackCoverageTests
Change-Id: Iaf652841bb9868783c924aa22fdf0c4f07e1e391
This commit is contained in:
Xiao Ma 2023-09-28 18:08:37 +09:00
commit 998f6b0eda

View file

@ -88,6 +88,11 @@ public class NetlinkUtilsTest {
if (SdkLevel.isAtLeastT() && targetSdk > 31) {
var ctxt = new String(Files.readAllBytes(Paths.get("/proc/thread-self/attr/current")));
assumeFalse("must not be platform app", ctxt.startsWith("u:r:platform_app:s0:"));
// NetworkStackCoverageTests uses the same UID with NetworkStack module, which
// still has the permission to send RTM_GETNEIGH message (sepolicy just blocks the
// access from untrusted_apps), also exclude the NetworkStackCoverageTests.
assumeFalse("network_stack context is expected to have permission to send RTM_GETNEIGH",
ctxt.startsWith("u:r:network_stack:s0"));
try {
NetlinkUtils.sendMessage(fd, req, 0, req.length, TEST_TIMEOUT_MS);
fail("RTM_GETNEIGH is not allowed for apps targeting SDK > 31 on T+ platforms,"