1
1
mirror of https://github.com/MarginaliaSearch/MarginaliaSearch.git synced 2025-10-05 21:22:39 +02:00
Files
MarginaliaSearch/code/libraries/native/test/nu/marginalia/UringQueueTest.java

45 lines
1.2 KiB
Java
Raw Normal View History

package nu.marginalia;
import nu.marginalia.ffi.LinuxSystemCalls;
import nu.marginalia.uring.UringQueue;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import java.io.IOException;
import java.lang.foreign.Arena;
import java.lang.foreign.MemorySegment;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.List;
class UringQueueTest {
Path file;
@BeforeEach
void setUp() throws IOException {
file = Files.createTempFile("uring", "dat");
Files.write(file, new byte[8192]);
}
@AfterEach
void tearDown() throws IOException {
Files.deleteIfExists(file);
}
@Test
public void testSunnyDay() throws IOException {
int fd = LinuxSystemCalls.openBuffered(file);
List<MemorySegment> segments = new ArrayList<>();
List<Long> offsets = new ArrayList<>();
for (int i = 0; i < 4; i++) {
segments.add(Arena.ofAuto().allocate(32));
offsets.add(32L*i);
}
var uring = UringQueue.open(fd, 16);
uring.readBatch(segments, offsets, false);
uring.close();
}
}