use a second map for SingleWriterBpfMap test

because the shared r/w lock on the first
conflicts with the exclusive r/w lock on the second

This fixes roughly *half* the BpfMapTest tests.

Test: TreeHugger, atest BpfMapTest less broken
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I9d500597cad16bb7756df3e6feb9a7aa762e59d9
This commit is contained in:
Maciej Żenczykowski 2024-06-15 11:47:26 -07:00
commit 45e9372733
3 changed files with 6 additions and 1 deletions

View file

@ -69,6 +69,8 @@ public final class BpfMapTest {
private static final int TEST_MAP_SIZE = 16;
private static final String TETHER_DOWNSTREAM6_FS_PATH =
"/sys/fs/bpf/tethering/map_test_tether_downstream6_map";
private static final String TETHER2_DOWNSTREAM6_FS_PATH =
"/sys/fs/bpf/tethering/map_test_tether2_downstream6_map";
private ArrayMap<TetherDownstream6Key, Tether6Value> mTestData;
@ -108,7 +110,7 @@ public final class BpfMapTest {
private BpfMap<TetherDownstream6Key, Tether6Value> openTestMap() throws Exception {
return mShouldTestSingleWriterMap
? new SingleWriterBpfMap<>(TETHER_DOWNSTREAM6_FS_PATH, TetherDownstream6Key.class,
? new SingleWriterBpfMap<>(TETHER2_DOWNSTREAM6_FS_PATH, TetherDownstream6Key.class,
Tether6Value.class)
: new BpfMap<>(TETHER_DOWNSTREAM6_FS_PATH, TetherDownstream6Key.class,
Tether6Value.class);

View file

@ -45,6 +45,8 @@
// Used only by TetheringPrivilegedTests, not by production code.
DEFINE_BPF_MAP_GRW(tether_downstream6_map, HASH, TetherDownstream6Key, Tether6Value, 16,
TETHERING_GID)
DEFINE_BPF_MAP_GRW(tether2_downstream6_map, HASH, TetherDownstream6Key, Tether6Value, 16,
TETHERING_GID)
// Used only by BpfBitmapTest, not by production code.
DEFINE_BPF_MAP_GRW(bitmap, ARRAY, int, uint64_t, 2, TETHERING_GID)

View file

@ -68,6 +68,7 @@ static const set<string> MAINLINE_FOR_S_PLUS = {
TETHERING "map_offload_tether_upstream6_map",
TETHERING "map_test_bitmap",
TETHERING "map_test_tether_downstream6_map",
TETHERING "map_test_tether2_downstream6_map",
TETHERING "prog_offload_schedcls_tether_downstream4_ether",
TETHERING "prog_offload_schedcls_tether_downstream4_rawip",
TETHERING "prog_offload_schedcls_tether_downstream6_ether",