MCPcopy Create free account
hub / github.com/apache/brpc / TaskTestMain

Method TaskTestMain

test/shared_memory_unittest.cc:625–654  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

623 }
624
625 static int TaskTestMain() {
626 int errors = 0;
627#if defined(OS_MACOSX)
628 mac::ScopedNSAutoreleasePool pool;
629#endif
630 const uint32_t kDataSize = 1024;
631 SharedMemory memory;
632 bool rv = memory.CreateNamedDeprecated(s_test_name_, true, kDataSize);
633 EXPECT_TRUE(rv);
634 if (rv != true)
635 errors++;
636 rv = memory.Map(kDataSize);
637 EXPECT_TRUE(rv);
638 if (rv != true)
639 errors++;
640 int *ptr = static_cast<int*>(memory.memory());
641
642 for (int idx = 0; idx < 20; idx++) {
643 memory.LockDeprecated();
644 int i = (1 << 16) + idx;
645 *ptr = i;
646 PlatformThread::Sleep(TimeDelta::FromMilliseconds(10));
647 if (*ptr != i)
648 errors++;
649 memory.UnlockDeprecated();
650 }
651
652 memory.Close();
653 return errors;
654 }
655
656 private:
657 static const char* const s_test_name_;

Callers

nothing calls this directly

Calls 2

MapMethod · 0.45
CloseMethod · 0.45

Tested by

no test coverage detected