/* * messageqtest.c * * Part of librfn (a general utility library from redfelineninja.org.uk) * * Copyright (C) 2013 Daniel Thompson * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. */ #undef NDEBUG #include #include #include #include #include int queue_buf[3]; messageq_t queue = MESSAGEQ_VAR_INIT( queue_buf, sizeof(queue_buf), sizeof(queue_buf[0])); int main() { messageq_t myqueue; /* * The messageq_t data structure is intended to be safe to *send* * messages from multiple threads (although only one receiver thread * is permitted). However at present these tests only check for * sequential correctness. */ /* prove the equivalence of the initializer and the init fn */ messageq_init(&myqueue, queue_buf, sizeof(queue_buf), sizeof(queue_buf[0])); verify(0 == memcmp(&queue, &myqueue, sizeof(queue))); /* simple claim, send, receive, release loop */ for (int i=0; i