MCPcopy Index your code
hub / github.com/questdb/questdb / testWriteFails

Method testWriteFails

core/src/test/java/io/questdb/test/FilesTest.java:1426–1456  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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 {

Callers

nothing calls this directly

Calls 12

openRWMethod · 0.95
mallocMethod · 0.95
putLongMethod · 0.95
truncateMethod · 0.95
writeMethod · 0.95
closeMethod · 0.95
freeMethod · 0.95
removeMethod · 0.95
ofMethod · 0.65
$Method · 0.65
assertMemoryLeakMethod · 0.45
assertEqualsMethod · 0.45

Tested by

no test coverage detected