12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- #include "catch.hpp"
- #include "shm_object.h"
- #include "shm.h"
- #include "shm_manager.h"
- TEST_CASE("ShmObjectCreate, creat/delete")
- {
- bg::ShmOptions opts(false, "Test", nullptr);
- char path[256];
- bg::detail::ShmManager::ShmBlock m_blocks[17]{};
- size_t count = opts.fixed_address_count;
- for(size_t i = 0; i < count; ++i)
- {
- size_t real_size = opts.shm_block_mmap_size / 8;
- size_t mmap_size = opts.shm_block_mmap_size / 8;
- snprintf(path, 0x100uLL, "%s-%03zu.mmap", opts.identifier, i);
- uintptr_t fixed_addr = 0ll;
- REQUIRE(opts.PopFixedAddress(&fixed_addr));
- void* memory = bg::detail::ShmObjectCreate(path, fixed_addr, &real_size, &mmap_size);
- REQUIRE(memory);
- memset(memory, 0, real_size);
- m_blocks[i].addr = memory;
- m_blocks[i].mmap_size = real_size;
- m_blocks[i].mmap_size = mmap_size;
- }
- for(size_t i = 0; i < count; ++i)
- {
- size_t real_size = opts.shm_block_mmap_size / 8;
- size_t mmap_size = opts.shm_block_mmap_size / 8;
- snprintf(path, 0x100uLL, "%s-%03zu.mmap", opts.identifier, i);
- void* memory = bg::detail::ShmObjectAttach(path, 0, &real_size, &mmap_size);
- REQUIRE(memory);
- memset(memory, 0, real_size);
- bg::detail::ShmObjectDelete(memory, mmap_size, path);
- }
- for(size_t i = 0; i < count; ++i)
- {
- size_t real_size = opts.shm_block_mmap_size / 8;
- size_t mmap_size = opts.shm_block_mmap_size / 8;
- snprintf(path, 0x100uLL, "%s-%03zu.mmap", opts.identifier, i);
- bg::detail::ShmObjectDelete(m_blocks[i].addr, m_blocks[i].mmap_size, path);
- }
- }
|