/* * Copyright (c) 2019 Jiri Svoboda * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * - Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * - Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include #include #include #include #include "../assoc.h" PCUT_INIT; PCUT_TEST_SUITE(assoc); static void test_recv_msg(void *, inet_ep2_t *, udp_msg_t *); static udp_assoc_cb_t test_assoc_cb = { .recv_msg = test_recv_msg }; PCUT_TEST_BEFORE { errno_t rc; /* We will be calling functions that perform logging */ rc = log_init("test-udp"); PCUT_ASSERT_ERRNO_VAL(EOK, rc); rc = udp_assocs_init(); PCUT_ASSERT_ERRNO_VAL(EOK, rc); } PCUT_TEST_AFTER { udp_assocs_fini(); } /** Test creating and deleting association */ PCUT_TEST(new_delete) { udp_assoc_t *assoc; inet_ep2_t epp; inet_ep2_init(&epp); assoc = udp_assoc_new(&epp, &test_assoc_cb, NULL); PCUT_ASSERT_NOT_NULL(assoc); udp_assoc_delete(assoc); } /** Test adding, removing association */ PCUT_TEST(add_remove) { udp_assoc_t *assoc; inet_ep2_t epp; errno_t rc; inet_ep2_init(&epp); assoc = udp_assoc_new(&epp, &test_assoc_cb, NULL); PCUT_ASSERT_NOT_NULL(assoc); rc = udp_assoc_add(assoc); PCUT_ASSERT_ERRNO_VAL(EOK, rc); udp_assoc_remove(assoc); udp_assoc_delete(assoc); } PCUT_TEST(addref_delref) { } PCUT_TEST(set_iplink) { } PCUT_TEST(send_recv) { } PCUT_TEST(received) { } PCUT_TEST(reset) { } static void test_recv_msg(void *arg, inet_ep2_t *epp, udp_msg_t *msg) { } PCUT_EXPORT(assoc);