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

Method testReadFails

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

Source from the content-addressed store, hash-verified

991 }
992
993 @Test
994 public void testReadFails() throws Exception {
995 assertMemoryLeak(() -> {
996 File temp = temporaryFolder.newFile();
997
998 try (Path path = new Path().of(temp.getAbsolutePath())) {
999 long fd1 = Files.openRW(path.$());
1000 long fileSize = 4096;
1001 long mem = Unsafe.malloc(fileSize, MemoryTag.NATIVE_DEFAULT);
1002
1003 long testValue = 0x1234567890ABCDEFL;
1004 Unsafe.putLong(mem, testValue);
1005
1006 try {
1007 Files.truncate(fd1, fileSize);
1008
1009 Assert.assertEquals(8L, Files.read(fd1, mem, 8L, 0));
1010 Assert.assertTrue(Files.read(fd1, mem, fileSize, -1) < 0);
1011 Assert.assertEquals(0, Files.read(fd1, mem, fileSize, fileSize));
1012 Assert.assertEquals(0, Files.read(fd1, mem, fileSize + 8, fileSize));
1013
1014 } finally {
1015 // Release mem, fd
1016 Files.close(fd1);
1017 Unsafe.free(mem, fileSize, MemoryTag.NATIVE_DEFAULT);
1018
1019 // Delete files
1020 TestUtils.remove(path.$());
1021 }
1022 }
1023 });
1024 }
1025
1026 @Test
1027 public void testReadOver2GB() throws Exception {

Callers

nothing calls this directly

Calls 13

openRWMethod · 0.95
mallocMethod · 0.95
putLongMethod · 0.95
truncateMethod · 0.95
readMethod · 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