????????????????? ????????
???????????? ???????[ 2012/9/27 11:08:08 ] ????????
??????????????????????????????????????Cmockery????????????????????????????????????????????????????Ч?????????????????У????????????????????????????????????????????????????????????????????
????????????????????????饗mpool.c?????????????饗dll.c??????????????????????????????????mpool_buffer_alloc??????????????????ú????????????????????dll_pop_head???????????????????dll_pop_head???????д??????????????????global_interrupt_disable??global_interrupt_enable????????????????????????dll_pop_head?????
mpool.c
void* mpool_buffer_alloc (mpool_handle_t _handle)
{
interrupt_level_t level;
mpool_node_t *p_node;
level = global_interrupt_disable ();
if (is_invalid_handle (_handle)) {
global_interrupt_enable (level);
return null;
}
p_node = (mpool_node_t *)dll_pop_head (&_handle->free_buffer_);
if (0 == p_node) {
_handle->stats_nobuf_ ++;
global_interrupt_enable (level);
return null;
}
global_interrupt_enable (level);
p_node->in_use_ = true;
return (void *)p_node->addr_;
}
dll.c
dll_node_t *dll_pop_head (dll_t *_p_dll)
{
dll_node_t *p_node = _p_dll->head_;
if (p_node != 0) {
_p_dll->count_--;
_p_dll->head_ = p_node->next_;
if (0 == _p_dll->head_) {
_p_dll->tail_ = 0;
}
else {
p_node->next_->prev_ = 0;
}
p_node->next_ = 0;
p_node->prev_ = 0;
}
return p_node;
}
????????????????????????????????????mpool_buffer_alloc?????????????????????????????е?handle??μ????????mpool_init?????????????????????????δ?г???
stub_dll.c
dll_node_t *g_p_node;
dll_node_t *dll_pop_head (dll_t *_p_dll)
{
return g_p_node;
}
test_mpool.c
void test_mpool_buffer_alloc ()
{
mpool_node_t mnode;
// set up test environment
mnode.addr_ = 0x5A5A5A5A;
mnode.in_use_ = false;
// do test
g_p_node = &mnode.node_;
UNITEST_EQUALS (mpool_buffer_alloc (handle)?? 0x5A5A5A5A);
g_p_node = 0;
UNITEST_EQUALS (mpool_buffer_alloc (handle)?? 0);
}
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11