| 1 |
/* |
| 2 |
* Test Reply Tracking |
| 3 |
*/ |
| 4 |
|
| 5 |
#undef NDEBUG |
| 6 |
#include <c-stdaux.h> |
| 7 |
#include <stdlib.h> |
| 8 |
#include <sys/types.h> |
| 9 |
#include <sys/socket.h> |
| 10 |
#include "bus/reply.h" |
| 11 |
|
| 12 |
static void test_basic(void) { |
| 13 |
ReplyRegistry registry; |
| 14 |
ReplyOwner owner; |
| 15 |
ReplySlot *slot1, *slot2; |
| 16 |
int r; |
| 17 |
|
| 18 |
reply_registry_init(®istry); |
| 19 |
reply_owner_init(&owner); |
| 20 |
|
| 21 |
r = reply_slot_new(&slot1, ®istry, &owner, NULL, NULL, 1, 1); |
| 22 |
c_assert(!r); |
| 23 |
|
| 24 |
r = reply_slot_new(&slot1, ®istry, &owner, NULL, NULL, 1, 1); |
| 25 |
c_assert(r == REPLY_E_EXISTS); |
| 26 |
|
| 27 |
slot2 = reply_slot_get_by_id(®istry, 1, 1); |
| 28 |
c_assert(slot2 == slot1); |
| 29 |
|
| 30 |
slot2 = reply_slot_get_by_id(®istry, 1, 2); |
| 31 |
c_assert(!slot2); |
| 32 |
|
| 33 |
slot2 = reply_slot_get_by_id(®istry, 2, 1); |
| 34 |
c_assert(!slot2); |
| 35 |
|
| 36 |
reply_slot_free(slot1); |
| 37 |
reply_owner_deinit(&owner); |
| 38 |
reply_registry_deinit(®istry); |
| 39 |
} |
| 40 |
|
| 41 |
int main(int argc, char **argv) { |
| 42 |
test_basic(); |
| 43 |
|
| 44 |
return 0; |
| 45 |
} |