@@ -316,75 +316,6 @@ TEST_F(UCPosixStoreTest, AioWaitTimesOutWhenCompletionIsLost)
316316 ASSERT_LT (std::chrono::duration_cast<std::chrono::milliseconds>(elapsed).count (), 1000 );
317317}
318318
319- TEST_F (UCPosixStoreTest, AioDumpSubmitsOwnedBufferWhenTimeoutCanReturn)
320- {
321- using namespace UC ::PosixStore;
322- PosixStore store;
323- ASSERT_EQ (store.Setup (MakeAioConfig (Path ())), UC::Status::OK ());
324- ScopedAioHooks hooks;
325- std::atomic<uintptr_t > submittedBuffer{0 };
326- TestHooks::SetAioSubmitHook ([&submittedBuffer](aio_context_t , int64_t nr, iocb** ios) {
327- submittedBuffer.store (ios[0 ]->aio_buf , std::memory_order_relaxed);
328- return static_cast <int32_t >(nr);
329- });
330- TestHooks::SetAioCancelHook ([](aio_context_t , struct iocb *, io_event*) { return 0 ; });
331- auto buffer = MakeAlignedBuffer (8 );
332- ASSERT_NE (buffer.get (), nullptr );
333- auto block = UC::Test::Detail::TypesHelper::MakeBlockIdRandomly ();
334- auto handle = store.Dump (MakeDumpDesc (" AioDumpOwnedBuffer" , block, buffer.get ()));
335- ASSERT_TRUE (handle.HasValue ());
336-
337- ASSERT_EQ (store.Wait (handle.Value ()), UC::Status::Timeout ());
338- ASSERT_NE (submittedBuffer.load (std::memory_order_relaxed), 0U );
339- ASSERT_NE (submittedBuffer.load (std::memory_order_relaxed),
340- reinterpret_cast <uintptr_t >(buffer.get ()));
341- }
342-
343- TEST_F (UCPosixStoreTest, AioLoadSubmitsOwnedBufferWhenTimeoutCanReturn)
344- {
345- using namespace UC ::PosixStore;
346- auto block = UC::Test::Detail::TypesHelper::MakeBlockIdRandomly ();
347- auto dumpBuffer = MakeAlignedBuffer (9 );
348- ASSERT_NE (dumpBuffer.get (), nullptr );
349- {
350- PosixStore store;
351- ASSERT_EQ (store.Setup (MakeAioConfig (Path (), 5000 )), UC::Status::OK ());
352- auto handle = store.Dump (MakeDumpDesc (" AioLoadOwnedBufferPrepare" , block, dumpBuffer.get ()));
353- ASSERT_TRUE (handle.HasValue ());
354- ASSERT_EQ (store.Wait (handle.Value ()), UC::Status::OK ());
355- bool found = false ;
356- for (size_t i = 0 ; i < 20 ; ++i) {
357- auto founds = store.Lookup (&block, 1 );
358- ASSERT_TRUE (founds.HasValue ());
359- if (founds.Value ()[0 ]) {
360- found = true ;
361- break ;
362- }
363- std::this_thread::sleep_for (std::chrono::milliseconds (50 ));
364- }
365- ASSERT_TRUE (found);
366- }
367-
368- PosixStore store;
369- ASSERT_EQ (store.Setup (MakeAioConfig (Path ())), UC::Status::OK ());
370- ScopedAioHooks hooks;
371- std::atomic<uintptr_t > submittedBuffer{0 };
372- TestHooks::SetAioSubmitHook ([&submittedBuffer](aio_context_t , int64_t nr, iocb** ios) {
373- submittedBuffer.store (ios[0 ]->aio_buf , std::memory_order_relaxed);
374- return static_cast <int32_t >(nr);
375- });
376- TestHooks::SetAioCancelHook ([](aio_context_t , struct iocb *, io_event*) { return 0 ; });
377- auto loadBuffer = MakeAlignedBuffer (0 );
378- ASSERT_NE (loadBuffer.get (), nullptr );
379- auto handle = store.Load (MakeDumpDesc (" AioLoadOwnedBuffer" , block, loadBuffer.get ()));
380- ASSERT_TRUE (handle.HasValue ());
381-
382- ASSERT_EQ (store.Wait (handle.Value ()), UC::Status::Timeout ());
383- ASSERT_NE (submittedBuffer.load (std::memory_order_relaxed), 0U );
384- ASSERT_NE (submittedBuffer.load (std::memory_order_relaxed),
385- reinterpret_cast <uintptr_t >(loadBuffer.get ()));
386- }
387-
388319TEST_F (UCPosixStoreTest, AioCheckFinishesLostCompletionAfterDeadline)
389320{
390321 using namespace UC ::PosixStore;
0 commit comments