Add tests for f_capability functions.
This includes my first go at mocking functions using function wrapping.
It seems that the linker is limited on how it handles function wrapping.
I cannot simply wrap functions pulled in via a library.
To work around this I implemented another Fake build settings file for handling this.
This is not an ideal situation and adds a bit of extra work.
The environment variable settings for LD_LIBRARY_PATH needs to also support the work parameter.
These changes expose a logic flaw in the if/else logic of the Fake program.
That bug is not fixed in this commit, it is simply noted in this commit log.
--- /dev/null
+# fss-0001
+
+cmocka 1.*
--- /dev/null
+# fss-0001
+#
+# The -Wl,--wrap does not work across shared files.
+# Therefore, this file is a work-around to inject the mocks into the library for testing purposes.
+# This should exaclty match the "settings" file, except for the additional "-Wl,--wrap" parts and the additional mock source file.
+#
+
+project_name f_capability
+
+version_major 0
+version_minor 5
+version_micro 8
+version_file micro
+version_target minor
+
+environment
+
+process_pre
+process_post
+
+modes individual
+modes_default individual
+
+build_compiler gcc
+build_indexer ar
+build_indexer_arguments rcs
+build_language c
+build_libraries -lc -lcap
+build_libraries-individual -lf_memory -lf_string -lf_type_array
+build_libraries_shared
+build_libraries_static
+build_sources_library capability.c ../../tests/c/mock-capability.c
+build_sources_library_shared
+build_sources_library_static
+build_sources_program
+build_sources_program_shared
+build_sources_program_static
+build_sources_headers capability.h capability-common.h
+build_sources_headers_shared
+build_sources_headers_static
+build_sources_script
+build_sources_setting
+build_script yes
+build_shared yes
+build_static no
+
+path_headers fll/level_0
+path_headers_preserve no
+path_library_script script
+path_library_shared shared
+path_library_static static
+path_program_script script
+path_program_shared shared
+path_program_static static
+path_sources
+path_standard yes
+
+search_exclusive yes
+search_shared yes
+search_static yes
+
+#defines -D_di_libcap_
+defines -D_libcap_legacy_only_
+defines_library
+defines_library_shared
+defines_library_static
+defines_program
+defines_program_shared
+defines_program_static
+defines_static
+defines_shared
+
+flags -O2 -z now -g -fdiagnostics-color=always -Wno-logical-not-parentheses -Wno-logical-op-parentheses -Wno-parentheses
+flags_library -fPIC
+flags_library_shared
+flags_library_static
+flags_program -fPIE
+flags_program_shared
+flags_program_static
+flags_shared
+flags_static
+
+# Inject mocks.
+flags -Wl,--wrap=cap_get_ambient
+flags -Wl,--wrap=cap_clear
+flags -Wl,--wrap=cap_clear_flag
+flags -Wl,--wrap=cap_compare
+flags -Wl,--wrap=cap_copy_ext
+flags -Wl,--wrap=cap_copy_int
+flags -Wl,--wrap=cap_drop_bound
+flags -Wl,--wrap=cap_dup
+flags -Wl,--wrap=cap_free
+flags -Wl,--wrap=cap_from_name
+flags -Wl,--wrap=cap_from_text
+flags -Wl,--wrap=cap_get_bound
+flags -Wl,--wrap=cap_get_fd
+flags -Wl,--wrap=cap_get_file
+flags -Wl,--wrap=cap_get_flag
+flags -Wl,--wrap=cap_get_mode
+flags -Wl,--wrap=cap_get_pid
+flags -Wl,--wrap=cap_get_proc
+flags -Wl,--wrap=cap_set_mode
+flags -Wl,--wrap=cap_get_nsowner
+flags -Wl,--wrap=cap_get_secbits
+flags -Wl,--wrap=cap_init
+flags -Wl,--wrap=cap_mode_name
+flags -Wl,--wrap=cap_reset_ambient
+flags -Wl,--wrap=cap_set_ambient
+flags -Wl,--wrap=cap_set_fd
+flags -Wl,--wrap=cap_set_file
+flags -Wl,--wrap=cap_set_flag
+flags -Wl,--wrap=cap_set_nsowner
+flags -Wl,--wrap=cap_set_proc
+flags -Wl,--wrap=cap_set_secbits
+flags -Wl,--wrap=cap_setgroups
+flags -Wl,--wrap=cap_setuid
+flags -Wl,--wrap=cap_size
+flags -Wl,--wrap=cap_to_name
+flags -Wl,--wrap=cap_to_text
--- /dev/null
+# fss-0001
+
+project_name test-f_capability
+
+version_major 0
+version_minor 5
+version_micro 8
+version_file major
+version_target major
+
+modes individual level monolithic
+modes_default individual
+
+build_compiler gcc
+build_indexer ar
+build_indexer_arguments rcs
+build_language c
+build_libraries -lc -lcmocka
+build_libraries-individual -lf_memory -lf_string -lf_type_array -lf_capability
+build_libraries-level -lfll_0
+build_libraries-monolithic -lfll
+build_sources_program test-capability-ambient_get.c test-capability-ambient_reset.c test-capability-ambient_set.c test-capability-clear.c test-capability-clear_flag.c test-capability-compare.c test-capability-copy.c test-capability-copy_external.c test-capability-copy_internal.c test-capability-delete.c test-capability-file_descriptor_get.c test-capability-file_descriptor_set.c test-capability-file_get.c test-capability-file_set.c test-capability-flag_get.c test-capability-flag_set.c test-capability-from_name.c test-capability-from_text.c test-capability-groups_set.c test-capability-initialize.c test-capability-mode_get.c test-capability-mode_get_name.c test-capability-mode_set.c test-capability-owner_get.c test-capability-owner_set.c test-capability-process_bound_drop.c test-capability-process_bound_get.c test-capability-process_get_by_id.c test-capability-process_get.c test-capability-process_set.c test-capability-security_bits_get.c test-capability-security_bits_set.c test-capability-size.c test-capability-supported_ambient.c test-capability-supported.c test-capability-supported_code.c test-capability-to_name.c test-capability-to_text.c test-capability-user_set.c test-capability.c
+build_script no
+build_shared yes
+build_static no
+
+path_headers tests/c
+path_headers_preserve no
+path_sources tests/c
+path_standard no
+
+search_exclusive yes
+search_shared yes
+search_static yes
+
+#defines -D_di_libcap_
+defines -D_libcap_legacy_only_
+defines -Ibuild/includes
+defines_static -Lbuild/libraries/static
+defines_shared -Lbuild/libraries/shared
+
+flags -O2 -z now -g -fdiagnostics-color=always -Wno-logical-not-parentheses -Wno-logical-op-parentheses -Wno-parentheses
+flags_program -fPIE
+flags_program_shared
+flags_program_static
+flags_shared
+flags_static
--- /dev/null
+# fss-0005 iki-0002
+
+settings:
+ load_build yes
+ fail exit
+
+ environment LD_LIBRARY_PATH
+
+main:
+ build settings-mocks
+ build settings-tests
+
+ operate ld_library_path
+
+ if exists build/programs/shared/test-f_capability
+ shell build/programs/shared/test-f_capability
+
+ if exists build/programs/static/test-f_capability
+ shell build/programs/static/test-f_capability
+
+ if not exists build/programs/shared/test-f_capability
+ and not exists build/programs/static/test-f_capability
+ operate not_created
+
+not_created:
+ print
+ print context:"error"Failed to test due to being unable to find either a shared or static test binary to perform tests. context:"error"
+
+ exit failure
+
+ld_library_path:
+ if defined environment LD_LIBRARY_PATH
+ and defined parameter work
+ define LD_LIBRARY_PATH 'build/libraries/shared:parameter:"work:value"libraries/shared':define:"LD_LIBRARY_PATH"'
+
+ else
+ if defined environment LD_LIBRARY_PATH
+ define LD_LIBRARY_PATH 'build/libraries/shared:parameter:define:"LD_LIBRARY_PATH"'
+
+ else
+ if defined parameter work
+ define LD_LIBRARY_PATH 'build/libraries/shared:parameter:"work:value"libraries/shared'
+
+ else
+ define LD_LIBRARY_PATH build/libraries/shared
--- /dev/null
+#include "mock-capability.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+int __wrap_cap_get_ambient(cap_value_t value) {
+
+ bool failure = mock_type(bool);
+
+ if (failure) {
+ return -1;
+ }
+
+ return 1;
+}
+
+int __wrap_cap_clear(cap_t capability) {
+
+ bool failure = mock_type(bool);
+
+ if (failure) {
+ errno = mock_type(int);
+
+ return -1;
+ }
+
+ return 1;
+}
+
+int __wrap_cap_clear_flag(cap_t capability, cap_flag_value_t flag_value) {
+
+ bool failure = mock_type(bool);
+
+ if (failure) {
+ errno = mock_type(int);
+
+ return -1;
+ }
+
+ return 1;
+}
+
+int __wrap_cap_compare(cap_t capability_1, cap_t capability_2) {
+
+ bool failure = mock_type(bool);
+
+ if (failure) {
+ errno = mock_type(int);
+
+ return -1;
+ }
+
+ return mock_type(int);
+}
+
+ssize_t __wrap_cap_copy_ext(void *data, cap_t capability, ssize_t size) {
+
+ bool failure = mock_type(bool);
+
+ if (failure) {
+ errno = mock_type(int);
+
+ return -1;
+ }
+
+ return 1;
+}
+
+cap_t __wrap_cap_copy_int(void *data) {
+
+ bool failure = mock_type(bool);
+
+ if (failure) {
+ errno = mock_type(int);
+
+ return (cap_t) 0;
+ }
+
+ return (cap_t) 1;
+}
+
+int __wrap_cap_drop_bound(cap_value_t value) {
+
+ bool failure = mock_type(bool);
+
+ if (failure) {
+ errno = mock_type(int);
+
+ return -1;
+ }
+
+ return 1;
+}
+
+cap_t __wrap_cap_dup(cap_t capability) {
+
+ bool failure = mock_type(bool);
+
+ if (failure) {
+ errno = mock_type(int);
+
+ return (cap_t) 0;
+ }
+
+ return (cap_t) 1;
+}
+
+int __wrap_cap_free(void *pointer) {
+
+ bool failure = mock_type(bool);
+
+ if (failure) {
+ errno = mock_type(int);
+
+ return -1;
+ }
+
+ return 1;
+}
+
+int __wrap_cap_from_name(const char *name, cap_value_t *value) {
+
+ bool failure = mock_type(bool);
+
+ if (failure) {
+ errno = mock_type(int);
+
+ return -1;
+ }
+
+ return 1;
+}
+
+cap_t __wrap_cap_from_text(const char *text) {
+
+ bool failure = mock_type(bool);
+
+ if (failure) {
+ errno = mock_type(int);
+
+ return (cap_t) 0;
+ }
+
+ return (cap_t) 1;
+}
+
+int __wrap_cap_get_bound(cap_value_t value) {
+
+ bool failure = mock_type(bool);
+
+ if (failure) {
+ errno = mock_type(int);
+
+ return -1;
+ }
+
+ return 1;
+}
+
+cap_t __wrap_cap_get_fd(int descriptor) {
+
+ bool failure = mock_type(bool);
+
+ if (failure) {
+ errno = mock_type(int);
+
+ return (cap_t) 0;
+ }
+
+ return (cap_t) 1;
+}
+
+cap_t __wrap_cap_get_file(const char *path) {
+
+ bool failure = mock_type(bool);
+
+ if (failure) {
+ errno = mock_type(int);
+
+ return (cap_t) 0;
+ }
+
+ return (cap_t) 1;
+}
+
+int __wrap_cap_get_flag(cap_t capability, cap_value_t value, cap_flag_t flag, cap_flag_value_t *flag_value) {
+
+ bool failure = mock_type(bool);
+
+ if (failure) {
+ errno = mock_type(int);
+
+ return -1;
+ }
+
+ return 1;
+}
+
+cap_mode_t __wrap_cap_get_mode(void) {
+
+ bool failure = mock_type(bool);
+
+ if (failure) {
+ errno = mock_type(int);
+
+ return (cap_mode_t) 0;
+ }
+
+ return (cap_mode_t) 1;
+}
+
+uid_t __wrap_cap_get_nsowner(cap_t) {
+
+ bool failure = mock_type(bool);
+
+ if (failure) {
+ errno = mock_type(int);
+
+ return (uid_t) -1;
+ }
+
+ return (uid_t) 1;
+}
+
+cap_t __wrap_cap_init(void) {
+
+ bool failure = mock_type(bool);
+
+ if (failure) {
+ errno = mock_type(int);
+
+ return (cap_t) 0;
+ }
+
+ return (cap_t) 1;
+}
+
+const char *__wrap_cap_mode_name(cap_mode_t mode) {
+
+ bool failure = mock_type(bool);
+
+ if (failure) {
+ errno = mock_type(int);
+
+ return (char *) 0;
+ }
+
+ return (char *) 1;
+}
+
+cap_t __wrap_cap_get_pid(pid_t pid) {
+
+ bool failure = mock_type(bool);
+
+ if (failure) {
+ errno = mock_type(int);
+
+ return (cap_t) 0;
+ }
+
+ return (cap_t) 1;
+}
+
+cap_t __wrap_cap_get_proc(void) {
+
+ bool failure = mock_type(bool);
+
+ if (failure) {
+ errno = mock_type(int);
+
+ return (cap_t) 0;
+ }
+
+ return (cap_t) 1;
+}
+
+unsigned __wrap_cap_get_secbits(void) {
+
+ bool failure = mock_type(bool);
+
+ if (failure) {
+ errno = mock_type(int);
+
+ return -1;
+ }
+
+ return 1;
+}
+
+int __wrap_cap_reset_ambient(void) {
+
+ bool failure = mock_type(bool);
+
+ if (failure) {
+ errno = mock_type(int);
+
+ return -1;
+ }
+
+ return 1;
+}
+
+int __wrap_cap_set_ambient(cap_value_t value, cap_flag_value_t flag_value) {
+
+ bool failure = mock_type(bool);
+
+ if (failure) {
+ errno = mock_type(int);
+
+ return -1;
+ }
+
+ return 1;
+}
+
+int __wrap_cap_set_fd(int descriptor, cap_t capability) {
+
+ bool failure = mock_type(bool);
+
+ if (failure) {
+ errno = mock_type(int);
+
+ return -1;
+ }
+
+ return 1;
+}
+
+int __wrap_cap_set_file(const char *path, cap_t capability) {
+
+ bool failure = mock_type(bool);
+
+ if (failure) {
+ errno = mock_type(int);
+
+ return -1;
+ }
+
+ return 1;
+}
+
+int __wrap_cap_set_flag(cap_t capability, cap_flag_t flag, int number, const cap_value_t *value, cap_flag_value_t flag_value) {
+
+ bool failure = mock_type(bool);
+
+ if (failure) {
+ errno = mock_type(int);
+
+ return -1;
+ }
+
+ return 1;
+}
+
+int __wrap_cap_set_mode(cap_mode_t mode) {
+
+ bool failure = mock_type(bool);
+
+ if (failure) {
+ errno = mock_type(int);
+
+ return -1;
+ }
+
+ return 1;
+}
+
+int __wrap_cap_set_nsowner(cap_t capability, uid_t id) {
+
+ bool failure = mock_type(bool);
+
+ if (failure) {
+ errno = mock_type(int);
+
+ return -1;
+ }
+
+ return 1;
+}
+
+int __wrap_cap_set_proc(cap_t capability) {
+
+ bool failure = mock_type(bool);
+
+ if (failure) {
+ errno = mock_type(int);
+
+ return -1;
+ }
+
+ return 1;
+}
+
+int __wrap_cap_set_secbits(unsigned bits) {
+
+ bool failure = mock_type(bool);
+
+ if (failure) {
+ errno = mock_type(int);
+
+ return -1;
+ }
+
+ return 1;
+}
+
+int __wrap_cap_setgroups(gid_t gid, size_t total, const gid_t groups[]) {
+
+ bool failure = mock_type(bool);
+
+ if (failure) {
+ errno = mock_type(int);
+
+ return -1;
+ }
+
+ return 1;
+}
+
+int __wrap_cap_setuid(uid_t uid) {
+
+ bool failure = mock_type(bool);
+
+ if (failure) {
+ errno = mock_type(int);
+
+ return -1;
+ }
+
+ return 1;
+}
+
+ssize_t __wrap_cap_size(cap_t capability) {
+
+ bool failure = mock_type(bool);
+
+ if (failure) {
+ errno = mock_type(int);
+
+ return -1;
+ }
+
+ return 1;
+}
+
+char * __wrap_cap_to_text(cap_t capability, ssize_t *size) {
+
+ bool failure = mock_type(bool);
+
+ if (failure) {
+ errno = mock_type(int);
+
+ return (char *) 0;
+ }
+
+ *size = mock_type(int);
+
+ return mock_type(char *);
+}
+
+char * __wrap_cap_to_name(cap_value_t value) {
+
+ bool failure = mock_type(bool);
+
+ if (failure) {
+ errno = mock_type(int);
+
+ return (char *) 0;
+ }
+
+ return mock_type(char *);
+}
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
--- /dev/null
+/**
+ * FLL - Level 0
+ *
+ * Project: Capability
+ * API Version: 0.5
+ * Licenses: lgpl-2.1-or-later
+ *
+ * Test the capability project.
+ */
+#ifndef _MOCK__capability_h
+#define _MOCK__capability_h
+
+// libc includes.
+#include <stdarg.h>
+#include <stddef.h>
+#include <setjmp.h>
+#include <stdint.h>
+
+// cmocka includes.
+#include <cmocka.h>
+
+// fll-0 includes.
+#include <fll/level_0/capability.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+const static int mock_errno_generic = 32767;
+
+extern int __wrap_cap_get_ambient(cap_value_t value);
+extern int __wrap_cap_clear(cap_t capability);
+extern int __wrap_cap_clear_flag(cap_t capability, cap_flag_value_t flag_value);
+extern int __wrap_cap_compare(cap_t capability_1, cap_t capability_2);
+extern ssize_t __wrap_cap_copy_ext(void *data, cap_t capability, ssize_t size);
+extern cap_t __wrap_cap_copy_int(void *data);
+extern int __wrap_cap_drop_bound(cap_value_t value);
+extern cap_t __wrap_cap_dup(cap_t capability);
+extern int __wrap_cap_free(void *pointer);
+extern int __wrap_cap_from_name(const char *name, cap_value_t *value);
+extern cap_t __wrap_cap_from_text(const char *text);
+extern int __wrap_cap_get_bound(cap_value_t value);
+extern cap_t __wrap_cap_get_fd(int descriptor);
+extern cap_t __wrap_cap_get_file(const char *path);
+extern int __wrap_cap_get_flag(cap_t capability, cap_value_t value, cap_flag_t flag, cap_flag_value_t *flag_value);
+extern cap_mode_t __wrap_cap_get_mode(void);
+extern uid_t __wrap_cap_get_nsowner(cap_t capability);
+extern cap_t __wrap_cap_init(void);
+extern const char *__wrap_cap_mode_name(cap_mode_t mode);
+extern cap_t __wrap_cap_get_pid(pid_t pid);
+extern cap_t __wrap_cap_get_proc(void);
+extern unsigned __wrap_cap_get_secbits(void);
+extern int __wrap_cap_reset_ambient(void);
+extern int __wrap_cap_set_ambient(cap_value_t value, cap_flag_value_t flag_value);
+extern int __wrap_cap_set_fd(int descriptor, cap_t capability);
+extern int __wrap_cap_set_file(const char *path, cap_t capability);
+extern int __wrap_cap_set_flag(cap_t capability, cap_flag_t flag, int number, const cap_value_t *value, cap_flag_value_t flag_value);
+extern int __wrap_cap_set_mode(cap_mode_t mode);
+extern int __wrap_cap_set_nsowner(cap_t capability, uid_t id);
+extern int __wrap_cap_set_proc(cap_t capability);
+extern int __wrap_cap_set_secbits(unsigned bits);
+extern int __wrap_cap_setgroups(gid_t gid, size_t total, const gid_t groups[]);
+extern int __wrap_cap_setuid(uid_t uid);
+extern ssize_t __wrap_cap_size(cap_t capability);
+extern char * __wrap_cap_to_text(cap_t capability, ssize_t *size);
+extern char * __wrap_cap_to_name(cap_value_t value);
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
+
+#endif // _MOCK__capability_h
--- /dev/null
+#include "test-capability.h"
+#include "test-capability-ambient_get.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void test__f_capability_ambient_get__works(void **state) {
+
+ f_capability_value_t value = f_capability_value_t_initialize;
+ int ambient = 0;
+
+ #if defined(_di_libcap_) || defined(_libcap_legacy_only_)
+ printf("[ WARN ] f_capability_ambient_get() is not implemented and cannot be fully tested.\n");
+ #else
+ will_return(__wrap_cap_get_ambient, false);
+ #endif // defined(_di_libcap_) || defined(_libcap_legacy_only_)
+
+ {
+ const f_status_t status = f_capability_ambient_get(value, &ambient);
+
+ #if defined(_di_libcap_) || defined(_libcap_legacy_only_)
+ assert_int_equal(F_status_set_fine(status), F_implemented_not);
+ #else
+ assert_int_equal(status, F_none);
+ assert_int_equal(ambient, 1);
+ #endif // defined(_di_libcap_) || defined(_libcap_legacy_only_)
+ }
+}
+
+void test__f_capability_ambient_get__fails(void **state) {
+
+ #if !defined(_di_libcap_) && !defined(_libcap_legacy_only_)
+ f_capability_value_t value = f_capability_value_t_initialize;
+ int ambient = 0;
+
+ {
+ will_return(__wrap_cap_get_ambient, true);
+
+ const f_status_t status = f_capability_ambient_get(value, &ambient);
+
+ assert_int_equal(F_status_set_fine(status), F_supported_not);
+ assert_int_equal(ambient, -1);
+ }
+ #endif // !defined(_di_libcap_) && !defined(_libcap_legacy_only_)
+}
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
--- /dev/null
+/**
+ * FLL - Level 0
+ *
+ * Project: Capability
+ * API Version: 0.5
+ * Licenses: lgpl-2.1-or-later
+ *
+ * Test the capability project.
+ */
+#ifndef _TEST__F_capability__ambient_get
+#define _TEST__F_capability__ambient_get
+
+/**
+ * Test that function works.
+ *
+ * @see f_capability_ambient_get()
+ */
+extern void test__f_capability_ambient_get__works(void **state);
+
+/**
+ * Test that function fails.
+ *
+ * @see f_capability_ambient_get()
+ */
+extern void test__f_capability_ambient_get__fails(void **state);
+
+#endif // _TEST__F_capability__ambient_get
--- /dev/null
+#include "test-capability.h"
+#include "test-capability-ambient_reset.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void test__f_capability_ambient_reset__works(void **state) {
+
+ #if defined(_di_libcap_) || defined(_libcap_legacy_only_)
+ printf("[ WARN ] f_capability_ambient_reset() is not implemented and cannot be fully tested.\n");
+ #else
+ will_return(__wrap_cap_get_ambient, false);
+ #endif // defined(_di_libcap_) || defined(_libcap_legacy_only_)
+
+ {
+ const f_status_t status = f_capability_ambient_reset();
+
+ #if defined(_di_libcap_) || defined(_libcap_legacy_only_)
+ assert_int_equal(F_status_set_fine(status), F_implemented_not);
+ #else
+ assert_int_equal(status, F_none);
+ #endif // defined(_di_libcap_) || defined(_libcap_legacy_only_)
+ }
+}
+
+void test__f_capability_ambient_reset__fails(void **state) {
+
+ #if !defined(_di_libcap_) && !defined(_libcap_legacy_only_)
+ {
+ will_return(__wrap_cap_get_ambient, true);
+ will_return(__wrap_cap_clear, EINVAL);
+
+ const f_status_t status = f_capability_ambient_reset();
+
+ assert_int_equal(F_status_set_fine(status), F_parameter);
+ }
+
+ int errnos[] = {
+ ENOMEM,
+ EPERM,
+ mock_errno_generic,
+ };
+
+ f_status_t statuss[] = {
+ F_memory_not,
+ F_prohibited,
+ F_failure,
+ };
+
+ for (int i = 0; i < 3; ++i) {
+
+ will_return(__wrap_cap_get_ambient, true);
+ will_return(__wrap_cap_clear, errnos[i]);
+
+ const f_status_t status = f_capability_ambient_reset();
+
+ assert_int_equal(F_status_set_fine(status), statuss[i]);
+ } // for
+ #endif // !defined(_di_libcap_) && !defined(_libcap_legacy_only_)
+}
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
--- /dev/null
+/**
+ * FLL - Level 0
+ *
+ * Project: Capability
+ * API Version: 0.5
+ * Licenses: lgpl-2.1-or-later
+ *
+ * Test the capability project.
+ */
+#ifndef _TEST__F_capability__ambient_reset
+#define _TEST__F_capability__ambient_reset
+
+/**
+ * Test that function works.
+ *
+ * @see f_capability_ambient_reset()
+ */
+extern void test__f_capability_ambient_reset__works(void **state);
+
+/**
+ * Test that function fails.
+ *
+ * @see f_capability_ambient_reset()
+ */
+extern void test__f_capability_ambient_reset__fails(void **state);
+
+#endif // _TEST__F_capability__ambient_reset
--- /dev/null
+#include "test-capability.h"
+#include "test-capability-ambient_set.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void test__f_capability_ambient_set__works(void **state) {
+
+ f_capability_value_t value = f_capability_value_t_initialize;
+ f_capability_flag_value_t flag_value = f_capability_flag_value_t_initialize;
+
+ #if defined(_di_libcap_) || defined(_libcap_legacy_only_)
+ printf("[ WARN ] f_capability_ambient_set() is not implemented and cannot be fully tested.\n");
+ #else
+ will_return(__wrap_cap_get_ambient, false);
+ #endif // defined(_di_libcap_) || defined(_libcap_legacy_only_)
+
+ {
+ const f_status_t status = f_capability_ambient_set(value, flag_value);
+
+ #if defined(_di_libcap_) || defined(_libcap_legacy_only_)
+ assert_int_equal(F_status_set_fine(status), F_implemented_not);
+ #else
+ assert_int_equal(status, F_none);
+ #endif // defined(_di_libcap_) || defined(_libcap_legacy_only_)
+ }
+}
+
+void test__f_capability_ambient_set__fails(void **state) {
+
+ #if !defined(_di_libcap_) && !defined(_libcap_legacy_only_)
+ f_capability_value_t value = f_capability_value_t_initialize;
+ f_capability_flag_value_t flag_value = f_capability_flag_value_t_initialize;
+
+ int errnos[] = {
+ ENOMEM,
+ EPERM,
+ mock_errno_generic,
+ };
+
+ f_status_t statuss[] = {
+ F_memory_not,
+ F_prohibited,
+ F_failure,
+ };
+
+ for (int i = 0; i < 3; ++i) {
+
+ will_return(__wrap_cap_get_ambient, true);
+ will_return(__wrap_cap_clear, errnos[i]);
+
+ const f_status_t status = f_capability_ambient_set(value, flag_value);
+
+ assert_int_equal(F_status_set_fine(status), statuss[i]);
+ } // for
+ #endif // !defined(_di_libcap_) && !defined(_libcap_legacy_only_)
+}
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
--- /dev/null
+/**
+ * FLL - Level 0
+ *
+ * Project: Capability
+ * API Version: 0.5
+ * Licenses: lgpl-2.1-or-later
+ *
+ * Test the capability project.
+ */
+#ifndef _TEST__F_capability__ambient_set
+#define _TEST__F_capability__ambient_set
+
+/**
+ * Test that function works.
+ *
+ * @see f_capability_ambient_set()
+ */
+extern void test__f_capability_ambient_set__works(void **state);
+
+/**
+ * Test that function fails.
+ *
+ * @see f_capability_ambient_set()
+ */
+extern void test__f_capability_ambient_set__fails(void **state);
+
+#endif // _TEST__F_capability__ambient_set
--- /dev/null
+#include "test-capability.h"
+#include "test-capability-clear.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void test__f_capability_clear__works(void **state) {
+
+ f_capability_t capability = f_capability_t_initialize;
+
+ #if defined(_di_libcap_)
+ printf("[ WARN ] f_capability_clear() is not implemented and cannot be fully tested.\n");
+ #else
+ will_return(__wrap_cap_clear, false);
+ #endif // defined(_di_libcap_)
+
+ {
+ const f_status_t status = f_capability_clear(&capability);
+
+ #if defined(_di_libcap_)
+ assert_int_equal(F_status_set_fine(status), F_implemented_not);
+ #else
+ assert_int_equal(status, F_none);
+ #endif // defined(_di_libcap_)
+ }
+}
+
+void test__f_capability_clear__fails(void **state) {
+
+ #if !defined(_di_libcap_)
+ f_capability_t capability = f_capability_t_initialize;
+
+ int errnos[] = {
+ EINVAL,
+ ENOMEM,
+ ERANGE,
+ mock_errno_generic,
+ };
+
+ f_status_t statuss[] = {
+ F_parameter,
+ F_memory_not,
+ F_range_not,
+ F_failure,
+ };
+
+ for (int i = 0; i < 4; ++i) {
+
+ will_return(__wrap_cap_clear, true);
+ will_return(__wrap_cap_clear, errnos[i]);
+
+ const f_status_t status = f_capability_clear(&capability);
+
+ assert_int_equal(F_status_set_fine(status), statuss[i]);
+ } // for
+ #endif // !defined(_di_libcap_)
+}
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
--- /dev/null
+/**
+ * FLL - Level 0
+ *
+ * Project: Capability
+ * API Version: 0.5
+ * Licenses: lgpl-2.1-or-later
+ *
+ * Test the capability project.
+ */
+#ifndef _TEST__F_capability__clear
+#define _TEST__F_capability__clear
+
+/**
+ * Test that function works.
+ *
+ * @see f_capability_clear()
+ */
+extern void test__f_capability_clear__works(void **state);
+
+/**
+ * Test that function fails.
+ *
+ * @see f_capability_clear()
+ */
+extern void test__f_capability_clear__fails(void **state);
+
+#endif // _TEST__F_capability__clear
--- /dev/null
+#include "test-capability.h"
+#include "test-capability-clear_flag.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void test__f_capability_clear_flag__works(void **state) {
+
+ f_capability_t capability = f_capability_t_initialize;
+ f_capability_flag_value_t flag_value = f_capability_flag_value_t_initialize;
+
+ #if defined(_di_libcap_)
+ printf("[ WARN ] f_capability_clear_flag() is not implemented and cannot be fully tested.\n");
+ #else
+ will_return(__wrap_cap_clear_flag, false);
+ #endif // defined(_di_libcap_)
+
+ {
+ const f_status_t status = f_capability_clear_flag(flag_value, &capability);
+
+ #if defined(_di_libcap_)
+ assert_int_equal(F_status_set_fine(status), F_implemented_not);
+ #else
+ assert_int_equal(status, F_none);
+ #endif // defined(_di_libcap_)
+ }
+}
+
+void test__f_capability_clear_flag__fails(void **state) {
+
+ #if !defined(_di_libcap_)
+ f_capability_t capability = f_capability_t_initialize;
+ f_capability_flag_value_t flag_value = f_capability_flag_value_t_initialize;
+
+ int errnos[] = {
+ EINVAL,
+ mock_errno_generic,
+ };
+
+ f_status_t statuss[] = {
+ F_parameter,
+ F_failure,
+ };
+
+ for (int i = 0; i < 2; ++i) {
+
+ will_return(__wrap_cap_clear_flag, true);
+ will_return(__wrap_cap_clear_flag, errnos[i]);
+
+ const f_status_t status = f_capability_clear_flag(flag_value, &capability);
+
+ assert_int_equal(F_status_set_fine(status), statuss[i]);
+ } // for
+ #endif // !defined(_di_libcap_)
+}
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
--- /dev/null
+/**
+ * FLL - Level 0
+ *
+ * Project: Capability
+ * API Version: 0.5
+ * Licenses: lgpl-2.1-or-later
+ *
+ * Test the capability project.
+ */
+#ifndef _TEST__F_capability__clear_flag
+#define _TEST__F_capability__clear_flag
+
+/**
+ * Test that function works.
+ *
+ * @see f_capability_clear_flag()
+ */
+extern void test__f_capability_clear_flag__works(void **state);
+
+/**
+ * Test that function fails.
+ *
+ * @see f_capability_clear_flag()
+ */
+extern void test__f_capability_clear_flag__fails(void **state);
+
+#endif // _TEST__F_capability__clear_flag
--- /dev/null
+#include "test-capability.h"
+#include "test-capability-compare.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void test__f_capability_compare__works(void **state) {
+
+ f_capability_t capability_1 = f_capability_t_initialize;
+ f_capability_t capability_2 = f_capability_t_initialize;
+ int flags = 0;
+
+ #if defined(_di_libcap_)
+ printf("[ WARN ] f_capability_compare() is not implemented and cannot be fully tested.\n");
+
+ {
+ const f_status_t status = f_capability_compare(capability_1, capability_2, &flags);
+
+ assert_int_equal(F_status_set_fine(status), F_implemented_not);
+ }
+ #else
+ {
+ will_return(__wrap_cap_compare, false);
+ will_return(__wrap_cap_compare, 0);
+
+ const f_status_t status = f_capability_compare(capability_1, capability_2, &flags);
+
+ assert_int_equal(status, F_equal_to);
+ }
+
+ {
+ will_return(__wrap_cap_compare, false);
+ will_return(__wrap_cap_compare, 1);
+
+ const f_status_t status = f_capability_compare(capability_1, capability_2, &flags);
+
+ assert_int_equal(status, F_equal_to_not);
+ assert_int_equal(flags, 1);
+ }
+ #endif // defined(_di_libcap_)
+}
+
+void test__f_capability_compare__fails(void **state) {
+
+ #if !defined(_di_libcap_)
+ f_capability_t capability_1 = f_capability_t_initialize;
+ f_capability_t capability_2 = f_capability_t_initialize;
+ int flags = 0;
+
+ int errnos[] = {
+ EINVAL,
+ mock_errno_generic,
+ };
+
+ f_status_t statuss[] = {
+ F_parameter,
+ F_failure,
+ };
+
+ for (int i = 0; i < 2; ++i) {
+
+ will_return(__wrap_cap_compare, true);
+ will_return(__wrap_cap_compare, errnos[i]);
+
+ const f_status_t status = f_capability_compare(capability_1, capability_2, &flags);
+
+ assert_int_equal(F_status_set_fine(status), statuss[i]);
+ } // for
+ #endif // !defined(_di_libcap_)
+}
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
--- /dev/null
+/**
+ * FLL - Level 0
+ *
+ * Project: Capability
+ * API Version: 0.5
+ * Licenses: lgpl-2.1-or-later
+ *
+ * Test the capability project.
+ */
+#ifndef _TEST__F_capability__compare
+#define _TEST__F_capability__compare
+
+/**
+ * Test that function works.
+ *
+ * @see f_capability_compare()
+ */
+extern void test__f_capability_compare__works(void **state);
+
+/**
+ * Test that function fails.
+ *
+ * @see f_capability_compare()
+ */
+extern void test__f_capability_compare__fails(void **state);
+
+#endif // _TEST__F_capability__compare
--- /dev/null
+#include "test-capability.h"
+#include "test-capability-copy.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void test__f_capability_copy__works(void **state) {
+
+ f_capability_t capability_1 = f_capability_t_initialize;
+ f_capability_t capability_2 = f_capability_t_initialize;
+
+ #if defined(_di_libcap_)
+ printf("[ WARN ] f_capability_copy() is not implemented and cannot be fully tested.\n");
+ #else
+ will_return(__wrap_cap_dup, false);
+ #endif // defined(_di_libcap_)
+
+ {
+ const f_status_t status = f_capability_copy(capability_1, &capability_2);
+
+ #if defined(_di_libcap_)
+ assert_int_equal(F_status_set_fine(status), F_implemented_not);
+ #else
+ assert_int_equal(status, F_none);
+ assert_int_equal(capability_2, 1);
+ #endif // defined(_di_libcap_)
+ }
+}
+
+void test__f_capability_copy__fails(void **state) {
+
+ #if !defined(_di_libcap_)
+ f_capability_t capability_1 = f_capability_t_initialize;
+ f_capability_t capability_2 = f_capability_t_initialize;
+
+ int errnos[] = {
+ EINVAL,
+ ENOMEM,
+ mock_errno_generic,
+ };
+
+ f_status_t statuss[] = {
+ F_parameter,
+ F_memory_not,
+ F_failure,
+ };
+
+ for (int i = 0; i < 3; ++i) {
+
+ will_return(__wrap_cap_dup, true);
+ will_return(__wrap_cap_dup, EINVAL);
+
+ const f_status_t status = f_capability_copy(capability_1, &capability_2);
+
+ assert_int_equal(F_status_set_fine(status), F_parameter);
+ } // for
+ #endif // !defined(_di_libcap_)
+}
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
--- /dev/null
+/**
+ * FLL - Level 0
+ *
+ * Project: Capability
+ * API Version: 0.5
+ * Licenses: lgpl-2.1-or-later
+ *
+ * Test the capability project.
+ */
+#ifndef _TEST__F_capability__copy
+#define _TEST__F_capability__copy
+
+/**
+ * Test that function works.
+ *
+ * @see f_capability_copy()
+ */
+extern void test__f_capability_copy__works(void **state);
+
+/**
+ * Test that function fails.
+ *
+ * @see f_capability_copy()
+ */
+extern void test__f_capability_copy__fails(void **state);
+
+#endif // _TEST__F_capability__copy
--- /dev/null
+#include "test-capability.h"
+#include "test-capability-copy_external.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void test__f_capability_copy_external__works(void **state) {
+
+ f_capability_t capability = f_capability_t_initialize;
+ ssize_t max = 0;
+ int stub = 0;
+ void *external = (void *) &stub;
+ ssize_t size = 0;
+
+ #if defined(_di_libcap_)
+ printf("[ WARN ] f_capability_copy_external() is not implemented and cannot be fully tested.\n");
+ #else
+ will_return(__wrap_cap_copy_ext, false);
+ #endif // defined(_di_libcap_)
+
+ {
+ const f_status_t status = f_capability_copy_external(capability, max, external, &size);
+
+ #if defined(_di_libcap_)
+ assert_int_equal(F_status_set_fine(status), F_implemented_not);
+ #else
+ assert_int_equal(status, F_none);
+ assert_int_equal(size, 1);
+ #endif // defined(_di_libcap_)
+ }
+}
+
+void test__f_capability_copy_external__fails(void **state) {
+
+ #if !defined(_di_libcap_)
+ f_capability_t capability = f_capability_t_initialize;
+ ssize_t max = 0;
+ int stub = 0;
+ void *external = (void *) &stub;
+ ssize_t size = 0;
+
+ int errnos[] = {
+ EINVAL,
+ ERANGE,
+ mock_errno_generic,
+ };
+
+ f_status_t statuss[] = {
+ F_parameter,
+ F_range_not,
+ F_failure,
+ };
+
+ for (int i = 0; i < 3; ++i) {
+
+ will_return(__wrap_cap_copy_ext, true);
+ will_return(__wrap_cap_copy_ext, errnos[i]);
+
+ const f_status_t status = f_capability_copy_external(capability, max, external, &size);
+
+ assert_int_equal(F_status_set_fine(status), statuss[i]);
+ } // for
+ #endif // !defined(_di_libcap_)
+}
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
--- /dev/null
+/**
+ * FLL - Level 0
+ *
+ * Project: Capability
+ * API Version: 0.5
+ * Licenses: lgpl-2.1-or-later
+ *
+ * Test the capability project.
+ */
+#ifndef _TEST__F_capability__copy_external
+#define _TEST__F_capability__copy_external
+
+/**
+ * Test that function works.
+ *
+ * @see f_capability_copy_external()
+ */
+extern void test__f_capability_copy_external__works(void **state);
+
+/**
+ * Test that function fails.
+ *
+ * @see f_capability_copy_external()
+ */
+extern void test__f_capability_copy_external__fails(void **state);
+
+#endif // _TEST__F_capability__copy_external
--- /dev/null
+#include "test-capability.h"
+#include "test-capability-copy_internal.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void test__f_capability_copy_internal__works(void **state) {
+
+ f_capability_t capability = f_capability_t_initialize;
+ int stub = 0;
+ void *external = (void *) &stub;
+
+ #if defined(_di_libcap_)
+ printf("[ WARN ] f_capability_copy_internal() is not implemented and cannot be fully tested.\n");
+ #else
+ will_return(__wrap_cap_copy_int, false);
+ #endif // defined(_di_libcap_)
+
+ {
+ const f_status_t status = f_capability_copy_internal(external, &capability);
+
+ #if defined(_di_libcap_)
+ assert_int_equal(F_status_set_fine(status), F_implemented_not);
+ #else
+ assert_int_equal(status, F_none);
+ assert_int_equal(capability, 1);
+ #endif // defined(_di_libcap_)
+ }
+}
+
+void test__f_capability_copy_internal__fails(void **state) {
+
+ #if !defined(_di_libcap_)
+ f_capability_t capability = f_capability_t_initialize;
+ int stub = 0;
+ void *external = (void *) &stub;
+
+ int errnos[] = {
+ EINVAL,
+ ERANGE,
+ mock_errno_generic,
+ };
+
+ f_status_t statuss[] = {
+ F_parameter,
+ F_range_not,
+ F_failure,
+ };
+
+ for (int i = 0; i < 3; ++i) {
+
+ will_return(__wrap_cap_copy_int, true);
+ will_return(__wrap_cap_copy_int, errnos[i]);
+
+ const f_status_t status = f_capability_copy_internal(external, &capability);
+
+ assert_int_equal(F_status_set_fine(status), statuss[i]);
+ } // for
+ #endif // !defined(_di_libcap_)
+}
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
--- /dev/null
+/**
+ * FLL - Level 0
+ *
+ * Project: Capability
+ * API Version: 0.5
+ * Licenses: lgpl-2.1-or-later
+ *
+ * Test the capability project.
+ */
+#ifndef _TEST__F_capability__copy_internal
+#define _TEST__F_capability__copy_internal
+
+/**
+ * Test that function works.
+ *
+ * @see f_capability_copy_internal()
+ */
+extern void test__f_capability_copy_internal__works(void **state);
+
+/**
+ * Test that function fails.
+ *
+ * @see f_capability_copy_internal()
+ */
+extern void test__f_capability_copy_internal__fails(void **state);
+
+#endif // _TEST__F_capability__copy_internal
--- /dev/null
+#include "test-capability.h"
+#include "test-capability-delete.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void test__f_capability_delete__works(void **state) {
+
+ f_capability_t capability = f_capability_t_initialize;
+
+ #if defined(_di_libcap_)
+ printf("[ WARN ] f_capability_delete() is not implemented and cannot be fully tested.\n");
+ #else
+ will_return(__wrap_cap_free, false);
+ #endif // defined(_di_libcap_)
+
+ {
+ const f_status_t status = f_capability_delete(&capability);
+
+ #if defined(_di_libcap_)
+ assert_int_equal(F_status_set_fine(status), F_implemented_not);
+ #else
+ assert_int_equal(status, F_none);
+ assert_int_equal(capability, 0);
+ #endif // defined(_di_libcap_)
+ }
+}
+
+void test__f_capability_delete__fails(void **state) {
+
+ #if !defined(_di_libcap_)
+ f_capability_t capability = f_capability_t_initialize;
+
+ int errnos[] = {
+ EINVAL,
+ ENOMEM,
+ mock_errno_generic,
+ };
+
+ f_status_t statuss[] = {
+ F_parameter,
+ F_memory_not,
+ F_failure,
+ };
+
+ for (int i = 0; i < 3; ++i) {
+
+ will_return(__wrap_cap_free, true);
+ will_return(__wrap_cap_free, errnos[i]);
+
+ const f_status_t status = f_capability_delete(&capability);
+
+ assert_int_equal(F_status_set_fine(status), statuss[i]);
+ } // for
+ #endif // !defined(_di_libcap_)
+}
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
--- /dev/null
+/**
+ * FLL - Level 0
+ *
+ * Project: Capability
+ * API Version: 0.5
+ * Licenses: lgpl-2.1-or-later
+ *
+ * Test the capability project.
+ */
+#ifndef _TEST__F_capability__delete
+#define _TEST__F_capability__delete
+
+/**
+ * Test that function works.
+ *
+ * @see f_capability_delete()
+ */
+extern void test__f_capability_delete__works(void **state);
+
+/**
+ * Test that function fails.
+ *
+ * @see f_capability_delete()
+ */
+extern void test__f_capability_delete__fails(void **state);
+
+#endif // _TEST__F_capability__delete
--- /dev/null
+#include "test-capability.h"
+#include "test-capability-file_descriptor_get.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void test__f_capability_file_descriptor_get__works(void **state) {
+
+ int descriptor = 0;
+ f_capability_t capability = f_capability_t_initialize;
+
+ #if defined(_di_libcap_)
+ printf("[ WARN ] f_capability_file_descriptor_get() is not implemented and cannot be fully tested.\n");
+ #else
+ will_return(__wrap_cap_get_fd, false);
+ #endif // defined(_di_libcap_)
+
+ {
+ const f_status_t status = f_capability_file_descriptor_get(descriptor, &capability);
+
+ #if defined(_di_libcap_)
+ assert_int_equal(F_status_set_fine(status), F_implemented_not);
+ #else
+ assert_int_equal(status, F_none);
+ #endif // defined(_di_libcap_)
+ }
+}
+
+void test__f_capability_file_descriptor_get__fails(void **state) {
+
+ #if !defined(_di_libcap_)
+ int descriptor = 0;
+ f_capability_t capability = f_capability_t_initialize;
+
+ int errnos[] = {
+ EACCES,
+ EBADFD,
+ ENAMETOOLONG,
+ ENOENT,
+ ENOMEM,
+ ENOTDIR,
+ EPERM,
+ EROFS,
+ mock_errno_generic,
+ };
+
+ f_status_t statuss[] = {
+ F_access_denied,
+ F_descriptor_not,
+ F_name_not,
+ F_file_found_not,
+ F_memory_not,
+ F_directory_not,
+ F_prohibited,
+ F_supported_not,
+ F_failure,
+ };
+
+ for (int i = 0; i < 9; ++i) {
+
+ will_return(__wrap_cap_get_fd, true);
+ will_return(__wrap_cap_get_fd, errnos[i]);
+
+ const f_status_t status = f_capability_file_descriptor_get(descriptor, &capability);
+
+ assert_int_equal(F_status_set_fine(status), statuss[i]);
+ } // for
+ #endif // !defined(_di_libcap_)
+}
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
--- /dev/null
+/**
+ * FLL - Level 0
+ *
+ * Project: Capability
+ * API Version: 0.5
+ * Licenses: lgpl-2.1-or-later
+ *
+ * Test the capability project.
+ */
+#ifndef _TEST__F_capability__file_descriptor_get
+#define _TEST__F_capability__file_descriptor_get
+
+/**
+ * Test that function works.
+ *
+ * @see f_capability_file_descriptor_get()
+ */
+extern void test__f_capability_file_descriptor_get__works(void **state);
+
+/**
+ * Test that function fails.
+ *
+ * @see f_capability_file_descriptor_get()
+ */
+extern void test__f_capability_file_descriptor_get__fails(void **state);
+
+#endif // _TEST__F_capability__file_descriptor_get
--- /dev/null
+#include "test-capability.h"
+#include "test-capability-file_descriptor_set.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void test__f_capability_file_descriptor_set__works(void **state) {
+
+ int descriptor = 0;
+ f_capability_t capability = f_capability_t_initialize;
+
+ #if defined(_di_libcap_)
+ printf("[ WARN ] f_capability_file_descriptor_set() is not implemented and cannot be fully tested.\n");
+ #else
+ will_return(__wrap_cap_set_fd, false);
+ #endif // defined(_di_libcap_)
+
+ {
+ const f_status_t status = f_capability_file_descriptor_set(descriptor, capability);
+
+ #if defined(_di_libcap_)
+ assert_int_equal(F_status_set_fine(status), F_implemented_not);
+ #else
+ assert_int_equal(status, F_none);
+ #endif // defined(_di_libcap_)
+ }
+}
+
+void test__f_capability_file_descriptor_set__fails(void **state) {
+
+ #if !defined(_di_libcap_)
+ int descriptor = 0;
+ f_capability_t capability = f_capability_t_initialize;
+
+ int errnos[] = {
+ EACCES,
+ EBADFD,
+ ENAMETOOLONG,
+ ENOENT,
+ ENOMEM,
+ ENOTDIR,
+ EPERM,
+ EROFS,
+ mock_errno_generic,
+ };
+
+ f_status_t statuss[] = {
+ F_access_denied,
+ F_descriptor_not,
+ F_name_not,
+ F_file_found_not,
+ F_memory_not,
+ F_directory_not,
+ F_prohibited,
+ F_supported_not,
+ F_failure,
+ };
+
+ for (int i = 0; i < 9; ++i) {
+
+ will_return(__wrap_cap_set_fd, true);
+ will_return(__wrap_cap_set_fd, errnos[i]);
+
+ const f_status_t status = f_capability_file_descriptor_set(descriptor, capability);
+
+ assert_int_equal(F_status_set_fine(status), statuss[i]);
+ } // for
+ #endif // !defined(_di_libcap_)
+}
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
--- /dev/null
+/**
+ * FLL - Level 0
+ *
+ * Project: Capability
+ * API Version: 0.5
+ * Licenses: lgpl-2.1-or-later
+ *
+ * Test the capability project.
+ */
+#ifndef _TEST__F_capability__file_descriptor_set
+#define _TEST__F_capability__file_descriptor_set
+
+/**
+ * Test that function works.
+ *
+ * @see f_capability_file_descriptor_set()
+ */
+extern void test__f_capability_file_descriptor_set__works(void **state);
+
+/**
+ * Test that function fails.
+ *
+ * @see f_capability_file_descriptor_set()
+ */
+extern void test__f_capability_file_descriptor_set__fails(void **state);
+
+#endif // _TEST__F_capability__file_descriptor_set
--- /dev/null
+#include "test-capability.h"
+#include "test-capability-file_get.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void test__f_capability_file_get__works(void **state) {
+
+ f_string_t path = f_string_t_initialize;
+ f_capability_t capability = f_capability_t_initialize;
+
+ #if defined(_di_libcap_)
+ printf("[ WARN ] f_capability_file_get() is not implemented and cannot be fully tested.\n");
+ #else
+ will_return(__wrap_cap_get_file, false);
+ #endif // defined(_di_libcap_)
+
+ {
+ const f_status_t status = f_capability_file_get(path, &capability);
+
+ #if defined(_di_libcap_)
+ assert_int_equal(F_status_set_fine(status), F_implemented_not);
+ #else
+ assert_int_equal(status, F_none);
+ #endif // defined(_di_libcap_)
+ }
+}
+
+void test__f_capability_file_get__fails(void **state) {
+
+ #if !defined(_di_libcap_)
+ f_string_t path = f_string_t_initialize;
+ f_capability_t capability = f_capability_t_initialize;
+
+ int errnos[] = {
+ EACCES,
+ EBADFD,
+ ENAMETOOLONG,
+ ENOENT,
+ ENOMEM,
+ ENOTDIR,
+ EPERM,
+ EROFS,
+ mock_errno_generic,
+ };
+
+ f_status_t statuss[] = {
+ F_access_denied,
+ F_descriptor_not,
+ F_name_not,
+ F_file_found_not,
+ F_memory_not,
+ F_directory_not,
+ F_prohibited,
+ F_supported_not,
+ F_failure,
+ };
+
+ for (int i = 0; i < 9; ++i) {
+
+ will_return(__wrap_cap_get_file, true);
+ will_return(__wrap_cap_get_file, errnos[i]);
+
+ const f_status_t status = f_capability_file_get(path, &capability);
+
+ assert_int_equal(F_status_set_fine(status), statuss[i]);
+ } // for
+ #endif // !defined(_di_libcap_)
+}
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
--- /dev/null
+/**
+ * FLL - Level 0
+ *
+ * Project: Capability
+ * API Version: 0.5
+ * Licenses: lgpl-2.1-or-later
+ *
+ * Test the capability project.
+ */
+#ifndef _TEST__F_capability__file_get
+#define _TEST__F_capability__file_get
+
+/**
+ * Test that function works.
+ *
+ * @see f_capability_file_get()
+ */
+extern void test__f_capability_file_get__works(void **state);
+
+/**
+ * Test that function fails.
+ *
+ * @see f_capability_file_get()
+ */
+extern void test__f_capability_file_get__fails(void **state);
+
+#endif // _TEST__F_capability__file_get
--- /dev/null
+#include "test-capability.h"
+#include "test-capability-file_set.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void test__f_capability_file_set__works(void **state) {
+
+ f_string_t path = f_string_t_initialize;
+ f_capability_t capability = f_capability_t_initialize;
+
+ #if defined(_di_libcap_)
+ printf("[ WARN ] f_capability_file_set() is not implemented and cannot be fully tested.\n");
+ #else
+ will_return(__wrap_cap_set_file, false);
+ #endif // defined(_di_libcap_)
+
+ {
+ const f_status_t status = f_capability_file_set(path, capability);
+
+ #if defined(_di_libcap_)
+ assert_int_equal(F_status_set_fine(status), F_implemented_not);
+ #else
+ assert_int_equal(status, F_none);
+ #endif // defined(_di_libcap_)
+ }
+}
+
+void test__f_capability_file_set__fails(void **state) {
+
+ #if !defined(_di_libcap_)
+ f_string_t path = f_string_t_initialize;
+ f_capability_t capability = f_capability_t_initialize;
+
+ int errnos[] = {
+ EACCES,
+ EBADFD,
+ ENAMETOOLONG,
+ ENOENT,
+ ENOMEM,
+ ENOTDIR,
+ EPERM,
+ EROFS,
+ mock_errno_generic,
+ };
+
+ f_status_t statuss[] = {
+ F_access_denied,
+ F_descriptor_not,
+ F_name_not,
+ F_file_found_not,
+ F_memory_not,
+ F_directory_not,
+ F_prohibited,
+ F_supported_not,
+ F_failure,
+ };
+
+ for (int i = 0; i < 9; ++i) {
+
+ will_return(__wrap_cap_set_file, true);
+ will_return(__wrap_cap_set_file, errnos[i]);
+
+ const f_status_t status = f_capability_file_set(path, capability);
+
+ assert_int_equal(F_status_set_fine(status), statuss[i]);
+ } // for
+ #endif // !defined(_di_libcap_)
+}
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
--- /dev/null
+/**
+ * FLL - Level 0
+ *
+ * Project: Capability
+ * API Version: 0.5
+ * Licenses: lgpl-2.1-or-later
+ *
+ * Test the capability project.
+ */
+#ifndef _TEST__F_capability__file_set
+#define _TEST__F_capability__file_set
+
+/**
+ * Test that function works.
+ *
+ * @see f_capability_file_set()
+ */
+extern void test__f_capability_file_set__works(void **state);
+
+/**
+ * Test that function fails.
+ *
+ * @see f_capability_file_set()
+ */
+extern void test__f_capability_file_set__fails(void **state);
+
+#endif // _TEST__F_capability__file_set
--- /dev/null
+#include "test-capability.h"
+#include "test-capability-flag_get.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void test__f_capability_flag_get__works(void **state) {
+
+ f_capability_flag_t flag = f_capability_flag_t_initialize;
+ f_capability_flag_value_t value = f_capability_flag_value_t_initialize;
+ f_capability_t capability = f_capability_t_initialize;
+ f_capability_value_t capability_value = f_capability_value_t_initialize;
+
+ #if defined(_di_libcap_)
+ printf("[ WARN ] f_capability_flag_get() is not implemented and cannot be fully tested.\n");
+ #else
+ will_return(__wrap_cap_get_flag, false);
+ #endif // defined(_di_libcap_)
+
+ {
+ const f_status_t status = f_capability_flag_get(capability, capability_value, flag, &value);
+
+ #if defined(_di_libcap_)
+ assert_int_equal(F_status_set_fine(status), F_implemented_not);
+ #else
+ assert_int_equal(status, F_none);
+ #endif // defined(_di_libcap_)
+ }
+}
+
+void test__f_capability_flag_get__fails(void **state) {
+
+ #if !defined(_di_libcap_)
+ f_capability_flag_t flag = f_capability_flag_t_initialize;
+ f_capability_flag_value_t value = f_capability_flag_value_t_initialize;
+ f_capability_t capability = f_capability_t_initialize;
+ f_capability_value_t capability_value = f_capability_value_t_initialize;
+
+ int errnos[] = {
+ EINVAL,
+ mock_errno_generic,
+ };
+
+ f_status_t statuss[] = {
+ F_parameter,
+ F_failure,
+ };
+
+ for (int i = 0; i < 2; ++i) {
+
+ will_return(__wrap_cap_get_flag, true);
+ will_return(__wrap_cap_get_flag, errnos[i]);
+
+ const f_status_t status = f_capability_flag_get(capability, capability_value, flag, &value);
+
+ assert_int_equal(F_status_set_fine(status), statuss[i]);
+ } // for
+ #endif // !defined(_di_libcap_)
+}
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
--- /dev/null
+/**
+ * FLL - Level 0
+ *
+ * Project: Capability
+ * API Version: 0.5
+ * Licenses: lgpl-2.1-or-later
+ *
+ * Test the capability project.
+ */
+#ifndef _TEST__F_capability__flag_get
+#define _TEST__F_capability__flag_get
+
+/**
+ * Test that function works.
+ *
+ * @see f_capability_flag_get()
+ */
+extern void test__f_capability_flag_get__works(void **state);
+
+/**
+ * Test that function fails.
+ *
+ * @see f_capability_flag_get()
+ */
+extern void test__f_capability_flag_get__fails(void **state);
+
+#endif // _TEST__F_capability__flag_get
--- /dev/null
+#include "test-capability.h"
+#include "test-capability-flag_set.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void test__f_capability_flag_set__works(void **state) {
+
+ f_capability_flag_t flag = f_capability_flag_t_initialize;
+ f_capability_flag_value_t value = f_capability_flag_value_t_initialize;
+ f_int32s_t codes = f_int32s_t_initialize;
+ f_capability_t capability = f_capability_t_initialize;
+
+ #if defined(_di_libcap_)
+ printf("[ WARN ] f_capability_flag_set() is not implemented and cannot be fully tested.\n");
+ #else
+ will_return(__wrap_cap_set_flag, false);
+ #endif // defined(_di_libcap_)
+
+ {
+ const f_status_t status = f_capability_flag_set(flag, value, codes, &capability);
+
+ #if defined(_di_libcap_)
+ assert_int_equal(F_status_set_fine(status), F_implemented_not);
+ #else
+ assert_int_equal(status, F_none);
+ #endif // defined(_di_libcap_)
+ }
+}
+
+void test__f_capability_flag_set__fails(void **state) {
+
+ #if !defined(_di_libcap_)
+ f_capability_flag_t flag = f_capability_flag_t_initialize;
+ f_capability_flag_value_t value = f_capability_flag_value_t_initialize;
+ f_int32s_t codes = f_int32s_t_initialize;
+ f_capability_t capability = f_capability_t_initialize;
+
+ int errnos[] = {
+ EINVAL,
+ mock_errno_generic,
+ };
+
+ f_status_t statuss[] = {
+ F_parameter,
+ F_failure,
+ };
+
+ for (int i = 0; i < 2; ++i) {
+
+ will_return(__wrap_cap_set_flag, true);
+ will_return(__wrap_cap_set_flag, errnos[i]);
+
+ const f_status_t status = f_capability_flag_set(flag, value, codes, &capability);
+
+ assert_int_equal(F_status_set_fine(status), statuss[i]);
+ } // for
+ #endif // !defined(_di_libcap_)
+}
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
--- /dev/null
+/**
+ * FLL - Level 0
+ *
+ * Project: Capability
+ * API Version: 0.5
+ * Licenses: lgpl-2.1-or-later
+ *
+ * Test the capability project.
+ */
+#ifndef _TEST__F_capability__flag_set
+#define _TEST__F_capability__flag_set
+
+/**
+ * Test that function works.
+ *
+ * @see f_capability_flag_set()
+ */
+extern void test__f_capability_flag_set__works(void **state);
+
+/**
+ * Test that function fails.
+ *
+ * @see f_capability_flag_set()
+ */
+extern void test__f_capability_flag_set__fails(void **state);
+
+#endif // _TEST__F_capability__flag_set
--- /dev/null
+#include "test-capability.h"
+#include "test-capability-from_name.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void test__f_capability_from_name__works(void **state) {
+
+ f_string_t name = f_string_t_initialize;
+ f_capability_value_t capability_value = f_capability_value_t_initialize;
+
+ #if defined(_di_libcap_)
+ printf("[ WARN ] f_capability_from_name() is not implemented and cannot be fully tested.\n");
+ #else
+ will_return(__wrap_cap_from_name, false);
+ #endif // defined(_di_libcap_)
+
+ {
+ const f_status_t status = f_capability_from_name(name, &capability_value);
+
+ #if defined(_di_libcap_)
+ assert_int_equal(F_status_set_fine(status), F_implemented_not);
+ #else
+ assert_int_equal(status, F_none);
+ #endif // defined(_di_libcap_)
+ }
+}
+
+void test__f_capability_from_name__fails(void **state) {
+
+ #if !defined(_di_libcap_)
+ f_string_t name = f_string_t_initialize;
+ f_capability_value_t capability_value = f_capability_value_t_initialize;
+
+ int errnos[] = {
+ EINVAL,
+ ENOMEM,
+ mock_errno_generic,
+ };
+
+ f_status_t statuss[] = {
+ F_parameter,
+ F_memory_not,
+ F_failure,
+ };
+
+ for (int i = 0; i < 3; ++i) {
+
+ will_return(__wrap_cap_from_name, true);
+ will_return(__wrap_cap_from_name, errnos[i]);
+
+ const f_status_t status = f_capability_from_name(name, &capability_value);
+
+ assert_int_equal(F_status_set_fine(status), statuss[i]);
+ } // for
+ #endif // !defined(_di_libcap_)
+}
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
--- /dev/null
+/**
+ * FLL - Level 0
+ *
+ * Project: Capability
+ * API Version: 0.5
+ * Licenses: lgpl-2.1-or-later
+ *
+ * Test the capability project.
+ */
+#ifndef _TEST__F_capability__from_name
+#define _TEST__F_capability__from_name
+
+/**
+ * Test that function works.
+ *
+ * @see f_capability_from_name()
+ */
+extern void test__f_capability_from_name__works(void **state);
+
+/**
+ * Test that function fails.
+ *
+ * @see f_capability_from_name()
+ */
+extern void test__f_capability_from_name__fails(void **state);
+
+#endif // _TEST__F_capability__from_name
--- /dev/null
+#include "test-capability.h"
+#include "test-capability-from_text.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void test__f_capability_from_text__works(void **state) {
+
+ f_string_t text = f_string_t_initialize;
+ f_capability_t capability = f_capability_t_initialize;
+
+ #if defined(_di_libcap_)
+ printf("[ WARN ] f_capability_from_text() is not implemented and cannot be fully tested.\n");
+ #else
+ will_return(__wrap_cap_from_text, false);
+ #endif // defined(_di_libcap_)
+
+ {
+ const f_status_t status = f_capability_from_text(text, &capability);
+
+ #if defined(_di_libcap_)
+ assert_int_equal(F_status_set_fine(status), F_implemented_not);
+ #else
+ assert_int_equal(status, F_none);
+ #endif // defined(_di_libcap_)
+ }
+}
+
+void test__f_capability_from_text__fails(void **state) {
+
+ #if !defined(_di_libcap_)
+ f_string_t text = f_string_t_initialize;
+ f_capability_t capability = f_capability_t_initialize;
+
+ int errnos[] = {
+ EINVAL,
+ ENOMEM,
+ mock_errno_generic,
+ };
+
+ f_status_t statuss[] = {
+ F_parameter,
+ F_memory_not,
+ F_failure,
+ };
+
+ for (int i = 0; i < 3; ++i) {
+
+ will_return(__wrap_cap_from_text, true);
+ will_return(__wrap_cap_from_text, errnos[i]);
+
+ const f_status_t status = f_capability_from_text(text, &capability);
+
+ assert_int_equal(F_status_set_fine(status), statuss[i]);
+ } // for
+ #endif // !defined(_di_libcap_)
+}
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
--- /dev/null
+/**
+ * FLL - Level 0
+ *
+ * Project: Capability
+ * API Version: 0.5
+ * Licenses: lgpl-2.1-or-later
+ *
+ * Test the capability project.
+ */
+#ifndef _TEST__F_capability__from_text
+#define _TEST__F_capability__from_text
+
+/**
+ * Test that function works.
+ *
+ * @see f_capability_from_text()
+ */
+extern void test__f_capability_from_text__works(void **state);
+
+/**
+ * Test that function fails.
+ *
+ * @see f_capability_from_text()
+ */
+extern void test__f_capability_from_text__fails(void **state);
+
+#endif // _TEST__F_capability__from_text
--- /dev/null
+#include "test-capability.h"
+#include "test-capability-groups_set.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void test__f_capability_groups_set__works(void **state) {
+
+ gid_t group;
+ size_t total = 2;
+ gid_t groups[total];
+
+ #if defined(_di_libcap_) || defined(_libcap_legacy_only_)
+ printf("[ WARN ] f_capability_groups_set() is not implemented and cannot be fully tested.\n");
+ #else
+ will_return(__wrap_cap_setgroups, false);
+ #endif // defined(_di_libcap_) || defined(_libcap_legacy_only_)
+
+ {
+ const f_status_t status = f_capability_groups_set(group, total, groups);
+
+ #if defined(_di_libcap_) || defined(_libcap_legacy_only_)
+ assert_int_equal(F_status_set_fine(status), F_implemented_not);
+ #else
+ assert_int_equal(status, F_none);
+ #endif // defined(_di_libcap_) || defined(_libcap_legacy_only_)
+ }
+}
+
+void test__f_capability_groups_set__fails(void **state) {
+
+ #if !defined(_di_libcap_) && !defined(_libcap_legacy_only_)
+ gid_t group;
+ size_t total = 2;
+ gid_t groups[total];
+
+ int errnos[] = {
+ EINVAL,
+ ENOMEM,
+ ERANGE,
+ mock_errno_generic,
+ };
+
+ f_status_t statuss[] = {
+ F_parameter,
+ F_memory_not,
+ F_range_not,
+ F_failure,
+ };
+
+ for (int i = 0; i < 4; ++i) {
+
+ will_return(__wrap_cap_setgroups, true);
+ will_return(__wrap_cap_setgroups, errnos[i]);
+
+ const f_status_t status = f_capability_groups_set(group, total, groups);
+
+ assert_int_equal(F_status_set_fine(status), statuss[i]);
+ } // for
+ #endif // !defined(_di_libcap_) && !defined(_libcap_legacy_only_)
+}
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
--- /dev/null
+/**
+ * FLL - Level 0
+ *
+ * Project: Capability
+ * API Version: 0.5
+ * Licenses: lgpl-2.1-or-later
+ *
+ * Test the capability project.
+ */
+#ifndef _TEST__F_capability__groups_set
+#define _TEST__F_capability__groups_set
+
+/**
+ * Test that function works.
+ *
+ * @see f_capability_groups_set()
+ */
+extern void test__f_capability_groups_set__works(void **state);
+
+/**
+ * Test that function fails.
+ *
+ * @see f_capability_groups_set()
+ */
+extern void test__f_capability_groups_set__fails(void **state);
+
+#endif // _TEST__F_capability__groups_set
--- /dev/null
+#include "test-capability.h"
+#include "test-capability-initialize.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void test__f_capability_initialize__works(void **state) {
+
+ f_capability_t capability = f_capability_t_initialize;
+
+ #if defined(_di_libcap_)
+ printf("[ WARN ] f_capability_initialize() is not implemented and cannot be fully tested.\n");
+ #else
+ will_return(__wrap_cap_init, false);
+ #endif // defined(_di_libcap_)
+
+ {
+ const f_status_t status = f_capability_initialize(&capability);
+
+ #if defined(_di_libcap_)
+ assert_int_equal(F_status_set_fine(status), F_implemented_not);
+ #else
+ assert_int_equal(status, F_none);
+ #endif // defined(_di_libcap_)
+ }
+}
+
+void test__f_capability_initialize__fails(void **state) {
+
+ #if !defined(_di_libcap_)
+ f_capability_t capability = f_capability_t_initialize;
+
+ int errnos[] = {
+ EINVAL,
+ ENOMEM,
+ mock_errno_generic,
+ };
+
+ f_status_t statuss[] = {
+ F_parameter,
+ F_memory_not,
+ F_failure,
+ };
+
+ for (int i = 0; i < 3; ++i) {
+
+ will_return(__wrap_cap_init, true);
+ will_return(__wrap_cap_init, errnos[i]);
+
+ const f_status_t status = f_capability_initialize(&capability);
+
+ assert_int_equal(F_status_set_fine(status), statuss[i]);
+ } // for
+ #endif // !defined(_di_libcap_)
+}
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
--- /dev/null
+/**
+ * FLL - Level 0
+ *
+ * Project: Capability
+ * API Version: 0.5
+ * Licenses: lgpl-2.1-or-later
+ *
+ * Test the capability project.
+ */
+#ifndef _TEST__F_capability__initialize
+#define _TEST__F_capability__initialize
+
+/**
+ * Test that function works.
+ *
+ * @see f_capability_initialize()
+ */
+extern void test__f_capability_initialize__works(void **state);
+
+/**
+ * Test that function fails.
+ *
+ * @see f_capability_initialize()
+ */
+extern void test__f_capability_initialize__fails(void **state);
+
+#endif // _TEST__F_capability__initialize
--- /dev/null
+#include "test-capability.h"
+#include "test-capability-mode_get.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void test__f_capability_mode_get__works(void **state) {
+
+ f_capability_mode_t mode = f_capability_mode_t_initialize;
+
+ #if defined(_di_libcap_) || defined(_libcap_legacy_only_)
+ printf("[ WARN ] f_capability_mode_get() is not implemented and cannot be fully tested.\n");
+ #else
+ will_return(__wrap_cap_mode_get, false);
+ #endif // defined(_di_libcap_) || defined(_libcap_legacy_only_)
+
+ {
+ const f_status_t status = f_capability_mode_get(&mode);
+
+ #if defined(_di_libcap_) || defined(_libcap_legacy_only_)
+ assert_int_equal(F_status_set_fine(status), F_implemented_not);
+ #else
+ assert_int_equal(status, F_none);
+ #endif // defined(_di_libcap_) || defined(_libcap_legacy_only_)
+ }
+}
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
--- /dev/null
+/**
+ * FLL - Level 0
+ *
+ * Project: Capability
+ * API Version: 0.5
+ * Licenses: lgpl-2.1-or-later
+ *
+ * Test the capability project.
+ */
+#ifndef _TEST__F_capability__mode_get
+#define _TEST__F_capability__mode_get
+
+/**
+ * Test that function works.
+ *
+ * @see f_capability_mode_get()
+ */
+extern void test__f_capability_mode_get__works(void **state);
+
+// cap_get_mode() doesn't return failure.
+
+#endif // _TEST__F_capability__mode_get
--- /dev/null
+#include "test-capability.h"
+#include "test-capability-mode_get_name.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void test__f_capability_mode_get_name__works(void **state) {
+
+ f_capability_mode_t mode = f_capability_mode_t_initialize;
+ f_string_constant_t constant = f_string_constant_t_initialize;
+
+ #if defined(_di_libcap_) || defined(_libcap_legacy_only_)
+ printf("[ WARN ] f_capability_mode_get_name() is not implemented and cannot be fully tested.\n");
+ #else
+ will_return(__wrap_cap_mode_get_name, false);
+ #endif // defined(_di_libcap_) || defined(_libcap_legacy_only_)
+
+ {
+ const f_status_t status = f_capability_mode_get_name(mode, &constant);
+
+ #if defined(_di_libcap_) || defined(_libcap_legacy_only_)
+ assert_int_equal(F_status_set_fine(status), F_implemented_not);
+ #else
+ assert_int_equal(status, F_none);
+ #endif // defined(_di_libcap_) || defined(_libcap_legacy_only_)
+ }
+}
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
--- /dev/null
+/**
+ * FLL - Level 0
+ *
+ * Project: Capability
+ * API Version: 0.5
+ * Licenses: lgpl-2.1-or-later
+ *
+ * Test the capability project.
+ */
+#ifndef _TEST__F_capability__mode_get_name
+#define _TEST__F_capability__mode_get_name
+
+/**
+ * Test that function works.
+ *
+ * @see f_capability_mode_get_name()
+ */
+extern void test__f_capability_mode_get_name__works(void **state);
+
+// cap_mode_name() doesn't return failure.
+
+#endif // _TEST__F_capability__mode_get_name
--- /dev/null
+#include "test-capability.h"
+#include "test-capability-mode_set.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void test__f_capability_mode_set__works(void **state) {
+
+ f_capability_mode_t mode = f_capability_mode_t_initialize;
+
+ #if defined(_di_libcap_) || defined(_libcap_legacy_only_)
+ printf("[ WARN ] f_capability_mode_set() is not implemented and cannot be fully tested.\n");
+ #else
+ will_return(__wrap_cap_mode_set, false);
+ #endif // defined(_di_libcap_) || defined(_libcap_legacy_only_)
+
+ {
+ const f_status_t status = f_capability_mode_set(mode);
+
+ #if defined(_di_libcap_) || defined(_libcap_legacy_only_)
+ assert_int_equal(F_status_set_fine(status), F_implemented_not);
+ #else
+ assert_int_equal(status, F_none);
+ #endif // defined(_di_libcap_) || defined(_libcap_legacy_only_)
+ }
+}
+
+void test__f_capability_mode_set__fails(void **state) {
+
+ #if !defined(_di_libcap_) && !defined(_libcap_legacy_only_)
+ f_capability_mode_t mode = f_capability_mode_t_initialize;
+
+ int errnos[] = {
+ EINVAL,
+ ENOMEM,
+ EPERM,
+ mock_errno_generic,
+ };
+
+ f_status_t statuss[] = {
+ F_parameter,
+ F_memory_not,
+ F_prohibited,
+ F_failure,
+ };
+
+ for (int i = 0; i < 4; ++i) {
+
+ will_return(__wrap_cap_mode_set, true);
+ will_return(__wrap_cap_mode_set, errnos[i]);
+
+ const f_status_t status = f_capability_mode_set(mode);
+
+ assert_int_equal(F_status_set_fine(status), statuss[i]);
+ } // for
+ #endif // !defined(_di_libcap_) && !defined(_libcap_legacy_only_)
+}
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
--- /dev/null
+/**
+ * FLL - Level 0
+ *
+ * Project: Capability
+ * API Version: 0.5
+ * Licenses: lgpl-2.1-or-later
+ *
+ * Test the capability project.
+ */
+#ifndef _TEST__F_capability__mode_set
+#define _TEST__F_capability__mode_set
+
+/**
+ * Test that function works.
+ *
+ * @see f_capability_mode_set()
+ */
+extern void test__f_capability_mode_set__works(void **state);
+
+/**
+ * Test that function fails.
+ *
+ * @see f_capability_mode_set()
+ */
+extern void test__f_capability_mode_set__fails(void **state);
+
+#endif // _TEST__F_capability__mode_set
--- /dev/null
+#include "test-capability.h"
+#include "test-capability-owner_get.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void test__f_capability_owner_get__works(void **state) {
+
+ f_capability_t capability = f_capability_t_initialize;
+ uid_t id;
+
+ #if defined(_di_libcap_) || defined(_libcap_legacy_only_)
+ printf("[ WARN ] f_capability_owner_get() is not implemented and cannot be fully tested.\n");
+ #else
+ will_return(__wrap_cap_get_nsowner, false);
+ #endif // defined(_di_libcap_) || defined(_libcap_legacy_only_)
+
+ {
+ const f_status_t status = f_capability_owner_get(capability, &id);
+
+ #if defined(_di_libcap_) || defined(_libcap_legacy_only_)
+ assert_int_equal(F_status_set_fine(status), F_implemented_not);
+ #else
+ assert_int_equal(status, F_none);
+ assert_int_equal(id, 1);
+ #endif // defined(_di_libcap_) || defined(_libcap_legacy_only_)
+ }
+}
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
--- /dev/null
+/**
+ * FLL - Level 0
+ *
+ * Project: Capability
+ * API Version: 0.5
+ * Licenses: lgpl-2.1-or-later
+ *
+ * Test the capability project.
+ */
+#ifndef _TEST__F_capability__owner_get
+#define _TEST__F_capability__owner_get
+
+/**
+ * Test that function works.
+ *
+ * @see f_capability_owner_get()
+ */
+extern void test__f_capability_owner_get__works(void **state);
+
+// cap_mode_name() doesn't return failure.
+
+#endif // _TEST__F_capability__owner_get
--- /dev/null
+#include "test-capability.h"
+#include "test-capability-owner_set.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void test__f_capability_owner_set__works(void **state) {
+
+ f_capability_t capability = f_capability_t_initialize;
+ uid_t id;
+
+ #if defined(_di_libcap_) || defined(_libcap_legacy_only_)
+ printf("[ WARN ] f_capability_owner_set() is not implemented and cannot be fully tested.\n");
+ #else
+ will_return(__wrap_cap_set_nsowner, false);
+ #endif // defined(_di_libcap_) || defined(_libcap_legacy_only_)
+
+ {
+ const f_status_t status = f_capability_owner_set(capability, id);
+
+ #if defined(_di_libcap_) || defined(_libcap_legacy_only_)
+ assert_int_equal(F_status_set_fine(status), F_implemented_not);
+ #else
+ assert_int_equal(status, F_none);
+ #endif // defined(_di_libcap_) || defined(_libcap_legacy_only_)
+ }
+}
+
+void test__f_capability_owner_set__fails(void **state) {
+
+ #if !defined(_di_libcap_) && !defined(_libcap_legacy_only_)
+ f_capability_t capability = f_capability_t_initialize;
+ uid_t id;
+
+ int errnos[] = {
+ EACCES,
+ EBADFD,
+ ENAMETOOLONG,
+ ENOENT,
+ ENOMEM,
+ ENOTDIR,
+ EPERM,
+ EROFS,
+ mock_errno_generic,
+ };
+
+ f_status_t statuss[] = {
+ F_access_denied,
+ F_descriptor_not,
+ F_name_not,
+ F_file_found_not,
+ F_memory_not,
+ F_directory_not,
+ F_prohibited,
+ F_supported_not,
+ F_failure,
+ };
+
+ for (int i = 0; i < 9; ++i) {
+
+ will_return(__wrap_cap_owner_set, true);
+ will_return(__wrap_cap_owner_set, errnos[i]);
+
+ const f_status_t status = f_capability_owner_set(capability, id);
+
+ assert_int_equal(F_status_set_fine(status), statuss[i]);
+ } // for
+ #endif // !defined(_di_libcap_) && !defined(_libcap_legacy_only_)
+}
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
--- /dev/null
+/**
+ * FLL - Level 0
+ *
+ * Project: Capability
+ * API Version: 0.5
+ * Licenses: lgpl-2.1-or-later
+ *
+ * Test the capability project.
+ */
+#ifndef _TEST__F_capability__owner_set
+#define _TEST__F_capability__owner_set
+
+/**
+ * Test that function works.
+ *
+ * @see f_capability_owner_set()
+ */
+extern void test__f_capability_owner_set__works(void **state);
+
+/**
+ * Test that function fails.
+ *
+ * @see f_capability_owner_set()
+ */
+extern void test__f_capability_owner_set__fails(void **state);
+
+#endif // _TEST__F_capability__owner_set
--- /dev/null
+#include "test-capability.h"
+#include "test-capability-process_bound_drop.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void test__f_capability_process_bound_drop__works(void **state) {
+
+ f_capability_value_t value = f_capability_value_t_initialize;
+ int bound = 0;
+
+ #if defined(_di_libcap_)
+ printf("[ WARN ] f_capability_process_bound_drop() is not implemented and cannot be fully tested.\n");
+ #else
+ will_return(__wrap_cap_drop_bound, false);
+ #endif // defined(_di_libcap_)
+
+ {
+ const f_status_t status = f_capability_process_bound_drop(value, &bound);
+
+ #if defined(_di_libcap_)
+ assert_int_equal(F_status_set_fine(status), F_implemented_not);
+ #else
+ assert_int_equal(status, F_none);
+ assert_int_equal(bound, 1);
+ #endif // defined(_di_libcap_)
+ }
+}
+
+void test__f_capability_process_bound_drop__fails(void **state) {
+
+ #if !defined(_di_libcap_)
+ f_capability_value_t value = f_capability_value_t_initialize;
+ int bound = 0;
+
+ int errnos[] = {
+ EINVAL,
+ ENOMEM,
+ EPERM,
+ mock_errno_generic,
+ };
+
+ f_status_t statuss[] = {
+ F_parameter,
+ F_memory_not,
+ F_prohibited,
+ F_failure,
+ };
+
+ for (int i = 0; i < 4; ++i) {
+
+ will_return(__wrap_cap_drop_bound, true);
+ will_return(__wrap_cap_drop_bound, errnos[i]);
+
+ const f_status_t status = f_capability_process_bound_drop(value, &bound);
+
+ assert_int_equal(F_status_set_fine(status), statuss[i]);
+ } // for
+ #endif // !defined(_di_libcap_)
+}
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
--- /dev/null
+/**
+ * FLL - Level 0
+ *
+ * Project: Capability
+ * API Version: 0.5
+ * Licenses: lgpl-2.1-or-later
+ *
+ * Test the capability project.
+ */
+#ifndef _TEST__F_capability__process_bound_drop
+#define _TEST__F_capability__process_bound_drop
+
+/**
+ * Test that function works.
+ *
+ * @see f_capability_process_bound_drop()
+ */
+extern void test__f_capability_process_bound_drop__works(void **state);
+
+/**
+ * Test that function fails.
+ *
+ * @see f_capability_process_bound_drop()
+ */
+extern void test__f_capability_process_bound_drop__fails(void **state);
+
+#endif // _TEST__F_capability__process_bound_drop
--- /dev/null
+#include "test-capability.h"
+#include "test-capability-process_bound_get.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void test__f_capability_process_bound_get__works(void **state) {
+
+ f_capability_value_t value = f_capability_value_t_initialize;
+ int bound = 0;
+
+ #if defined(_di_libcap_)
+ printf("[ WARN ] f_capability_process_bound_get() is not implemented and cannot be fully tested.\n");
+ #else
+ will_return(__wrap_cap_get_bound, false);
+ #endif // defined(_di_libcap_)
+
+ {
+ const f_status_t status = f_capability_process_bound_get(value, &bound);
+
+ #if defined(_di_libcap_)
+ assert_int_equal(F_status_set_fine(status), F_implemented_not);
+ #else
+ assert_int_equal(status, F_none);
+ assert_int_equal(bound, 1);
+ #endif // defined(_di_libcap_)
+ }
+}
+
+void test__f_capability_process_bound_get__fails(void **state) {
+
+ #if !defined(_di_libcap_)
+ f_capability_value_t value = f_capability_value_t_initialize;
+ int bound = 0;
+
+ int errnos[] = {
+ mock_errno_generic,
+ };
+
+ f_status_t statuss[] = {
+ F_known_not,
+ };
+
+ for (int i = 0; i < 1; ++i) {
+
+ will_return(__wrap_cap_get_bound, true);
+ will_return(__wrap_cap_get_bound, errnos[i]);
+
+ const f_status_t status = f_capability_process_bound_get(value, &bound);
+
+ assert_int_equal(F_status_set_fine(status), statuss[i]);
+ } // for
+ #endif // !defined(_di_libcap_)
+}
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
--- /dev/null
+/**
+ * FLL - Level 0
+ *
+ * Project: Capability
+ * API Version: 0.5
+ * Licenses: lgpl-2.1-or-later
+ *
+ * Test the capability project.
+ */
+#ifndef _TEST__F_capability__process_bound_get
+#define _TEST__F_capability__process_bound_get
+
+/**
+ * Test that function works.
+ *
+ * @see f_capability_process_bound_get()
+ */
+extern void test__f_capability_process_bound_get__works(void **state);
+
+/**
+ * Test that function fails.
+ *
+ * @see f_capability_process_bound_get()
+ */
+extern void test__f_capability_process_bound_get__fails(void **state);
+
+#endif // _TEST__F_capability__process_bound_get
--- /dev/null
+#include "test-capability.h"
+#include "test-capability-process_get.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void test__f_capability_process_get__works(void **state) {
+
+ f_capability_t capability = f_capability_t_initialize;
+
+ #if defined(_di_libcap_)
+ printf("[ WARN ] f_capability_process_get() is not implemented and cannot be fully tested.\n");
+ #else
+ will_return(__wrap_cap_get_proc, false);
+ #endif // defined(_di_libcap_)
+
+ {
+ const f_status_t status = f_capability_process_get(&capability);
+
+ #if defined(_di_libcap_)
+ assert_int_equal(F_status_set_fine(status), F_implemented_not);
+ #else
+ assert_int_equal(status, F_none);
+ #endif // defined(_di_libcap_)
+ }
+}
+
+void test__f_capability_process_get__fails(void **state) {
+
+ #if !defined(_di_libcap_)
+ f_capability_t capability = f_capability_t_initialize;
+
+ int errnos[] = {
+ EINVAL,
+ ENOMEM,
+ mock_errno_generic,
+ };
+
+ f_status_t statuss[] = {
+ F_parameter,
+ F_memory_not,
+ F_failure,
+ };
+
+ for (int i = 0; i < 3; ++i) {
+
+ will_return(__wrap_cap_get_proc, true);
+ will_return(__wrap_cap_get_proc, errnos[i]);
+
+ const f_status_t status = f_capability_process_get(&capability);
+
+ assert_int_equal(F_status_set_fine(status), statuss[i]);
+ } // for
+ #endif // !defined(_di_libcap_)
+}
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
--- /dev/null
+/**
+ * FLL - Level 0
+ *
+ * Project: Capability
+ * API Version: 0.5
+ * Licenses: lgpl-2.1-or-later
+ *
+ * Test the capability project.
+ */
+#ifndef _TEST__F_capability__process_get
+#define _TEST__F_capability__process_get
+
+/**
+ * Test that function works.
+ *
+ * @see f_capability_process_get()
+ */
+extern void test__f_capability_process_get__works(void **state);
+
+/**
+ * Test that function fails.
+ *
+ * @see f_capability_process_get()
+ */
+extern void test__f_capability_process_get__fails(void **state);
+
+#endif // _TEST__F_capability__process_get
--- /dev/null
+#include "test-capability.h"
+#include "test-capability-process_get_by_id.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void test__f_capability_process_get_by_id__works(void **state) {
+
+ f_capability_t capability = f_capability_t_initialize;
+ pid_t pid;
+
+ #if defined(_di_libcap_)
+ printf("[ WARN ] f_capability_process_get_by_id() is not implemented and cannot be fully tested.\n");
+ #else
+ will_return(__wrap_cap_get_pid, false);
+ #endif // defined(_di_libcap_)
+
+ {
+ const f_status_t status = f_capability_process_get_by_id(pid, &capability);
+
+ #if defined(_di_libcap_)
+ assert_int_equal(F_status_set_fine(status), F_implemented_not);
+ #else
+ assert_int_equal(status, F_none);
+ assert_int_equal(capability, 1);
+ #endif // defined(_di_libcap_)
+ }
+}
+
+void test__f_capability_process_get_by_id__fails(void **state) {
+
+ #if !defined(_di_libcap_)
+ f_capability_t capability = f_capability_t_initialize;
+ pid_t pid;
+
+ int errnos[] = {
+ mock_errno_generic,
+ };
+
+ f_status_t statuss[] = {
+ F_failure,
+ };
+
+ for (int i = 0; i < 1; ++i) {
+
+ will_return(__wrap_cap_get_pid, true);
+ will_return(__wrap_cap_get_pid, errnos[i]);
+
+ const f_status_t status = f_capability_process_get_by_id(pid, &capability);
+
+ assert_int_equal(F_status_set_fine(status), statuss[i]);
+ } // for
+ #endif // !defined(_di_libcap_)
+}
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
--- /dev/null
+/**
+ * FLL - Level 0
+ *
+ * Project: Capability
+ * API Version: 0.5
+ * Licenses: lgpl-2.1-or-later
+ *
+ * Test the capability project.
+ */
+#ifndef _TEST__F_capability__process_get_by_id
+#define _TEST__F_capability__process_get_by_id
+
+/**
+ * Test that function works.
+ *
+ * @see f_capability_process_get_by_id()
+ */
+extern void test__f_capability_process_get_by_id__works(void **state);
+
+/**
+ * Test that function fails.
+ *
+ * @see f_capability_process_get_by_id()
+ */
+extern void test__f_capability_process_get_by_id__fails(void **state);
+
+#endif // _TEST__F_capability__process_get_by_id
--- /dev/null
+#include "test-capability.h"
+#include "test-capability-process_set.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void test__f_capability_process_set__works(void **state) {
+
+ f_capability_t capability = f_capability_t_initialize;
+
+ #if defined(_di_libcap_)
+ printf("[ WARN ] f_capability_process_set() is not implemented and cannot be fully tested.\n");
+ #else
+ will_return(__wrap_cap_set_proc, false);
+ #endif // defined(_di_libcap_)
+
+ {
+ const f_status_t status = f_capability_process_set(capability);
+
+ #if defined(_di_libcap_)
+ assert_int_equal(F_status_set_fine(status), F_implemented_not);
+ #else
+ assert_int_equal(status, F_none);
+ #endif // defined(_di_libcap_)
+ }
+}
+
+void test__f_capability_process_set__fails(void **state) {
+
+ #if !defined(_di_libcap_)
+ f_capability_t capability = f_capability_t_initialize;
+
+ int errnos[] = {
+ EINVAL,
+ ENOMEM,
+ EPERM,
+ mock_errno_generic,
+ };
+
+ f_status_t statuss[] = {
+ F_parameter,
+ F_memory_not,
+ F_prohibited,
+ F_failure,
+ };
+
+ for (int i = 0; i < 4; ++i) {
+
+ will_return(__wrap_cap_set_proc, true);
+ will_return(__wrap_cap_set_proc, errnos[i]);
+
+ const f_status_t status = f_capability_process_set(capability);
+
+ assert_int_equal(F_status_set_fine(status), statuss[i]);
+ } // for
+ #endif // !defined(_di_libcap_)
+}
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
--- /dev/null
+/**
+ * FLL - Level 0
+ *
+ * Project: Capability
+ * API Version: 0.5
+ * Licenses: lgpl-2.1-or-later
+ *
+ * Test the capability project.
+ */
+#ifndef _TEST__F_capability__process_set
+#define _TEST__F_capability__process_set
+
+/**
+ * Test that function works.
+ *
+ * @see f_capability_process_set()
+ */
+extern void test__f_capability_process_set__works(void **state);
+
+/**
+ * Test that function fails.
+ *
+ * @see f_capability_process_set()
+ */
+extern void test__f_capability_process_set__fails(void **state);
+
+#endif // _TEST__F_capability__process_set
--- /dev/null
+#include "test-capability.h"
+#include "test-capability-security_bits_get.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void test__f_capability_security_bits_get__works(void **state) {
+
+ f_capability_bits_t bits = f_capability_bits_t_initialize;
+
+ #if defined(_di_libcap_) || defined(_libcap_legacy_only_)
+ printf("[ WARN ] f_capability_security_bits_get() is not implemented and cannot be fully tested.\n");
+ #else
+ will_return(__wrap_cap_get_secbits, false);
+ #endif // defined(_di_libcap_) || defined(_libcap_legacy_only_)
+
+ {
+ const f_status_t status = f_capability_security_bits_get(&bits);
+
+ #if defined(_di_libcap_) || defined(_libcap_legacy_only_)
+ assert_int_equal(F_status_set_fine(status), F_implemented_not);
+ #else
+ assert_int_equal(status, F_none);
+ #endif // defined(_di_libcap_) || defined(_libcap_legacy_only_)
+ }
+}
+
+void test__f_capability_security_bits_get__fails(void **state) {
+
+ #if !defined(_di_libcap_) && !defined(_libcap_legacy_only_)
+ f_capability_bits_t bits = f_capability_bits_t_initialize;
+
+ int errnos[] = {
+ EINVAL,
+ ENOMEM,
+ EPERM,
+ mock_errno_generic,
+ };
+
+ f_status_t statuss[] = {
+ F_parameter,
+ F_memory_not,
+ F_prohibited,
+ F_failure,
+ };
+
+ for (int i = 0; i < 4; ++i) {
+
+ will_return(__wrap_cap_get_secbits, true);
+ will_return(__wrap_cap_get_secbits, errnos[i]);
+
+ const f_status_t status = f_capability_security_bits_get(&bits);
+
+ assert_int_equal(F_status_set_fine(status), statuss[i]);
+ } // for
+ #endif // !defined(_di_libcap_) && !defined(_libcap_legacy_only_)
+}
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
--- /dev/null
+/**
+ * FLL - Level 0
+ *
+ * Project: Capability
+ * API Version: 0.5
+ * Licenses: lgpl-2.1-or-later
+ *
+ * Test the capability project.
+ */
+#ifndef _TEST__F_capability__security_bits_get
+#define _TEST__F_capability__security_bits_get
+
+/**
+ * Test that function works.
+ *
+ * @see f_capability_security_bits_get()
+ */
+extern void test__f_capability_security_bits_get__works(void **state);
+
+/**
+ * Test that function fails.
+ *
+ * @see f_capability_security_bits_get()
+ */
+extern void test__f_capability_security_bits_get__fails(void **state);
+
+#endif // _TEST__F_capability__security_bits_get
--- /dev/null
+#include "test-capability.h"
+#include "test-capability-security_bits_set.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void test__f_capability_security_bits_set__works(void **state) {
+
+ f_capability_bits_t bits = f_capability_bits_t_initialize;
+
+ #if defined(_di_libcap_) || defined(_libcap_legacy_only_)
+ printf("[ WARN ] f_capability_security_bits_set() is not implemented and cannot be fully tested.\n");
+ #else
+ will_return(__wrap_cap_set_secbits, false);
+ #endif // defined(_di_libcap_) || defined(_libcap_legacy_only_)
+
+ {
+ const f_status_t status = f_capability_security_bits_set(bits);
+
+ #if defined(_di_libcap_) || defined(_libcap_legacy_only_)
+ assert_int_equal(F_status_set_fine(status), F_implemented_not);
+ #else
+ assert_int_equal(status, F_none);
+ #endif // defined(_di_libcap_) || defined(_libcap_legacy_only_)
+ }
+}
+
+void test__f_capability_security_bits_set__fails(void **state) {
+
+ #if !defined(_di_libcap_) && !defined(_libcap_legacy_only_)
+ f_capability_bits_t bits = f_capability_bits_t_initialize;
+
+ int errnos[] = {
+ EACCES,
+ EBADFD,
+ ENAMETOOLONG,
+ ENOENT,
+ ENOMEM,
+ ENOTDIR,
+ EPERM,
+ EROFS,
+ mock_errno_generic,
+ };
+
+ f_status_t statuss[] = {
+ F_access_denied,
+ F_descriptor_not,
+ F_name_not,
+ F_file_found_not,
+ F_memory_not,
+ F_directory_not,
+ F_prohibited,
+ F_supported_not,
+ F_failure,
+ };
+
+ for (int i = 0; i < 9; ++i) {
+
+ will_return(__wrap_cap_set_secbits, true);
+ will_return(__wrap_cap_set_secbits, errnos[i]);
+
+ const f_status_t status = f_capability_security_bits_set(bits);
+
+ assert_int_equal(F_status_set_fine(status), statuss[i]);
+ } // for
+ #endif // !defined(_di_libcap_) && !defined(_libcap_legacy_only_)
+}
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
--- /dev/null
+/**
+ * FLL - Level 0
+ *
+ * Project: Capability
+ * API Version: 0.5
+ * Licenses: lgpl-2.1-or-later
+ *
+ * Test the capability project.
+ */
+#ifndef _TEST__F_capability__security_bits_set
+#define _TEST__F_capability__security_bits_set
+
+/**
+ * Test that function works.
+ *
+ * @see f_capability_security_bits_set()
+ */
+extern void test__f_capability_security_bits_set__works(void **state);
+
+/**
+ * Test that function fails.
+ *
+ * @see f_capability_security_bits_set()
+ */
+extern void test__f_capability_security_bits_set__fails(void **state);
+
+#endif // _TEST__F_capability__security_bits_set
--- /dev/null
+#include "test-capability.h"
+#include "test-capability-size.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void test__f_capability_size__works(void **state) {
+
+ f_capability_t capability = f_capability_t_initialize;
+ ssize_t size = 0;
+
+ #if defined(_di_libcap_)
+ printf("[ WARN ] f_capability_size() is not implemented and cannot be fully tested.\n");
+ #else
+ will_return(__wrap_cap_size, false);
+ #endif // defined(_di_libcap_)
+
+ {
+ const f_status_t status = f_capability_size(capability, &size);
+
+ #if defined(_di_libcap_)
+ assert_int_equal(F_status_set_fine(status), F_implemented_not);
+ #else
+ assert_int_equal(status, F_none);
+ assert_int_equal(size, 1);
+ #endif // defined(_di_libcap_)
+ }
+}
+
+void test__f_capability_size__fails(void **state) {
+
+ #if !defined(_di_libcap_)
+ f_capability_t capability = f_capability_t_initialize;
+ ssize_t size = 0;
+
+ int errnos[] = {
+ EINVAL,
+ ENOMEM,
+ EPERM,
+ mock_errno_generic,
+ };
+
+ f_status_t statuss[] = {
+ F_parameter,
+ F_memory_not,
+ F_prohibited,
+ F_failure,
+ };
+
+ for (int i = 0; i < 4; ++i) {
+
+ will_return(__wrap_cap_size, true);
+ will_return(__wrap_cap_size, errnos[i]);
+
+ const f_status_t status = f_capability_size(capability, &size);
+
+ assert_int_equal(F_status_set_fine(status), statuss[i]);
+ } // for
+ #endif // !defined(_di_libcap_)
+}
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
--- /dev/null
+/**
+ * FLL - Level 0
+ *
+ * Project: Capability
+ * API Version: 0.5
+ * Licenses: lgpl-2.1-or-later
+ *
+ * Test the capability project.
+ */
+#ifndef _TEST__F_capability__size
+#define _TEST__F_capability__size
+
+/**
+ * Test that function works.
+ *
+ * @see f_capability_size()
+ */
+extern void test__f_capability_size__works(void **state);
+
+/**
+ * Test that function fails.
+ *
+ * @see f_capability_size()
+ */
+extern void test__f_capability_size__fails(void **state);
+
+#endif // _TEST__F_capability__size
--- /dev/null
+#include "test-capability.h"
+#include "test-capability-supported.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void test__f_capability_supported__works(void **state) {
+
+ {
+ const f_status_t status = f_capability_supported();
+
+ #if defined(_di_libcap_)
+ assert_int_equal(status, F_false);
+ #else
+ assert_int_equal(status, F_true);
+ #endif // defined(_di_libcap_)
+ }
+}
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
--- /dev/null
+/**
+ * FLL - Level 0
+ *
+ * Project: Capability
+ * API Version: 0.5
+ * Licenses: lgpl-2.1-or-later
+ *
+ * Test the capability project.
+ */
+#ifndef _TEST__F_capability__supported
+#define _TEST__F_capability__supported
+
+/**
+ * Test that function works.
+ *
+ * @see f_capability_supported()
+ */
+extern void test__f_capability_supported__works(void **state);
+
+// f_capability_supported() doesn't return failure.
+
+#endif // _TEST__F_capability__supported
--- /dev/null
+#include "test-capability.h"
+#include "test-capability-supported_ambient.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void test__f_capability_supported_ambient__works(void **state) {
+
+ #if defined(_di_libcap_) || defined(_libcap_legacy_only_)
+ {
+ const f_status_t status = f_capability_supported_ambient();
+
+ assert_int_equal(status, F_false);
+ }
+ #else
+ {
+ const f_status_t status = f_capability_supported_ambient();
+
+ will_return(__wrap_cap_get_ambient, false);
+
+ assert_int_equal(status, F_true);
+ }
+
+ {
+ const f_status_t status = f_capability_supported_ambient();
+
+ will_return(__wrap_cap_get_ambient, true);
+ will_return(__wrap_cap_get_ambient, mock_errno_generic);
+
+ assert_int_equal(status, F_false);
+ }
+ #endif // defined(_di_libcap_) || defined(_libcap_legacy_only_)
+}
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
--- /dev/null
+/**
+ * FLL - Level 0
+ *
+ * Project: Capability
+ * API Version: 0.5
+ * Licenses: lgpl-2.1-or-later
+ *
+ * Test the capability project.
+ */
+#ifndef _TEST__F_capability__supported_ambient
+#define _TEST__F_capability__supported_ambient
+
+/**
+ * Test that function works.
+ *
+ * @see f_capability_supported_ambient()
+ */
+extern void test__f_capability_supported_ambient__works(void **state);
+
+// f_capability_supported_ambient() doesn't return failure.
+
+#endif // _TEST__F_capability__supported_ambient
--- /dev/null
+#include "test-capability.h"
+#include "test-capability-supported_code.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void test__f_capability_supported_code__works(void **state) {
+
+ f_capability_value_t value = f_capability_value_t_initialize;
+
+ #if defined(_di_libcap_)
+ {
+ const f_status_t status = f_capability_supported_code(value);
+
+ assert_int_equal(status, F_false);
+ }
+ #else
+ {
+ will_return(__wrap_cap_get_bound, false);
+
+ const f_status_t status = f_capability_supported_code(value);
+
+ assert_int_equal(status, F_true);
+ }
+
+ {
+ will_return(__wrap_cap_get_bound, F_true);
+ will_return(__wrap_cap_get_bound, mock_errno_generic);
+
+ const f_status_t status = f_capability_supported_code(value);
+
+ assert_int_equal(status, F_false);
+ }
+ #endif // defined(_di_libcap_)
+}
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
--- /dev/null
+/**
+ * FLL - Level 0
+ *
+ * Project: Capability
+ * API Version: 0.5
+ * Licenses: lgpl-2.1-or-later
+ *
+ * Test the capability project.
+ */
+#ifndef _TEST__F_capability__supported_code
+#define _TEST__F_capability__supported_code
+
+/**
+ * Test that function works.
+ *
+ * @see f_capability_supported_code()
+ */
+extern void test__f_capability_supported_code__works(void **state);
+
+// f_capability_supported_code() doesn't return failure.
+
+#endif // _TEST__F_capability__supported_code
--- /dev/null
+#include "test-capability.h"
+#include "test-capability-to_name.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void test__f_capability_to_name__works(void **state) {
+
+ int code = CAP_CHOWN;
+ char string[] = "CAP_CHOWN";
+ f_string_dynamic_t name = f_string_dynamic_t_initialize;
+
+ #if defined(_di_libcap_)
+ printf("[ WARN ] f_capability_to_name() is not implemented and cannot be fully tested.\n");
+ #else
+ will_return(__wrap_cap_to_name, false);
+ will_return(__wrap_cap_to_name, string);
+ will_return(__wrap_cap_free, false);
+ #endif // defined(_di_libcap_)
+
+ {
+ const f_status_t status = f_capability_to_name(code, &name);
+
+ #if defined(_di_libcap_)
+ assert_int_equal(F_status_set_fine(status), F_implemented_not);
+ #else
+ assert_string_equal(name.string, string);
+ assert_int_equal(name.used, 9);
+ #endif // defined(_di_libcap_)
+ }
+
+ f_string_dynamic_resize(0, &name);
+}
+
+void test__f_capability_to_name__fails(void **state) {
+
+ #if !defined(_di_libcap_)
+ int code = CAP_CHOWN;
+ f_string_dynamic_t name = f_string_dynamic_t_initialize;
+
+ int errnos[] = {
+ EINVAL,
+ ENOMEM,
+ mock_errno_generic,
+ };
+
+ f_status_t statuss[] = {
+ F_parameter,
+ F_memory_not,
+ F_failure,
+ };
+
+ for (int i = 0; i < 3; ++i) {
+
+ will_return(__wrap_cap_to_name, true);
+ will_return(__wrap_cap_to_name, errnos[i]);
+
+ const f_status_t status = f_capability_to_name(code, &name);
+
+ assert_int_equal(F_status_set_fine(status), statuss[i]);
+ assert_int_equal(name.used, 0);
+ } // for
+ #endif // !defined(_di_libcap_)
+}
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
--- /dev/null
+/**
+ * FLL - Level 0
+ *
+ * Project: Capability
+ * API Version: 0.5
+ * Licenses: lgpl-2.1-or-later
+ *
+ * Test the capability project.
+ */
+#ifndef _TEST__F_capability__to_name
+#define _TEST__F_capability__to_name
+
+/**
+ * Test that function works.
+ *
+ * @see f_capability_to_name()
+ */
+extern void test__f_capability_to_name__works(void **state);
+
+/**
+ * Test that function fails.
+ *
+ * @see f_capability_to_name()
+ */
+extern void test__f_capability_to_name__fails(void **state);
+
+#endif // _TEST__F_capability__to_name
--- /dev/null
+#include "test-capability.h"
+#include "test-capability-to_text.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void test__f_capability_to_text__works(void **state) {
+
+ f_capability_t capability = f_capability_t_initialize;
+ char string[] = "CAP_CHOWN";
+ f_string_dynamic_t text = f_string_dynamic_t_initialize;
+
+ #if defined(_di_libcap_)
+ printf("[ WARN ] f_capability_to_text() is not implemented and cannot be fully tested.\n");
+ #else
+ will_return(__wrap_cap_to_text, false);
+ will_return(__wrap_cap_to_text, 9);
+ will_return(__wrap_cap_to_text, string);
+ will_return(__wrap_cap_free, false);
+ #endif // defined(_di_libcap_)
+
+ {
+ const f_status_t status = f_capability_to_text(capability, &text);
+
+ #if defined(_di_libcap_)
+ assert_int_equal(F_status_set_fine(status), F_implemented_not);
+ #else
+ assert_string_equal(text.string, string);
+ assert_int_equal(text.used, 9);
+ #endif // defined(_di_libcap_)
+ }
+
+ f_string_dynamic_resize(0, &text);
+}
+
+void test__f_capability_to_text__fails(void **state) {
+
+ #if !defined(_di_libcap_)
+ f_capability_t capability = f_capability_t_initialize;
+ f_string_dynamic_t text = f_string_dynamic_t_initialize;
+
+ int errnos[] = {
+ EINVAL,
+ ENOMEM,
+ mock_errno_generic,
+ };
+
+ f_status_t statuss[] = {
+ F_parameter,
+ F_memory_not,
+ F_failure,
+ };
+
+ for (int i = 0; i < 3; ++i) {
+
+ will_return(__wrap_cap_to_text, true);
+ will_return(__wrap_cap_to_text, errnos[i]);
+
+ const f_status_t status = f_capability_to_text(capability, &text);
+
+ assert_int_equal(F_status_set_fine(status), statuss[i]);
+ assert_int_equal(text.used, 0);
+ } // for
+ #endif // !defined(_di_libcap_)
+}
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
--- /dev/null
+/**
+ * FLL - Level 0
+ *
+ * Project: Capability
+ * API Version: 0.5
+ * Licenses: lgpl-2.1-or-later
+ *
+ * Test the capability project.
+ */
+#ifndef _TEST__F_capability__to_text
+#define _TEST__F_capability__to_text
+
+/**
+ * Test that function works.
+ *
+ * @see f_capability_to_text()
+ */
+extern void test__f_capability_to_text__works(void **state);
+
+/**
+ * Test that function fails.
+ *
+ * @see f_capability_to_text()
+ */
+extern void test__f_capability_to_text__fails(void **state);
+
+#endif // _TEST__F_capability__to_text
--- /dev/null
+#include "test-capability.h"
+#include "test-capability-user_set.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void test__f_capability_user_set__works(void **state) {
+
+ uid_t uid;
+
+ #if defined(_di_libcap_) || defined(_libcap_legacy_only_)
+ printf("[ WARN ] f_capability_user_set() is not implemented and cannot be fully tested.\n");
+ #else
+ will_return(__wrap_cap_setuid, false);
+ #endif // defined(_di_libcap_) || defined(_libcap_legacy_only_)
+
+ {
+ const f_status_t status = f_capability_user_set(uid);
+
+ #if defined(_di_libcap_) || defined(_libcap_legacy_only_)
+ assert_int_equal(F_status_set_fine(status), F_implemented_not);
+ #else
+ assert_int_equal(status, F_none);
+ #endif // defined(_di_libcap_) || defined(_libcap_legacy_only_)
+ }
+}
+
+void test__f_capability_user_set__fails(void **state) {
+
+ #if !defined(_di_libcap_) && !defined(_libcap_legacy_only_)
+ uid_t uid;
+
+ int errnos[] = {
+ EINVAL,
+ ENOMEM,
+ EPERM,
+ mock_errno_generic,
+ };
+
+ f_status_t statuss[] = {
+ F_parameter,
+ F_memory_not,
+ F_prohibited,
+ F_failure,
+ };
+
+ for (int i = 0; i < 4; ++i) {
+
+ will_return(__wrap_cap_setuid, true);
+ will_return(__wrap_cap_setuid, errnos[i]);
+
+ const f_status_t status = f_capability_user_set(uid);
+
+ assert_int_equal(F_status_set_fine(status), statuss[i]);
+ } // for
+ #endif // !defined(_di_libcap_) && !defined(_libcap_legacy_only_)
+}
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
--- /dev/null
+/**
+ * FLL - Level 0
+ *
+ * Project: Capability
+ * API Version: 0.5
+ * Licenses: lgpl-2.1-or-later
+ *
+ * Test the capability project.
+ */
+#ifndef _TEST__F_capability__user_set
+#define _TEST__F_capability__user_set
+
+/**
+ * Test that function works.
+ *
+ * @see f_capability_user_set()
+ */
+extern void test__f_capability_user_set__works(void **state);
+
+/**
+ * Test that function fails.
+ *
+ * @see f_capability_user_set()
+ */
+extern void test__f_capability_user_set__fails(void **state);
+
+#endif // _TEST__F_capability__user_set
--- /dev/null
+#include "test-capability.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+int setup(void **state) {
+
+ return 0;
+}
+
+int setdown(void **state) {
+
+ errno = 0;
+
+ return 0;
+}
+
+int main(void) {
+
+ const struct CMUnitTest tests[] = {
+ cmocka_unit_test(test__f_capability_ambient_get__works),
+ cmocka_unit_test(test__f_capability_ambient_get__fails),
+
+ cmocka_unit_test(test__f_capability_ambient_reset__works),
+ cmocka_unit_test(test__f_capability_ambient_reset__fails),
+
+ cmocka_unit_test(test__f_capability_ambient_set__works),
+ cmocka_unit_test(test__f_capability_ambient_set__fails),
+
+ cmocka_unit_test(test__f_capability_clear__works),
+ cmocka_unit_test(test__f_capability_clear__fails),
+
+ cmocka_unit_test(test__f_capability_clear_flag__works),
+ cmocka_unit_test(test__f_capability_clear_flag__fails),
+
+ cmocka_unit_test(test__f_capability_compare__works),
+ cmocka_unit_test(test__f_capability_compare__fails),
+
+ cmocka_unit_test(test__f_capability_copy__works),
+ cmocka_unit_test(test__f_capability_copy__fails),
+
+ cmocka_unit_test(test__f_capability_copy_external__works),
+ cmocka_unit_test(test__f_capability_copy_external__fails),
+
+ cmocka_unit_test(test__f_capability_copy_internal__works),
+ cmocka_unit_test(test__f_capability_copy_internal__fails),
+
+ cmocka_unit_test(test__f_capability_delete__works),
+ cmocka_unit_test(test__f_capability_delete__fails),
+
+ cmocka_unit_test(test__f_capability_file_descriptor_get__works),
+ cmocka_unit_test(test__f_capability_file_descriptor_get__fails),
+
+ cmocka_unit_test(test__f_capability_file_descriptor_set__works),
+ cmocka_unit_test(test__f_capability_file_descriptor_set__fails),
+
+ cmocka_unit_test(test__f_capability_file_get__works),
+ cmocka_unit_test(test__f_capability_file_get__fails),
+
+ cmocka_unit_test(test__f_capability_file_set__works),
+ cmocka_unit_test(test__f_capability_file_set__fails),
+
+ cmocka_unit_test(test__f_capability_flag_get__works),
+ cmocka_unit_test(test__f_capability_flag_get__fails),
+
+ cmocka_unit_test(test__f_capability_flag_set__works),
+ cmocka_unit_test(test__f_capability_flag_set__fails),
+
+ cmocka_unit_test(test__f_capability_from_name__works),
+ cmocka_unit_test(test__f_capability_from_name__fails),
+
+ cmocka_unit_test(test__f_capability_from_text__works),
+ cmocka_unit_test(test__f_capability_from_text__fails),
+
+ cmocka_unit_test(test__f_capability_groups_set__works),
+ cmocka_unit_test(test__f_capability_groups_set__fails),
+
+ cmocka_unit_test(test__f_capability_initialize__works),
+ cmocka_unit_test(test__f_capability_initialize__fails),
+
+ cmocka_unit_test(test__f_capability_mode_get__works),
+ // cap_get_mode() doesn't return failure.
+
+ cmocka_unit_test(test__f_capability_mode_get_name__works),
+ // cap_mode_name() doesn't return failure.
+
+ cmocka_unit_test(test__f_capability_mode_set__works),
+ cmocka_unit_test(test__f_capability_mode_set__fails),
+
+ cmocka_unit_test(test__f_capability_owner_get__works),
+ // cap_get_nsowner() doesn't return failure.
+
+ cmocka_unit_test(test__f_capability_owner_set__works),
+ cmocka_unit_test(test__f_capability_owner_set__fails),
+
+ cmocka_unit_test(test__f_capability_process_bound_drop__works),
+ cmocka_unit_test(test__f_capability_process_bound_drop__fails),
+
+ cmocka_unit_test(test__f_capability_process_bound_get__works),
+ cmocka_unit_test(test__f_capability_process_bound_get__fails),
+
+ cmocka_unit_test(test__f_capability_process_get_by_id__works),
+ cmocka_unit_test(test__f_capability_process_get_by_id__fails),
+
+ cmocka_unit_test(test__f_capability_process_get__works),
+ cmocka_unit_test(test__f_capability_process_get__fails),
+
+ cmocka_unit_test(test__f_capability_process_set__works),
+ cmocka_unit_test(test__f_capability_process_set__fails),
+
+ cmocka_unit_test(test__f_capability_security_bits_get__works),
+ cmocka_unit_test(test__f_capability_security_bits_get__fails),
+
+ cmocka_unit_test(test__f_capability_security_bits_set__works),
+ cmocka_unit_test(test__f_capability_security_bits_set__fails),
+
+ cmocka_unit_test(test__f_capability_size__works),
+ cmocka_unit_test(test__f_capability_size__fails),
+
+ cmocka_unit_test(test__f_capability_supported__works),
+ // f_capability_supported() doesn't return failure.
+
+ cmocka_unit_test(test__f_capability_supported_ambient__works),
+ // f_capability_supported_ambient() doesn't return failure.
+
+ cmocka_unit_test(test__f_capability_supported_code__works),
+ // f_capability_supported_code() doesn't return failure.
+
+ cmocka_unit_test(test__f_capability_to_name__works),
+ cmocka_unit_test(test__f_capability_to_name__fails),
+
+ cmocka_unit_test(test__f_capability_to_text__works),
+ cmocka_unit_test(test__f_capability_to_text__fails),
+
+ cmocka_unit_test(test__f_capability_user_set__works),
+ cmocka_unit_test(test__f_capability_user_set__fails),
+ };
+
+ return cmocka_run_group_tests(tests, setup, setdown);
+}
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
--- /dev/null
+/**
+ * FLL - Level 0
+ *
+ * Project: Capability
+ * API Version: 0.5
+ * Licenses: lgpl-2.1-or-later
+ *
+ * Test the capability project.
+ */
+#ifndef _TEST__F_capability_h
+#define _TEST__F_capability_h
+
+// libc includes.
+#include <stdarg.h>
+#include <stddef.h>
+#include <setjmp.h>
+#include <stdint.h>
+
+// cmocka includes.
+#include <cmocka.h>
+
+// fll-0 includes.
+#include <fll/level_0/capability.h>
+
+// mock includes.
+#include "mock-capability.h"
+
+// test includes.
+#include "test-capability-ambient_get.h"
+#include "test-capability-ambient_reset.h"
+#include "test-capability-ambient_set.h"
+#include "test-capability-clear.h"
+#include "test-capability-clear_flag.h"
+#include "test-capability-compare.h"
+#include "test-capability-copy.h"
+#include "test-capability-copy_external.h"
+#include "test-capability-copy_internal.h"
+#include "test-capability-delete.h"
+#include "test-capability-file_descriptor_get.h"
+#include "test-capability-file_descriptor_set.h"
+#include "test-capability-file_get.h"
+#include "test-capability-file_set.h"
+#include "test-capability-flag_get.h"
+#include "test-capability-flag_set.h"
+#include "test-capability-from_name.h"
+#include "test-capability-from_text.h"
+#include "test-capability-groups_set.h"
+#include "test-capability-initialize.h"
+#include "test-capability-mode_get.h"
+#include "test-capability-mode_get_name.h"
+#include "test-capability-mode_set.h"
+#include "test-capability-owner_get.h"
+#include "test-capability-owner_set.h"
+#include "test-capability-process_bound_drop.h"
+#include "test-capability-process_bound_get.h"
+#include "test-capability-process_get_by_id.h"
+#include "test-capability-process_get.h"
+#include "test-capability-process_set.h"
+#include "test-capability-security_bits_get.h"
+#include "test-capability-security_bits_set.h"
+#include "test-capability-size.h"
+#include "test-capability-supported_ambient.h"
+#include "test-capability-supported.h"
+#include "test-capability-supported_code.h"
+#include "test-capability-to_name.h"
+#include "test-capability-to_text.h"
+#include "test-capability-user_set.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * Perform any setup operations.
+ *
+ * @param state
+ * The test state.
+ *
+ * @return
+ * The status of this function, where 0 means success.
+ */
+extern int setup(void **state);
+
+/**
+ * Peform any setdown operations.
+ *
+ * @param state
+ * The test state.
+ *
+ * @return
+ * The status of this function, where 0 means success.
+ */
+extern int setdown(void **state);
+
+/**
+ * Run all tests.
+ *
+ * @return
+ * The final result of the tests.
+ *
+ * @see cmocka_run_group_tests()
+ * @see cmocka_unit_test()
+ */
+extern int main(void);
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
+
+#endif // _TEST__F_capability_h
-# fss-0000
+# fss-0001
cmocka 1.*
build settings
build settings-tests
- if defined environment LD_LIBRARY_PATH
- define LD_LIBRARY_PATH build/libraries/shared:define:"LD_LIBRARY_PATH"
- else
- define LD_LIBRARY_PATH build/libraries/shared
+ operate ld_library_path
if exists build/programs/shared/test-f_memory
shell build/programs/shared/test-f_memory
print context:"error"Failed to test due to being unable to find either a shared or static test binary to perform tests. context:"error"
exit failure
+
+ld_library_path:
+ if defined environment LD_LIBRARY_PATH
+ and defined parameter work
+ define LD_LIBRARY_PATH 'build/libraries/shared:parameter:"work:value"libraries/shared':define:"LD_LIBRARY_PATH"'
+
+ else
+ if defined environment LD_LIBRARY_PATH
+ define LD_LIBRARY_PATH 'build/libraries/shared:parameter:define:"LD_LIBRARY_PATH"'
+
+ else
+ if defined parameter work
+ define LD_LIBRARY_PATH 'build/libraries/shared:parameter:"work:value"libraries/shared'
+
+ else
+ define LD_LIBRARY_PATH build/libraries/shared
-# fss-0000
+# fss-0001
cmocka 1.*
build settings
build settings-tests
- if defined environment LD_LIBRARY_PATH
- define LD_LIBRARY_PATH build/libraries/shared:define:"LD_LIBRARY_PATH"
- else
- define LD_LIBRARY_PATH build/libraries/shared
+ operate ld_library_path
if exists build/programs/shared/test-f_type_array
shell build/programs/shared/test-f_type_array
print context:"error"Failed to test due to being unable to find either a shared or static test binary to perform tests. context:"error"
exit failure
+
+ld_library_path:
+ if defined environment LD_LIBRARY_PATH
+ and defined parameter work
+ define LD_LIBRARY_PATH 'build/libraries/shared:parameter:"work:value"libraries/shared':define:"LD_LIBRARY_PATH"'
+
+ else
+ if defined environment LD_LIBRARY_PATH
+ define LD_LIBRARY_PATH 'build/libraries/shared:parameter:define:"LD_LIBRARY_PATH"'
+
+ else
+ if defined parameter work
+ define LD_LIBRARY_PATH 'build/libraries/shared:parameter:"work:value"libraries/shared'
+
+ else
+ define LD_LIBRARY_PATH build/libraries/shared