convert BpfDumpTest from U32 to S32
no need to use U32, of which uses I'd like to eliminate wherever possible Test: TreeHugger Signed-off-by: Maciej Żenczykowski <maze@google.com> Change-Id: I8c0a2df73c4153b21d33ee7a8f5d434f0fc80103
This commit is contained in:
parent
89a81fa85f
commit
463f211a76
1 changed files with 16 additions and 16 deletions
|
|
@ -57,8 +57,8 @@ public class BpfDumpTest {
|
|||
|
||||
@Test
|
||||
public void testToBase64EncodedString() {
|
||||
final Struct.U32 key = new Struct.U32(TEST_KEY);
|
||||
final Struct.U32 value = new Struct.U32(TEST_VAL);
|
||||
final Struct.S32 key = new Struct.S32(TEST_KEY);
|
||||
final Struct.S32 value = new Struct.S32(TEST_VAL);
|
||||
|
||||
// Verified in python:
|
||||
// import base64
|
||||
|
|
@ -71,15 +71,15 @@ public class BpfDumpTest {
|
|||
|
||||
@Test
|
||||
public void testFromBase64EncodedString() {
|
||||
Pair<Struct.U32, Struct.U32> decodedKeyValue = BpfDump.fromBase64EncodedString(
|
||||
Struct.U32.class, Struct.U32.class, TEST_KEY_VAL_BASE64);
|
||||
Pair<Struct.S32, Struct.S32> decodedKeyValue = BpfDump.fromBase64EncodedString(
|
||||
Struct.S32.class, Struct.S32.class, TEST_KEY_VAL_BASE64);
|
||||
assertEquals(TEST_KEY, decodedKeyValue.first.val);
|
||||
assertEquals(TEST_VAL, decodedKeyValue.second.val);
|
||||
}
|
||||
|
||||
private void assertThrowsIllegalArgumentException(final String testStr) {
|
||||
assertThrows(IllegalArgumentException.class,
|
||||
() -> BpfDump.fromBase64EncodedString(Struct.U32.class, Struct.U32.class, testStr));
|
||||
() -> BpfDump.fromBase64EncodedString(Struct.S32.class, Struct.S32.class, testStr));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -96,7 +96,7 @@ public class BpfDumpTest {
|
|||
TEST_KEY_VAL_BASE64 + BASE64_DELIMITER + TEST_KEY_BASE64);
|
||||
}
|
||||
|
||||
private String getDumpMap(final IBpfMap<Struct.U32, Struct.U32> map) {
|
||||
private String getDumpMap(final IBpfMap<Struct.S32, Struct.S32> map) {
|
||||
final StringWriter sw = new StringWriter();
|
||||
BpfDump.dumpMap(map, new PrintWriter(sw), "mapName", "header",
|
||||
(key, val) -> "key=" + key.val + ", val=" + val.val);
|
||||
|
|
@ -105,9 +105,9 @@ public class BpfDumpTest {
|
|||
|
||||
@Test
|
||||
public void testDumpMap() throws Exception {
|
||||
final IBpfMap<Struct.U32, Struct.U32> map =
|
||||
new TestBpfMap<>(Struct.U32.class, Struct.U32.class);
|
||||
map.updateEntry(new Struct.U32(123), new Struct.U32(456));
|
||||
final IBpfMap<Struct.S32, Struct.S32> map =
|
||||
new TestBpfMap<>(Struct.S32.class, Struct.S32.class);
|
||||
map.updateEntry(new Struct.S32(123), new Struct.S32(456));
|
||||
|
||||
final String dump = getDumpMap(map);
|
||||
assertEquals(dump, "mapName:\n"
|
||||
|
|
@ -117,10 +117,10 @@ public class BpfDumpTest {
|
|||
|
||||
@Test
|
||||
public void testDumpMapMultipleEntries() throws Exception {
|
||||
final IBpfMap<Struct.U32, Struct.U32> map =
|
||||
new TestBpfMap<>(Struct.U32.class, Struct.U32.class);
|
||||
map.updateEntry(new Struct.U32(123), new Struct.U32(456));
|
||||
map.updateEntry(new Struct.U32(789), new Struct.U32(123));
|
||||
final IBpfMap<Struct.S32, Struct.S32> map =
|
||||
new TestBpfMap<>(Struct.S32.class, Struct.S32.class);
|
||||
map.updateEntry(new Struct.S32(123), new Struct.S32(456));
|
||||
map.updateEntry(new Struct.S32(789), new Struct.S32(123));
|
||||
|
||||
final String dump = getDumpMap(map);
|
||||
assertTrue(dump.contains("mapName:"));
|
||||
|
|
@ -129,7 +129,7 @@ public class BpfDumpTest {
|
|||
assertTrue(dump.contains("key=789, val=123"));
|
||||
}
|
||||
|
||||
private String getDumpMapStatus(final IBpfMap<Struct.U32, Struct.U32> map) {
|
||||
private String getDumpMapStatus(final IBpfMap<Struct.S32, Struct.S32> map) {
|
||||
final StringWriter sw = new StringWriter();
|
||||
BpfDump.dumpMapStatus(map, new PrintWriter(sw), "mapName", "mapPath");
|
||||
return sw.toString();
|
||||
|
|
@ -137,8 +137,8 @@ public class BpfDumpTest {
|
|||
|
||||
@Test
|
||||
public void testGetMapStatus() {
|
||||
final IBpfMap<Struct.U32, Struct.U32> map =
|
||||
new TestBpfMap<>(Struct.U32.class, Struct.U32.class);
|
||||
final IBpfMap<Struct.S32, Struct.S32> map =
|
||||
new TestBpfMap<>(Struct.S32.class, Struct.S32.class);
|
||||
assertEquals("mapName: OK\n", getDumpMapStatus(map));
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue