mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2025-01-26 18:35:28 +00:00
sys_arch unit tests: refine test_sys_arch_waiting_fn a bit
This commit is contained in:
parent
81e4726607
commit
972b7c2bfd
@ -97,7 +97,7 @@ u32_t sys_arch_sem_wait(sys_sem_t *sem, u32_t timeout)
|
|||||||
/* wait infinite */
|
/* wait infinite */
|
||||||
LWIP_ASSERT("cannot wait without waiting callback", the_waiting_fn != NULL);
|
LWIP_ASSERT("cannot wait without waiting callback", the_waiting_fn != NULL);
|
||||||
do {
|
do {
|
||||||
int expectSomething = the_waiting_fn(sem);
|
int expectSomething = the_waiting_fn(sem, NULL);
|
||||||
LWIP_ASSERT("*sem > 0", *sem > 0);
|
LWIP_ASSERT("*sem > 0", *sem > 0);
|
||||||
LWIP_ASSERT("expecting a semaphore count but it's 0", !expectSomething || (*sem > 1));
|
LWIP_ASSERT("expecting a semaphore count but it's 0", !expectSomething || (*sem > 1));
|
||||||
ret++;
|
ret++;
|
||||||
@ -106,7 +106,7 @@ u32_t sys_arch_sem_wait(sys_sem_t *sem, u32_t timeout)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (the_waiting_fn) {
|
if (the_waiting_fn) {
|
||||||
int expectSomething = the_waiting_fn(sem);
|
int expectSomething = the_waiting_fn(sem, NULL);
|
||||||
LWIP_ASSERT("expecting a semaphore count but it's 0", !expectSomething || (*sem > 1));
|
LWIP_ASSERT("expecting a semaphore count but it's 0", !expectSomething || (*sem > 1));
|
||||||
}
|
}
|
||||||
LWIP_ASSERT("*sem > 0", *sem > 0);
|
LWIP_ASSERT("*sem > 0", *sem > 0);
|
||||||
@ -275,7 +275,7 @@ u32_t sys_arch_mbox_fetch(sys_mbox_t *q, void **msg, u32_t timeout)
|
|||||||
/* wait infinite */
|
/* wait infinite */
|
||||||
LWIP_ASSERT("cannot wait without waiting callback", the_waiting_fn != NULL);
|
LWIP_ASSERT("cannot wait without waiting callback", the_waiting_fn != NULL);
|
||||||
do {
|
do {
|
||||||
int expectSomething = the_waiting_fn(q);
|
int expectSomething = the_waiting_fn(NULL, q);
|
||||||
LWIP_ASSERT("q->used >= 0", q->used >= 0);
|
LWIP_ASSERT("q->used >= 0", q->used >= 0);
|
||||||
LWIP_ASSERT("expecting item available but it's 0", !expectSomething || (q->used > 0));
|
LWIP_ASSERT("expecting item available but it's 0", !expectSomething || (q->used > 0));
|
||||||
ret++;
|
ret++;
|
||||||
@ -284,7 +284,7 @@ u32_t sys_arch_mbox_fetch(sys_mbox_t *q, void **msg, u32_t timeout)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (the_waiting_fn) {
|
if (the_waiting_fn) {
|
||||||
int expectSomething = the_waiting_fn(q);
|
int expectSomething = the_waiting_fn(NULL, q);
|
||||||
LWIP_ASSERT("expecting item available count but it's 0", !expectSomething || (q->used > 0));
|
LWIP_ASSERT("expecting item available count but it's 0", !expectSomething || (q->used > 0));
|
||||||
}
|
}
|
||||||
LWIP_ASSERT("q->used >= 0", q->used >= 0);
|
LWIP_ASSERT("q->used >= 0", q->used >= 0);
|
||||||
|
@ -56,12 +56,12 @@ typedef u32_t sys_thread_t;
|
|||||||
#define SYS_ARCH_PROTECT(lev)
|
#define SYS_ARCH_PROTECT(lev)
|
||||||
#define SYS_ARCH_UNPROTECT(lev)
|
#define SYS_ARCH_UNPROTECT(lev)
|
||||||
|
|
||||||
/* to implement doing something while waiting:
|
/* to implement doing something while blocking on an mbox or semaphore:
|
||||||
* pass a function to test_sys_arch_wait_callback() that returns
|
* pass a function to test_sys_arch_wait_callback() that returns
|
||||||
* '0' if waiting again and
|
* '0' if waiting again and
|
||||||
* '1' if now there should be something to do (used for asserting)
|
* '1' if now there should be something to do (used for asserting)
|
||||||
*/
|
*/
|
||||||
typedef int (*test_sys_arch_waiting_fn)(void* wait_element);
|
typedef int (*test_sys_arch_waiting_fn)(sys_sem_t* wait_sem, sys_mbox_t* wait_mbox);
|
||||||
void test_sys_arch_wait_callback(test_sys_arch_waiting_fn waiting_fn);
|
void test_sys_arch_wait_callback(test_sys_arch_waiting_fn waiting_fn);
|
||||||
|
|
||||||
#endif /* LWIP_HDR_TEST_SYS_ARCH_H */
|
#endif /* LWIP_HDR_TEST_SYS_ARCH_H */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user