| 52 | }; |
| 53 | |
| 54 | TEST_F(SimpleIOExecutorTest, testNormal) { |
| 55 | std::string expect(4096, '0'); |
| 56 | auto fd = open(kTestFile, O_RDWR | O_DIRECT | O_CREAT, 0600); |
| 57 | auto output = memalign(4096, kBufferSize); |
| 58 | memcpy((char*)output, expect.data(), expect.length()); |
| 59 | _executor->submitIO( |
| 60 | fd, IOCB_CMD_PWRITE, output, expect.length(), 0, |
| 61 | [](io_event_t& event) mutable { EXPECT_EQ(4096, (int32_t)event.res); }); |
| 62 | std::this_thread::sleep_for(300ms); |
| 63 | memset(output, 0, kBufferSize); |
| 64 | _executor->submitIO(fd, IOCB_CMD_PREAD, output, kBufferSize, 0, |
| 65 | [&expect, output](io_event_t event) mutable { |
| 66 | EXPECT_EQ(4096, (int32_t)event.res); |
| 67 | EXPECT_EQ(expect, |
| 68 | std::string((char*)output, event.res)); |
| 69 | }); |
| 70 | std::this_thread::sleep_for(300ms); |
| 71 | close(fd); |
| 72 | free(output); |
| 73 | unlink(kTestFile); |
| 74 | } |
| 75 | |
| 76 | TEST_F(SimpleIOExecutorTest, testException) { |
| 77 | auto output = memalign(4096, kBufferSize); |