This implements the last of the intended unit tests for f_thread.
flags -Wl,--wrap=pthread_attr_setinheritsched
flags -Wl,--wrap=pthread_attr_setschedparam
flags -Wl,--wrap=pthread_attr_setschedpolicy
+flags -Wl,--wrap=pthread_attr_setschedprio
flags -Wl,--wrap=pthread_attr_setscope
flags -Wl,--wrap=pthread_attr_setscopesize
flags -Wl,--wrap=pthread_attr_setstack
flags -Wl,--wrap=pthread_getattr_default_np
flags -Wl,--wrap=pthread_getcpuclockid
flags -Wl,--wrap=pthread_getconcurrency
+flags -Wl,--wrap=pthread_getschedparam
flags -Wl,--wrap=pthread_getspecific
flags -Wl,--wrap=pthread_join
flags -Wl,--wrap=pthread_key_create
flags -Wl,--wrap=pthread_key_delete
-flags -Wl,--wrap=pthread_self
-flags -Wl,--wrap=pthread_setattr_default_np
-flags -Wl,--wrap=pthread_setcancelstate
-flags -Wl,--wrap=pthread_setcanceltype
-flags -Wl,--wrap=pthread_setconcurrency
-flags -Wl,--wrap=pthread_setspecific
-flags -Wl,--wrap=pthread_testcancel
-flags -Wl,--wrap=pthread_timedjoin_np
-flags -Wl,--wrap=pthread_tryjoin_np
-
-flags -Wl,--wrap=pthread_rwlock_destroy
-flags -Wl,--wrap=pthread_rwlock_init
-flags -Wl,--wrap=pthread_rwlock_rdlock
-flags -Wl,--wrap=pthread_rwlock_timedrdlock
-flags -Wl,--wrap=pthread_rwlock_timedwrlock
-flags -Wl,--wrap=pthread_rwlock_tryrdlock
-flags -Wl,--wrap=pthread_rwlock_trywrlock
-flags -Wl,--wrap=pthread_rwlock_unlock
-flags -Wl,--wrap=pthread_rwlock_wrlock
-flags -Wl,--wrap=pthread_rwlockattr_destroy
-flags -Wl,--wrap=pthread_rwlockattr_init
-flags -Wl,--wrap=pthread_rwlockattr_getpshared
-flags -Wl,--wrap=pthread_rwlockattr_setpshared
+flags -Wl,--wrap=pthread_kill
flags -Wl,--wrap=pthread_mutex_destroy
+flags -Wl,--wrap=pthread_mutex_getprioceiling
flags -Wl,--wrap=pthread_mutex_init
flags -Wl,--wrap=pthread_mutex_lock
+flags -Wl,--wrap=pthread_mutex_setprioceiling
flags -Wl,--wrap=pthread_mutex_timedlock
flags -Wl,--wrap=pthread_mutex_trylock
flags -Wl,--wrap=pthread_mutex_unlock
flags -Wl,--wrap=pthread_mutexattr_setprotocol
flags -Wl,--wrap=pthread_mutexattr_setpshared
flags -Wl,--wrap=pthread_mutexattr_settype
+flags -Wl,--wrap=pthread_once
+flags -Wl,--wrap=pthread_rwlock_destroy
+flags -Wl,--wrap=pthread_rwlock_init
+flags -Wl,--wrap=pthread_rwlock_rdlock
+flags -Wl,--wrap=pthread_rwlock_timedrdlock
+flags -Wl,--wrap=pthread_rwlock_timedwrlock
+flags -Wl,--wrap=pthread_rwlock_tryrdlock
+flags -Wl,--wrap=pthread_rwlock_trywrlock
+flags -Wl,--wrap=pthread_rwlock_unlock
+flags -Wl,--wrap=pthread_rwlock_wrlock
+flags -Wl,--wrap=pthread_rwlockattr_destroy
+flags -Wl,--wrap=pthread_rwlockattr_init
+flags -Wl,--wrap=pthread_rwlockattr_getpshared
+flags -Wl,--wrap=pthread_rwlockattr_setpshared
+flags -Wl,--wrap=pthread_self
+flags -Wl,--wrap=pthread_setattr_default_np
+flags -Wl,--wrap=pthread_setcancelstate
+flags -Wl,--wrap=pthread_setcanceltype
+flags -Wl,--wrap=pthread_setconcurrency
+flags -Wl,--wrap=pthread_setschedparam
+flags -Wl,--wrap=pthread_setschedprio
+flags -Wl,--wrap=pthread_setspecific
+flags -Wl,--wrap=pthread_sigmask
+flags -Wl,--wrap=pthread_sigqueue
+flags -Wl,--wrap=pthread_spin_destroy
+flags -Wl,--wrap=pthread_spin_init
+flags -Wl,--wrap=pthread_spin_lock
+flags -Wl,--wrap=pthread_spin_trylock
+flags -Wl,--wrap=pthread_spin_unlock
+flags -Wl,--wrap=pthread_testcancel
+flags -Wl,--wrap=pthread_timedjoin_np
+flags -Wl,--wrap=pthread_tryjoin_np
+flags -Wl,--wrap=sem_close
flags -Wl,--wrap=sem_destroy
+flags -Wl,--wrap=sem_getvalue
+flags -Wl,--wrap=sem_init
+flags -Wl,--wrap=sem_open
+flags -Wl,--wrap=sem_post
+flags -Wl,--wrap=sem_timedwait
+flags -Wl,--wrap=sem_trywait
+flags -Wl,--wrap=sem_unlink
+flags -Wl,--wrap=sem_wait
build_sources_program test-thread-mutex_attribute_protocol_get.c test-thread-mutex_attribute_protocol_set.c
build_sources_program test-thread-mutex_create.c test-thread-mutex_delete.c
build_sources_program test-thread-mutex_lock.c test-thread-mutex_lock_timed.c test-thread-mutex_lock_try.c
+build_sources_program test-thread-scheduler_parameter_get.c test-thread-scheduler_parameter_set.c
+build_sources_program test-thread-scheduler_priority_set.c
+build_sources_program test-thread-signal_mask.c test-thread-signal_queue.c test-thread-signal_write.c
+build_sources_program test-thread-spin_create.c test-thread-spin_delete.c
+build_sources_program test-thread-spin_lock.c test-thread-spin_lock_try.c test-thread-spin_unlock.c
+build_sources_program test-thread-mutex_priority_ceiling_get.c test-thread-mutex_priority_ceiling_set.c
+build_sources_program test-thread-once.c
+build_sources_program test-thread-semaphore_create.c test-thread-semaphore_delete.c
+build_sources_program test-thread-semaphore_file_open.c test-thread-semaphore_file_close.c test-thread-semaphore_file_delete.c
+build_sources_program test-thread-semaphore_lock.c test-thread-semaphore_lock_timed.c test-thread-semaphore_lock_try.c
+build_sources_program test-thread-semaphore_unlock.c
+build_sources_program test-thread-semaphore_value_get.c
build_sources_program test-thread.c
return 0;
}
-int __wrap_pthread_attr_setschedparam(pthread_attr_t *restrict attr, const struct sched_param *restrict param) {
+int __wrap_pthread_attr_setschedparam(pthread_attr_t * restrict attr, const struct sched_param * restrict param) {
const bool failure = mock_type(bool);
int __wrap_pthread_getconcurrency(void) {
- return mock_type(int);;
+ return mock_type(int);
}
int __wrap_pthread_getcpuclockid(pthread_t thread, clockid_t *clock_id) {
return 0;
}
+int __wrap_pthread_getschedparam(pthread_t pthread, int *policy, struct sched_param *param) {
+
+ const bool failure = mock_type(bool);
+
+ if (failure) {
+ return mock_type(int);
+ }
+
+ return 0;
+}
+
void *__wrap_pthread_getspecific(pthread_key_t key) {
return mock_type(void *);
return mock_type(int);
}
+int __wrap_pthread_kill(pthread_t thread, int sig) {
+
+ const bool failure = mock_type(bool);
+
+ if (failure) {
+ return mock_type(int);
+ }
+
+ return 0;
+}
+
pthread_t __wrap_pthread_self(void) {
return mock_type(int);
return 0;
}
+int __wrap_pthread_setschedparam(pthread_t pthread, int policy, const struct sched_param *param) {
+
+ const bool failure = mock_type(bool);
+
+ if (failure) {
+ return mock_type(int);
+ }
+
+ return 0;
+}
+
+int __wrap_pthread_setschedprio(pthread_t thread, int prio) {
+
+ const bool failure = mock_type(bool);
+
+ if (failure) {
+ return mock_type(int);
+ }
+
+ return 0;
+}
+
int __wrap_pthread_setspecific(pthread_key_t key, const void *value) {
const bool failure = mock_type(bool);
return 0;
}
+int __wrap_pthread_sigmask(int how, const sigset_t *set, sigset_t *oldset) {
+
+ const bool failure = mock_type(bool);
+
+ if (failure) {
+ return mock_type(int);
+ }
+
+ return 0;
+}
+
+int __wrap_pthread_sigqueue(pthread_t thread, int sig, const union sigval value) {
+
+ const bool failure = mock_type(bool);
+
+ if (failure) {
+ return mock_type(int);
+ }
+
+ return 0;
+}
+
+int __wrap_pthread_spin_destroy(pthread_spinlock_t *spinlock) {
+
+ const bool failure = mock_type(bool);
+
+ if (failure) {
+ return mock_type(int);
+ }
+
+ return 0;
+}
+
+int __wrap_pthread_spin_init(pthread_spinlock_t *spinlock, int pshared) {
+
+ const bool failure = mock_type(bool);
+
+ if (failure) {
+ return mock_type(int);
+ }
+
+ return 0;
+}
+
+int __wrap_pthread_spin_lock(pthread_spinlock_t *spinlock) {
+
+ const bool failure = mock_type(bool);
+
+ if (failure) {
+ return mock_type(int);
+ }
+
+ return 0;
+}
+
+int __wrap_pthread_spin_trylock(pthread_spinlock_t *spinlock) {
+
+ const bool failure = mock_type(bool);
+
+ if (failure) {
+ return mock_type(int);
+ }
+
+ return 0;
+}
+
+int __wrap_pthread_spin_unlock(pthread_spinlock_t *spinlock) {
+
+ const bool failure = mock_type(bool);
+
+ if (failure) {
+ return mock_type(int);
+ }
+
+ return 0;
+}
+
void __wrap_pthread_testcancel(void) {
}
return 0;
}
+int __wrap_pthread_mutex_getprioceiling(const pthread_mutex_t * restrict mutex, int *prioceiling) {
+
+ const bool failure = mock_type(bool);
+
+ if (failure) {
+ return mock_type(int);
+ }
+
+ return 0;
+}
+
int __wrap_pthread_mutex_init(pthread_mutex_t *mutex, const pthread_mutexattr_t *attr) {
const bool failure = mock_type(bool);
return 0;
}
+int __wrap_pthread_mutex_setprioceiling(pthread_mutex_t *mutex, int prioceiling, int *old_ceiling) {
+
+ const bool failure = mock_type(bool);
+
+ if (failure) {
+ return mock_type(int);
+ }
+
+ return 0;
+}
+
int __wrap_pthread_mutex_timedlock(pthread_mutex_t *mutex, const struct timespec *timeout) {
const bool failure = mock_type(bool);
return 0;
}
-int __wrap_sem_destroy(sem_t *sem) {
+int __wrap_pthread_once(pthread_once_t *once_control, void (*init_routine)(void)) {
const bool failure = mock_type(bool);
return 0;
}
+int __wrap_sem_close(sem_t *sem) {
+
+ const bool failure = mock_type(bool);
+
+ if (failure) {
+ errno = mock_type(int);
+
+ return -1;
+ }
+
+ return 0;
+}
+
+int __wrap_sem_destroy(sem_t *sem) {
+
+ const bool failure = mock_type(bool);
+
+ if (failure) {
+ errno = mock_type(int);
+
+ return -1;
+ }
+
+ return 0;
+}
+
+int __wrap_sem_getvalue(sem_t * restrict sem, int * restrict sval) {
+
+ const bool failure = mock_type(bool);
+
+ if (failure) {
+ errno = mock_type(int);
+
+ return -1;
+ }
+
+ return 0;
+}
+
+int __wrap_sem_init(sem_t *sem, int pshared, unsigned int value) {
+
+ const bool failure = mock_type(bool);
+
+ if (failure) {
+ errno = mock_type(int);
+
+ return -1;
+ }
+
+ return 0;
+}
+
+sem_t *__wrap_sem_open(const char *name, int oflag, ...) {
+
+ const bool failure = mock_type(bool);
+
+ if (failure) {
+ errno = mock_type(int);
+
+ return SEM_FAILED;
+ }
+
+ return ((sem_t *) 1);
+}
+
+int __wrap_sem_post(sem_t *sem) {
+
+ const bool failure = mock_type(bool);
+
+ if (failure) {
+ errno = mock_type(int);
+
+ return -1;
+ }
+
+ return 0;
+}
+
+int __wrap_sem_timedwait(sem_t * restrict sem, const struct timespec * restrict abs_timeout) {
+
+ const bool failure = mock_type(bool);
+
+ if (failure) {
+ errno = mock_type(int);
+
+ return -1;
+ }
+
+ return 0;
+}
+
+int __wrap_sem_trywait(sem_t *sem) {
+
+ const bool failure = mock_type(bool);
+
+ if (failure) {
+ errno = mock_type(int);
+
+ return -1;
+ }
+
+ return 0;
+}
+
+int __wrap_sem_unlink(const char *name) {
+
+ const bool failure = mock_type(bool);
+
+ if (failure) {
+ errno = mock_type(int);
+
+ return -1;
+ }
+
+ return 0;
+}
+
+int __wrap_sem_wait(sem_t *sem) {
+
+ const bool failure = mock_type(bool);
+
+ if (failure) {
+ errno = mock_type(int);
+
+ return -1;
+ }
+
+ return 0;
+}
+
void stub(void) {
}
#define _MOCK__thread_h
// Libc includes.
+#include <semaphore.h>
#include <stdarg.h>
#include <stddef.h>
#include <setjmp.h>
extern int __wrap_pthread_attr_destroy(pthread_attr_t *attr);
extern int __wrap_pthread_attr_getaffinity_np(const pthread_attr_t *attr, size_t cpusetsize, cpu_set_t *cpuset);
extern int __wrap_pthread_attr_getdetachstate(const pthread_attr_t *attr, int *detachstate);
-extern int __wrap_pthread_attr_getguardsize(const pthread_attr_t *restrict attr, size_t *restrict guardsize);
-extern int __wrap_pthread_attr_getinheritsched(const pthread_attr_t *restrict attr, int *restrict inheritsched);
-extern int __wrap_pthread_attr_getschedparam(const pthread_attr_t *restrict attr, struct sched_param *restrict param);
-extern int __wrap_pthread_attr_getschedpolicy(const pthread_attr_t *restrict attr, int *restrict policy);
+extern int __wrap_pthread_attr_getguardsize(const pthread_attr_t * restrict attr, size_t * restrict guardsize);
+extern int __wrap_pthread_attr_getinheritsched(const pthread_attr_t * restrict attr, int * restrict inheritsched);
+extern int __wrap_pthread_attr_getschedparam(const pthread_attr_t * restrict attr, struct sched_param * restrict param);
+extern int __wrap_pthread_attr_getschedpolicy(const pthread_attr_t * restrict attr, int * restrict policy);
extern int __wrap_pthread_attr_getscope(const pthread_attr_t *attr, int *contentionscope);
extern int __wrap_pthread_attr_getstack(const pthread_attr_t *attr, void **stackaddr, size_t *stacksize);
extern int __wrap_pthread_attr_getstacksize(const pthread_attr_t *attr, size_t *stacksize);
extern int __wrap_pthread_attr_setdetachstate(pthread_attr_t *attr, int detachstate);
extern int __wrap_pthread_attr_setguardsize(pthread_attr_t *attr, size_t guardsize);
extern int __wrap_pthread_attr_setinheritsched(pthread_attr_t *attr, int inheritsched);
-extern int __wrap_pthread_attr_setschedparam(pthread_attr_t *restrict attr, const struct sched_param *restrict param);
+extern int __wrap_pthread_attr_setschedparam(pthread_attr_t * restrict attr, const struct sched_param * restrict param);
extern int __wrap_pthread_attr_setschedpolicy(pthread_attr_t *attr, int policy);
extern int __wrap_pthread_attr_setscope(pthread_attr_t *attr, int contentionscope);
extern int __wrap_pthread_attr_setstack(pthread_attr_t *attr, void *stackaddr, size_t stacksize);
extern int __wrap_pthread_getattr_default_np(pthread_attr_t *attr);
extern int __wrap_pthread_getconcurrency(void);
extern int __wrap_pthread_getcpuclockid(pthread_t thread, clockid_t *clock_id);
+extern int __wrap_pthread_getschedparam(pthread_t pthread, int *policy, struct sched_param *param);
extern void *__wrap_pthread_getspecific(pthread_key_t key);
extern int __wrap_pthread_join(pthread_t pthread, void **value_ptr);
extern int __wrap_pthread_key_create(pthread_key_t *key, void (*destructor)(void*));
extern int __wrap_pthread_key_delete(pthread_key_t key);
+extern int __wrap_pthread_kill(pthread_t thread, int sig);
extern pthread_t __wrap_pthread_self(void);
extern int __wrap_pthread_setattr_default_np(const pthread_attr_t *attr);
extern int __wrap_pthread_setcancelstate(int state, int *oldstate);
extern int __wrap_pthread_setcanceltype(int type, int *oldtype);
extern int __wrap_pthread_setconcurrency(int new_level);
+extern int __wrap_pthread_setschedparam(pthread_t pthread, int policy, const struct sched_param *param);
+extern int __wrap_pthread_setschedprio(pthread_t thread, int prio);
extern int __wrap_pthread_setspecific(pthread_key_t key, const void *value);
+extern int __wrap_pthread_sigmask(int how, const sigset_t *set, sigset_t *oldset);
+extern int __wrap_pthread_sigqueue(pthread_t thread, int sig, const union sigval value);
+extern int __wrap_pthread_spin_destroy(pthread_spinlock_t *spinlock);
+extern int __wrap_pthread_spin_init(pthread_spinlock_t *spinlock, int pshared);
+extern int __wrap_pthread_spin_lock(pthread_spinlock_t *spinlock);
+extern int __wrap_pthread_spin_trylock(pthread_spinlock_t *spinlock);
+extern int __wrap_pthread_spin_unlock(pthread_spinlock_t *spinlock);
extern void __wrap_pthread_testcancel(void);
extern int __wrap_pthread_timedjoin_np(pthread_t thread, void **retval);
extern int __wrap_pthread_tryjoin_np(pthread_t thread, void **retval, const struct timespec *abstime);
extern int __wrap_pthread_rwlockattr_getpshared(const pthread_rwlockattr_t *attr, int *pshared);
extern int __wrap_pthread_rwlockattr_setpshared(pthread_rwlockattr_t *attr, int pshared);
extern int __wrap_pthread_mutex_destroy(pthread_mutex_t *mutex);
+extern int __wrap_pthread_mutex_getprioceiling(const pthread_mutex_t * restrict mutex, int *prioceiling);
extern int __wrap_pthread_mutex_init(pthread_mutex_t *mutex, const pthread_mutexattr_t *attr);
extern int __wrap_pthread_mutex_lock(pthread_mutex_t *mutex);
+extern int __wrap_pthread_mutex_setprioceiling(pthread_mutex_t *mutex, int prioceiling, int *old_ceiling);
extern int __wrap_pthread_mutex_timedlock(pthread_mutex_t *mutex, const struct timespec *timeout);
extern int __wrap_pthread_mutex_trylock(pthread_mutex_t *mutex);
extern int __wrap_pthread_mutex_unlock(pthread_mutex_t *mutex);
extern int __wrap_pthread_mutexattr_setprotocol(pthread_mutexattr_t *attr, int protocol);
extern int __wrap_pthread_mutexattr_setpshared(pthread_mutexattr_t *attr, int pshared);
extern int __wrap_pthread_mutexattr_settype(pthread_mutexattr_t *attr, int kind);
+extern int __wrap_pthread_once(pthread_once_t *once_control, void (*init_routine)(void));
+extern int __wrap_sem_close(sem_t *sem);
extern int __wrap_sem_destroy(sem_t *sem);
-
-/*
-sem_init
-sem_open
-sem_close
-sem_unlink
-sem_wait
-sem_timedwait
-sem_trywait
-sem_post
-sem_getvalue
-pthread_mutex_getprioceiling
-pthread_mutex_setprioceiling
-pthread_mutex_unlock
-pthread_once
-pthread_getschedparam
-pthread_setschedparam
-pthread_setschedprio
-pthread_sigmask
-pthread_sigqueue
-pthread_spin_init
-pthread_spin_lock
-pthread_spin_trylock
-pthread_spin_unlock
-pthread_rwlock_unlock
-*/
+extern int __wrap_sem_getvalue(sem_t * restrict sem, int * restrict sval);
+extern int __wrap_sem_init(sem_t *sem, int pshared, unsigned int value);
+extern sem_t *__wrap_sem_open(const char *name, int oflag, ...);
+extern int __wrap_sem_post(sem_t *sem);
+extern int __wrap_sem_timedwait(sem_t * restrict sem, const struct timespec * restrict abs_timeout);
+extern int __wrap_sem_trywait(sem_t *sem);
+extern int __wrap_sem_unlink(const char *name);
+extern int __wrap_sem_wait(sem_t *sem);
/**
* A stub intended to be used for passing to functions like f_thread_at_fork().
--- /dev/null
+#include "test-thread.h"
+#include "test-thread-mutex_priority_ceiling_get.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void test__f_thread_mutex_priority_ceiling_get__fails(void **state) {
+
+ f_thread_mutex_t mutex = f_thread_mutex_t_initialize;
+ int ceiling = 0;
+
+ int errnos[] = {
+ EINVAL,
+ EPERM,
+ mock_errno_generic,
+ };
+
+ f_status_t statuss[] = {
+ F_parameter,
+ F_prohibited,
+ F_failure,
+ };
+
+ for (uint8_t i = 0; i < 3; ++i) {
+
+ will_return(__wrap_pthread_mutex_getprioceiling, true);
+ will_return(__wrap_pthread_mutex_getprioceiling, errnos[i]);
+
+ const f_status_t status = f_thread_mutex_priority_ceiling_get(&mutex, &ceiling);
+
+ assert_int_equal(status, F_status_set_error(statuss[i]));
+ } // for
+}
+
+void test__f_thread_mutex_priority_ceiling_get__parameter_checking(void **state) {
+
+ f_thread_mutex_t mutex = f_thread_mutex_t_initialize;
+ int ceiling = 0;
+
+ {
+ const f_status_t status = f_thread_mutex_priority_ceiling_get(0, 0);
+
+ assert_int_equal(status, F_status_set_error(F_parameter));
+ }
+
+ {
+ const f_status_t status = f_thread_mutex_priority_ceiling_get(&mutex, 0);
+
+ assert_int_equal(status, F_status_set_error(F_parameter));
+ }
+
+ {
+ const f_status_t status = f_thread_mutex_priority_ceiling_get(0, &ceiling);
+
+ assert_int_equal(status, F_status_set_error(F_parameter));
+ }
+}
+
+void test__f_thread_mutex_priority_ceiling_get__works(void **state) {
+
+ f_thread_mutex_t mutex = f_thread_mutex_t_initialize;
+ int ceiling = 0;
+
+ {
+ will_return(__wrap_pthread_mutex_getprioceiling, false);
+
+ const f_status_t status = f_thread_mutex_priority_ceiling_get(&mutex, &ceiling);
+
+ assert_int_equal(status, F_none);
+ }
+}
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
--- /dev/null
+/**
+ * FLL - Level 0
+ *
+ * Project: Thread
+ * API Version: 0.5
+ * Licenses: lgpl-2.1-or-later
+ *
+ * Test the thread project.
+ */
+#ifndef _TEST__F_thread__mutex_priority_ceiling_get_h
+#define _TEST__F_thread__mutex_priority_ceiling_get_h
+
+/**
+ * Test that function fails.
+ *
+ * @see f_thread_mutex_priority_ceiling_get()
+ */
+extern void test__f_thread_mutex_priority_ceiling_get__fails(void **state);
+
+/**
+ * Test that parameter checking works as expected.
+ *
+ * @see f_thread_mutex_priority_ceiling_get()
+ */
+extern void test__f_thread_mutex_priority_ceiling_get__parameter_checking(void **state);
+
+/**
+ * Test that function works.
+ *
+ * @see f_thread_mutex_priority_ceiling_get()
+ */
+extern void test__f_thread_mutex_priority_ceiling_get__works(void **state);
+
+#endif // _TEST__F_thread__mutex_priority_ceiling_get_h
--- /dev/null
+#include "test-thread.h"
+#include "test-thread-mutex_priority_ceiling_set.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void test__f_thread_mutex_priority_ceiling_set__fails(void **state) {
+
+ f_thread_mutex_t mutex = f_thread_mutex_t_initialize;
+ int ceiling = 0;
+ int previous = 0;
+
+ int errnos[] = {
+ EAGAIN,
+ EDEADLK,
+ EINVAL,
+ ENOTRECOVERABLE,
+ EOWNERDEAD,
+ EPERM,
+ mock_errno_generic,
+ };
+
+ f_status_t statuss[] = {
+ F_resource_not,
+ F_deadlock,
+ F_parameter,
+ F_recover_not,
+ F_dead,
+ F_prohibited,
+ F_failure,
+ };
+
+ for (uint8_t i = 0; i < 7; ++i) {
+
+ will_return(__wrap_pthread_mutex_setprioceiling, true);
+ will_return(__wrap_pthread_mutex_setprioceiling, errnos[i]);
+
+ const f_status_t status = f_thread_mutex_priority_ceiling_set(ceiling, &mutex, &previous);
+
+ assert_int_equal(status, F_status_set_error(statuss[i]));
+ } // for
+}
+
+void test__f_thread_mutex_priority_ceiling_set__parameter_checking(void **state) {
+
+ int ceiling = 0;
+ int previous = 0;
+
+ {
+ const f_status_t status = f_thread_mutex_priority_ceiling_set(ceiling, 0, &previous);
+
+ assert_int_equal(status, F_status_set_error(F_parameter));
+ }
+}
+
+void test__f_thread_mutex_priority_ceiling_set__works(void **state) {
+
+ f_thread_mutex_t mutex = f_thread_mutex_t_initialize;
+ int ceiling = 0;
+ int previous = 0;
+
+ {
+ will_return(__wrap_pthread_mutex_setprioceiling, false);
+
+ const f_status_t status = f_thread_mutex_priority_ceiling_set(ceiling, &mutex, &previous);
+
+ assert_int_equal(status, F_none);
+ }
+}
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
--- /dev/null
+/**
+ * FLL - Level 0
+ *
+ * Project: Thread
+ * API Version: 0.5
+ * Licenses: lgpl-2.1-or-later
+ *
+ * Test the thread project.
+ */
+#ifndef _TEST__F_thread__mutex_priority_ceiling_set_h
+#define _TEST__F_thread__mutex_priority_ceiling_set_h
+
+/**
+ * Test that function fails.
+ *
+ * @see f_thread_mutex_priority_ceiling_set()
+ */
+extern void test__f_thread_mutex_priority_ceiling_set__fails(void **state);
+
+/**
+ * Test that parameter checking works as expected.
+ *
+ * @see f_thread_mutex_priority_ceiling_set()
+ */
+extern void test__f_thread_mutex_priority_ceiling_set__parameter_checking(void **state);
+
+/**
+ * Test that function works.
+ *
+ * @see f_thread_mutex_priority_ceiling_set()
+ */
+extern void test__f_thread_mutex_priority_ceiling_set__works(void **state);
+
+#endif // _TEST__F_thread__mutex_priority_ceiling_set_h
--- /dev/null
+#include "test-thread.h"
+#include "test-thread-once.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void test__f_thread_once__fails(void **state) {
+
+ f_thread_once_t once = f_thread_once_t_initialize;
+
+ int errnos[] = {
+ EINVAL,
+ mock_errno_generic,
+ };
+
+ f_status_t statuss[] = {
+ F_parameter,
+ F_failure,
+ };
+
+ for (uint8_t i = 0; i < 2; ++i) {
+
+ will_return(__wrap_pthread_once, true);
+ will_return(__wrap_pthread_once, errnos[i]);
+
+ const f_status_t status = f_thread_once(stub, &once);
+
+ assert_int_equal(status, F_status_set_error(statuss[i]));
+ } // for
+}
+
+void test__f_thread_once__parameter_checking(void **state) {
+
+ f_thread_once_t once = f_thread_once_t_initialize;
+
+ {
+ const f_status_t status = f_thread_once(0, 0);
+
+ assert_int_equal(status, F_status_set_error(F_parameter));
+ }
+
+ {
+ const f_status_t status = f_thread_once(stub, 0);
+
+ assert_int_equal(status, F_status_set_error(F_parameter));
+ }
+
+ {
+ const f_status_t status = f_thread_once(0, &once);
+
+ assert_int_equal(status, F_status_set_error(F_parameter));
+ }
+}
+
+void test__f_thread_once__works(void **state) {
+
+ f_thread_once_t once = f_thread_once_t_initialize;
+
+ {
+ will_return(__wrap_pthread_once, false);
+
+ const f_status_t status = f_thread_once(stub, &once);
+
+ assert_int_equal(status, F_none);
+ }
+}
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
--- /dev/null
+/**
+ * FLL - Level 0
+ *
+ * Project: Thread
+ * API Version: 0.5
+ * Licenses: lgpl-2.1-or-later
+ *
+ * Test the thread project.
+ */
+#ifndef _TEST__F_thread__once_h
+#define _TEST__F_thread__once_h
+
+/**
+ * Test that function fails.
+ *
+ * @see f_thread_once()
+ */
+extern void test__f_thread_once__fails(void **state);
+
+/**
+ * Test that parameter checking works as expected.
+ *
+ * @see f_thread_once()
+ */
+extern void test__f_thread_once__parameter_checking(void **state);
+
+/**
+ * Test that function works.
+ *
+ * @see f_thread_once()
+ */
+extern void test__f_thread_once__works(void **state);
+
+#endif // _TEST__F_thread__once_h
--- /dev/null
+#include "test-thread.h"
+#include "test-thread-scheduler_parameter_get.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void test__f_thread_scheduler_parameter_get__fails(void **state) {
+
+ f_thread_id_t id = f_thread_id_t_initialize;
+ int policy = 0;
+ struct sched_param parameter;
+
+ memset(¶meter, 0, sizeof(struct sched_param));
+
+ int errnos[] = {
+ ENOTSUP,
+ mock_errno_generic,
+ };
+
+ f_status_t statuss[] = {
+ F_supported_not,
+ F_failure,
+ };
+
+ for (uint8_t i = 0; i < 2; ++i) {
+
+ will_return(__wrap_pthread_getschedparam, true);
+ will_return(__wrap_pthread_getschedparam, errnos[i]);
+
+ const f_status_t status = f_thread_scheduler_parameter_get(id, &policy, ¶meter);
+
+ assert_int_equal(status, F_status_set_error(statuss[i]));
+ } // for
+}
+
+void test__f_thread_scheduler_parameter_get__parameter_checking(void **state) {
+
+ f_thread_id_t id = f_thread_id_t_initialize;
+ int policy = 0;
+ struct sched_param parameter;
+
+ memset(¶meter, 0, sizeof(struct sched_param));
+
+ {
+ const f_status_t status = f_thread_scheduler_parameter_get(id, 0, 0);
+
+ assert_int_equal(status, F_status_set_error(F_parameter));
+ }
+
+ {
+ const f_status_t status = f_thread_scheduler_parameter_get(id, &policy, 0);
+
+ assert_int_equal(status, F_status_set_error(F_parameter));
+ }
+
+ {
+ const f_status_t status = f_thread_scheduler_parameter_get(id, 0, ¶meter);
+
+ assert_int_equal(status, F_status_set_error(F_parameter));
+ }
+}
+
+void test__f_thread_scheduler_parameter_get__works(void **state) {
+
+ f_thread_id_t id = f_thread_id_t_initialize;
+ int policy = 0;
+ struct sched_param parameter;
+
+ memset(¶meter, 0, sizeof(struct sched_param));
+
+ {
+ will_return(__wrap_pthread_getschedparam, false);
+
+ const f_status_t status = f_thread_scheduler_parameter_get(id, &policy, ¶meter);
+
+ assert_int_equal(status, F_none);
+ }
+}
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
--- /dev/null
+/**
+ * FLL - Level 0
+ *
+ * Project: Thread
+ * API Version: 0.5
+ * Licenses: lgpl-2.1-or-later
+ *
+ * Test the thread project.
+ */
+#ifndef _TEST__F_thread__scheduler_parameter_get_h
+#define _TEST__F_thread__scheduler_parameter_get_h
+
+/**
+ * Test that function fails.
+ *
+ * @see f_thread_scheduler_parameter_get()
+ */
+extern void test__f_thread_scheduler_parameter_get__fails(void **state);
+
+/**
+ * Test that parameter checking works as expected.
+ *
+ * @see f_thread_scheduler_parameter_get()
+ */
+extern void test__f_thread_scheduler_parameter_get__parameter_checking(void **state);
+
+/**
+ * Test that function works.
+ *
+ * @see f_thread_scheduler_parameter_get()
+ */
+extern void test__f_thread_scheduler_parameter_get__works(void **state);
+
+#endif // _TEST__F_thread__scheduler_parameter_get_h
--- /dev/null
+#include "test-thread.h"
+#include "test-thread-scheduler_parameter_set.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void test__f_thread_scheduler_parameter_set__fails(void **state) {
+
+ f_thread_id_t id = f_thread_id_t_initialize;
+ int policy = 0;
+ struct sched_param parameter;
+
+ memset(¶meter, 0, sizeof(struct sched_param));
+
+ int errnos[] = {
+ EINVAL,
+ EPERM,
+ mock_errno_generic,
+ };
+
+ f_status_t statuss[] = {
+ F_parameter,
+ F_prohibited,
+ F_failure,
+ };
+
+ for (uint8_t i = 0; i < 3; ++i) {
+
+ will_return(__wrap_pthread_setschedparam, true);
+ will_return(__wrap_pthread_setschedparam, errnos[i]);
+
+ const f_status_t status = f_thread_scheduler_parameter_set(id, policy, ¶meter);
+
+ assert_int_equal(status, F_status_set_error(statuss[i]));
+ } // for
+}
+
+void test__f_thread_scheduler_parameter_set__parameter_checking(void **state) {
+
+ f_thread_id_t id = f_thread_id_t_initialize;
+ int policy = 0;
+
+ {
+ const f_status_t status = f_thread_scheduler_parameter_set(id, policy, 0);
+
+ assert_int_equal(status, F_status_set_error(F_parameter));
+ }
+}
+
+void test__f_thread_scheduler_parameter_set__works(void **state) {
+
+ f_thread_id_t id = f_thread_id_t_initialize;
+ int policy = 0;
+ struct sched_param parameter;
+
+ memset(¶meter, 0, sizeof(struct sched_param));
+
+ {
+ will_return(__wrap_pthread_setschedparam, false);
+
+ const f_status_t status = f_thread_scheduler_parameter_set(id, policy, ¶meter);
+
+ assert_int_equal(status, F_none);
+ }
+}
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
--- /dev/null
+/**
+ * FLL - Level 0
+ *
+ * Project: Thread
+ * API Version: 0.5
+ * Licenses: lgpl-2.1-or-later
+ *
+ * Test the thread project.
+ */
+#ifndef _TEST__F_thread__scheduler_parameter_set_h
+#define _TEST__F_thread__scheduler_parameter_set_h
+
+/**
+ * Test that function fails.
+ *
+ * @see f_thread_scheduler_parameter_set()
+ */
+extern void test__f_thread_scheduler_parameter_set__fails(void **state);
+
+/**
+ * Test that parameter checking works as expected.
+ *
+ * @see f_thread_scheduler_parameter_set()
+ */
+extern void test__f_thread_scheduler_parameter_set__parameter_checking(void **state);
+
+/**
+ * Test that function works.
+ *
+ * @see f_thread_scheduler_parameter_set()
+ */
+extern void test__f_thread_scheduler_parameter_set__works(void **state);
+
+#endif // _TEST__F_thread__scheduler_parameter_set_h
--- /dev/null
+#include "test-thread.h"
+#include "test-thread-scheduler_priority_set.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void test__f_thread_scheduler_priority_set__fails(void **state) {
+
+ f_thread_id_t id = f_thread_id_t_initialize;
+ int priority = 0;
+
+ int errnos[] = {
+ EINVAL,
+ EPERM,
+ ESRCH,
+ mock_errno_generic,
+ };
+
+ f_status_t statuss[] = {
+ F_parameter,
+ F_prohibited,
+ F_found_not,
+ F_failure,
+ };
+
+ for (uint8_t i = 0; i < 4; ++i) {
+
+ will_return(__wrap_pthread_setschedprio, true);
+ will_return(__wrap_pthread_setschedprio, errnos[i]);
+
+ const f_status_t status = f_thread_scheduler_priority_set(id, priority);
+
+ assert_int_equal(status, F_status_set_error(statuss[i]));
+ } // for
+}
+
+void test__f_thread_scheduler_priority_set__works(void **state) {
+
+ f_thread_id_t id = f_thread_id_t_initialize;
+ int priority = 0;
+
+ {
+ will_return(__wrap_pthread_setschedprio, false);
+
+ const f_status_t status = f_thread_scheduler_priority_set(id, priority);
+
+ assert_int_equal(status, F_none);
+ }
+}
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
--- /dev/null
+/**
+ * FLL - Level 0
+ *
+ * Project: Thread
+ * API Version: 0.5
+ * Licenses: lgpl-2.1-or-later
+ *
+ * Test the thread project.
+ */
+#ifndef _TEST__F_thread__scheduler_priority_set_h
+#define _TEST__F_thread__scheduler_priority_set_h
+
+/**
+ * Test that function fails.
+ *
+ * @see f_thread_scheduler_priority_set()
+ */
+extern void test__f_thread_scheduler_priority_set__fails(void **state);
+
+/**
+ * Test that function works.
+ *
+ * @see f_thread_scheduler_priority_set()
+ */
+extern void test__f_thread_scheduler_priority_set__works(void **state);
+
+#endif // _TEST__F_thread__scheduler_priority_set_h
--- /dev/null
+#include "test-thread.h"
+#include "test-thread-semaphore_create.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void test__f_thread_semaphore_create__fails(void **state) {
+
+ f_thread_semaphore_t semaphore = f_thread_semaphore_t_initialize;
+ bool shared = F_false;
+ unsigned int value = 0;
+
+ int errnos[] = {
+ EINVAL,
+ ENOSYS,
+ mock_errno_generic,
+ };
+
+ f_status_t statuss[] = {
+ F_parameter,
+ F_supported_not,
+ F_failure,
+ };
+
+ for (uint8_t i = 0; i < 3; ++i) {
+
+ will_return(__wrap_sem_init, true);
+ will_return(__wrap_sem_init, errnos[i]);
+
+ const f_status_t status = f_thread_semaphore_create(shared, value, &semaphore);
+
+ assert_int_equal(status, F_status_set_error(statuss[i]));
+ } // for
+}
+
+void test__f_thread_semaphore_create__parameter_checking(void **state) {
+
+ bool shared = F_false;
+ unsigned int value = 0;
+
+ {
+ const f_status_t status = f_thread_semaphore_create(shared, value, 0);
+
+ assert_int_equal(status, F_status_set_error(F_parameter));
+ }
+}
+
+void test__f_thread_semaphore_create__works(void **state) {
+
+ f_thread_semaphore_t semaphore = f_thread_semaphore_t_initialize;
+ bool shared = F_false;
+ unsigned int value = 0;
+
+ {
+ will_return(__wrap_sem_init, false);
+
+ const f_status_t status = f_thread_semaphore_create(shared, value, &semaphore);
+
+ assert_int_equal(status, F_none);
+ }
+}
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
--- /dev/null
+/**
+ * FLL - Level 0
+ *
+ * Project: Thread
+ * API Version: 0.5
+ * Licenses: lgpl-2.1-or-later
+ *
+ * Test the thread project.
+ */
+#ifndef _TEST__F_thread__semaphore_create_h
+#define _TEST__F_thread__semaphore_create_h
+
+/**
+ * Test that function fails.
+ *
+ * @see f_thread_semaphore_create()
+ */
+extern void test__f_thread_semaphore_create__fails(void **state);
+
+/**
+ * Test that parameter checking works as expected.
+ *
+ * @see f_thread_semaphore_create()
+ */
+extern void test__f_thread_semaphore_create__parameter_checking(void **state);
+
+/**
+ * Test that function works.
+ *
+ * @see f_thread_semaphore_create()
+ */
+extern void test__f_thread_semaphore_create__works(void **state);
+
+#endif // _TEST__F_thread__semaphore_create_h
--- /dev/null
+#include "test-thread.h"
+#include "test-thread-semaphore_delete.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void test__f_thread_semaphore_delete__fails(void **state) {
+
+ f_thread_semaphore_t semaphore = f_thread_semaphore_t_initialize;
+
+ int errnos[] = {
+ EINVAL,
+ mock_errno_generic,
+ };
+
+ f_status_t statuss[] = {
+ F_parameter,
+ F_failure,
+ };
+
+ for (uint8_t i = 0; i < 2; ++i) {
+
+ will_return(__wrap_sem_destroy, true);
+ will_return(__wrap_sem_destroy, errnos[i]);
+
+ const f_status_t status = f_thread_semaphore_delete(&semaphore);
+
+ assert_int_equal(status, F_status_set_error(statuss[i]));
+ } // for
+}
+
+void test__f_thread_semaphore_delete__parameter_checking(void **state) {
+
+ {
+ const f_status_t status = f_thread_semaphore_delete(0);
+
+ assert_int_equal(status, F_status_set_error(F_parameter));
+ }
+}
+
+void test__f_thread_semaphore_delete__works(void **state) {
+
+ f_thread_semaphore_t semaphore = f_thread_semaphore_t_initialize;
+
+ {
+ will_return(__wrap_sem_destroy, false);
+
+ const f_status_t status = f_thread_semaphore_delete(&semaphore);
+
+ assert_int_equal(status, F_none);
+ }
+}
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
--- /dev/null
+/**
+ * FLL - Level 0
+ *
+ * Project: Thread
+ * API Version: 0.5
+ * Licenses: lgpl-2.1-or-later
+ *
+ * Test the thread project.
+ */
+#ifndef _TEST__F_thread__semaphore_delete_h
+#define _TEST__F_thread__semaphore_delete_h
+
+/**
+ * Test that function fails.
+ *
+ * @see f_thread_semaphore_delete()
+ */
+extern void test__f_thread_semaphore_delete__fails(void **state);
+
+/**
+ * Test that parameter checking works as expected.
+ *
+ * @see f_thread_semaphore_delete()
+ */
+extern void test__f_thread_semaphore_delete__parameter_checking(void **state);
+
+/**
+ * Test that function works.
+ *
+ * @see f_thread_semaphore_delete()
+ */
+extern void test__f_thread_semaphore_delete__works(void **state);
+
+#endif // _TEST__F_thread__semaphore_delete_h
--- /dev/null
+#include "test-thread.h"
+#include "test-thread-semaphore_file_delete.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void test__f_thread_semaphore_file_close__fails(void **state) {
+
+ f_thread_semaphore_t semaphore = f_thread_semaphore_t_initialize;
+
+ int errnos[] = {
+ EINVAL,
+ mock_errno_generic,
+ };
+
+ f_status_t statuss[] = {
+ F_parameter,
+ F_failure,
+ };
+
+ for (uint8_t i = 0; i < 2; ++i) {
+
+ will_return(__wrap_sem_close, true);
+ will_return(__wrap_sem_close, errnos[i]);
+
+ const f_status_t status = f_thread_semaphore_file_close(&semaphore);
+
+ assert_int_equal(status, F_status_set_error(statuss[i]));
+ } // for
+}
+
+void test__f_thread_semaphore_file_close__parameter_checking(void **state) {
+
+ {
+ const f_status_t status = f_thread_semaphore_file_close(0);
+
+ assert_int_equal(status, F_status_set_error(F_parameter));
+ }
+}
+
+void test__f_thread_semaphore_file_close__works(void **state) {
+
+ f_thread_semaphore_t semaphore = f_thread_semaphore_t_initialize;
+
+ {
+ will_return(__wrap_sem_close, false);
+
+ const f_status_t status = f_thread_semaphore_file_close(&semaphore);
+
+ assert_int_equal(status, F_none);
+ }
+}
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
--- /dev/null
+/**
+ * FLL - Level 0
+ *
+ * Project: Thread
+ * API Version: 0.5
+ * Licenses: lgpl-2.1-or-later
+ *
+ * Test the thread project.
+ */
+#ifndef _TEST__F_thread__semaphore_file_delete_h
+#define _TEST__F_thread__semaphore_file_delete_h
+
+/**
+ * Test that function fails.
+ *
+ * @see f_thread_semaphore_file_close()
+ */
+extern void test__f_thread_semaphore_file_close__fails(void **state);
+
+/**
+ * Test that parameter checking works as expected.
+ *
+ * @see f_thread_semaphore_file_close()
+ */
+extern void test__f_thread_semaphore_file_close__parameter_checking(void **state);
+
+/**
+ * Test that function works.
+ *
+ * @see f_thread_semaphore_file_close()
+ */
+extern void test__f_thread_semaphore_file_close__works(void **state);
+
+#endif // _TEST__F_thread__semaphore_file_delete_h
--- /dev/null
+#include "test-thread.h"
+#include "test-thread-semaphore_file_delete.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void test__f_thread_semaphore_file_delete__fails(void **state) {
+
+ f_string_static_t name = macro_f_string_static_t_initialize("test", 0, 4);
+
+ int errnos[] = {
+ EACCES,
+ EINVAL,
+ ENAMETOOLONG,
+ ENOENT,
+ mock_errno_generic,
+ };
+
+ f_status_t statuss[] = {
+ F_status_set_error(F_access_denied),
+ F_status_set_error(F_parameter),
+ F_status_set_error(F_name_not),
+ F_file_found_not,
+ F_status_set_error(F_failure),
+ };
+
+ for (uint8_t i = 0; i < 5; ++i) {
+
+ will_return(__wrap_sem_unlink, true);
+ will_return(__wrap_sem_unlink, errnos[i]);
+
+ const f_status_t status = f_thread_semaphore_file_delete(name);
+
+ assert_int_equal(status, statuss[i]);
+ } // for
+}
+
+void test__f_thread_semaphore_file_delete__works(void **state) {
+
+ f_string_static_t name = macro_f_string_static_t_initialize("test", 0, 4);
+
+ {
+ will_return(__wrap_sem_unlink, false);
+
+ const f_status_t status = f_thread_semaphore_file_delete(name);
+
+ assert_int_equal(status, F_none);
+ }
+}
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
--- /dev/null
+/**
+ * FLL - Level 0
+ *
+ * Project: Thread
+ * API Version: 0.5
+ * Licenses: lgpl-2.1-or-later
+ *
+ * Test the thread project.
+ */
+#ifndef _TEST__F_thread__semaphore_file_destroy_h
+#define _TEST__F_thread__semaphore_file_destroy_h
+
+/**
+ * Test that function fails.
+ *
+ * @see f_thread_semaphore_file_delete()
+ */
+extern void test__f_thread_semaphore_file_delete__fails(void **state);
+
+/**
+ * Test that function works.
+ *
+ * @see f_thread_semaphore_file_delete()
+ */
+extern void test__f_thread_semaphore_file_delete__works(void **state);
+
+#endif // _TEST__F_thread__semaphore_file_destroy_h
--- /dev/null
+#include "test-thread.h"
+#include "test-thread-semaphore_file_open.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void test__f_thread_semaphore_file_open__fails(void **state) {
+
+ f_string_static_t name = macro_f_string_static_t_initialize("test", 0, 4);
+ f_thread_semaphore_t semaphore = f_thread_semaphore_t_initialize;
+ f_thread_semaphore_t *semaphore_ptr = &semaphore;
+ int flag = 0;
+ mode_t mode = 0;
+ unsigned value = 0;
+
+ int errnos[] = {
+ EACCES,
+ EEXIST,
+ EINVAL,
+ EMFILE,
+ ENAMETOOLONG,
+ ENFILE,
+ ENOENT,
+ ENOMEM,
+ mock_errno_generic,
+ };
+
+ f_status_t statuss[] = {
+ F_access_denied,
+ F_file_found,
+ F_parameter,
+ F_file_descriptor_max,
+ F_name_not,
+ F_file_open_max,
+ F_file_found_not,
+ F_memory_not,
+ F_failure,
+ };
+
+ for (uint8_t i = 0; i < 9; ++i) {
+
+ semaphore_ptr = &semaphore;
+
+ will_return(__wrap_sem_open, true);
+ will_return(__wrap_sem_open, errnos[i]);
+
+ const f_status_t status = f_thread_semaphore_file_open(name, flag, mode, value, &semaphore_ptr);
+
+ assert_int_equal(status, F_status_set_error(statuss[i]));
+ } // for
+
+ flag = O_CREAT;
+
+ for (uint8_t i = 0; i < 9; ++i) {
+
+ will_return(__wrap_sem_open, true);
+ will_return(__wrap_sem_open, errnos[i]);
+
+ const f_status_t status = f_thread_semaphore_file_open(name, flag, mode, value, &semaphore_ptr);
+
+ assert_int_equal(status, F_status_set_error(statuss[i]));
+ } // for
+}
+
+void test__f_thread_semaphore_file_open__parameter_checking(void **state) {
+
+ f_string_static_t name = macro_f_string_static_t_initialize("test", 0, 4);
+ int flag = 0;
+ mode_t mode = 0;
+ unsigned value = 0;
+
+ {
+ const f_status_t status = f_thread_semaphore_file_open(name, flag, mode, value, 0);
+
+ assert_int_equal(status, F_status_set_error(F_parameter));
+ }
+}
+
+void test__f_thread_semaphore_file_open__works(void **state) {
+
+ f_string_static_t name = macro_f_string_static_t_initialize("test", 0, 4);
+ f_thread_semaphore_t semaphore = f_thread_semaphore_t_initialize;
+ f_thread_semaphore_t *semaphore_ptr = &semaphore;
+ int flag = 0;
+ mode_t mode = 0;
+ unsigned value = 0;
+
+ {
+ will_return(__wrap_sem_open, false);
+
+ const f_status_t status = f_thread_semaphore_file_open(name, flag, mode, value, &semaphore_ptr);
+
+ assert_int_equal(status, F_none);
+ }
+
+ {
+ flag = O_CREAT;
+ semaphore_ptr = &semaphore;
+
+ will_return(__wrap_sem_open, false);
+
+ const f_status_t status = f_thread_semaphore_file_open(name, flag, mode, value, &semaphore_ptr);
+
+ assert_int_equal(status, F_none);
+ }
+}
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
--- /dev/null
+/**
+ * FLL - Level 0
+ *
+ * Project: Thread
+ * API Version: 0.5
+ * Licenses: lgpl-2.1-or-later
+ *
+ * Test the thread project.
+ */
+#ifndef _TEST__F_thread__semaphore_file_open_h
+#define _TEST__F_thread__semaphore_file_open_h
+
+/**
+ * Test that function fails.
+ *
+ * @see f_thread_semaphore_file_open()
+ */
+extern void test__f_thread_semaphore_file_open__fails(void **state);
+
+/**
+ * Test that parameter checking works as expected.
+ *
+ * @see f_thread_semaphore_file_open()
+ */
+extern void test__f_thread_semaphore_file_open__parameter_checking(void **state);
+
+/**
+ * Test that function works.
+ *
+ * @see f_thread_semaphore_file_open()
+ */
+extern void test__f_thread_semaphore_file_open__works(void **state);
+
+#endif // _TEST__F_thread__semaphore_file_open_h
--- /dev/null
+#include "test-thread.h"
+#include "test-thread-semaphore_lock.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void test__f_thread_semaphore_lock__fails(void **state) {
+
+ f_thread_semaphore_t semaphore = f_thread_semaphore_t_initialize;
+
+ int errnos[] = {
+ EINTR,
+ EINVAL,
+ mock_errno_generic,
+ };
+
+ f_status_t statuss[] = {
+ F_interrupt,
+ F_parameter,
+ F_failure,
+ };
+
+ for (uint8_t i = 0; i < 3; ++i) {
+
+ will_return(__wrap_sem_wait, true);
+ will_return(__wrap_sem_wait, errnos[i]);
+
+ const f_status_t status = f_thread_semaphore_lock(&semaphore);
+
+ assert_int_equal(status, F_status_set_error(statuss[i]));
+ } // for
+}
+
+void test__f_thread_semaphore_lock__parameter_checking(void **state) {
+
+ {
+ const f_status_t status = f_thread_semaphore_lock(0);
+
+ assert_int_equal(status, F_status_set_error(F_parameter));
+ }
+}
+
+void test__f_thread_semaphore_lock__works(void **state) {
+
+ f_thread_semaphore_t semaphore = f_thread_semaphore_t_initialize;
+
+ {
+ will_return(__wrap_sem_wait, false);
+
+ const f_status_t status = f_thread_semaphore_lock(&semaphore);
+
+ assert_int_equal(status, F_none);
+ }
+}
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
--- /dev/null
+/**
+ * FLL - Level 0
+ *
+ * Project: Thread
+ * API Version: 0.5
+ * Licenses: lgpl-2.1-or-later
+ *
+ * Test the thread project.
+ */
+#ifndef _TEST__F_thread__semaphore_lock_h
+#define _TEST__F_thread__semaphore_lock_h
+
+/**
+ * Test that function fails.
+ *
+ * @see f_thread_semaphore_lock()
+ */
+extern void test__f_thread_semaphore_lock__fails(void **state);
+
+/**
+ * Test that parameter checking works as expected.
+ *
+ * @see f_thread_semaphore_lock()
+ */
+extern void test__f_thread_semaphore_lock__parameter_checking(void **state);
+
+/**
+ * Test that function works.
+ *
+ * @see f_thread_semaphore_lock()
+ */
+extern void test__f_thread_semaphore_lock__works(void **state);
+
+#endif // _TEST__F_thread__semaphore_lock_h
--- /dev/null
+#include "test-thread.h"
+#include "test-thread-semaphore_lock_timed.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void test__f_thread_semaphore_lock_timed__fails(void **state) {
+
+ f_thread_semaphore_t semaphore = f_thread_semaphore_t_initialize;
+ struct timespec timeout;
+
+ memset(&timeout, 0, sizeof(struct timespec));
+
+ int errnos[] = {
+ EINTR,
+ EINVAL,
+ ETIMEDOUT,
+ mock_errno_generic,
+ };
+
+ f_status_t statuss[] = {
+ F_status_set_error(F_interrupt),
+ F_status_set_error(F_parameter),
+ F_time,
+ F_status_set_error(F_failure),
+ };
+
+ for (uint8_t i = 0; i < 4; ++i) {
+
+ will_return(__wrap_sem_timedwait, true);
+ will_return(__wrap_sem_timedwait, errnos[i]);
+
+ const f_status_t status = f_thread_semaphore_lock_timed(&timeout, &semaphore);
+
+ assert_int_equal(status, statuss[i]);
+ } // for
+}
+
+void test__f_thread_semaphore_lock_timed__parameter_checking(void **state) {
+
+ f_thread_semaphore_t semaphore = f_thread_semaphore_t_initialize;
+ struct timespec timeout;
+
+ memset(&timeout, 0, sizeof(struct timespec));
+
+ {
+ const f_status_t status = f_thread_semaphore_lock_timed(0, 0);
+
+ assert_int_equal(status, F_status_set_error(F_parameter));
+ }
+
+ {
+ const f_status_t status = f_thread_semaphore_lock_timed(&timeout, 0);
+
+ assert_int_equal(status, F_status_set_error(F_parameter));
+ }
+
+ {
+ const f_status_t status = f_thread_semaphore_lock_timed(0, &semaphore);
+
+ assert_int_equal(status, F_status_set_error(F_parameter));
+ }
+}
+
+void test__f_thread_semaphore_lock_timed__works(void **state) {
+
+ f_thread_semaphore_t semaphore = f_thread_semaphore_t_initialize;
+ struct timespec timeout;
+
+ memset(&timeout, 0, sizeof(struct timespec));
+
+ {
+ will_return(__wrap_sem_timedwait, false);
+
+ const f_status_t status = f_thread_semaphore_lock_timed(&timeout, &semaphore);
+
+ assert_int_equal(status, F_none);
+ }
+}
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
--- /dev/null
+/**
+ * FLL - Level 0
+ *
+ * Project: Thread
+ * API Version: 0.5
+ * Licenses: lgpl-2.1-or-later
+ *
+ * Test the thread project.
+ */
+#ifndef _TEST__F_thread__semaphore_lock_timed_h
+#define _TEST__F_thread__semaphore_lock_timed_h
+
+/**
+ * Test that function fails.
+ *
+ * @see f_thread_semaphore_lock_timed()
+ */
+extern void test__f_thread_semaphore_lock_timed__fails(void **state);
+
+/**
+ * Test that parameter checking works as expected.
+ *
+ * @see f_thread_semaphore_lock_timed()
+ */
+extern void test__f_thread_semaphore_lock_timed__parameter_checking(void **state);
+
+/**
+ * Test that function works.
+ *
+ * @see f_thread_semaphore_lock_timed()
+ */
+extern void test__f_thread_semaphore_lock_timed__works(void **state);
+
+#endif // _TEST__F_thread__semaphore_lock_timed_h
--- /dev/null
+#include "test-thread.h"
+#include "test-thread-semaphore_lock_try.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void test__f_thread_semaphore_lock_try__fails(void **state) {
+
+ f_thread_semaphore_t semaphore = f_thread_semaphore_t_initialize;
+
+ int errnos[] = {
+ EAGAIN,
+ EINTR,
+ EINVAL,
+ mock_errno_generic,
+ };
+
+ f_status_t statuss[] = {
+ F_resource_not,
+ F_interrupt,
+ F_parameter,
+ F_failure,
+ };
+
+ for (uint8_t i = 0; i < 4; ++i) {
+
+ will_return(__wrap_sem_trywait, true);
+ will_return(__wrap_sem_trywait, errnos[i]);
+
+ const f_status_t status = f_thread_semaphore_lock_try(&semaphore);
+
+ assert_int_equal(status, F_status_set_error(statuss[i]));
+ } // for
+}
+
+void test__f_thread_semaphore_lock_try__parameter_checking(void **state) {
+
+ {
+ const f_status_t status = f_thread_semaphore_lock_try(0);
+
+ assert_int_equal(status, F_status_set_error(F_parameter));
+ }
+}
+
+void test__f_thread_semaphore_lock_try__works(void **state) {
+
+ f_thread_semaphore_t semaphore = f_thread_semaphore_t_initialize;
+
+ {
+ will_return(__wrap_sem_trywait, false);
+
+ const f_status_t status = f_thread_semaphore_lock_try(&semaphore);
+
+ assert_int_equal(status, F_none);
+ }
+}
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
--- /dev/null
+/**
+ * FLL - Level 0
+ *
+ * Project: Thread
+ * API Version: 0.5
+ * Licenses: lgpl-2.1-or-later
+ *
+ * Test the thread project.
+ */
+#ifndef _TEST__F_thread__semaphore_lock_try_h
+#define _TEST__F_thread__semaphore_lock_try_h
+
+/**
+ * Test that function fails.
+ *
+ * @see f_thread_semaphore_lock_try()
+ */
+extern void test__f_thread_semaphore_lock_try__fails(void **state);
+
+/**
+ * Test that parameter checking works as expected.
+ *
+ * @see f_thread_semaphore_lock_try()
+ */
+extern void test__f_thread_semaphore_lock_try__parameter_checking(void **state);
+
+/**
+ * Test that function works.
+ *
+ * @see f_thread_semaphore_lock_try()
+ */
+extern void test__f_thread_semaphore_lock_try__works(void **state);
+
+#endif // _TEST__F_thread__semaphore_lock_try_h
--- /dev/null
+#include "test-thread.h"
+#include "test-thread-semaphore_unlock.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void test__f_thread_semaphore_unlock__fails(void **state) {
+
+ f_thread_semaphore_t semaphore = f_thread_semaphore_t_initialize;
+
+ int errnos[] = {
+ EOVERFLOW,
+ EINVAL,
+ mock_errno_generic,
+ };
+
+ f_status_t statuss[] = {
+ F_number_overflow,
+ F_parameter,
+ F_failure,
+ };
+
+ for (uint8_t i = 0; i < 3; ++i) {
+
+ will_return(__wrap_sem_post, true);
+ will_return(__wrap_sem_post, errnos[i]);
+
+ const f_status_t status = f_thread_semaphore_unlock(&semaphore);
+
+ assert_int_equal(status, F_status_set_error(statuss[i]));
+ } // for
+}
+
+void test__f_thread_semaphore_unlock__parameter_checking(void **state) {
+
+ {
+ const f_status_t status = f_thread_semaphore_unlock(0);
+
+ assert_int_equal(status, F_status_set_error(F_parameter));
+ }
+}
+
+void test__f_thread_semaphore_unlock__works(void **state) {
+
+ f_thread_semaphore_t semaphore = f_thread_semaphore_t_initialize;
+
+ {
+ will_return(__wrap_sem_post, false);
+
+ const f_status_t status = f_thread_semaphore_unlock(&semaphore);
+
+ assert_int_equal(status, F_none);
+ }
+}
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
--- /dev/null
+/**
+ * FLL - Level 0
+ *
+ * Project: Thread
+ * API Version: 0.5
+ * Licenses: lgpl-2.1-or-later
+ *
+ * Test the thread project.
+ */
+#ifndef _TEST__F_thread__semaphore_unlock_h
+#define _TEST__F_thread__semaphore_unlock_h
+
+/**
+ * Test that function fails.
+ *
+ * @see f_thread_semaphore_unlock()
+ */
+extern void test__f_thread_semaphore_unlock__fails(void **state);
+
+/**
+ * Test that parameter checking works as expected.
+ *
+ * @see f_thread_semaphore_unlock()
+ */
+extern void test__f_thread_semaphore_unlock__parameter_checking(void **state);
+
+/**
+ * Test that function works.
+ *
+ * @see f_thread_semaphore_unlock()
+ */
+extern void test__f_thread_semaphore_unlock__works(void **state);
+
+#endif // _TEST__F_thread__semaphore_unlock_h
--- /dev/null
+#include "test-thread.h"
+#include "test-thread-semaphore_value_get.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void test__f_thread_semaphore_value_get__fails(void **state) {
+
+ f_thread_semaphore_t semaphore = f_thread_semaphore_t_initialize;
+ int value = 0;
+
+ int errnos[] = {
+ EINVAL,
+ mock_errno_generic,
+ };
+
+ f_status_t statuss[] = {
+ F_parameter,
+ F_failure,
+ };
+
+ for (uint8_t i = 0; i < 2; ++i) {
+
+ will_return(__wrap_sem_getvalue, true);
+ will_return(__wrap_sem_getvalue, errnos[i]);
+
+ const f_status_t status = f_thread_semaphore_value_get(&semaphore, &value);
+
+ assert_int_equal(status, F_status_set_error(statuss[i]));
+ } // for
+}
+
+void test__f_thread_semaphore_value_get__parameter_checking(void **state) {
+
+ f_thread_semaphore_t semaphore = f_thread_semaphore_t_initialize;
+ int value = 0;
+
+ {
+ const f_status_t status = f_thread_semaphore_value_get(0, 0);
+
+ assert_int_equal(status, F_status_set_error(F_parameter));
+ }
+
+ {
+ const f_status_t status = f_thread_semaphore_value_get(&semaphore, 0);
+
+ assert_int_equal(status, F_status_set_error(F_parameter));
+ }
+
+ {
+ const f_status_t status = f_thread_semaphore_value_get(0, &value);
+
+ assert_int_equal(status, F_status_set_error(F_parameter));
+ }
+}
+
+void test__f_thread_semaphore_value_get__works(void **state) {
+
+ f_thread_semaphore_t semaphore = f_thread_semaphore_t_initialize;
+ int value = 0;
+
+ {
+ will_return(__wrap_sem_getvalue, false);
+
+ const f_status_t status = f_thread_semaphore_value_get(&semaphore, &value);
+
+ assert_int_equal(status, F_none);
+ }
+}
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
--- /dev/null
+/**
+ * FLL - Level 0
+ *
+ * Project: Thread
+ * API Version: 0.5
+ * Licenses: lgpl-2.1-or-later
+ *
+ * Test the thread project.
+ */
+#ifndef _TEST__F_thread__semaphore_value_get_h
+#define _TEST__F_thread__semaphore_value_get_h
+
+/**
+ * Test that function fails.
+ *
+ * @see f_thread_semaphore_value_get()
+ */
+extern void test__f_thread_semaphore_value_get__fails(void **state);
+
+/**
+ * Test that parameter checking works as expected.
+ *
+ * @see f_thread_semaphore_value_get()
+ */
+extern void test__f_thread_semaphore_value_get__parameter_checking(void **state);
+
+/**
+ * Test that function works.
+ *
+ * @see f_thread_semaphore_value_get()
+ */
+extern void test__f_thread_semaphore_value_get__works(void **state);
+
+#endif // _TEST__F_thread__semaphore_value_get_h
--- /dev/null
+#include "test-thread.h"
+#include "test-thread-signal_mask.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void test__f_thread_signal_mask__fails(void **state) {
+
+ int how = 0;
+ sigset_t next;
+ sigset_t current;
+
+ memset(&next, 0, sizeof(sigset_t));
+ memset(¤t, 0, sizeof(sigset_t));
+
+ int errnos[] = {
+ EFAULT,
+ EINVAL,
+ mock_errno_generic,
+ };
+
+ f_status_t statuss[] = {
+ F_buffer,
+ F_parameter,
+ F_failure,
+ };
+
+ for (uint8_t i = 0; i < 3; ++i) {
+
+ will_return(__wrap_pthread_sigmask, true);
+ will_return(__wrap_pthread_sigmask, errnos[i]);
+
+ const f_status_t status = f_thread_signal_mask(how, &next, ¤t);
+
+ assert_int_equal(status, F_status_set_error(statuss[i]));
+ } // for
+}
+
+void test__f_thread_signal_mask__parameter_checking(void **state) {
+
+ int how = 0;
+ sigset_t next;
+ sigset_t current;
+
+ memset(&next, 0, sizeof(sigset_t));
+ memset(¤t, 0, sizeof(sigset_t));
+
+ {
+ const f_status_t status = f_thread_signal_mask(how, 0, 0);
+
+ assert_int_equal(status, F_status_set_error(F_parameter));
+ }
+
+ {
+ will_return(__wrap_pthread_sigmask, false);
+
+ const f_status_t status = f_thread_signal_mask(how, &next, 0);
+
+ assert_int_equal(status, F_none);
+ }
+
+ {
+ will_return(__wrap_pthread_sigmask, false);
+
+ const f_status_t status = f_thread_signal_mask(how, 0, ¤t);
+
+ assert_int_equal(status, F_none);
+ }
+}
+
+void test__f_thread_signal_mask__works(void **state) {
+
+ int how = 0;
+ sigset_t next;
+ sigset_t current;
+
+ memset(&next, 0, sizeof(sigset_t));
+ memset(¤t, 0, sizeof(sigset_t));
+
+ {
+ will_return(__wrap_pthread_sigmask, false);
+
+ const f_status_t status = f_thread_signal_mask(how, &next, ¤t);
+
+ assert_int_equal(status, F_none);
+ }
+}
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
--- /dev/null
+/**
+ * FLL - Level 0
+ *
+ * Project: Thread
+ * API Version: 0.5
+ * Licenses: lgpl-2.1-or-later
+ *
+ * Test the thread project.
+ */
+#ifndef _TEST__F_thread__signal_mask_h
+#define _TEST__F_thread__signal_mask_h
+
+/**
+ * Test that function fails.
+ *
+ * @see f_thread_signal_mask()
+ */
+extern void test__f_thread_signal_mask__fails(void **state);
+
+/**
+ * Test that parameter checking works as expected.
+ *
+ * @see f_thread_signal_mask()
+ */
+extern void test__f_thread_signal_mask__parameter_checking(void **state);
+
+/**
+ * Test that function works.
+ *
+ * @see f_thread_signal_mask()
+ */
+extern void test__f_thread_signal_mask__works(void **state);
+
+#endif // _TEST__F_thread__signal_mask_h
--- /dev/null
+#include "test-thread.h"
+#include "test-thread-signal_queue.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void test__f_thread_signal_queue__fails(void **state) {
+
+ f_thread_id_t id = f_thread_id_t_initialize;
+ int signal = 0;
+ union sigval value;
+
+ memset(&value, 0, sizeof(union sigval));
+
+ #ifdef _pthread_sigqueue_unsupported_
+ const f_status_t status = f_thread_signal_queue(id, signal, value);
+
+ assert_int_equal(status, F_status_set_error(F_implemented_not));
+ #else
+ {
+ int errnos[] = {
+ EAGAIN,
+ ENOSYS,
+ EINVAL,
+ ESRCH,
+ mock_errno_generic,
+ };
+
+ f_status_t statuss[] = {
+ F_resource_not,
+ F_supported_not,
+ F_parameter,
+ F_found_not,
+ F_failure,
+ };
+
+ for (uint8_t i = 0; i < 5; ++i) {
+
+ will_return(__wrap_pthread_sigqueue, true);
+ will_return(__wrap_pthread_sigqueue, errnos[i]);
+
+ const f_status_t status = f_thread_signal_queue(id, signal, value);
+
+ assert_int_equal(status, F_status_set_error(statuss[i]));
+ } // for
+ }
+ #endif // _pthread_sigqueue_unsupported_
+}
+
+void test__f_thread_signal_queue__works(void **state) {
+
+ f_thread_id_t id = f_thread_id_t_initialize;
+ int signal = 0;
+ union sigval value;
+
+ memset(&value, 0, sizeof(union sigval));
+
+ #ifdef _pthread_sigqueue_unsupported_
+ const f_status_t status = f_thread_signal_queue(id, signal, value);
+
+ assert_int_equal(status, F_status_set_error(F_implemented_not));
+ #else
+ {
+ will_return(__wrap_pthread_sigqueue, false);
+
+ const f_status_t status = f_thread_signal_queue(id, signal, value);
+
+ assert_int_equal(status, F_none);
+ }
+ #endif // _pthread_sigqueue_unsupported_
+}
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
--- /dev/null
+/**
+ * FLL - Level 0
+ *
+ * Project: Thread
+ * API Version: 0.5
+ * Licenses: lgpl-2.1-or-later
+ *
+ * Test the thread project.
+ */
+#ifndef _TEST__F_thread__signal_queue_h
+#define _TEST__F_thread__signal_queue_h
+
+/**
+ * Test that function fails.
+ *
+ * @see f_thread_signal_queue()
+ */
+extern void test__f_thread_signal_queue__fails(void **state);
+
+/**
+ * Test that parameter checking works as expected.
+ *
+ * @see f_thread_signal_queue()
+ */
+extern void test__f_thread_signal_queue__parameter_checking(void **state);
+
+/**
+ * Test that function works.
+ *
+ * @see f_thread_signal_queue()
+ */
+extern void test__f_thread_signal_queue__works(void **state);
+
+#endif // _TEST__F_thread__signal_queue_h
--- /dev/null
+#include "test-thread.h"
+#include "test-thread-signal_write.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void test__f_thread_signal_write__fails(void **state) {
+
+ f_thread_id_t id = f_thread_id_t_initialize;
+ int signal = 1;
+
+ {
+ int errnos[] = {
+ EINVAL,
+ ESRCH,
+ mock_errno_generic,
+ };
+
+ f_status_t statuss[] = {
+ F_parameter,
+ F_found_not,
+ F_failure,
+ };
+
+ for (uint8_t i = 0; i < 3; ++i) {
+
+ will_return(__wrap_pthread_kill, true);
+ will_return(__wrap_pthread_kill, errnos[i]);
+
+ const f_status_t status = f_thread_signal_write(id, signal);
+
+ assert_int_equal(status, F_status_set_error(statuss[i]));
+ } // for
+ }
+
+ {
+ signal = 0;
+
+ int errnos[] = {
+ EINVAL,
+ ESRCH,
+ mock_errno_generic,
+ };
+
+ f_status_t statuss[] = {
+ F_status_set_error(F_parameter),
+ F_found_not,
+ F_status_set_error(F_failure),
+ };
+
+ for (uint8_t i = 0; i < 3; ++i) {
+
+ will_return(__wrap_pthread_kill, true);
+ will_return(__wrap_pthread_kill, errnos[i]);
+
+ const f_status_t status = f_thread_signal_write(id, signal);
+
+ assert_int_equal(status, statuss[i]);
+ } // for
+ }
+}
+
+void test__f_thread_signal_write__works(void **state) {
+
+ f_thread_id_t id = f_thread_id_t_initialize;
+ int signal = 1;
+
+ {
+ will_return(__wrap_pthread_kill, false);
+
+ const f_status_t status = f_thread_signal_write(id, signal);
+
+ assert_int_equal(status, F_none);
+ }
+
+ {
+ signal = 0;
+
+ will_return(__wrap_pthread_kill, false);
+
+ const f_status_t status = f_thread_signal_write(id, signal);
+
+ assert_int_equal(status, F_found);
+ }
+}
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
--- /dev/null
+/**
+ * FLL - Level 0
+ *
+ * Project: Thread
+ * API Version: 0.5
+ * Licenses: lgpl-2.1-or-later
+ *
+ * Test the thread project.
+ */
+#ifndef _TEST__F_thread__signal_write_h
+#define _TEST__F_thread__signal_write_h
+
+/**
+ * Test that function fails.
+ *
+ * @see f_thread_signal_write()
+ */
+extern void test__f_thread_signal_write__fails(void **state);
+
+/**
+ * Test that function works.
+ *
+ * @see f_thread_signal_write()
+ */
+extern void test__f_thread_signal_write__works(void **state);
+
+#endif // _TEST__F_thread__signal_write_h
--- /dev/null
+#include "test-thread.h"
+#include "test-thread-spin_create.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void test__f_thread_spin_create__fails(void **state) {
+
+ f_thread_spin_t spin = f_thread_spin_t_initialize;
+ int shared = 0;
+
+ int errnos[] = {
+ EAGAIN,
+ ENOMEM,
+ mock_errno_generic,
+ };
+
+ f_status_t statuss[] = {
+ F_resource_not,
+ F_memory_not,
+ F_failure,
+ };
+
+ for (uint8_t i = 0; i < 3; ++i) {
+
+ will_return(__wrap_pthread_spin_init, true);
+ will_return(__wrap_pthread_spin_init, errnos[i]);
+
+ const f_status_t status = f_thread_spin_create(shared, &spin);
+
+ assert_int_equal(status, F_status_set_error(statuss[i]));
+ } // for
+}
+
+void test__f_thread_spin_create__parameter_checking(void **state) {
+
+ int shared = 0;
+
+ {
+ const f_status_t status = f_thread_spin_create(shared, 0);
+
+ assert_int_equal(status, F_status_set_error(F_parameter));
+ }
+}
+
+void test__f_thread_spin_create__works(void **state) {
+
+ f_thread_spin_t spin = f_thread_spin_t_initialize;
+ int shared = 0;
+
+ {
+ will_return(__wrap_pthread_spin_init, false);
+
+ const f_status_t status = f_thread_spin_create(shared, &spin);
+
+ assert_int_equal(status, F_none);
+ }
+}
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
--- /dev/null
+/**
+ * FLL - Level 0
+ *
+ * Project: Thread
+ * API Version: 0.5
+ * Licenses: lgpl-2.1-or-later
+ *
+ * Test the thread project.
+ */
+#ifndef _TEST__F_thread__spin_create_h
+#define _TEST__F_thread__spin_create_h
+
+/**
+ * Test that function fails.
+ *
+ * @see f_thread_spin_create()
+ */
+extern void test__f_thread_spin_create__fails(void **state);
+
+/**
+ * Test that parameter checking works as expected.
+ *
+ * @see f_thread_spin_create()
+ */
+extern void test__f_thread_spin_create__parameter_checking(void **state);
+
+/**
+ * Test that function works.
+ *
+ * @see f_thread_spin_create()
+ */
+extern void test__f_thread_spin_create__works(void **state);
+
+#endif // _TEST__F_thread__spin_create_h
--- /dev/null
+#include "test-thread.h"
+#include "test-thread-spin_delete.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void test__f_thread_spin_delete__fails(void **state) {
+
+ f_thread_spin_t spin = f_thread_spin_t_initialize;
+
+ int errnos[] = {
+ EBUSY,
+ EINVAL,
+ mock_errno_generic,
+ };
+
+ f_status_t statuss[] = {
+ F_busy,
+ F_parameter,
+ F_failure,
+ };
+
+ for (uint8_t i = 0; i < 3; ++i) {
+
+ will_return(__wrap_pthread_spin_destroy, true);
+ will_return(__wrap_pthread_spin_destroy, errnos[i]);
+
+ const f_status_t status = f_thread_spin_delete(&spin);
+
+ assert_int_equal(status, F_status_set_error(statuss[i]));
+ } // for
+}
+
+void test__f_thread_spin_delete__parameter_checking(void **state) {
+
+ {
+ const f_status_t status = f_thread_spin_delete(0);
+
+ assert_int_equal(status, F_status_set_error(F_parameter));
+ }
+}
+
+void test__f_thread_spin_delete__works(void **state) {
+
+ f_thread_spin_t spin = f_thread_spin_t_initialize;
+
+ {
+ will_return(__wrap_pthread_spin_destroy, false);
+
+ const f_status_t status = f_thread_spin_delete(&spin);
+
+ assert_int_equal(status, F_none);
+ }
+}
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
--- /dev/null
+/**
+ * FLL - Level 0
+ *
+ * Project: Thread
+ * API Version: 0.5
+ * Licenses: lgpl-2.1-or-later
+ *
+ * Test the thread project.
+ */
+#ifndef _TEST__F_thread__spin_delete_h
+#define _TEST__F_thread__spin_delete_h
+
+/**
+ * Test that function fails.
+ *
+ * @see f_thread_spin_delete()
+ */
+extern void test__f_thread_spin_delete__fails(void **state);
+
+/**
+ * Test that parameter checking works as expected.
+ *
+ * @see f_thread_spin_delete()
+ */
+extern void test__f_thread_spin_delete__parameter_checking(void **state);
+
+/**
+ * Test that function works.
+ *
+ * @see f_thread_spin_delete()
+ */
+extern void test__f_thread_spin_delete__works(void **state);
+
+#endif // _TEST__F_thread__spin_delete_h
--- /dev/null
+#include "test-thread.h"
+#include "test-thread-spin_lock.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void test__f_thread_spin_lock__fails(void **state) {
+
+ f_thread_spin_t spin = f_thread_spin_t_initialize;
+
+ int errnos[] = {
+ EAGAIN,
+ EDEADLK,
+ EINVAL,
+ mock_errno_generic,
+ };
+
+ f_status_t statuss[] = {
+ F_resource_not,
+ F_deadlock,
+ F_parameter,
+ F_failure,
+ };
+
+ for (uint8_t i = 0; i < 4; ++i) {
+
+ will_return(__wrap_pthread_spin_lock, true);
+ will_return(__wrap_pthread_spin_lock, errnos[i]);
+
+ const f_status_t status = f_thread_spin_lock(&spin);
+
+ assert_int_equal(status, F_status_set_error(statuss[i]));
+ } // for
+}
+
+void test__f_thread_spin_lock__parameter_checking(void **state) {
+
+ {
+ const f_status_t status = f_thread_spin_lock(0);
+
+ assert_int_equal(status, F_status_set_error(F_parameter));
+ }
+}
+
+void test__f_thread_spin_lock__works(void **state) {
+
+ f_thread_spin_t spin = f_thread_spin_t_initialize;
+
+ {
+ will_return(__wrap_pthread_spin_lock, false);
+
+ const f_status_t status = f_thread_spin_lock(&spin);
+
+ assert_int_equal(status, F_none);
+ }
+}
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
--- /dev/null
+/**
+ * FLL - Level 0
+ *
+ * Project: Thread
+ * API Version: 0.5
+ * Licenses: lgpl-2.1-or-later
+ *
+ * Test the thread project.
+ */
+#ifndef _TEST__F_thread__spin_lock_h
+#define _TEST__F_thread__spin_lock_h
+
+/**
+ * Test that function fails.
+ *
+ * @see f_thread_spin_lock()
+ */
+extern void test__f_thread_spin_lock__fails(void **state);
+
+/**
+ * Test that parameter checking works as expected.
+ *
+ * @see f_thread_spin_lock()
+ */
+extern void test__f_thread_spin_lock__parameter_checking(void **state);
+
+/**
+ * Test that function works.
+ *
+ * @see f_thread_spin_lock()
+ */
+extern void test__f_thread_spin_lock__works(void **state);
+
+#endif // _TEST__F_thread__spin_lock_h
--- /dev/null
+#include "test-thread.h"
+#include "test-thread-spin_lock_try.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void test__f_thread_spin_lock_try__fails(void **state) {
+
+ f_thread_spin_t spin = f_thread_spin_t_initialize;
+
+ int errnos[] = {
+ EAGAIN,
+ EBUSY,
+ EINVAL,
+ mock_errno_generic,
+ };
+
+ f_status_t statuss[] = {
+ F_status_set_error(F_resource_not),
+ F_busy,
+ F_status_set_error(F_parameter),
+ F_status_set_error(F_failure),
+ };
+
+ for (uint8_t i = 0; i < 4; ++i) {
+
+ will_return(__wrap_pthread_spin_trylock, true);
+ will_return(__wrap_pthread_spin_trylock, errnos[i]);
+
+ const f_status_t status = f_thread_spin_lock_try(&spin);
+
+ assert_int_equal(status, statuss[i]);
+ } // for
+}
+
+void test__f_thread_spin_lock_try__parameter_checking(void **state) {
+
+ {
+ const f_status_t status = f_thread_spin_lock_try(0);
+
+ assert_int_equal(status, F_status_set_error(F_parameter));
+ }
+}
+
+void test__f_thread_spin_lock_try__works(void **state) {
+
+ f_thread_spin_t spin = f_thread_spin_t_initialize;
+
+ {
+ will_return(__wrap_pthread_spin_trylock, false);
+
+ const f_status_t status = f_thread_spin_lock_try(&spin);
+
+ assert_int_equal(status, F_none);
+ }
+}
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
--- /dev/null
+/**
+ * FLL - Level 0
+ *
+ * Project: Thread
+ * API Version: 0.5
+ * Licenses: lgpl-2.1-or-later
+ *
+ * Test the thread project.
+ */
+#ifndef _TEST__F_thread__spin_lock_try_h
+#define _TEST__F_thread__spin_lock_try_h
+
+/**
+ * Test that function fails.
+ *
+ * @see f_thread_spin_lock_try()
+ */
+extern void test__f_thread_spin_lock_try__fails(void **state);
+
+/**
+ * Test that parameter checking works as expected.
+ *
+ * @see f_thread_spin_lock_try()
+ */
+extern void test__f_thread_spin_lock_try__parameter_checking(void **state);
+
+/**
+ * Test that function works.
+ *
+ * @see f_thread_spin_lock_try()
+ */
+extern void test__f_thread_spin_lock_try__works(void **state);
+
+#endif // _TEST__F_thread__spin_lock_try_h
--- /dev/null
+#include "test-thread.h"
+#include "test-thread-spin_unlock.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void test__f_thread_spin_unlock__fails(void **state) {
+
+ f_thread_spin_t spin = f_thread_spin_t_initialize;
+
+ int errnos[] = {
+ EAGAIN,
+ EBUSY,
+ EINVAL,
+ EPERM,
+ mock_errno_generic,
+ };
+
+ f_status_t statuss[] = {
+ F_resource_not,
+ F_busy,
+ F_parameter,
+ F_prohibited,
+ F_failure,
+ };
+
+ for (uint8_t i = 0; i < 5; ++i) {
+
+ will_return(__wrap_pthread_spin_unlock, true);
+ will_return(__wrap_pthread_spin_unlock, errnos[i]);
+
+ const f_status_t status = f_thread_spin_unlock(&spin);
+
+ assert_int_equal(status, F_status_set_error(statuss[i]));
+ } // for
+}
+
+void test__f_thread_spin_unlock__parameter_checking(void **state) {
+
+ {
+ const f_status_t status = f_thread_spin_unlock(0);
+
+ assert_int_equal(status, F_status_set_error(F_parameter));
+ }
+}
+
+void test__f_thread_spin_unlock__works(void **state) {
+
+ f_thread_spin_t spin = f_thread_spin_t_initialize;
+
+ {
+ will_return(__wrap_pthread_spin_unlock, false);
+
+ const f_status_t status = f_thread_spin_unlock(&spin);
+
+ assert_int_equal(status, F_none);
+ }
+}
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
--- /dev/null
+/**
+ * FLL - Level 0
+ *
+ * Project: Thread
+ * API Version: 0.5
+ * Licenses: lgpl-2.1-or-later
+ *
+ * Test the thread project.
+ */
+#ifndef _TEST__F_thread__spin_unlock_h
+#define _TEST__F_thread__spin_unlock_h
+
+/**
+ * Test that function fails.
+ *
+ * @see f_thread_spin_unlock()
+ */
+extern void test__f_thread_spin_unlock__fails(void **state);
+
+/**
+ * Test that parameter checking works as expected.
+ *
+ * @see f_thread_spin_unlock()
+ */
+extern void test__f_thread_spin_unlock__parameter_checking(void **state);
+
+/**
+ * Test that function works.
+ *
+ * @see f_thread_spin_unlock()
+ */
+extern void test__f_thread_spin_unlock__works(void **state);
+
+#endif // _TEST__F_thread__spin_unlock_h
}
{
+ for (uint8_t i = 0; i < length; ++i) {
+ will_return(__wrap_pthread_spin_destroy, false);
+ } // for
+
const f_status_t status = f_thread_spins_decimate_by(length, &data);
assert_int_equal(status, F_none);
}
{
+ for (uint8_t i = 0; i < length; ++i) {
+ will_return(__wrap_pthread_spin_destroy, false);
+ } // for
+
const f_status_t status = f_thread_spins_decrease_by(length, &data);
assert_int_equal(status, F_none);
cmocka_unit_test(test__f_thread_mutex_lock_try__fails),
cmocka_unit_test(test__f_thread_mutex_lock_try__works),
+ cmocka_unit_test(test__f_thread_mutex_priority_ceiling_get__fails),
+ cmocka_unit_test(test__f_thread_mutex_priority_ceiling_get__works),
+
+ cmocka_unit_test(test__f_thread_mutex_priority_ceiling_set__fails),
+ cmocka_unit_test(test__f_thread_mutex_priority_ceiling_set__works),
+
+ cmocka_unit_test(test__f_thread_once__fails),
+ cmocka_unit_test(test__f_thread_once__works),
+
+ cmocka_unit_test(test__f_thread_scheduler_parameter_get__fails),
+ cmocka_unit_test(test__f_thread_scheduler_parameter_get__works),
+
+ cmocka_unit_test(test__f_thread_scheduler_parameter_set__fails),
+ cmocka_unit_test(test__f_thread_scheduler_parameter_set__works),
+
+ cmocka_unit_test(test__f_thread_scheduler_priority_set__fails),
+ cmocka_unit_test(test__f_thread_scheduler_priority_set__works),
+
+ cmocka_unit_test(test__f_thread_semaphore_create__fails),
+ cmocka_unit_test(test__f_thread_semaphore_create__works),
+
+ cmocka_unit_test(test__f_thread_semaphore_delete__fails),
+ cmocka_unit_test(test__f_thread_semaphore_delete__works),
+
+ cmocka_unit_test(test__f_thread_semaphore_file_close__fails),
+ cmocka_unit_test(test__f_thread_semaphore_file_close__works),
+
+ cmocka_unit_test(test__f_thread_semaphore_file_delete__fails),
+ cmocka_unit_test(test__f_thread_semaphore_file_delete__works),
+
+ cmocka_unit_test(test__f_thread_semaphore_file_open__fails),
+ cmocka_unit_test(test__f_thread_semaphore_file_open__works),
+
+ cmocka_unit_test(test__f_thread_semaphore_lock__fails),
+ cmocka_unit_test(test__f_thread_semaphore_lock__works),
+
+ cmocka_unit_test(test__f_thread_semaphore_lock_timed__fails),
+ cmocka_unit_test(test__f_thread_semaphore_lock_timed__works),
+
+ cmocka_unit_test(test__f_thread_semaphore_lock_try__fails),
+ cmocka_unit_test(test__f_thread_semaphore_lock_try__works),
+
+ cmocka_unit_test(test__f_thread_semaphore_unlock__fails),
+ cmocka_unit_test(test__f_thread_semaphore_unlock__works),
+
+ cmocka_unit_test(test__f_thread_semaphore_value_get__fails),
+ cmocka_unit_test(test__f_thread_semaphore_value_get__works),
+
+ cmocka_unit_test(test__f_thread_signal_mask__fails),
+ cmocka_unit_test(test__f_thread_signal_mask__works),
+
+ cmocka_unit_test(test__f_thread_signal_queue__fails),
+ cmocka_unit_test(test__f_thread_signal_queue__works),
+
+ cmocka_unit_test(test__f_thread_signal_write__fails),
+ cmocka_unit_test(test__f_thread_signal_write__works),
+
+ cmocka_unit_test(test__f_thread_spin_create__fails),
+ cmocka_unit_test(test__f_thread_spin_create__works),
+
+ cmocka_unit_test(test__f_thread_spin_delete__fails),
+ cmocka_unit_test(test__f_thread_spin_delete__works),
+
+ cmocka_unit_test(test__f_thread_spin_lock__fails),
+ cmocka_unit_test(test__f_thread_spin_lock__works),
+
+ cmocka_unit_test(test__f_thread_spin_lock_try__fails),
+ cmocka_unit_test(test__f_thread_spin_lock_try__works),
+
+ cmocka_unit_test(test__f_thread_spin_unlock__fails),
+ cmocka_unit_test(test__f_thread_spin_unlock__works),
+
#ifndef _di_level_0_parameter_checking_
cmocka_unit_test(test__f_thread_attributes_adjust__parameter_checking),
cmocka_unit_test(test__f_thread_attributes_decimate_by__parameter_checking),
cmocka_unit_test(test__f_thread_mutex_lock_timed__parameter_checking),
cmocka_unit_test(test__f_thread_mutex_lock_try__parameter_checking),
+
+ cmocka_unit_test(test__f_thread_mutex_priority_ceiling_get__parameter_checking),
+ cmocka_unit_test(test__f_thread_mutex_priority_ceiling_set__parameter_checking),
+
+ cmocka_unit_test(test__f_thread_once__parameter_checking),
+
+ cmocka_unit_test(test__f_thread_scheduler_parameter_get__parameter_checking),
+ cmocka_unit_test(test__f_thread_scheduler_parameter_set__parameter_checking),
+ // f_thread_scheduler_priority_set() doesn't use parameter checking.
+
+ cmocka_unit_test(test__f_thread_semaphore_create__parameter_checking),
+ cmocka_unit_test(test__f_thread_semaphore_delete__parameter_checking),
+
+ cmocka_unit_test(test__f_thread_semaphore_file_close__parameter_checking),
+ // f_thread_semaphore_file_delete() doesn't use parameter checking.
+ cmocka_unit_test(test__f_thread_semaphore_file_open__parameter_checking),
+
+ cmocka_unit_test(test__f_thread_semaphore_lock__parameter_checking),
+ cmocka_unit_test(test__f_thread_semaphore_lock_timed__parameter_checking),
+ cmocka_unit_test(test__f_thread_semaphore_lock_try__parameter_checking),
+
+ cmocka_unit_test(test__f_thread_semaphore_unlock__parameter_checking),
+
+ cmocka_unit_test(test__f_thread_semaphore_value_get__parameter_checking),
+
+ cmocka_unit_test(test__f_thread_signal_mask__parameter_checking),
+ // f_thread_signal_queue() doesn't use parameter checking.
+ // f_thread_signal_write() doesn't use parameter checking.
+
+ cmocka_unit_test(test__f_thread_spin_create__parameter_checking),
+ cmocka_unit_test(test__f_thread_spin_delete__parameter_checking),
+
+ cmocka_unit_test(test__f_thread_spin_lock__parameter_checking),
+ cmocka_unit_test(test__f_thread_spin_lock_try__parameter_checking),
+ cmocka_unit_test(test__f_thread_spin_unlock__parameter_checking),
#endif // _di_level_0_parameter_checking_
};
#include "test-thread-mutex_lock.h"
#include "test-thread-mutex_lock_timed.h"
#include "test-thread-mutex_lock_try.h"
+#include "test-thread-mutex_priority_ceiling_get.h"
+#include "test-thread-mutex_priority_ceiling_set.h"
+#include "test-thread-once.h"
+#include "test-thread-scheduler_parameter_get.h"
+#include "test-thread-scheduler_parameter_set.h"
+#include "test-thread-scheduler_priority_set.h"
+#include "test-thread-semaphore_create.h"
+#include "test-thread-semaphore_delete.h"
+#include "test-thread-semaphore_file_close.h"
+#include "test-thread-semaphore_file_delete.h"
+#include "test-thread-semaphore_file_open.h"
+#include "test-thread-semaphore_lock.h"
+#include "test-thread-semaphore_lock_timed.h"
+#include "test-thread-semaphore_lock_try.h"
+#include "test-thread-semaphore_unlock.h"
+#include "test-thread-semaphore_value_get.h"
+#include "test-thread-signal_mask.h"
+#include "test-thread-signal_queue.h"
+#include "test-thread-signal_write.h"
+#include "test-thread-spin_create.h"
+#include "test-thread-spin_delete.h"
+#include "test-thread-spin_lock.h"
+#include "test-thread-spin_lock_try.h"
+#include "test-thread-spin_unlock.h"
#ifdef __cplusplus
extern "C" {