Co-authored-by: Geoff Simmons <geoff@uplex.de>
This commit is contained in:
4
test/pico_sem_test/CMakeLists.txt
Normal file
4
test/pico_sem_test/CMakeLists.txt
Normal file
@ -0,0 +1,4 @@
|
||||
add_executable(pico_sem_test pico_sem_test.c)
|
||||
|
||||
target_link_libraries(pico_sem_test PRIVATE pico_test pico_sync)
|
||||
pico_add_extra_outputs(pico_sem_test)
|
29
test/pico_sem_test/pico_sem_test.c
Normal file
29
test/pico_sem_test/pico_sem_test.c
Normal file
@ -0,0 +1,29 @@
|
||||
/**
|
||||
* Copyright (c) 2022 Raspberry Pi (Trading) Ltd.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "pico/sem.h"
|
||||
#include "pico/test.h"
|
||||
#include "pico/stdio.h"
|
||||
|
||||
PICOTEST_MODULE_NAME("SEM", "semaphore test");
|
||||
|
||||
int main() {
|
||||
semaphore_t sem;
|
||||
|
||||
stdio_init_all();
|
||||
sem_init(&sem, 1, 1);
|
||||
|
||||
PICOTEST_START();
|
||||
|
||||
PICOTEST_START_SECTION("sem_try_acquire");
|
||||
PICOTEST_CHECK(sem_try_acquire(&sem), "available permit not acquired");
|
||||
PICOTEST_CHECK(!sem_try_acquire(&sem), "success with no permits");
|
||||
PICOTEST_END_SECTION();
|
||||
|
||||
PICOTEST_END_TEST();
|
||||
}
|
Reference in New Issue
Block a user