41 using LERR_(LIFECYCLE);
50 TY* ptr =
reinterpret_cast<TY*
> (entry.access());
59 return reinterpret_cast<metadata::Buff*
> (std::addressof(something));
63 const size_t TEST_MAX_SIZE = 1024 * 1024;
86 unique_ptr<BufferMetadata>
meta_;
92 SIZE_A = 1 + rani(TEST_MAX_SIZE);
93 SIZE_B = 1 + rani(TEST_MAX_SIZE);
132 CHECK ( &
meta_->get(key));
133 CHECK ( &
meta_->get(key1));
134 CHECK ( &
meta_->get(key2));
136 CHECK ( isSameObject (
meta_->get(key),
meta_->get(key)));
137 CHECK ( isSameObject (
meta_->get(key),
meta_->get(key1)));
138 CHECK (!isSameObject (
meta_->get(key),
meta_->get(key2)));
143 CHECK (!
meta_->isLocked(key));
150 CHECK (!isSameObject (m1,m2));
153 CHECK (SOME_POINTER == m2.
access());
156 HashVal keyX =
meta_->key(key1, SOME_POINTER);
157 CHECK (
meta_->isLocked(keyX));
158 CHECK (keyX != key1);
161 CHECK ( isSameObject (m1,
meta_->get(key)));
162 CHECK ( isSameObject (m1,
meta_->get(key1)));
163 CHECK ( isSameObject (m2,
meta_->get(keyX)));
170 CHECK (SOME_POINTER == m2.
access());
171 CHECK (
meta_->isLocked(keyX));
172 CHECK (
meta_->isKnown(keyX));
176 CHECK (!
meta_->isLocked(keyX));
177 CHECK (
meta_->isKnown(keyX));
178 CHECK (
meta_->isKnown(key1));
181 CHECK ( isSameObject (m2,
meta_->get(keyX)));
184 meta_->release(keyX);
185 CHECK (!
meta_->isLocked(keyX));
186 CHECK (!
meta_->isKnown(keyX));
187 CHECK (
meta_->isKnown(key1));
203 TypeHandler attachTestFrame = TypeHandler::create<TestFrame>();
212 bufferType1 =
meta_->key(bufferType1, transaction1);
213 rawBuffType =
meta_->key(rawBuffType, transaction2);
218 using RawBuffer = std::byte;
219 void* storage = malloc (2*
SIZE_B);
222 RawBuffer* rawbuf = (RawBuffer*)storage;
239 CHECK (transaction1 == f0.
localTag());
240 CHECK (transaction1 == f1.
localTag());
241 CHECK (transaction1 == f2.
localTag());
242 CHECK (transaction2 == r0.
localTag());
243 CHECK (transaction2 == r1.
localTag());
245 auto adr =[](
auto* x){
return reinterpret_cast<size_t>(x); };
247 CHECK (adr(f0.
access()) == adr(frames+0));
248 CHECK (adr(f1.
access()) == adr(frames+1));
249 CHECK (adr(f2.
access()) == adr(frames+2));
250 CHECK (adr(r0.
access()) == adr(rawbuf+0 ));
254 CHECK (defaultFrame == f0.
access());
255 CHECK (defaultFrame == f1.
access());
256 CHECK (defaultFrame == f2.
access());
259 HashVal handle_f0(f0);
260 HashVal handle_f1(f1);
261 HashVal handle_f2(f2);
262 HashVal handle_r0(r0);
263 HashVal handle_r1(r1);
266 accessAs<TestFrame> (f0) =
testData(1);
267 accessAs<TestFrame> (f1) =
testData(2);
268 accessAs<TestFrame> (f2) =
testData(3);
278 strncpy (& accessAs<char> (r0), randStr(
SIZE_B - 1).c_str(),
SIZE_B);
279 strncpy (& accessAs<char> (r1), randStr(
SIZE_B - 1).c_str(),
SIZE_B);
295 meta_->release(handle_f0);
296 meta_->release(handle_f1);
297 meta_->release(handle_f2);
298 meta_->release(handle_r0);
299 meta_->release(handle_r1);
309 CHECK (!
meta_->isLocked(handle_f0));
310 CHECK (!
meta_->isLocked(handle_f1));
311 CHECK (!
meta_->isLocked(handle_f2));
312 CHECK (!
meta_->isLocked(handle_r0));
313 CHECK (!
meta_->isLocked(handle_r1));
322 CHECK (
NIL ==
meta_->get(key).state());
323 CHECK (
meta_->get(key).isTypeKey());
324 CHECK (!
meta_->isLocked(key));
334 CHECK (
LOCKED == entry.state());
335 CHECK (!entry.isTypeKey());
337 CHECK (SOME_POINTER == entry.access());
343 CHECK (
EMITTED == entry.state());
344 CHECK (entry.isLocked());
349 CHECK (
EMITTED == entry.state());
352 CHECK (
FREE == entry.state());
353 CHECK (!entry.isLocked());
354 CHECK (!entry.isTypeKey());
364 auto* SOME_OTHER_LOCATION = mark_as_Buffer(*
this);
365 entry.lock (SOME_OTHER_LOCATION);
366 CHECK (
LOCKED == entry.state());
367 CHECK (entry.isLocked());
372 CHECK (
BLOCKED == entry.state());
378 CHECK (SOME_OTHER_LOCATION == entry.access());
381 CHECK (!entry.isLocked());
384 meta_->lock(key, SOME_POINTER);
385 CHECK (entry.isLocked());
389 CHECK (
BLOCKED == entry.state());
390 CHECK (SOME_POINTER == entry.access());
394 CHECK (
meta_->isKnown(entry));
395 CHECK (entry.isLocked());
398 meta_->release(entry);
399 CHECK (!
meta_->isKnown(entry));
400 CHECK (
meta_->isKnown(key));
placeholder type for the contents of a data buffer.
an opaque mark to be used by the BufferProvider implementation.
A complete metadata Entry, based on a Key.
BufferState state() const
Entry & mark(BufferState newState)
Buffer state machine.
Mock data frame for simulated rendering.
Lumiera error handling (C++ interface).
string randStr(size_t len)
create garbage string of given length
TestFrame & testData(uint seqNr, uint chanNr)
Helper to access a specific frame of test data at a fixed memory location.
@ BLOCKED
allocated buffer blocked by protocol failure
@ NIL
abstract entry, not yet allocated
@ LOCKED
allocated buffer actively in use
@ FREE
allocated buffer, no longer in use
@ EMITTED
allocated buffer, returned from client
Steam-Layer implementation namespace root.
Test runner and basic definitions for tests.
bool isSameObject(A const &a, B const &b)
compare plain object identity, based directly on the referee's memory identities.
bool isnil(lib::time::Duration const &dur)
Simplistic test class runner.
#define LAUNCHER(_TEST_CLASS_, _GROUPS_)
A pair of functors to maintain a datastructure within a buffer.
A collection of frequently used helper functions to support unit testing.
#define VERIFY_ERROR(ERROR_ID, ERRONEOUS_STATEMENT)
Macro to verify that a statement indeed raises an exception.
Unit test helper to generate fake test data frames.
Tiny helper functions and shortcuts to be used everywhere Consider this header to be effectively incl...