MCPcopy Create free account
hub / github.com/alibaba/async_simple / TEST_F

Function TEST_F

async_simple/executors/test/SimpleIOExecutorTest.cpp:54–74  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

52};
53
54TEST_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
76TEST_F(SimpleIOExecutorTest, testException) {
77 auto output = memalign(4096, kBufferSize);

Callers

nothing calls this directly

Calls 5

stringFunction · 0.85
submitIOMethod · 0.80
openFunction · 0.50
closeFunction · 0.50
dataMethod · 0.45

Tested by

no test coverage detected