aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlmaz Mingaleev <mingaleev@google.com>2024-04-30 13:30:15 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2024-04-30 13:30:15 +0000
commit9265fbef09d9c10e9babe35d368d11a21cc2a94d (patch)
tree9acb081bad2d5f36a4399eda9c4391c2b4e1b49b
parent90ebde7475e4c4c5767836e80810f64db499041c (diff)
parentf5c6e8194f134e370fee64d38d40d7523a147e83 (diff)
downloadlibcore-9265fbef09d9c10e9babe35d368d11a21cc2a94d.tar.gz
Merge "Add Os.capset test." into main
-rw-r--r--luni/src/test/java/libcore/android/system/OsTest.java15
1 files changed, 15 insertions, 0 deletions
diff --git a/luni/src/test/java/libcore/android/system/OsTest.java b/luni/src/test/java/libcore/android/system/OsTest.java
index 209f30bec27..1d4225e872d 100644
--- a/luni/src/test/java/libcore/android/system/OsTest.java
+++ b/luni/src/test/java/libcore/android/system/OsTest.java
@@ -22,6 +22,8 @@ import android.system.NetlinkSocketAddress;
import android.system.Os;
import android.system.OsConstants;
import android.system.PacketSocketAddress;
+import android.system.StructCapUserData;
+import android.system.StructCapUserHeader;
import android.system.StructCmsghdr;
import android.system.StructMsghdr;
import android.system.StructRlimit;
@@ -2306,6 +2308,19 @@ public class OsTest {
Os.munmap(address, size);
}
+ @Test
+ public void testCapset() throws Exception {
+ var header = new StructCapUserHeader(_LINUX_CAPABILITY_VERSION_3, /* pid= */0);
+ var existing = Os.capget(header);
+ var noCapabilities = new StructCapUserData(0, 0, 0);
+
+ try {
+ Os.capset(header, new StructCapUserData[] { noCapabilities, noCapabilities });
+ } finally {
+ Os.capset(header, existing);
+ }
+ }
+
/*
* Checks that all ways of accessing the environment are consistent by collecting:
* osEnvironment - The environment returned by Os.environ()