Explorar o código

sys_arch unit tests: refine test_sys_arch_waiting_fn a bit

goldsimon %!s(int64=9) %!d(string=hai) anos
pai
achega
972b7c2bfd
Modificáronse 2 ficheiros con 6 adicións e 6 borrados
  1. 4 4
      test/unit/arch/sys_arch.c
  2. 2 2
      test/unit/arch/sys_arch.h

+ 4 - 4
test/unit/arch/sys_arch.c

@@ -97,7 +97,7 @@ u32_t sys_arch_sem_wait(sys_sem_t *sem, u32_t timeout)
       /* wait infinite */
       LWIP_ASSERT("cannot wait without waiting callback", the_waiting_fn != NULL);
       do {
-        int expectSomething = the_waiting_fn(sem);
+        int expectSomething = the_waiting_fn(sem, NULL);
         LWIP_ASSERT("*sem > 0", *sem > 0);
         LWIP_ASSERT("expecting a semaphore count but it's 0", !expectSomething || (*sem > 1));
         ret++;
@@ -106,7 +106,7 @@ u32_t sys_arch_sem_wait(sys_sem_t *sem, u32_t timeout)
     else
     {
       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("*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 */
       LWIP_ASSERT("cannot wait without waiting callback", the_waiting_fn != NULL);
       do {
-        int expectSomething = the_waiting_fn(q);
+        int expectSomething = the_waiting_fn(NULL, q);
         LWIP_ASSERT("q->used >= 0", q->used >= 0);
         LWIP_ASSERT("expecting item available but it's 0", !expectSomething || (q->used > 0));
         ret++;
@@ -284,7 +284,7 @@ u32_t sys_arch_mbox_fetch(sys_mbox_t *q, void **msg, u32_t timeout)
     else
     {
       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("q->used >= 0", q->used >= 0);

+ 2 - 2
test/unit/arch/sys_arch.h

@@ -56,12 +56,12 @@ typedef u32_t sys_thread_t;
 #define SYS_ARCH_PROTECT(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
  * '0' if waiting again and
  * '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);
 
 #endif /* LWIP_HDR_TEST_SYS_ARCH_H */