Skip to content

Commit 73a9c9a

Browse files
raiden00placassis
authored andcommitted
testing/ostest: accept -ENOENT from work_cancel() for unqueued work
Since nuttx commit 5a209a853e ("sched/wqueue: restore -ENOENT from work_cancel() for unqueued work") work_cancel() and work_cancel_wq() return -ENOENT when the work is not queued. The tester thread queues work with zero delay, so the worker may already have consumed it by the time it is cancelled and the ASSERT(ret == OK) fires; Accept -ENOENT there and expect it when cancelling idle work in the API validation test. Signed-off-by: raiden00pl <raiden00@railab.me>
1 parent 2f76986 commit 73a9c9a

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

testing/ostest/wqueue.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -768,10 +768,10 @@ static void api_validation_test(FAR struct kwork_wqueue_s *wqueue)
768768
ASSERT(work_cancel_sync_wq(wqueue, NULL) == -EINVAL);
769769
ASSERT(work_queue_priority_wq(NULL) == -EINVAL);
770770

771-
/* Cancelling idle work is intentionally idempotent. */
771+
/* Cancelling idle work reports -ENOENT. */
772772

773-
ASSERT(work_cancel_wq(wqueue, &work) == OK);
774-
ASSERT(work_cancel_sync_wq(wqueue, &work) == OK);
773+
ASSERT(work_cancel_wq(wqueue, &work) == -ENOENT);
774+
ASSERT(work_cancel_sync_wq(wqueue, &work) == -ENOENT);
775775
ASSERT(work_available(&work));
776776
printf("wqueue_test: API validation done\n");
777777
}
@@ -843,15 +843,15 @@ static FAR void *tester(FAR void *arg)
843843
ret = work_queue_wq(val[1], &work, empty_worker, NULL, 0);
844844
ASSERT(ret == OK);
845845
ret = work_cancel_wq(val[1], &work);
846-
ASSERT(ret == OK);
846+
ASSERT(ret == OK || ret == -ENOENT);
847847
}
848848
else
849849
{
850850
ret = work_queue((int)(uintptr_t)val[0], &work,
851851
empty_worker, NULL, 0);
852852
ASSERT(ret == OK);
853853
ret = work_cancel((int)(uintptr_t)val[0], &work);
854-
ASSERT(ret == OK);
854+
ASSERT(ret == OK || ret == -ENOENT);
855855
}
856856

857857
usleep((int)(uintptr_t)val[2]);

0 commit comments

Comments
 (0)