2016-08-26 18:26:10 +08:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2016 Intel Corporation
|
|
|
|
*
|
2017-01-19 09:01:01 +08:00
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
2016-08-26 18:26:10 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <ztest.h>
|
2017-06-04 00:20:27 +08:00
|
|
|
#include <net/buf.h>
|
|
|
|
|
|
|
|
struct net_buf_pool _net_buf_pool_list[1];
|
2016-08-26 18:26:10 +08:00
|
|
|
|
2016-12-14 14:33:50 +08:00
|
|
|
unsigned int irq_lock(void)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void irq_unlock(unsigned int key)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2016-08-26 18:26:10 +08:00
|
|
|
#include <net/buf.c>
|
|
|
|
|
2017-02-21 21:27:20 +08:00
|
|
|
void k_queue_init(struct k_queue *fifo) {}
|
|
|
|
void k_queue_append_list(struct k_queue *fifo, void *head, void *tail) {}
|
2016-08-26 18:26:10 +08:00
|
|
|
|
2016-11-10 17:45:17 +08:00
|
|
|
int k_is_in_isr(void)
|
2016-08-26 18:26:10 +08:00
|
|
|
{
|
2016-11-10 17:45:17 +08:00
|
|
|
return 0;
|
2016-08-26 18:26:10 +08:00
|
|
|
}
|
|
|
|
|
2017-04-21 22:47:21 +08:00
|
|
|
void *k_queue_get(struct k_queue *fifo, s32_t timeout)
|
2016-08-26 18:26:10 +08:00
|
|
|
{
|
2016-12-14 14:33:50 +08:00
|
|
|
return NULL;
|
2016-08-26 18:26:10 +08:00
|
|
|
}
|
|
|
|
|
2017-02-21 21:27:20 +08:00
|
|
|
void k_queue_append(struct k_queue *fifo, void *data)
|
2016-08-26 18:26:10 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2017-02-21 21:49:52 +08:00
|
|
|
void k_queue_prepend(struct k_queue *fifo, void *data)
|
2016-08-26 18:26:10 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2016-12-14 14:33:50 +08:00
|
|
|
#define TEST_BUF_COUNT 1
|
|
|
|
#define TEST_BUF_SIZE 74
|
|
|
|
|
|
|
|
NET_BUF_POOL_DEFINE(bufs_pool, TEST_BUF_COUNT, TEST_BUF_SIZE,
|
|
|
|
sizeof(int), NULL);
|
|
|
|
|
2016-08-26 18:26:10 +08:00
|
|
|
static void test_get_single_buffer(void)
|
|
|
|
{
|
|
|
|
struct net_buf *buf;
|
|
|
|
|
2016-10-19 04:24:51 +08:00
|
|
|
buf = net_buf_alloc(&bufs_pool, K_NO_WAIT);
|
2016-08-26 18:26:10 +08:00
|
|
|
|
2017-04-14 00:25:39 +08:00
|
|
|
zassert_equal(buf->ref, 1, "Invalid refcount");
|
|
|
|
zassert_equal(buf->len, 0, "Invalid length");
|
|
|
|
zassert_equal(buf->flags, 0, "Invalid flags");
|
|
|
|
zassert_equal_ptr(buf->frags, NULL, "Frags not NULL");
|
2016-08-26 18:26:10 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void test_main(void)
|
|
|
|
{
|
|
|
|
ztest_test_suite(net_buf_test,
|
|
|
|
ztest_unit_test(test_get_single_buffer)
|
|
|
|
);
|
|
|
|
|
|
|
|
ztest_run_test_suite(net_buf_test);
|
|
|
|
}
|