Use mg_queue in mip

This commit is contained in:
cpq committed 2023-02-24 19:40:31 +00:00
1 parent 4436093816
commit 910f19fe55
11 files changed
+86 -212

No files matched your search

+1 -2
View File
@@ -81,8 +81,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
mg_tcpip_rx(&mif, pkt, size);
mg_mgr_free(&mgr);
free(pkt);
free((char *) mif.rx.ptr);
free((char *) mif.tx.ptr);
mg_tcpip_free(&mif);
}
return 0;
-31
View File
@@ -17,36 +17,6 @@ static int s_num_tests = 0;
} \
} while (0)
static void test_queue(void) {
static uint8_t
buf[sizeof(size_t) + sizeof(uint16_t) + 3]; // fit 1 element but not 2
uint16_t val = 1234;
static struct queue q = {buf, sizeof(buf), 0, 0};
// Write to an empty queue, and read back
ASSERT(q_avail(&q) == 0);
ASSERT(q_write(&q, &val, sizeof(val)) == true);
ASSERT(q_avail(&q) == sizeof(val));
ASSERT(q.head > q.tail);
// Only one element may fit
ASSERT(q_write(&q, &val, sizeof(val)) == false);
val = 0;
ASSERT(q_read(&q, &val) == sizeof(val));
ASSERT(val == 1234);
ASSERT(q_avail(&q) == 0);
// Second write - wrap over the buffer boundary
ASSERT(q_write(&q, &val, sizeof(val)) == true);
ASSERT(q_avail(&q) == sizeof(val));
ASSERT(q.head < q.tail);
// Only one element may fit
ASSERT(q_write(&q, &val, sizeof(val)) == false);
val = 0;
ASSERT(q_read(&q, &val) == sizeof(val));
ASSERT(val == 1234);
ASSERT(q_avail(&q) == 0);
}
static void test_statechange(void) {
char tx[1540];
struct mg_tcpip_if iface;
@@ -79,7 +49,6 @@ static void test_poll(void) {
}
int main(void) {
test_queue();
test_statechange();
test_poll();
printf("SUCCESS. Total tests: %d\n", s_num_tests);