Skip to content

Commit

Permalink
Diagnose JUnit Test
Browse files Browse the repository at this point in the history
  • Loading branch information
matthiasblaesing committed Dec 12, 2024
1 parent 17f4e59 commit bafe65b
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions contrib/platform/test/com/sun/jna/platform/linux/UdevTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,29 +74,32 @@ public void testEnumerateDevices() {
// No additional reference is acquired from getParent
if (parent != null && parent2 != null) {
// Devnode should match same parent without restricting to block and disk
assertEquals("Partition parent should match with and without filter",
assertEquals(String.format(
"Partition parent should match with and without filter (%s)",
devnode
),
parent.getDevnode(), parent2.getDevnode());
// Save the size and major
parentSize = parent.getSysattrValue("size");
parentMajor = parent.getPropertyValue("MAJOR");
}
}
String size = device.getSysattrValue("size");
assertTrue("Size must be nonnegative", 0 <= Long.parseLong(size));
assertTrue(String.format("Size must be nonnegative (%s)", devnode), 0 <= Long.parseLong(size));
if (parentSize != null) {
assertTrue("Partition can't be bigger than its disk",
assertTrue(String.format("Partition can't be bigger than its disk (%s)", devnode),
Long.parseLong(size) <= Long.parseLong(parentSize));
}
String major = device.getPropertyValue("MAJOR");
assertTrue("Major value must be nonnegative", 0 <= Long.parseLong(major));
assertTrue(String.format("Major value must be nonnegative (%s)", devnode), 0 <= Long.parseLong(major));
if (parentMajor != null) {
assertEquals("Partition and its parent disk should have same major number", major,
assertEquals(String.format("Partition and its parent disk should have same major number (%s)", devnode), major,
parentMajor);
}
assertEquals("DevType mismatch", devType, device.getDevtype());
assertEquals("Subsystem mismatch", "block", device.getSubsystem());
assertEquals("Syspath mismatch", syspath, device.getSyspath());
assertTrue("Syspath should end with name", syspath.endsWith(device.getSysname()));
assertEquals(String.format("DevType mismatch (%s)", devnode), devType, device.getDevtype());
assertEquals(String.format("Subsystem mismatch (%s)", devnode), "block", device.getSubsystem());
assertEquals(String.format("Syspath mismatch (%s)", devnode), syspath, device.getSyspath());
assertTrue(String.format("Syspath should end with name (%s)", devnode), syspath.endsWith(device.getSysname()));
}
} finally {
// Release the reference and iterate to the next device
Expand Down

0 comments on commit bafe65b

Please sign in to comment.