Changeset 25525133 in mainline
- Timestamp:
- 2019-10-14T07:32:28Z (5 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 89ba88c
- Parents:
- 16b0ac3
- git-author:
- Jiri Svoboda <jiri@…> (2019-10-13 17:32:15)
- git-committer:
- Jiri Svoboda <jiri@…> (2019-10-14 07:32:28)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/net/udp/test/assoc.c
r16b0ac3 r25525133 31 31 #include <io/log.h> 32 32 #include <pcut/pcut.h> 33 #include <str.h> 33 34 34 35 #include "../assoc.h" 36 #include "../msg.h" 35 37 36 38 PCUT_INIT; … … 93 95 } 94 96 97 /** Test adding, removing a reference to association */ 95 98 PCUT_TEST(addref_delref) 96 99 { 100 udp_assoc_t *assoc; 101 inet_ep2_t epp; 102 103 inet_ep2_init(&epp); 104 105 assoc = udp_assoc_new(&epp, &test_assoc_cb, NULL); 106 PCUT_ASSERT_NOT_NULL(assoc); 107 108 udp_assoc_addref(assoc); 109 udp_assoc_delref(assoc); 110 111 udp_assoc_delete(assoc); 97 112 } 98 113 114 /** Test setting IP link in association */ 99 115 PCUT_TEST(set_iplink) 100 116 { 101 } 117 udp_assoc_t *assoc; 118 inet_ep2_t epp; 119 120 inet_ep2_init(&epp); 121 122 assoc = udp_assoc_new(&epp, &test_assoc_cb, NULL); 123 PCUT_ASSERT_NOT_NULL(assoc); 124 125 udp_assoc_set_iplink(assoc, 42); 126 PCUT_ASSERT_INT_EQUALS(42, assoc->ident.local_link); 127 128 udp_assoc_delete(assoc); 129 } 102 130 103 131 PCUT_TEST(send_recv) … … 105 133 } 106 134 135 /** Test udp_assoc_received() */ 107 136 PCUT_TEST(received) 108 137 { 138 udp_assoc_t *assoc; 139 inet_ep2_t epp; 140 errno_t rc; 141 udp_msg_t *msg; 142 const char *msgstr = "Hello"; 143 bool received; 144 145 msg = udp_msg_new(); 146 PCUT_ASSERT_NOT_NULL(msg); 147 msg->data_size = str_size(msgstr) + 1; 148 msg->data = str_dup(msgstr); 149 150 inet_ep2_init(&epp); 151 inet_addr(&epp.remote.addr, 127, 0, 0, 1); 152 epp.remote.port = 1; 153 inet_addr(&epp.local.addr, 127, 0, 0, 1); 154 epp.local.port = 2; 155 156 assoc = udp_assoc_new(&epp, &test_assoc_cb, (void *) &received); 157 PCUT_ASSERT_NOT_NULL(assoc); 158 159 rc = udp_assoc_add(assoc); 160 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 161 162 received = false; 163 udp_assoc_received(&epp, msg); 164 PCUT_ASSERT_TRUE(received); 165 166 udp_assoc_remove(assoc); 167 udp_assoc_delete(assoc); 109 168 } 110 169 170 /** Test udp_assoc_reset() */ 111 171 PCUT_TEST(reset) 112 172 { 173 udp_assoc_t *assoc; 174 inet_ep2_t epp; 175 176 inet_ep2_init(&epp); 177 assoc = udp_assoc_new(&epp, &test_assoc_cb, NULL); 178 PCUT_ASSERT_NOT_NULL(assoc); 179 180 udp_assoc_reset(assoc); 181 udp_assoc_delete(assoc); 113 182 } 114 183 115 184 static void test_recv_msg(void *arg, inet_ep2_t *epp, udp_msg_t *msg) 116 185 { 186 bool *received = (bool *) arg; 187 188 *received = true; 117 189 } 118 190
Note:
See TracChangeset
for help on using the changeset viewer.