()
| 1424 | } |
| 1425 | |
| 1426 | @Test |
| 1427 | public void testWriteFails() throws Exception { |
| 1428 | assertMemoryLeak(() -> { |
| 1429 | File temp = temporaryFolder.newFile(); |
| 1430 | |
| 1431 | try (Path path = new Path().of(temp.getAbsolutePath())) { |
| 1432 | long fd1 = Files.openRW(path.$()); |
| 1433 | long mem = Unsafe.malloc(8, MemoryTag.NATIVE_DEFAULT); |
| 1434 | |
| 1435 | long testValue = 0x1234567890ABCDEFL; |
| 1436 | Unsafe.putLong(mem, testValue); |
| 1437 | long fileSize = (2L << 30) + 4096; |
| 1438 | |
| 1439 | try { |
| 1440 | Files.truncate(fd1, fileSize); |
| 1441 | |
| 1442 | Assert.assertEquals(8L, Files.write(fd1, mem, 8, 0)); |
| 1443 | Assert.assertEquals(-1L, Files.write(fd1, mem, -1, fileSize)); |
| 1444 | Assert.assertEquals(-1L, Files.write(-1, mem, 8, fileSize)); |
| 1445 | |
| 1446 | } finally { |
| 1447 | // Release mem, fd |
| 1448 | Files.close(fd1); |
| 1449 | Unsafe.free(mem, 8, MemoryTag.NATIVE_DEFAULT); |
| 1450 | |
| 1451 | // Delete files |
| 1452 | TestUtils.remove(path.$()); |
| 1453 | } |
| 1454 | } |
| 1455 | }); |
| 1456 | } |
| 1457 | |
| 1458 | @Test |
| 1459 | public void testWriteOver2GB() throws Exception { |
nothing calls this directly
no test coverage detected