Skip to content
Snippets Groups Projects
Commit f6d0d2c1 authored by Connor O'Brien's avatar Connor O'Brien
Browse files

KernelCpuUidBpfMapReaderTest: test UID removal with absent UIDs


The original implementation of
KernelCpuUidBpfMapReader.removeUidsInRange did not work unless data
was present for the first & last UIDs in the range. Add a test case to
verify the fix for this issue & prevent regressions

Test: confirm test passes with fix & fails without it
Bug: 157887803
Change-Id: Icfabb7298dbfb1a7f1b89dadbe33bae0492922b6
Signed-off-by: default avatarConnor O'Brien <connoro@google.com>
parent b3bd77fc
No related branches found
No related tags found
No related merge requests found
......@@ -179,6 +179,21 @@ public class KernelCpuUidBpfMapReaderTest {
testOpenAndReadData(changedData);
}
@Test
public void testRemoveUidsInRange_firstAndLastAbsent() {
final SparseArray<long[]> data = getTestSparseArray(200, 50);
data.delete(0);
data.delete(5);
mReader.setData(data);
testOpenAndReadData(data);
SparseArray<long[]> changedData = new SparseArray<>();
for (int i = 6; i < 200; i++) {
changedData.put(i, data.get(i));
}
mReader.removeUidsInRange(0, 5);
testOpenAndReadData(changedData);
}
private void testOpenAndReadData(SparseArray<long[]> expectedData) {
try (BpfMapIterator iter = mReader.open()) {
long[] actual;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment