The "preserve_path_headers" in settings-mocks and settings-tests should be set to "yes".
Add missing dependencies-tests file for any project providing tests.
Remove at_id <= 0 parameter checks because this is already handled by EBADF.
Fix alphabetic ordering of errno returns for f_directory.
I started doing this for f_file as well until I realized how much there is to do.
I won't continue this for f_file because I don't plan on adding tests for f_file for this next release.
The ENOTDIR should return F_directory_not rather than F_directory.
Unable to perform many of the tests because the dynamic linker wrapper is not properlly handling stat() and scandir() as expected.
These tests are commented out, incomplete, and comments are added describing why.
path_library_static static
has_path_standard yes
-preserve_path_headers no
+preserve_path_headers yes
search_exclusive yes
search_shared yes
path_sources tests/unit/c
has_path_standard no
-preserve_path_headers no
+preserve_path_headers yes
search_exclusive yes
search_shared yes
path_sources_object
has_path_standard yes
-preserve_path_headers no
+preserve_path_headers yes
search_exclusive yes
search_shared yes
path_sources tests/unit/c
has_path_standard no
-preserve_path_headers no
+preserve_path_headers yes
search_exclusive yes
search_shared yes
path_sources_object
has_path_standard yes
-preserve_path_headers no
+preserve_path_headers yes
search_exclusive yes
search_shared yes
path_sources tests/unit/c
has_path_standard no
-preserve_path_headers no
+preserve_path_headers yes
search_exclusive yes
search_shared yes
path_sources tests/unit/c
has_path_standard no
-preserve_path_headers no
+preserve_path_headers yes
search_exclusive yes
search_shared yes
--- /dev/null
+# fss-0001
+
+cmocka 1.*
path_sources tests/unit/c
has_path_standard no
-preserve_path_headers no
+preserve_path_headers yes
search_exclusive yes
search_shared yes
--- /dev/null
+# fss-0001
+
+cmocka 1.*
path_sources_object
has_path_standard yes
-preserve_path_headers no
+preserve_path_headers yes
search_exclusive yes
search_shared yes
path_sources tests/unit/c
has_path_standard no
-preserve_path_headers no
+preserve_path_headers yes
search_exclusive yes
search_shared yes
#ifndef _di_f_directory_create_at_
f_status_t f_directory_create_at(const int at_id, const f_string_static_t path, const mode_t mode) {
- #ifndef _di_level_0_parameter_checking_
- if (at_id <= 0) return F_status_set_error(F_parameter);
- #endif // _di_level_0_parameter_checking_
if (!path.used) {
return F_data_not;
if (stat(path.string, &file_stat) < 0) {
if (errno == EACCES) return F_status_set_error(F_access_denied);
if (errno == EFAULT) return F_status_set_error(F_buffer);
+ if (errno == ELOOP) return F_status_set_error(F_loop);
if (errno == ENAMETOOLONG) return F_status_set_error(F_name);
if (errno == ENOENT) return F_file_found_not;
if (errno == ENOMEM) return F_status_set_error(F_memory_not);
if (errno == ENOTDIR) return F_false;
if (errno == EOVERFLOW) return F_status_set_error(F_number_overflow);
- if (errno == ELOOP) return F_status_set_error(F_loop);
return F_status_set_error(F_file_stat);
}
if (errno == EACCES) return F_status_set_error(F_access_denied);
if (errno == EBADF) return F_status_set_error(F_directory_descriptor);
if (errno == EFAULT) return F_status_set_error(F_buffer);
+ if (errno == ELOOP) return F_status_set_error(F_loop);
if (errno == ENAMETOOLONG) return F_status_set_error(F_name);
if (errno == ENOENT) return F_file_found_not;
if (errno == ENOMEM) return F_status_set_error(F_memory_not);
if (errno == ENOTDIR) return F_false;
if (errno == EOVERFLOW) return F_status_set_error(F_number_overflow);
- if (errno == ELOOP) return F_status_set_error(F_loop);
return F_status_set_error(F_file_stat);
}
if (length == -1) {
if (errno == ENOMEM) return F_status_set_error(F_memory_not);
- else return F_status_set_error(F_failure);
+
+ return F_status_set_error(F_failure);
}
for (; i < length; ++i) {
#ifndef _di_f_directory_open_at_
f_status_t f_directory_open_at(const int at_id, const f_string_static_t path, const bool dereference, int *id) {
#ifndef _di_level_0_parameter_checking_
- if (at_id <= 0) return F_status_set_error(F_parameter);
if (!id) return F_status_set_error(F_parameter);
#endif // _di_level_0_parameter_checking_
if (errno == ENFILE) return F_status_set_error(F_file_open_max);
if (errno == ENOENT) return F_status_set_error(F_file_found_not);
if (errno == ENOMEM) return F_status_set_error(F_memory_not);
- if (errno == ENOTDIR) return F_status_set_error(F_directory);
+ if (errno == ENOTDIR) return F_status_set_error(F_directory_not);
if (errno == ENOTEMPTY) return F_status_set_error(F_directory_empty_not);
if (errno == EPERM) return F_status_set_error(F_prohibited);
if (errno == EROFS) return F_status_set_error(F_read_only);
if (errno == ENFILE) return F_status_set_error(F_file_open_max);
if (errno == ENOENT) return F_status_set_error(F_file_found_not);
if (errno == ENOMEM) return F_status_set_error(F_memory_not);
- if (errno == ENOTDIR) return F_status_set_error(F_directory);
+ if (errno == ENOTDIR) return F_status_set_error(F_directory_not);
if (errno == ENOTEMPTY) return F_status_set_error(F_directory_empty_not);
if (errno == EPERM) return F_status_set_error(F_prohibited);
if (errno == EROFS) return F_status_set_error(F_read_only);
return private_f_directory_create(path, mode);
}
- if (errno == ENAMETOOLONG) return F_status_set_error(F_name);
+ if (errno == EACCES) return F_status_set_error(F_access_denied);
if (errno == EFAULT) return F_status_set_error(F_buffer);
+ if (errno == ELOOP) return F_status_set_error(F_loop);
+ if (errno == ENAMETOOLONG) return F_status_set_error(F_name);
if (errno == ENOMEM) return F_status_set_error(F_memory_not);
+ if (errno == ENOTDIR) return F_status_set_error(F_directory_not);
if (errno == EOVERFLOW) return F_status_set_error(F_number_overflow);
- if (errno == ENOTDIR) return F_status_set_error(F_directory);
- if (errno == EACCES) return F_status_set_error(F_access_denied);
- if (errno == ELOOP) return F_status_set_error(F_loop);
return F_status_set_error(F_file_stat);
}
if (errno == ELOOP) return F_status_set_error(F_loop);
if (errno == ENAMETOOLONG) return F_status_set_error(F_name);
if (errno == ENOENT) return F_status_set_error(F_file_found_not);
- if (errno == ENOTDIR) return F_status_set_error(F_directory);
+ if (errno == ENOTDIR) return F_status_set_error(F_directory_not);
if (errno == EPERM) return F_status_set_error(F_prohibited);
if (errno == EROFS) return F_status_set_error(F_read_only);
if (errno == ESRCH) return F_status_set_error(F_search);
if (errno == ENAMETOOLONG) return F_status_set_error(F_name);
if (errno == ENOENT) return private_f_directory_create_at(at_id, path, mode);
if (errno == ENOMEM) return F_status_set_error(F_memory_not);
- if (errno == ENOTDIR) return F_status_set_error(F_directory);
+ if (errno == ENOTDIR) return F_status_set_error(F_directory_not);
if (errno == EOVERFLOW) return F_status_set_error(F_number_overflow);
return F_status_set_error(F_file_stat);
if (errno == ELOOP) return F_status_set_error(F_loop);
if (errno == ENAMETOOLONG) return F_status_set_error(F_name);
if (errno == ENOENT) return F_status_set_error(F_file_found_not);
- if (errno == ENOTDIR) return F_status_set_error(F_directory);
+ if (errno == ENOTDIR) return F_status_set_error(F_directory_not);
if (errno == EPERM) return F_status_set_error(F_prohibited);
if (errno == EROFS) return F_status_set_error(F_read_only);
if (errno == ESRCH) return F_status_set_error(F_search);
* F_data_not if path.used is 0.
*
* F_access_denied (with error bit) on access denied.
- * F_directory (with error bit) if a supposed directory in path is not actually a directory.
+ * F_directory_not (with error bit) if a supposed directory in path is not actually a directory.
* F_directory_link_max (with error bit) max links limit reached or exceeded.
* F_file_found (with error bit) of a directory aleady exists at the path.
* F_file_found_not (with error bit) if a file within the path is not found (such as a broken symbolic link).
* F_data_not if path.used is 0.
*
* F_access_denied (with error bit) on access denied.
- * F_directory (with error bit) if a supposed directory in path is not actually a directory.
+ * F_directory_not (with error bit) if a supposed directory in path is not actually a directory.
* F_directory_descriptor (with error bit) for bad directory descriptor for at_id.
* F_directory_link_max (with error bit) max links limit reached or exceeded.
* F_file_found (with error bit) of a directory aleady exists at the path.
*
* F_access_denied (with error bit) on access denied.
* F_busy (with error bit) if file is busy.
- * F_directory (with error bit) if a supposed directory in path is not actually a directory.
+ * F_directory_not (with error bit) if a supposed directory in path is not actually a directory.
* F_directory_empty_not (with error bit) if the directory is not empty.
* F_file_descriptor_max (with error bit) if max file descriptors is reached.
* F_file_found_not (with error bit) if file not found.
*
* F_access_denied (with error bit) on access denied.
* F_busy (with error bit) if file is busy.
- * F_directory (with error bit) if a supposed directory in path is not actually a directory.
+ * F_directory_not (with error bit) if a supposed directory in path is not actually a directory.
* F_directory_empty_not (with error bit) if the directory is not empty.
* F_file_descriptor_max (with error bit) if max file descriptors is reached.
* F_file_found_not (with error bit) if file not found.
* F_access_denied (with error bit) on access denied.
* F_buffer (with error bit) if the buffer is invalid.
* F_busy (with error bit) if file system is too busy to perform write.
- * F_directory (with error bit) if a supposed directory in path is not actually a directory.
+ * F_directory_not (with error bit) if a supposed directory in path is not actually a directory.
* F_directory_descriptor (with error bit) for bad directory descriptor for at_id.
* F_file_found (with error bit) if a file aleady exists at the path.
* F_file_open_max (with error bit) when system-wide max open files is reached.
* F_access_denied (with error bit) on access denied.
* F_buffer (with error bit) if the buffer is invalid.
* F_busy (with error bit) if file system is too busy to perform write.
- * F_directory (with error bit) if a supposed directory in path is not actually a directory.
+ * F_directory_not (with error bit) if a supposed directory in path is not actually a directory.
* F_directory_descriptor (with error bit) for bad directory descriptor for at_id.
* F_file_found (with error bit) if a file aleady exists at the path (when calling utimensat()).
* F_file_open_max (with error bit) when system-wide max open files is reached.
* A structure representing a listing of paths found within a directory.
*
* Each property represents a set of paths grouped by directory entity file type.
+ *
+ * block: For S_IFBLK.
+ * character: For S_IFCHR.
+ * directory: For S_IFDIR.
+ * regular: For S_IFREG.
+ * link: For S_IFLNK.
+ * fifo: For S_IFIFO.
+ * socket: For S_IFSOCK.
+ * unknown: For anything else.
*/
#ifndef _di_f_directory_listing_t_
typedef struct {
if (errno == ENOENT) return F_status_set_error(F_file_found_not);
if (errno == ENOMEM) return F_status_set_error(F_memory_not);
if (errno == ENOSPC) return F_status_set_error(F_space_not);
- if (errno == ENOTDIR) return F_status_set_error(F_directory);
+ if (errno == ENOTDIR) return F_status_set_error(F_directory_not);
if (errno == EPERM) return F_status_set_error(F_prohibited);
if (errno == EROFS) return F_status_set_error(F_read_only);
if (errno == ENOENT) return F_status_set_error(F_file_found_not);
if (errno == ENOMEM) return F_status_set_error(F_memory_not);
if (errno == ENOSPC) return F_status_set_error(F_space_not);
- if (errno == ENOTDIR) return F_status_set_error(F_directory);
+ if (errno == ENOTDIR) return F_status_set_error(F_directory_not);
if (errno == EPERM) return F_status_set_error(F_prohibited);
if (errno == EROFS) return F_status_set_error(F_read_only);
--- /dev/null
+# fss-0001
+
+cmocka 1.*
--- /dev/null
+# fss-0001
+
+build_name f_directory
+
+version_major 0
+version_minor 5
+version_micro 9
+version_file micro
+version_target minor
+
+environment
+
+process_pre
+process_post
+
+modes individual level monolithic clang test
+modes_default individual
+
+build_compiler gcc
+build_compiler-clang clang
+build_indexer ar
+build_indexer_arguments rcs
+build_language c
+build_libraries -lc
+build_libraries-individual -lf_memory -lf_string
+build_libraries_shared
+build_libraries_static
+build_sources_library directory.c directory/common.c private-directory.c ../../tests/unit/c/mock-directory.c
+build_sources_library_shared
+build_sources_library_static
+build_sources_headers directory.h directory/common.h directory/type.h
+build_sources_headers_shared
+build_sources_headers_static
+build_script yes
+build_shared yes
+build_static no
+
+path_headers fll/level_0
+path_library_script script
+path_library_shared shared
+path_library_static static
+
+has_path_standard yes
+preserve_path_headers yes
+
+search_exclusive yes
+search_shared yes
+search_static yes
+
+defines
+defines_library
+defines_library_shared
+defines_library_static
+defines_static
+defines_shared
+
+flags -O2 -z now -g -fdiagnostics-color=always -Wno-logical-not-parentheses -Wno-parentheses
+flags-clang -Wno-logical-op-parentheses
+flags-test -fstack-protector
+flags_library -fPIC
+flags_library_shared
+flags_library_static
+flags_shared
+flags_static
+
+# Inject mocks.
+flags -Wl,--wrap=alphasort
+flags -Wl,--wrap=fstatat
+flags -Wl,--wrap=mkdir
+flags -Wl,--wrap=mkdirat
+flags -Wl,--wrap=nftw
+flags -Wl,--wrap=open
+flags -Wl,--wrap=openat
+flags -Wl,--wrap=remove
+flags -Wl,--wrap=scandir
+flags -Wl,--wrap=stat
+flags -Wl,--wrap=strncmp
+flags -Wl,--wrap=strnlen
+flags -Wl,--wrap=utimensat
+flags -Wl,--wrap=versionsort
--- /dev/null
+# fss-0001
+
+build_name test-f_directory
+
+version_major 0
+version_minor 5
+version_micro 9
+version_file major
+version_target major
+
+modes individual level monolithic clang test
+modes_default individual
+
+build_compiler gcc
+build_compiler-clang clang
+build_indexer ar
+build_indexer_arguments rcs
+build_language c
+build_libraries -lc -lcmocka
+build_libraries-individual -lf_memory -lf_string -lf_directory
+build_libraries-level -lfll_0
+build_libraries-monolithic -lfll
+build_sources_program test-directory-create.c test-directory-create_at.c test-directory-exists.c test-directory-exists_at.c test-directory-is.c test-directory-is_at.c test-directory-list.c test-directory-open.c test-directory-open_at.c test-directory-remove.c test-directory-remove_custom.c test-directory-touch.c test-directory-touch_at.c test-directory.c
+
+build_script no
+build_shared yes
+build_static no
+
+path_headers tests/unit/c
+path_sources tests/unit/c
+
+has_path_standard no
+preserve_path_headers yes
+
+search_exclusive yes
+search_shared yes
+search_static yes
+
+defines
+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-parentheses
+flags-clang -Wno-logical-op-parentheses
+flags-test -fstack-protector
+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_directory
+ shell build/programs/shared/test-f_directory
+
+ if exists build/programs/static/test-f_directory
+ shell build/programs/static/test-f_directory
+
+ if not exists build/programs/shared/test-f_directory
+ and not exists build/programs/static/test-f_directory
+ 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:"reset"'
+
+ 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-directory.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+int __wrap_alphasort(const struct dirent **a, const struct dirent **b) {
+
+ const bool failure = mock_type(bool);
+
+ if (failure) {
+ errno = mock_type(int);
+
+ return -1;
+ }
+
+ return mock_type(int);
+}
+
+int __wrap_fstatat(int dirfd, const char *pathname, struct stat *statbuf, int flags) {
+
+ const bool failure = mock_type(bool);
+
+ if (failure) {
+ errno = mock_type(int);
+
+ return -1;
+ }
+
+ struct stat * const mocked_stat = mock_type(struct stat *);
+
+ statbuf->st_dev = mocked_stat->st_dev;
+ statbuf->st_ino = mocked_stat->st_ino;
+ statbuf->st_mode = mocked_stat->st_mode;
+ statbuf->st_nlink = mocked_stat->st_nlink;
+ statbuf->st_uid = mocked_stat->st_uid;
+ statbuf->st_gid = mocked_stat->st_gid;
+ statbuf->st_rdev = mocked_stat->st_rdev;
+ statbuf->st_size = mocked_stat->st_size;
+ statbuf->st_blksize = mocked_stat->st_blksize;
+ statbuf->st_blocks = mocked_stat->st_blocks;
+ statbuf->st_atime = mocked_stat->st_atime;
+ statbuf->st_mtime = mocked_stat->st_mtime;
+ statbuf->st_ctime = mocked_stat->st_ctime;
+
+ return mock_type(int);
+}
+
+int __wrap_mkdir(const char *pathname, mode_t mode) {
+
+ const bool failure = mock_type(bool);
+
+ if (failure) {
+ errno = mock_type(int);
+
+ return -1;
+ }
+
+ return mock_type(int);
+}
+
+int __wrap_mkdirat(int dirfd, const char *pathname, mode_t mode) {
+
+ const bool failure = mock_type(bool);
+
+ if (failure) {
+ errno = mock_type(int);
+
+ return -1;
+ }
+
+ return mock_type(int);
+}
+
+int __wrap_nftw(const char *dirpath, int (*fn) (const char *fpath, const struct stat *sb, int typeflag, struct FTW *ftwbuf), int nopenfd, int flags) {
+
+ const bool failure = mock_type(bool);
+
+ if (failure) {
+ errno = mock_type(int);
+
+ return -1;
+ }
+
+ return mock_type(int);
+}
+
+int __wrap_open(const char *pathname, int flags) {
+
+ const bool failure = mock_type(bool);
+
+ if (failure) {
+ errno = mock_type(int);
+
+ return -1;
+ }
+
+ return mock_type(int);
+}
+
+int __wrap_openat(int dirfd, const char *pathname, int flags) {
+
+ const bool failure = mock_type(bool);
+
+ if (failure) {
+ errno = mock_type(int);
+
+ return -1;
+ }
+
+ return mock_type(int);
+}
+
+int __wrap_remove(const char *pathname) {
+
+ const bool failure = mock_type(bool);
+
+ if (failure) {
+ errno = mock_type(int);
+
+ return -1;
+ }
+
+ return mock_type(int);
+}
+
+int __wrap_scandir(const char *dirp, struct dirent ***namelist, int (*filter)(const struct dirent *), int (*compar)(const struct dirent **, const struct dirent **)) {
+
+ const bool failure = mock_type(bool);
+
+ if (failure) {
+ errno = mock_type(int);
+
+ return -1;
+ }
+
+ *namelist = mock_type(struct dirent **);
+
+ return mock_type(int);
+}
+
+int __wrap_stat(const char *pathname, struct stat *statbuf) {
+
+ const bool failure = mock_type(bool);
+
+ if (failure) {
+ errno = mock_type(int);
+
+ return -1;
+ }
+
+ return mock_type(int);
+}
+
+int __wrap_strncmp(const char *s1, const char *s2, size_t n) {
+
+ return mock_type(size_t);
+}
+
+size_t __wrap_strnlen(const char *s, size_t maxlen) {
+
+ return mock_type(size_t);
+}
+
+int __wrap_utimensat(int dirfd, const char *pathname, const struct timespec times[2], int flags) {
+
+ const bool failure = mock_type(bool);
+
+ if (failure) {
+ errno = mock_type(int);
+
+ return -1;
+ }
+
+ return mock_type(int);
+}
+
+int __wrap_versionsort(const struct dirent **a, const struct dirent **b) {
+
+ const bool failure = mock_type(bool);
+
+ if (failure) {
+ errno = mock_type(int);
+
+ return -1;
+ }
+
+ return mock_type(int);
+}
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
--- /dev/null
+/**
+ * FLL - Level 0
+ *
+ * Project: Directory
+ * API Version: 0.5
+ * Licenses: lgpl-2.1-or-later
+ *
+ * Test the directory project.
+ */
+#ifndef _MOCK__directory_h
+#define _MOCK__directory_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/directory.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+const static int mock_errno_generic = 32767;
+
+extern int __wrap_alphasort(const struct dirent **a, const struct dirent **b);
+extern int __wrap_fstatat(int dirfd, const char *pathname, struct stat *statbuf, int flags);
+extern int __wrap_mkdir(const char *pathname, mode_t mode);
+extern int __wrap_mkdirat(int dirfd, const char *pathname, mode_t mode);
+extern int __wrap_nftw(const char *dirpath, int (*fn) (const char *fpath, const struct stat *sb, int typeflag, struct FTW *ftwbuf), int nopenfd, int flags);
+extern int __wrap_open(const char *pathname, int flags);
+extern int __wrap_openat(int dirfd, const char *pathname, int flags);
+extern int __wrap_remove(const char *pathname);
+extern int __wrap_scandir(const char *dirp, struct dirent ***namelist, int (*filter)(const struct dirent *), int (*compar)(const struct dirent **, const struct dirent **));
+extern int __wrap_stat(const char *pathname, struct stat *statbuf);
+extern int __wrap_strncmp(const char *s1, const char *s2, size_t n);
+extern size_t __wrap_strnlen(const char *s, size_t maxlen);
+extern int __wrap_utimensat(int dirfd, const char *pathname, const struct timespec times[2], int flags);
+extern int __wrap_versionsort(const struct dirent **a, const struct dirent **b);
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
+
+#endif // _MOCK__directory_h
--- /dev/null
+#include "test-directory.h"
+#include "test-directory-create.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void test__f_directory_create__fails(void **state) {
+
+ const f_string_static_t path = macro_f_string_static_t_initialize("test", 0, 4);
+
+ int errnos[] = {
+ EACCES,
+ EDQUOT,
+ EEXIST,
+ EFAULT,
+ EINVAL,
+ ELOOP,
+ EMLINK,
+ ENAMETOOLONG,
+ ENOENT,
+ ENOMEM,
+ ENOSPC,
+ ENOTDIR,
+ EPERM,
+ EROFS,
+ mock_errno_generic,
+ };
+
+ f_status_t statuss[] = {
+ F_access_denied,
+ F_filesystem_quota_block,
+ F_file_found,
+ F_buffer,
+ F_parameter,
+ F_loop,
+ F_directory_link_max,
+ F_name,
+ F_file_found_not,
+ F_memory_not,
+ F_space_not,
+ F_directory_not,
+ F_prohibited,
+ F_read_only,
+ F_failure,
+ };
+
+ for (int i = 0; i < 15; ++i) {
+
+ will_return(__wrap_mkdir, true);
+ will_return(__wrap_mkdir, errnos[i]);
+
+ const f_status_t status = f_directory_create(path, 0);
+
+ assert_int_equal(F_status_set_fine(status), statuss[i]);
+ } // for
+}
+
+void test__f_directory_create__returns_data_not(void **state) {
+
+ {
+ const f_status_t status = f_directory_create(f_string_empty_s, 0);
+
+ assert_int_equal(status, F_data_not);
+ }
+}
+
+void test__f_directory_create__works(void **state) {
+
+ const f_string_static_t path = macro_f_string_static_t_initialize("test", 0, 4);
+
+ {
+ will_return(__wrap_mkdir, false);
+ will_return(__wrap_mkdir, 0);
+
+ const f_status_t status = f_directory_create(path, 0);
+
+ assert_int_equal(status, F_none);
+ }
+}
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
--- /dev/null
+/**
+ * FLL - Level 0
+ *
+ * Project: Directory
+ * API Version: 0.5
+ * Licenses: lgpl-2.1-or-later
+ *
+ * Test the directory project.
+ */
+#ifndef _TEST__F_directory_create_h
+#define _TEST__F_directory_create_h
+
+/**
+ * Test that function fails.
+ *
+ * @see f_directory_create()
+ */
+extern void test__f_directory_create__fails(void **state);
+
+/**
+ * Test that function works but the path is empty.
+ *
+ * @see f_directory_create()
+ */
+extern void test__f_directory_create__returns_data_not(void **state);
+
+/**
+ * Test that function works.
+ *
+ * @see f_directory_create()
+ */
+extern void test__f_directory_create__works(void **state);
+
+#endif // _TEST__F_directory_create_h
--- /dev/null
+#include "test-directory.h"
+#include "test-directory-create.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void test__f_directory_create_at__fails(void **state) {
+
+ const f_string_static_t path = macro_f_string_static_t_initialize("test", 0, 4);
+
+ int errnos[] = {
+ EACCES,
+ EBADF,
+ EDQUOT,
+ EEXIST,
+ EFAULT,
+ EINVAL,
+ ELOOP,
+ EMLINK,
+ ENAMETOOLONG,
+ ENOENT,
+ ENOMEM,
+ ENOSPC,
+ ENOTDIR,
+ EPERM,
+ EROFS,
+ mock_errno_generic,
+ };
+
+ f_status_t statuss[] = {
+ F_access_denied,
+ F_directory_descriptor,
+ F_filesystem_quota_block,
+ F_file_found,
+ F_buffer,
+ F_parameter,
+ F_loop,
+ F_directory_link_max,
+ F_name,
+ F_file_found_not,
+ F_memory_not,
+ F_space_not,
+ F_directory_not,
+ F_prohibited,
+ F_read_only,
+ F_failure,
+ };
+
+ for (int i = 0; i < 16; ++i) {
+
+ will_return(__wrap_mkdirat, true);
+ will_return(__wrap_mkdirat, errnos[i]);
+
+ const f_status_t status = f_directory_create_at(0, path, 0);
+
+ assert_int_equal(F_status_set_fine(status), statuss[i]);
+ } // for
+}
+
+void test__f_directory_create_at__returns_data_not(void **state) {
+
+ {
+ const f_status_t status = f_directory_create_at(0, f_string_empty_s, 0);
+
+ assert_int_equal(status, F_data_not);
+ }
+}
+
+void test__f_directory_create_at__works(void **state) {
+
+ const f_string_static_t path = macro_f_string_static_t_initialize("test", 0, 4);
+
+ {
+ will_return(__wrap_mkdirat, false);
+ will_return(__wrap_mkdirat, 0);
+
+ const f_status_t status = f_directory_create_at(0, path, 0);
+
+ assert_int_equal(status, F_none);
+ }
+}
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
--- /dev/null
+/**
+ * FLL - Level 0
+ *
+ * Project: Directory
+ * API Version: 0.5
+ * Licenses: lgpl-2.1-or-later
+ *
+ * Test the directory project.
+ */
+#ifndef _TEST__F_directory_create_at_h
+#define _TEST__F_directory_create_at_h
+
+/**
+ * Test that function fails.
+ *
+ * @see f_directory_create_at()
+ */
+extern void test__f_directory_create_at__fails(void **state);
+
+/**
+ * Test that function works but the path is empty.
+ *
+ * @see f_directory_create_at()
+ */
+extern void test__f_directory_create_at__returns_data_not(void **state);
+
+/**
+ * Test that function works.
+ *
+ * @see f_directory_create_at()
+ */
+extern void test__f_directory_create_at__works(void **state);
+
+#endif // _TEST__F_directory_create_at_h
--- /dev/null
+#include "test-directory.h"
+#include "test-directory-exists.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void test__f_directory_exists__fails(void **state) {
+
+ const f_string_static_t path = macro_f_string_static_t_initialize("test", 0, 4);
+
+ int errnos[] = {
+ EACCES,
+ EFAULT,
+ ELOOP,
+ ENAMETOOLONG,
+ ENOENT,
+ ENOMEM,
+ ENOTDIR,
+ EOVERFLOW,
+ mock_errno_generic,
+ };
+
+ f_status_t statuss[] = {
+ F_access_denied,
+ F_buffer,
+ F_loop,
+ F_name,
+ F_file_found_not,
+ F_memory_not,
+ F_false,
+ F_number_overflow,
+ F_file_stat,
+ };
+
+ for (int i = 0; i < 9; ++i) {
+
+ will_return(__wrap_stat, true);
+ will_return(__wrap_stat, errnos[i]);
+
+ const f_status_t status = f_directory_exists(path);
+
+ assert_int_equal(F_status_set_fine(status), statuss[i]);
+ } // for
+}
+
+void test__f_directory_exists__returns_data_not(void **state) {
+
+ {
+ const f_status_t status = f_directory_exists(f_string_empty_s);
+
+ assert_int_equal(status, F_data_not);
+ }
+}
+
+void test__f_directory_exists__returns_false(void **state) {
+
+ const f_string_static_t path = macro_f_string_static_t_initialize("test", 0, 4);
+
+ struct stat statistics;
+
+ memset(&statistics, 0, sizeof (struct stat));
+
+ {
+ will_return(__wrap_stat, false);
+ will_return(__wrap_stat, &statistics);
+ will_return(__wrap_stat, 0);
+
+ const f_status_t status = f_directory_exists(path);
+
+ assert_int_equal(status, F_false);
+ }
+}
+
+void test__f_directory_exists__returns_true(void **state) {
+
+ const f_string_static_t path = macro_f_string_static_t_initialize("test", 0, 4);
+
+ struct stat statistics;
+
+ memset(&statistics, 0, sizeof (struct stat));
+
+ statistics.st_mode = 1 | S_IFDIR;
+
+ {
+ will_return(__wrap_stat, false);
+ will_return(__wrap_stat, &statistics);
+ will_return(__wrap_stat, 0);
+
+ const f_status_t status = f_directory_exists(path);
+
+ assert_int_equal(status, F_true);
+ }
+}
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
--- /dev/null
+/**
+ * FLL - Level 0
+ *
+ * Project: Directory
+ * API Version: 0.5
+ * Licenses: lgpl-2.1-or-later
+ *
+ * Test the directory project.
+ */
+#ifndef _TEST__F_directory_exists_h
+#define _TEST__F_directory_exists_h
+
+/**
+ * Test that function fails.
+ *
+ * @see f_directory_exists()
+ */
+extern void test__f_directory_exists__fails(void **state);
+
+/**
+ * Test that function works but the path is empty.
+ *
+ * @see f_directory_exists()
+ */
+extern void test__f_directory_exists__returns_data_not(void **state);
+
+/**
+ * Test that function works and returns F_false.
+ *
+ * @see f_directory_exists()
+ */
+extern void test__f_directory_exists__returns_false(void **state);
+
+/**
+ * Test that function works and returns F_true.
+ *
+ * @see f_directory_exists()
+ */
+extern void test__f_directory_exists__returns_true(void **state);
+
+#endif // _TEST__F_directory_exists_h
--- /dev/null
+#include "test-directory.h"
+#include "test-directory-exists_at.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void test__f_directory_exists_at__fails(void **state) {
+
+ const f_string_static_t path = macro_f_string_static_t_initialize("test", 0, 4);
+
+ int errnos[] = {
+ EACCES,
+ EBADF,
+ EFAULT,
+ ELOOP,
+ ENAMETOOLONG,
+ ENOENT,
+ ENOMEM,
+ ENOTDIR,
+ EOVERFLOW,
+ mock_errno_generic,
+ };
+
+ f_status_t statuss[] = {
+ F_access_denied,
+ F_directory_descriptor,
+ F_buffer,
+ F_loop,
+ F_name,
+ F_file_found_not,
+ F_memory_not,
+ F_false,
+ F_number_overflow,
+ F_file_stat,
+ };
+
+ for (int i = 0; i < 10; ++i) {
+
+ will_return(__wrap_stat, true);
+ will_return(__wrap_stat, errnos[i]);
+
+ const f_status_t status = f_directory_exists_at(0, path, 0);
+
+ assert_int_equal(F_status_set_fine(status), statuss[i]);
+ } // for
+}
+
+void test__f_directory_exists_at__returns_data_not(void **state) {
+
+ {
+ const f_status_t status = f_directory_exists_at(0, f_string_empty_s, 0);
+
+ assert_int_equal(status, F_data_not);
+ }
+}
+
+void test__f_directory_exists_at__returns_false(void **state) {
+
+ const f_string_static_t path = macro_f_string_static_t_initialize("test", 0, 4);
+
+ struct stat statistics;
+
+ memset(&statistics, 0, sizeof (struct stat));
+
+ {
+ will_return(__wrap_stat, false);
+ will_return(__wrap_stat, &statistics);
+ will_return(__wrap_stat, 0);
+
+ const f_status_t status = f_directory_exists_at(0, path, 0);
+
+ assert_int_equal(status, F_false);
+ }
+}
+
+void test__f_directory_exists_at__returns_true(void **state) {
+
+ const f_string_static_t path = macro_f_string_static_t_initialize("test", 0, 4);
+
+ struct stat statistics;
+
+ memset(&statistics, 0, sizeof (struct stat));
+
+ statistics.st_mode = 1 | S_IFDIR;
+
+ {
+ will_return(__wrap_stat, false);
+ will_return(__wrap_stat, &statistics);
+ will_return(__wrap_stat, 0);
+
+ const f_status_t status = f_directory_exists_at(0, path, 0);
+
+ assert_int_equal(status, F_true);
+ }
+}
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
--- /dev/null
+/**
+ * FLL - Level 0
+ *
+ * Project: Directory
+ * API Version: 0.5
+ * Licenses: lgpl-2.1-or-later
+ *
+ * Test the directory project.
+ */
+#ifndef _TEST__F_directory_exists_at_h
+#define _TEST__F_directory_exists_at_h
+
+/**
+ * Test that function fails.
+ *
+ * @see f_directory_exists_at()
+ */
+extern void test__f_directory_exists_at__fails(void **state);
+
+/**
+ * Test that function works but the path is empty.
+ *
+ * @see f_directory_exists_at()
+ */
+extern void test__f_directory_exists_at__returns_data_not(void **state);
+
+/**
+ * Test that function works and returns F_false.
+ *
+ * @see f_directory_exists_at()
+ */
+extern void test__f_directory_exists_at__returns_false(void **state);
+
+/**
+ * Test that function works and returns F_true.
+ *
+ * @see f_directory_exists_at()
+ */
+extern void test__f_directory_exists_at__returns_true(void **state);
+
+#endif // _TEST__F_directory_exists_at_h
--- /dev/null
+#include "test-directory.h"
+#include "test-directory-is.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void test__f_directory_is__fails(void **state) {
+
+ const f_string_static_t path = macro_f_string_static_t_initialize("test", 0, 4);
+
+ int errnos[] = {
+ EACCES,
+ EFAULT,
+ ENAMETOOLONG,
+ ENOENT,
+ ENOMEM,
+ ENOTDIR,
+ EOVERFLOW,
+ mock_errno_generic,
+ };
+
+ f_status_t statuss[] = {
+ F_access_denied,
+ F_buffer,
+ F_loop,
+ F_name,
+ F_file_found_not,
+ F_memory_not,
+ F_false,
+ F_number_overflow,
+ F_file_stat,
+ };
+
+ for (int i = 0; i < 8; ++i) {
+
+ will_return(__wrap_stat, true);
+ will_return(__wrap_stat, errnos[i]);
+
+ const f_status_t status = f_directory_is(path);
+
+ assert_int_equal(F_status_set_fine(status), statuss[i]);
+ } // for
+}
+
+void test__f_directory_is__returns_data_not(void **state) {
+
+ {
+ const f_status_t status = f_directory_is(f_string_empty_s);
+
+ assert_int_equal(status, F_data_not);
+ }
+}
+
+void test__f_directory_is__returns_false(void **state) {
+
+ const f_string_static_t path = macro_f_string_static_t_initialize("test", 0, 4);
+
+ struct stat statistics;
+
+ memset(&statistics, 0, sizeof (struct stat));
+
+ {
+ will_return(__wrap_stat, false);
+ will_return(__wrap_stat, &statistics);
+ will_return(__wrap_stat, 0);
+
+ const f_status_t status = f_directory_is(path);
+
+ assert_int_equal(status, F_false);
+ }
+}
+
+void test__f_directory_is__returns_true(void **state) {
+
+ const f_string_static_t path = macro_f_string_static_t_initialize("test", 0, 4);
+
+ struct stat statistics;
+
+ memset(&statistics, 0, sizeof (struct stat));
+
+ statistics.st_mode = 1 | S_IFDIR;
+
+ {
+ will_return(__wrap_stat, false);
+ will_return(__wrap_stat, &statistics);
+ will_return(__wrap_stat, 0);
+
+ const f_status_t status = f_directory_is(path);
+
+ assert_int_equal(status, F_true);
+ }
+}
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
--- /dev/null
+/**
+ * FLL - Level 0
+ *
+ * Project: Directory
+ * API Version: 0.5
+ * Licenses: lgpl-2.1-or-later
+ *
+ * Test the directory project.
+ */
+#ifndef _TEST__F_directory_is_h
+#define _TEST__F_directory_is_h
+
+/**
+ * Test that function fails.
+ *
+ * @see f_directory_is()
+ */
+extern void test__f_directory_is__fails(void **state);
+
+/**
+ * Test that function works but the path is empty.
+ *
+ * @see f_directory_is()
+ */
+extern void test__f_directory_is__returns_data_not(void **state);
+
+/**
+ * Test that function works and returns F_false.
+ *
+ * @see f_directory_is()
+ */
+extern void test__f_directory_is__returns_false(void **state);
+
+/**
+ * Test that function works and returns F_true.
+ *
+ * @see f_directory_is()
+ */
+extern void test__f_directory_is__returns_true(void **state);
+
+#endif // _TEST__F_directory_is_h
--- /dev/null
+#include "test-directory.h"
+#include "test-directory-is_at.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void test__f_directory_is_at__fails(void **state) {
+
+ const f_string_static_t path = macro_f_string_static_t_initialize("test", 0, 4);
+
+ int errnos[] = {
+ EACCES,
+ EBADF,
+ EFAULT,
+ ELOOP,
+ ENAMETOOLONG,
+ ENOENT,
+ ENOMEM,
+ ENOTDIR,
+ EOVERFLOW,
+ mock_errno_generic,
+ };
+
+ f_status_t statuss[] = {
+ F_access_denied,
+ F_directory_descriptor,
+ F_buffer,
+ F_loop,
+ F_name,
+ F_file_found_not,
+ F_memory_not,
+ F_false,
+ F_number_overflow,
+ F_file_stat,
+ };
+
+ for (int i = 0; i < 10; ++i) {
+
+ will_return(__wrap_stat, true);
+ will_return(__wrap_stat, errnos[i]);
+
+ const f_status_t status = f_directory_is_at(0, path, 0);
+
+ assert_int_equal(F_status_set_fine(status), statuss[i]);
+ } // for
+}
+
+void test__f_directory_is_at__returns_data_not(void **state) {
+
+ {
+ const f_status_t status = f_directory_is_at(0, f_string_empty_s, 0);
+
+ assert_int_equal(status, F_data_not);
+ }
+}
+
+void test__f_directory_is_at__returns_false(void **state) {
+
+ const f_string_static_t path = macro_f_string_static_t_initialize("test", 0, 4);
+
+ struct stat statistics;
+
+ memset(&statistics, 0, sizeof (struct stat));
+
+ {
+ will_return(__wrap_stat, false);
+ will_return(__wrap_stat, &statistics);
+ will_return(__wrap_stat, 0);
+
+ const f_status_t status = f_directory_is_at(0, path, 0);
+
+ assert_int_equal(status, F_false);
+ }
+}
+
+void test__f_directory_is_at__returns_true(void **state) {
+
+ const f_string_static_t path = macro_f_string_static_t_initialize("test", 0, 4);
+
+ struct stat statistics;
+
+ memset(&statistics, 0, sizeof (struct stat));
+
+ statistics.st_mode = 1 | S_IFDIR;
+
+ {
+ will_return(__wrap_stat, false);
+ will_return(__wrap_stat, &statistics);
+ will_return(__wrap_stat, 0);
+
+ const f_status_t status = f_directory_is_at(0, path, 0);
+
+ assert_int_equal(status, F_true);
+ }
+}
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
--- /dev/null
+/**
+ * FLL - Level 0
+ *
+ * Project: Directory
+ * API Version: 0.5
+ * Licenses: lgpl-2.1-or-later
+ *
+ * Test the directory project.
+ */
+#ifndef _TEST__F_directory_is_at_h
+#define _TEST__F_directory_is_at_h
+
+/**
+ * Test that function fails.
+ *
+ * @see f_directory_is_at()
+ */
+extern void test__f_directory_is_at__fails(void **state);
+
+/**
+ * Test that function works but the path is empty.
+ *
+ * @see f_directory_is_at()
+ */
+extern void test__f_directory_is_at__returns_data_not(void **state);
+
+/**
+ * Test that function works and returns F_false.
+ *
+ * @see f_directory_is_at()
+ */
+extern void test__f_directory_is_at__returns_false(void **state);
+
+/**
+ * Test that function works and returns F_true.
+ *
+ * @see f_directory_is_at()
+ */
+extern void test__f_directory_is_at__returns_true(void **state);
+
+#endif // _TEST__F_directory_is_at_h
--- /dev/null
+#include "test-directory.h"
+#include "test-directory-list.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void test__f_directory_list__fails(void **state) {
+
+ const f_string_static_t path = macro_f_string_static_t_initialize("test", 0, 4);
+
+ f_string_dynamics_t names = f_string_dynamics_t_initialize;
+
+ {
+ int errnos[] = {
+ ENOMEM,
+ mock_errno_generic,
+ };
+
+ f_status_t statuss[] = {
+ F_memory_not,
+ F_failure,
+ };
+
+ for (int i = 0; i < 2; ++i) {
+
+ will_return(__wrap_scandir, true);
+ will_return(__wrap_scandir, errnos[i]);
+
+ const f_status_t status = f_directory_list(path, 0, 0, &names);
+
+ assert_int_equal(F_status_set_fine(status), statuss[i]);
+ assert_int_equal(F_status_set_fine(status), statuss[i]);
+ } // for
+ }
+
+ f_string_dynamics_resize(0, &names);
+}
+
+#ifndef _di_level_0_parameter_checking_
+ void test__f_directory_list__parameter_checking(void **state) {
+
+ const f_string_static_t path = macro_f_string_static_t_initialize("test", 0, 4);
+
+ {
+ const f_status_t status = f_directory_list(path, 0, 0, 0);
+
+ assert_int_equal(F_status_set_fine(status), F_parameter);
+ }
+ }
+#endif // _di_level_0_parameter_checking_
+
+void test__f_directory_list__returns_data_not(void **state) {
+
+ f_string_dynamics_t names = f_string_dynamics_t_initialize;
+
+ {
+ const f_status_t status = f_directory_list(f_string_empty_s, 0, 0, &names);
+
+ assert_int_equal(status, F_data_not);
+ }
+
+ f_string_dynamics_resize(0, &names);
+}
+
+void test__f_directory_list__returns_directory_empty(void **state) {
+
+ f_string_dynamics_t names = f_string_dynamics_t_initialize;
+ const f_string_static_t path = macro_f_string_static_t_initialize("test", 0, 4);
+
+ {
+ will_return(__wrap_scandir, false);
+ will_return(__wrap_scandir, 0);
+
+ const f_status_t status = f_directory_list(path, 0, 0, &names);
+
+ assert_int_equal(status, F_directory_empty);
+ }
+
+ f_string_dynamics_resize(0, &names);
+}
+
+void test__f_directory_list__works(void **state) {
+
+ f_string_dynamics_t names = f_string_dynamics_t_initialize;
+ const f_string_static_t path = macro_f_string_static_t_initialize("test", 0, 4);
+
+ {
+ struct dirent directory;
+ memset(&directory, 0, sizeof(struct dirent));
+
+ struct dirent directories[2];
+
+ memset(directories, 0, sizeof(struct dirent) * 2);
+
+ directories[0] = directory;
+
+ will_return(__wrap_scandir, false);
+ will_return(__wrap_scandir, &directories);
+ will_return(__wrap_strnlen, 1);
+ will_return(__wrap_strncmp, 1);
+ will_return(__wrap_strncmp, 1);
+
+ const f_status_t status = f_directory_list(path, 0, 0, &names);
+
+ assert_int_equal(status, F_none);
+ }
+
+ f_string_dynamics_resize(0, &names);
+}
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
--- /dev/null
+/**
+ * FLL - Level 0
+ *
+ * Project: Directory
+ * API Version: 0.5
+ * Licenses: lgpl-2.1-or-later
+ *
+ * Test the directory project.
+ */
+#ifndef _TEST__F_directory_list_h
+#define _TEST__F_directory_list_h
+
+/**
+ * Test that function fails.
+ *
+ * @see f_directory_list()
+ */
+extern void test__f_directory_list__fails(void **state);
+
+/**
+ * Test that parameter checking works as expected.
+ *
+ * @see f_directory_list()
+ */
+#ifndef _di_level_0_parameter_checking_
+ extern void test__f_directory_list__parameter_checking(void **state);
+#endif // _di_level_0_parameter_checking_
+
+/**
+ * Test that function works but the path is empty.
+ *
+ * @see f_directory_list()
+ */
+extern void test__f_directory_list__returns_data_not(void **state);
+
+/**
+ * Test that function works but returns F_directory_empty.
+ *
+ * @see f_directory_list()
+ */
+extern void test__f_directory_list__returns_directory_empty(void **state);
+
+/**
+ * Test that function works.
+ *
+ * @see f_directory_list()
+ */
+extern void test__f_directory_list__works(void **state);
+
+#endif // _TEST__F_directory_list_h
--- /dev/null
+#include "test-directory.h"
+#include "test-directory-open.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void test__f_directory_open__fails(void **state) {
+
+ const f_string_static_t path = macro_f_string_static_t_initialize("test", 0, 4);
+
+ int errnos[] = {
+ EACCES,
+ EFAULT,
+ EFBIG,
+ EOVERFLOW,
+ EINTR,
+ EINVAL,
+ ELOOP,
+ ENAMETOOLONG,
+ ENFILE,
+ ENOENT,
+ ENOMEM,
+ ENOSPC,
+ ENOTDIR,
+ EPERM,
+ EROFS,
+ mock_errno_generic,
+ };
+
+ f_status_t statuss[] = {
+ F_access_denied,
+ F_buffer,
+ F_number_overflow,
+ F_number_overflow,
+ F_interrupt,
+ F_parameter,
+ F_loop,
+ F_name,
+ F_file_open_max,
+ F_directory_found_not,
+ F_memory_not,
+ F_space_not,
+ F_file_type_not_directory,
+ F_prohibited,
+ F_read_only,
+ F_failure,
+ };
+
+ for (int i = 0; i < 16; ++i) {
+
+ int id = 0;
+
+ will_return(__wrap_open, true);
+ will_return(__wrap_open, errnos[i]);
+
+ const f_status_t status = f_directory_open(path, F_false, &id);
+
+ assert_int_equal(F_status_set_fine(status), statuss[i]);
+ } // for
+}
+
+#ifndef _di_level_0_parameter_checking_
+ void test__f_directory_open__parameter_checking(void **state) {
+
+ const f_string_static_t path = macro_f_string_static_t_initialize("test", 0, 4);
+
+ {
+ const f_status_t status = f_directory_open(path, 0, 0);
+
+ assert_int_equal(F_status_set_fine(status), F_parameter);
+ }
+ }
+#endif // _di_level_0_parameter_checking_
+
+void test__f_directory_open__returns_data_not(void **state) {
+
+ {
+ int id = 0;
+
+ const f_status_t status = f_directory_open(f_string_empty_s, F_false, &id);
+
+ assert_int_equal(status, F_data_not);
+ }
+}
+
+void test__f_directory_open__works(void **state) {
+
+ const f_string_static_t path = macro_f_string_static_t_initialize("test", 0, 4);
+
+ {
+ int id = 0;
+
+ will_return(__wrap_open, false);
+ will_return(__wrap_open, 5);
+
+ const f_status_t status = f_directory_open(path, F_false, &id);
+
+ assert_int_equal(status, F_none);
+ assert_int_equal(id, 5);
+ }
+}
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
--- /dev/null
+/**
+ * FLL - Level 0
+ *
+ * Project: Directory
+ * API Version: 0.5
+ * Licenses: lgpl-2.1-or-later
+ *
+ * Test the directory project.
+ */
+#ifndef _TEST__F_directory_open_h
+#define _TEST__F_directory_open_h
+
+/**
+ * Test that function fails.
+ *
+ * @see f_directory_open()
+ */
+extern void test__f_directory_open__fails(void **state);
+
+/**
+ * Test that parameter checking works as expected.
+ *
+ * @see f_directory_open()
+ */
+#ifndef _di_level_0_parameter_checking_
+ extern void test__f_directory_open__parameter_checking(void **state);
+#endif // _di_level_0_parameter_checking_
+
+/**
+ * Test that function works but the path is empty.
+ *
+ * @see f_directory_open()
+ */
+extern void test__f_directory_open__returns_data_not(void **state);
+
+/**
+ * Test that function works.
+ *
+ * @see f_directory_open()
+ */
+extern void test__f_directory_open__works(void **state);
+
+#endif // _TEST__F_directory_open_h
--- /dev/null
+#include "test-directory.h"
+#include "test-directory-open_at.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void test__f_directory_open_at__fails(void **state) {
+
+ const int at = 1;
+ const f_string_static_t path = macro_f_string_static_t_initialize("test", 0, 4);
+
+ int errnos[] = {
+ EACCES,
+ EBADF,
+ EFAULT,
+ EFBIG,
+ EOVERFLOW,
+ EINTR,
+ EINVAL,
+ ELOOP,
+ ENAMETOOLONG,
+ ENFILE,
+ ENOENT,
+ ENOMEM,
+ ENOSPC,
+ ENOTDIR,
+ EPERM,
+ EROFS,
+ mock_errno_generic,
+ };
+
+ f_status_t statuss[] = {
+ F_access_denied,
+ F_directory_descriptor,
+ F_buffer,
+ F_number_overflow,
+ F_number_overflow,
+ F_interrupt,
+ F_parameter,
+ F_loop,
+ F_name,
+ F_file_open_max,
+ F_directory_found_not,
+ F_memory_not,
+ F_space_not,
+ F_file_type_not_directory,
+ F_prohibited,
+ F_read_only,
+ F_failure,
+ };
+
+ for (int i = 0; i < 17; ++i) {
+
+ int id = 0;
+
+ will_return(__wrap_openat, true);
+ will_return(__wrap_openat, errnos[i]);
+
+ const f_status_t status = f_directory_open_at(at, path, F_false, &id);
+
+ assert_int_equal(F_status_set_fine(status), statuss[i]);
+ } // for
+}
+
+#ifndef _di_level_0_parameter_checking_
+ void test__f_directory_open_at__parameter_checking(void **state) {
+
+ const f_string_static_t path = macro_f_string_static_t_initialize("test", 0, 4);
+
+ {
+ const f_status_t status = f_directory_open_at(0, path, 0, 0);
+
+ assert_int_equal(F_status_set_fine(status), F_parameter);
+ }
+ }
+#endif // _di_level_0_parameter_checking_
+
+void test__f_directory_open_at__returns_data_not(void **state) {
+
+ const int at = 1;
+
+ {
+ int id = 0;
+
+ const f_status_t status = f_directory_open_at(at, f_string_empty_s, F_false, &id);
+
+ assert_int_equal(status, F_data_not);
+ }
+}
+
+void test__f_directory_open_at__works(void **state) {
+
+ const int at = 1;
+
+ const f_string_static_t path = macro_f_string_static_t_initialize("test", 0, 4);
+
+ {
+ int id = 0;
+
+ will_return(__wrap_openat, false);
+ will_return(__wrap_openat, 5);
+
+ const f_status_t status = f_directory_open_at(at, path, F_false, &id);
+
+ assert_int_equal(status, F_none);
+ assert_int_equal(id, 5);
+ }
+}
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
--- /dev/null
+/**
+ * FLL - Level 0
+ *
+ * Project: Directory
+ * API Version: 0.5
+ * Licenses: lgpl-2.1-or-later
+ *
+ * Test the directory project.
+ */
+#ifndef _TEST__F_directory_open_at_h
+#define _TEST__F_directory_open_at_h
+
+/**
+ * Test that function fails.
+ *
+ * @see f_directory_open_at()
+ */
+extern void test__f_directory_open_at__fails(void **state);
+
+/**
+ * Test that parameter checking works as expected.
+ *
+ * @see f_directory_open_at()
+ */
+#ifndef _di_level_0_parameter_checking_
+ extern void test__f_directory_open_at__parameter_checking(void **state);
+#endif // _di_level_0_parameter_checking_
+
+/**
+ * Test that function works but the path is empty.
+ *
+ * @see f_directory_open_at()
+ */
+extern void test__f_directory_open_at__returns_data_not(void **state);
+
+/**
+ * Test that function works.
+ *
+ * @see f_directory_open_at()
+ */
+extern void test__f_directory_open_at__works(void **state);
+
+#endif // _TEST__F_directory_open_at_h
--- /dev/null
+#include "test-directory.h"
+#include "test-directory-remove.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void test__f_directory_remove__fails(void **state) {
+
+ const f_string_static_t path = macro_f_string_static_t_initialize("test", 0, 4);
+
+ int errnos[] = {
+ EACCES,
+ EBUSY,
+ EFAULT,
+ EINVAL,
+ EIO,
+ EISDIR,
+ ELOOP,
+ EMFILE,
+ ENAMETOOLONG,
+ ENFILE,
+ ENOENT,
+ ENOMEM,
+ ENOTDIR,
+ ENOTEMPTY,
+ EPERM,
+ EROFS,
+ mock_errno_generic,
+ };
+
+ f_status_t statuss[] = {
+ F_access_denied,
+ F_busy,
+ F_buffer,
+ F_parameter,
+ F_input_output,
+ F_file_type_directory,
+ F_loop,
+ F_file_descriptor_max,
+ F_name,
+ F_file_open_max,
+ F_file_found_not,
+ F_memory_not,
+ F_directory_not,
+ F_directory_empty_not,
+ F_prohibited,
+ F_read_only,
+ F_failure,
+ };
+
+ {
+ for (int i = 0; i < 17; ++i) {
+
+ will_return(__wrap_remove, true);
+ will_return(__wrap_remove, errnos[i]);
+
+ const f_status_t status = f_directory_remove(path, 0, F_false);
+
+ assert_int_equal(F_status_set_fine(status), statuss[i]);
+ } // for
+ }
+
+ {
+ for (int i = 0; i < 17; ++i) {
+
+ will_return(__wrap_nftw, false);
+ will_return(__wrap_nftw, 0);
+ will_return(__wrap_remove, true);
+ will_return(__wrap_remove, errnos[i]);
+
+ const f_status_t status = f_directory_remove(path, 1, F_false);
+
+ assert_int_equal(F_status_set_fine(status), statuss[i]);
+ } // for
+ }
+
+ {
+ for (int i = 0; i < 17; ++i) {
+
+ will_return(__wrap_nftw, true);
+ will_return(__wrap_nftw, errnos[i]);
+
+ const f_status_t status = f_directory_remove(path, 1, F_true);
+
+ assert_int_equal(F_status_set_fine(status), statuss[i]);
+ } // for
+ }
+}
+
+#ifndef _di_level_0_parameter_checking_
+ void test__f_directory_remove__parameter_checking(void **state) {
+
+ const f_string_static_t path = macro_f_string_static_t_initialize("test", 0, 4);
+
+ {
+ const f_status_t status = f_directory_remove(path, -1, 0);
+
+ assert_int_equal(F_status_set_fine(status), F_parameter);
+ }
+ }
+#endif // _di_level_0_parameter_checking_
+
+void test__f_directory_remove__returns_data_not(void **state) {
+
+ {
+ const f_status_t status = f_directory_remove(f_string_empty_s, 0, F_false);
+
+ assert_int_equal(status, F_data_not);
+ }
+}
+
+void test__f_directory_remove__works(void **state) {
+
+ const f_string_static_t path = macro_f_string_static_t_initialize("test", 0, 4);
+
+ {
+ will_return(__wrap_remove, false);
+ will_return(__wrap_remove, 0);
+
+ const f_status_t status = f_directory_remove(path, 0, F_false);
+
+ assert_int_equal(status, F_none);
+ }
+
+ {
+ const f_status_t status = f_directory_remove(path, 0, F_true);
+
+ assert_int_equal(F_status_set_fine(status), F_none);
+ }
+
+ {
+ will_return(__wrap_nftw, false);
+ will_return(__wrap_nftw, 0);
+ will_return(__wrap_remove, false);
+ will_return(__wrap_remove, 0);
+
+ const f_status_t status = f_directory_remove(path, 1, F_false);
+
+ assert_int_equal(status, F_none);
+ }
+
+ {
+ will_return(__wrap_nftw, false);
+ will_return(__wrap_nftw, 0);
+
+ const f_status_t status = f_directory_remove(path, 1, F_true);
+
+ assert_int_equal(status, F_none);
+ }
+}
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
--- /dev/null
+/**
+ * FLL - Level 0
+ *
+ * Project: Directory
+ * API Version: 0.5
+ * Licenses: lgpl-2.1-or-later
+ *
+ * Test the directory project.
+ */
+#ifndef _TEST__F_directory_remove_h
+#define _TEST__F_directory_remove_h
+
+/**
+ * Test that function fails.
+ *
+ * @see f_directory_remove()
+ */
+extern void test__f_directory_remove__fails(void **state);
+
+/**
+ * Test that parameter checking works as expected.
+ *
+ * @see f_directory_remove()
+ */
+#ifndef _di_level_0_parameter_checking_
+ extern void test__f_directory_remove__parameter_checking(void **state);
+#endif // _di_level_0_parameter_checking_
+
+/**
+ * Test that function works but the path is empty.
+ *
+ * @see f_directory_remove()
+ */
+extern void test__f_directory_remove__returns_data_not(void **state);
+
+/**
+ * Test that function works.
+ *
+ * @see f_directory_remove()
+ */
+extern void test__f_directory_remove__works(void **state);
+
+#endif // _TEST__F_directory_remove_h
--- /dev/null
+#include "test-directory.h"
+#include "test-directory-remove_custom.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void test__f_directory_remove_custom__fails(void **state) {
+
+ const f_string_static_t path = macro_f_string_static_t_initialize("test", 0, 4);
+
+ int errnos[] = {
+ EACCES,
+ EBUSY,
+ EFAULT,
+ EINVAL,
+ EIO,
+ EISDIR,
+ ELOOP,
+ EMFILE,
+ ENAMETOOLONG,
+ ENFILE,
+ ENOENT,
+ ENOMEM,
+ ENOTDIR,
+ ENOTEMPTY,
+ EPERM,
+ EROFS,
+ mock_errno_generic,
+ };
+
+ f_status_t statuss[] = {
+ F_access_denied,
+ F_busy,
+ F_buffer,
+ F_parameter,
+ F_input_output,
+ F_file_type_directory,
+ F_loop,
+ F_file_descriptor_max,
+ F_name,
+ F_file_open_max,
+ F_file_found_not,
+ F_memory_not,
+ F_directory_not,
+ F_directory_empty_not,
+ F_prohibited,
+ F_read_only,
+ F_failure,
+ };
+
+ {
+ for (int i = 0; i < 17; ++i) {
+
+ will_return(__wrap_remove, true);
+ will_return(__wrap_remove, errnos[i]);
+
+ const f_status_t status = f_directory_remove_custom(path, 0, F_false, 0);
+
+ assert_int_equal(F_status_set_fine(status), statuss[i]);
+ } // for
+ }
+
+ {
+ for (int i = 0; i < 17; ++i) {
+
+ will_return(__wrap_nftw, false);
+ will_return(__wrap_nftw, 0);
+ will_return(__wrap_remove, true);
+ will_return(__wrap_remove, errnos[i]);
+
+ const f_status_t status = f_directory_remove_custom(path, 1, F_false, 0);
+
+ assert_int_equal(F_status_set_fine(status), statuss[i]);
+ } // for
+ }
+
+ {
+ for (int i = 0; i < 17; ++i) {
+
+ will_return(__wrap_nftw, true);
+ will_return(__wrap_nftw, errnos[i]);
+
+ const f_status_t status = f_directory_remove_custom(path, 1, F_true, 0);
+
+ assert_int_equal(F_status_set_fine(status), statuss[i]);
+ } // for
+ }
+}
+
+#ifndef _di_level_0_parameter_checking_
+ void test__f_directory_remove_custom__parameter_checking(void **state) {
+
+ const f_string_static_t path = macro_f_string_static_t_initialize("test", 0, 4);
+
+ {
+ const f_status_t status = f_directory_remove_custom(path, -1, 0, 0);
+
+ assert_int_equal(F_status_set_fine(status), F_parameter);
+ }
+ }
+#endif // _di_level_0_parameter_checking_
+
+void test__f_directory_remove_custom__returns_data_not(void **state) {
+
+ {
+ const f_status_t status = f_directory_remove_custom(f_string_empty_s, 0, F_false, 0);
+
+ assert_int_equal(status, F_data_not);
+ }
+}
+
+void test__f_directory_remove_custom__works(void **state) {
+
+ const f_string_static_t path = macro_f_string_static_t_initialize("test", 0, 4);
+
+ {
+ will_return(__wrap_remove, false);
+ will_return(__wrap_remove, 0);
+
+ const f_status_t status = f_directory_remove_custom(path, 0, F_false, 0);
+
+ assert_int_equal(status, F_none);
+ }
+
+ {
+ const f_status_t status = f_directory_remove_custom(path, 0, F_true, 0);
+
+ assert_int_equal(F_status_set_fine(status), F_none);
+ }
+
+ {
+ will_return(__wrap_nftw, false);
+ will_return(__wrap_nftw, 0);
+ will_return(__wrap_remove, false);
+ will_return(__wrap_remove, 0);
+
+ const f_status_t status = f_directory_remove_custom(path, 1, F_false, 0);
+
+ assert_int_equal(status, F_none);
+ }
+
+ {
+ will_return(__wrap_nftw, false);
+ will_return(__wrap_nftw, 0);
+
+ const f_status_t status = f_directory_remove_custom(path, 1, F_true, 0);
+
+ assert_int_equal(status, F_none);
+ }
+}
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
--- /dev/null
+/**
+ * FLL - Level 0
+ *
+ * Project: Directory
+ * API Version: 0.5
+ * Licenses: lgpl-2.1-or-later
+ *
+ * Test the directory project.
+ */
+#ifndef _TEST__F_directory_remove_custom_h
+#define _TEST__F_directory_remove_custom_h
+
+/**
+ * Test that function fails.
+ *
+ * @see f_directory_remove_custom()
+ */
+extern void test__f_directory_remove_custom__fails(void **state);
+
+/**
+ * Test that parameter checking works as expected.
+ *
+ * @see f_directory_remove_custom()
+ */
+#ifndef _di_level_0_parameter_checking_
+ extern void test__f_directory_remove_custom__parameter_checking(void **state);
+#endif // _di_level_0_parameter_checking_
+
+/**
+ * Test that function works but the path is empty.
+ *
+ * @see f_directory_remove_custom()
+ */
+extern void test__f_directory_remove_custom__returns_data_not(void **state);
+
+/**
+ * Test that function works.
+ *
+ * @see f_directory_remove_custom()
+ */
+extern void test__f_directory_remove_custom__works(void **state);
+
+#endif // _TEST__F_directory_remove_custom_h
--- /dev/null
+#include "test-directory.h"
+#include "test-directory-touch.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void test__f_directory_touch__fails(void **state) {
+
+ const f_string_static_t path = macro_f_string_static_t_initialize("test", 0, 4);
+
+ {
+ int errnos[] = {
+ EACCES,
+ EFAULT,
+ ELOOP,
+ ENAMETOOLONG,
+ ENOMEM,
+ ENOTDIR,
+ EOVERFLOW,
+ mock_errno_generic,
+ };
+
+ f_status_t statuss[] = {
+ F_access_denied,
+ F_buffer,
+ F_loop,
+ F_name,
+ F_memory_not,
+ F_directory_not,
+ F_number_overflow,
+ F_failure,
+ };
+
+ for (int i = 0; i < 8; ++i) {
+
+ will_return(__wrap_stat, true);
+ will_return(__wrap_stat, errnos[i]);
+
+ const f_status_t status = f_directory_touch(path, 0);
+
+ assert_int_equal(F_status_set_fine(status), statuss[i]);
+ } // for
+ }
+
+ {
+ int errnos[] = {
+ EACCES,
+ EDQUOT,
+ EEXIST,
+ EFAULT,
+ EINVAL,
+ ELOOP,
+ EMLINK,
+ ENAMETOOLONG,
+ ENOENT,
+ ENOMEM,
+ ENOSPC,
+ ENOTDIR,
+ EPERM,
+ EROFS,
+ mock_errno_generic,
+ };
+
+ f_status_t statuss[] = {
+ F_access_denied,
+ F_filesystem_quota_block,
+ F_file_found,
+ F_buffer,
+ F_parameter,
+ F_loop,
+ F_directory_link_max,
+ F_name,
+ F_file_found_not,
+ F_memory_not,
+ F_space_not,
+ F_directory_not,
+ F_prohibited,
+ F_read_only,
+ F_failure,
+ };
+
+ for (int i = 0; i < 15; ++i) {
+
+ will_return(__wrap_stat, true);
+ will_return(__wrap_stat, ENOENT);
+ will_return(__wrap_mkdir, true);
+ will_return(__wrap_mkdir, errnos[i]);
+
+ const f_status_t status = f_directory_touch(path, 0);
+
+ assert_int_equal(F_status_set_fine(status), statuss[i]);
+ } // for
+ } // for
+
+ {
+ int errnos[] = {
+ EACCES,
+ EBADF,
+ EFAULT,
+ EINVAL,
+ ELOOP,
+ ENAMETOOLONG,
+ ENOENT,
+ ENOTDIR,
+ EPERM,
+ EROFS,
+ ESRCH,
+ mock_errno_generic,
+ };
+
+ f_status_t statuss[] = {
+ F_access_denied,
+ F_directory_descriptor,
+ F_buffer,
+ F_parameter,
+ F_loop,
+ F_name,
+ F_file_found_not,
+ F_directory_not,
+ F_prohibited,
+ F_read_only,
+ F_search,
+ F_failure,
+ };
+
+ for (int i = 0; i < 12; ++i) {
+
+ will_return(__wrap_mkdir, false);
+ will_return(__wrap_mkdir, 0);
+ will_return(__wrap_utimensat, true);
+ will_return(__wrap_utimensat, errnos[i]);
+
+ const f_status_t status = f_directory_touch(path, 0);
+
+ assert_int_equal(F_status_set_fine(status), statuss[i]);
+ } // for
+ }
+}
+
+void test__f_directory_touch__returns_data_not(void **state) {
+
+ {
+ const f_status_t status = f_directory_touch(f_string_empty_s, 0);
+
+ assert_int_equal(status, F_data_not);
+ }
+}
+
+void test__f_directory_touch__works(void **state) {
+
+ const f_string_static_t path = macro_f_string_static_t_initialize("test", 0, 4);
+
+ {
+ will_return(__wrap_mkdir, false);
+ will_return(__wrap_mkdir, 0);
+ will_return(__wrap_utimensat, false);
+ will_return(__wrap_utimensat, 0);
+
+ const f_status_t status = f_directory_touch(path, 0);
+
+ assert_int_equal(status, F_none);
+ }
+
+ {
+ will_return(__wrap_mkdir, true);
+ will_return(__wrap_mkdir, ENOENT);
+ will_return(__wrap_mkdir, false);
+ will_return(__wrap_mkdir, 0);
+
+ const f_status_t status = f_directory_touch(path, 0);
+
+ assert_int_equal(status, F_none);
+ }
+}
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
--- /dev/null
+/**
+ * FLL - Level 0
+ *
+ * Project: Directory
+ * API Version: 0.5
+ * Licenses: lgpl-2.1-or-later
+ *
+ * Test the directory project.
+ */
+#ifndef _TEST__F_directory_touch_h
+#define _TEST__F_directory_touch_h
+
+/**
+ * Test that function fails.
+ *
+ * @see f_directory_touch()
+ */
+extern void test__f_directory_touch__fails(void **state);
+
+/**
+ * Test that function works but the path is empty.
+ *
+ * @see f_directory_touch()
+ */
+extern void test__f_directory_touch__returns_data_not(void **state);
+
+/**
+ * Test that function works.
+ *
+ * @see f_directory_touch()
+ */
+extern void test__f_directory_touch__works(void **state);
+
+#endif // _TEST__F_directory_touch_h
--- /dev/null
+#include "test-directory.h"
+#include "test-directory-touch_at.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void test__f_directory_touch_at__fails(void **state) {
+
+ const f_string_static_t path = macro_f_string_static_t_initialize("test", 0, 4);
+
+ {
+ int errnos[] = {
+ EACCES,
+ EFAULT,
+ ELOOP,
+ ENAMETOOLONG,
+ ENOMEM,
+ ENOTDIR,
+ EOVERFLOW,
+ mock_errno_generic,
+ };
+
+ f_status_t statuss[] = {
+ F_access_denied,
+ F_buffer,
+ F_loop,
+ F_name,
+ F_memory_not,
+ F_directory_not,
+ F_number_overflow,
+ F_failure,
+ };
+
+ for (int i = 0; i < 8; ++i) {
+
+ will_return(__wrap_stat, true);
+ will_return(__wrap_stat, errnos[i]);
+
+ const f_status_t status = f_directory_touch_at(1, path, 0, 0);
+
+ assert_int_equal(F_status_set_fine(status), statuss[i]);
+ } // for
+ }
+
+ {
+ int errnos[] = {
+ EACCES,
+ EDQUOT,
+ EEXIST,
+ EFAULT,
+ EINVAL,
+ ELOOP,
+ EMLINK,
+ ENAMETOOLONG,
+ ENOENT,
+ ENOMEM,
+ ENOSPC,
+ ENOTDIR,
+ EPERM,
+ EROFS,
+ mock_errno_generic,
+ };
+
+ f_status_t statuss[] = {
+ F_access_denied,
+ F_filesystem_quota_block,
+ F_file_found,
+ F_buffer,
+ F_parameter,
+ F_loop,
+ F_directory_link_max,
+ F_name,
+ F_file_found_not,
+ F_memory_not,
+ F_space_not,
+ F_directory_not,
+ F_prohibited,
+ F_read_only,
+ F_failure,
+ };
+
+ for (int i = 0; i < 15; ++i) {
+
+ will_return(__wrap_stat, true);
+ will_return(__wrap_stat, ENOENT);
+ will_return(__wrap_mkdir, true);
+ will_return(__wrap_mkdir, errnos[i]);
+
+ const f_status_t status = f_directory_touch_at(1, path, 0, 0);
+
+ assert_int_equal(F_status_set_fine(status), statuss[i]);
+ } // for
+ } // for
+
+ {
+ int errnos[] = {
+ EACCES,
+ EBADF,
+ EFAULT,
+ EINVAL,
+ ELOOP,
+ ENAMETOOLONG,
+ ENOENT,
+ ENOTDIR,
+ EPERM,
+ EROFS,
+ ESRCH,
+ mock_errno_generic,
+ };
+
+ f_status_t statuss[] = {
+ F_access_denied,
+ F_directory_descriptor,
+ F_buffer,
+ F_parameter,
+ F_loop,
+ F_name,
+ F_file_found_not,
+ F_directory_not,
+ F_prohibited,
+ F_read_only,
+ F_search,
+ F_failure,
+ };
+
+ for (int i = 0; i < 12; ++i) {
+
+ will_return(__wrap_mkdir, false);
+ will_return(__wrap_mkdir, 0);
+ will_return(__wrap_utimensat, true);
+ will_return(__wrap_utimensat, errnos[i]);
+
+ const f_status_t status = f_directory_touch_at(1, path, 0, 0);
+
+ assert_int_equal(F_status_set_fine(status), statuss[i]);
+ } // for
+ }
+}
+
+void test__f_directory_touch_at__returns_data_not(void **state) {
+
+ {
+ const f_status_t status = f_directory_touch_at(1, f_string_empty_s, 0, 0);
+
+ assert_int_equal(status, F_data_not);
+ }
+}
+
+void test__f_directory_touch_at__works(void **state) {
+
+ const f_string_static_t path = macro_f_string_static_t_initialize("test", 0, 4);
+
+ {
+ will_return(__wrap_mkdir, false);
+ will_return(__wrap_mkdir, 0);
+ will_return(__wrap_utimensat, false);
+ will_return(__wrap_utimensat, 0);
+
+ const f_status_t status = f_directory_touch_at(1, path, 0, 0);
+
+ assert_int_equal(status, F_none);
+ }
+
+ {
+ will_return(__wrap_mkdir, true);
+ will_return(__wrap_mkdir, ENOENT);
+ will_return(__wrap_mkdir, false);
+ will_return(__wrap_mkdir, 0);
+
+ const f_status_t status = f_directory_touch_at(1, path, 0, 0);
+
+ assert_int_equal(status, F_none);
+ }
+}
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
--- /dev/null
+/**
+ * FLL - Level 0
+ *
+ * Project: Directory
+ * API Version: 0.5
+ * Licenses: lgpl-2.1-or-later
+ *
+ * Test the directory project.
+ */
+#ifndef _TEST__F_directory_touch_at_h
+#define _TEST__F_directory_touch_at_h
+
+/**
+ * Test that function fails.
+ *
+ * @see f_directory_touch_at()
+ */
+extern void test__f_directory_touch_at__fails(void **state);
+
+/**
+ * Test that function works but the path is empty.
+ *
+ * @see f_directory_touch_at()
+ */
+extern void test__f_directory_touch_at__returns_data_not(void **state);
+
+/**
+ * Test that function works.
+ *
+ * @see f_directory_touch_at()
+ */
+extern void test__f_directory_touch_at__works(void **state);
+
+#endif // _TEST__F_directory_touch_at_h
--- /dev/null
+#include "test-directory.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_directory_create__fails),
+ cmocka_unit_test(test__f_directory_create__returns_data_not),
+ cmocka_unit_test(test__f_directory_create__works),
+
+ cmocka_unit_test(test__f_directory_create_at__fails),
+ cmocka_unit_test(test__f_directory_create_at__returns_data_not),
+ cmocka_unit_test(test__f_directory_create_at__works),
+
+ // Unable to perform tests because stat() appears to not properly get mocked.
+ //cmocka_unit_test(test__f_directory_exists__fails),
+ //cmocka_unit_test(test__f_directory_exists__returns_data_not),
+ //cmocka_unit_test(test__f_directory_exists__returns_false),
+ //cmocka_unit_test(test__f_directory_exists__returns_true),
+
+ // Unable to perform tests because stat() appears to not properly get mocked.
+ //cmocka_unit_test(test__f_directory_exists_at__fails),
+ //cmocka_unit_test(test__f_directory_exists_at__returns_data_not),
+ //cmocka_unit_test(test__f_directory_exists_at__returns_false),
+ //cmocka_unit_test(test__f_directory_exists_at__returns_true),
+
+ // Unable to perform tests because stat() appears to not properly get mocked.
+ //cmocka_unit_test(test__f_directory_is__fails),
+ //cmocka_unit_test(test__f_directory_is__returns_data_not),
+ //cmocka_unit_test(test__f_directory_is__returns_false),
+ //cmocka_unit_test(test__f_directory_is__returns_true),
+
+ // Unable to perform tests because stat() appears to not properly get mocked.
+ //cmocka_unit_test(test__f_directory_is_at__fails),
+ //cmocka_unit_test(test__f_directory_is_at__returns_data_not),
+ //cmocka_unit_test(test__f_directory_is_at__returns_false),
+ //cmocka_unit_test(test__f_directory_is_at__returns_true),
+
+ // Unable to perform tests because scandir() appears to not properly get mocked.
+ //cmocka_unit_test(test__f_directory_list__fails),
+ //cmocka_unit_test(test__f_directory_list__returns_data_not),
+ //cmocka_unit_test(test__f_directory_list__returns_directory_empty),
+ //cmocka_unit_test(test__f_directory_list__works),
+
+ cmocka_unit_test(test__f_directory_open__fails),
+ cmocka_unit_test(test__f_directory_open__returns_data_not),
+ cmocka_unit_test(test__f_directory_open__works),
+
+ cmocka_unit_test(test__f_directory_open_at__fails),
+ cmocka_unit_test(test__f_directory_open_at__returns_data_not),
+ cmocka_unit_test(test__f_directory_open_at__works),
+
+ cmocka_unit_test(test__f_directory_remove__fails),
+ cmocka_unit_test(test__f_directory_remove__returns_data_not),
+ cmocka_unit_test(test__f_directory_remove__works),
+
+ cmocka_unit_test(test__f_directory_remove_custom__fails),
+ cmocka_unit_test(test__f_directory_remove_custom__returns_data_not),
+ cmocka_unit_test(test__f_directory_remove_custom__works),
+
+ // Unable to perform tests because stat() appears to not properly get mocked.
+ //cmocka_unit_test(test__f_directory_touch__fails),
+ //cmocka_unit_test(test__f_directory_touch__returns_data_not),
+ //cmocka_unit_test(test__f_directory_touch__works),
+
+ // Unable to perform tests because stat() appears to not properly get mocked.
+ //cmocka_unit_test(test__f_directory_touch_at__fails),
+ //cmocka_unit_test(test__f_directory_touch_at__returns_data_not),
+ //cmocka_unit_test(test__f_directory_touch_at__works),
+
+ #ifndef _di_level_0_parameter_checking_
+ // f_directory_create() doesn't use parameter checking.
+ // f_directory_create_at() doesn't use parameter checking.
+ // f_directory_exists() doesn't use parameter checking.
+ // f_directory_exists_at() doesn't use parameter checking.
+ // f_directory_is() doesn't use parameter checking.
+ // f_directory_is_at() doesn't use parameter checking.
+ cmocka_unit_test(test__f_directory_list__parameter_checking),
+ cmocka_unit_test(test__f_directory_open__parameter_checking),
+ cmocka_unit_test(test__f_directory_open_at__parameter_checking),
+ cmocka_unit_test(test__f_directory_remove__parameter_checking),
+ cmocka_unit_test(test__f_directory_remove_custom__parameter_checking),
+ // f_directory_touch() doesn't use parameter checking.
+ // f_directory_touch_at() doesn't use parameter checking.
+ #endif // _di_level_0_parameter_checking_
+ };
+
+ return cmocka_run_group_tests(tests, setup, setdown);
+}
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
--- /dev/null
+/**
+ * FLL - Level 0
+ *
+ * Project: Directory
+ * API Version: 0.5
+ * Licenses: lgpl-2.1-or-later
+ *
+ * Test the directory project.
+ */
+#ifndef _TEST__F_directory_h
+#define _TEST__F_directory_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/directory.h>
+
+// Mock includes.
+#include "mock-directory.h"
+
+// Test includes.
+#include "test-directory-create.h"
+#include "test-directory-create_at.h"
+#include "test-directory-exists.h"
+#include "test-directory-exists_at.h"
+#include "test-directory-is.h"
+#include "test-directory-is_at.h"
+#include "test-directory-list.h"
+#include "test-directory-open.h"
+#include "test-directory-open_at.h"
+#include "test-directory-remove.h"
+#include "test-directory-remove_custom.h"
+#include "test-directory-touch.h"
+#include "test-directory-touch_at.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_directory_h
#ifndef _di_f_file_size_at_
f_status_t f_file_size_at(const int at_id, const f_string_static_t path, const bool dereference, f_array_length_t * const size) {
#ifndef _di_level_0_parameter_checking_
- if (at_id <= 0) return F_status_set_error(F_parameter);
if (!size) return F_status_set_error(F_parameter);
#endif // _di_level_0_parameter_checking_
#ifndef _di_f_file_stat_at_
f_status_t f_file_stat_at(const int at_id, const f_string_static_t path, const int flag, struct stat * const stat_file) {
#ifndef _di_level_0_parameter_checking_
- if (at_id <= 0) return F_status_set_error(F_parameter);
if (!stat_file) return F_status_set_error(F_parameter);
#endif // _di_level_0_parameter_checking_
if (fsync(id) < 0) {
if (errno == EBADF) return F_status_set_error(F_file_descriptor);
+ if (errno == EDQUOT) return F_status_set_error(F_filesystem_quota_block);
if (errno == EIO) return F_status_set_error(F_input_output);
if (errno == ENOSPC) return F_status_set_error(F_space_not);
if (errno == EROFS) return F_status_set_error(F_supported_not);
- if (errno == EDQUOT) return F_status_set_error(F_filesystem_quota_block);
return F_status_set_error(F_failure);
}
if (symlink(target.string, point.string) < 0) {
if (errno == EACCES) return F_status_set_error(F_access_denied);
+ if (errno == EFBIG || errno == EOVERFLOW) return F_status_set_error(F_number_overflow);
if (errno == EDQUOT) return F_status_set_error(F_filesystem_quota_block);
if (errno == EEXIST) return F_status_set_error(F_file_found);
- if (errno == ENAMETOOLONG) return F_status_set_error(F_name);
if (errno == EFAULT) return F_status_set_error(F_buffer);
- if (errno == EFBIG || errno == EOVERFLOW) return F_status_set_error(F_number_overflow);
if (errno == EINTR) return F_status_set_error(F_interrupt);
if (errno == EINVAL) return F_status_set_error(F_parameter);
if (errno == ELOOP) return F_status_set_error(F_loop);
+ if (errno == ENAMETOOLONG) return F_status_set_error(F_name);
if (errno == ENOENT) return F_status_set_error(F_file_found_not);
- if (errno == ENOTDIR) return F_status_set_error(F_directory);
if (errno == ENOMEM) return F_status_set_error(F_memory_not);
if (errno == ENOSPC) return F_status_set_error(F_space_not);
+ if (errno == ENOTDIR) return F_status_set_error(F_directory);
if (errno == EPERM) return F_status_set_error(F_prohibited);
if (errno == EROFS) return F_status_set_error(F_read_only);
if (errno == ETXTBSY) return F_status_set_error(F_busy);
if (symlinkat(target.string, at_id, point.string) < 0) {
if (errno == EACCES) return F_status_set_error(F_access_denied);
+ if (errno == EBADF) return F_status_set_error(F_directory_descriptor);
if (errno == EDQUOT) return F_status_set_error(F_filesystem_quota_block);
- if (errno == EEXIST) return F_status_set_error(F_file_found);
- if (errno == ENAMETOOLONG) return F_status_set_error(F_name);
if (errno == EFAULT) return F_status_set_error(F_buffer);
+ if (errno == EEXIST) return F_status_set_error(F_file_found);
if (errno == EFBIG || errno == EOVERFLOW) return F_status_set_error(F_number_overflow);
if (errno == EINTR) return F_status_set_error(F_interrupt);
if (errno == EINVAL) return F_status_set_error(F_parameter);
if (errno == ELOOP) return F_status_set_error(F_loop);
+ if (errno == ENAMETOOLONG) return F_status_set_error(F_name);
if (errno == ENOENT) return F_status_set_error(F_file_found_not);
- if (errno == ENOTDIR) return F_status_set_error(F_directory);
- if (errno == EBADF) return F_status_set_error(F_directory_descriptor);
if (errno == ENOMEM) return F_status_set_error(F_memory_not);
if (errno == ENOSPC) return F_status_set_error(F_space_not);
+ if (errno == ENOTDIR) return F_status_set_error(F_directory);
if (errno == EPERM) return F_status_set_error(F_prohibited);
if (errno == EROFS) return F_status_set_error(F_read_only);
if (errno == ETXTBSY) return F_status_set_error(F_busy);
if (readlinkat(at_id, path.string, target->string, target->used) < 0) {
if (errno == EACCES) return F_status_set_error(F_access_denied);
+ if (errno == EBADF) return F_status_set_error(F_directory_descriptor);
if (errno == EFAULT) return F_status_set_error(F_buffer);
if (errno == EINVAL) return F_status_set_error(F_parameter);
if (errno == EIO) return F_status_set_error(F_input_output);
if (errno == ENOENT) return F_status_set_error(F_file_found_not);
if (errno == ENOMEM) return F_status_set_error(F_memory_not);
if (errno == ENOTDIR) return F_status_set_error(F_directory);
- if (errno == EBADF) return F_status_set_error(F_directory_descriptor);
return F_status_set_error(F_failure);
}
if (chmod(path.string, mode) < 0) {
if (errno == EACCES) return F_status_set_error(F_access_denied);
- if (errno == ENAMETOOLONG) return F_status_set_error(F_name);
if (errno == EFAULT) return F_status_set_error(F_buffer);
+ if (errno == EIO) return F_status_set_error(F_input_output);
if (errno == ELOOP) return F_status_set_error(F_loop);
+ if (errno == ENAMETOOLONG) return F_status_set_error(F_name);
if (errno == ENOENT) return F_status_set_error(F_file_found_not);
if (errno == ENOMEM) return F_status_set_error(F_memory_not);
if (errno == ENOTDIR) return F_status_set_error(F_directory);
if (errno == EPERM) return F_status_set_error(F_access_mode);
if (errno == EROFS) return F_status_set_error(F_read_only);
- if (errno == EIO) return F_status_set_error(F_input_output);
return F_status_set_error(F_failure);
}
if (fchmodat(at_id, path.string, mode, 0) < 0) {
if (errno == EACCES) return F_status_set_error(F_access_denied);
- if (errno == ENAMETOOLONG) return F_status_set_error(F_name);
+ if (errno == EBADF) return F_status_set_error(F_directory_descriptor);
if (errno == EFAULT) return F_status_set_error(F_buffer);
+ if (errno == EIO) return F_status_set_error(F_input_output);
if (errno == ELOOP) return F_status_set_error(F_loop);
+ if (errno == ENAMETOOLONG) return F_status_set_error(F_name);
if (errno == ENOENT) return F_status_set_error(F_file_found_not);
if (errno == ENOMEM) return F_status_set_error(F_memory_not);
if (errno == ENOTDIR) return F_status_set_error(F_directory);
- if (errno == EBADF) return F_status_set_error(F_directory_descriptor);
if (errno == EPERM) return F_status_set_error(F_access_mode);
if (errno == EROFS) return F_status_set_error(F_read_only);
- if (errno == EIO) return F_status_set_error(F_input_output);
return F_status_set_error(F_failure);
}
if (file->id == -1) {
if (errno == EACCES) return F_status_set_error(F_access_denied);
- if (errno == EDQUOT) return F_status_set_error(F_filesystem_quota_block);
if (errno == EEXIST) return F_status_set_error(F_file_found);
- if (errno == ENAMETOOLONG) return F_status_set_error(F_name);
if (errno == EFAULT) return F_status_set_error(F_buffer);
if (errno == EFBIG || errno == EOVERFLOW) return F_status_set_error(F_number_overflow);
+ if (errno == EDQUOT) return F_status_set_error(F_filesystem_quota_block);
if (errno == EINTR) return F_status_set_error(F_interrupt);
if (errno == EINVAL) return F_status_set_error(F_parameter);
+ if (errno == EISDIR) return F_status_set_error(F_directory);
if (errno == ELOOP) return F_status_set_error(F_loop);
+ if (errno == ENAMETOOLONG) return F_status_set_error(F_name);
if (errno == ENFILE) return F_status_set_error(F_file_open_max);
if (errno == ENOENT) return F_status_set_error(F_file_found_not);
- if (errno == ENOTDIR) return F_status_set_error(F_file_type_not_directory);
if (errno == ENOMEM) return F_status_set_error(F_memory_not);
if (errno == ENOSPC) return F_status_set_error(F_space_not);
+ if (errno == ENOTDIR) return F_status_set_error(F_file_type_not_directory);
+ if (errno == EOPNOTSUPP) return F_status_set_error(F_supported_not);
if (errno == EPERM) return F_status_set_error(F_prohibited);
if (errno == EROFS) return F_status_set_error(F_read_only);
if (errno == ETXTBSY) return F_status_set_error(F_busy);
- if (errno == EISDIR) return F_status_set_error(F_directory);
- if (errno == EOPNOTSUPP) return F_status_set_error(F_supported_not);
return F_status_set_error(F_failure);
}
if (file->id == -1) {
if (errno == EACCES) return F_status_set_error(F_access_denied);
+ if (errno == EBADF) return F_status_set_error(F_directory_descriptor);
if (errno == EDQUOT) return F_status_set_error(F_filesystem_quota_block);
if (errno == EEXIST) return F_status_set_error(F_file_found);
- if (errno == ENAMETOOLONG) return F_status_set_error(F_name);
if (errno == EFAULT) return F_status_set_error(F_buffer);
if (errno == EFBIG || errno == EOVERFLOW) return F_status_set_error(F_number_overflow);
if (errno == EINTR) return F_status_set_error(F_interrupt);
if (errno == EINVAL) return F_status_set_error(F_parameter);
+ if (errno == EISDIR) return F_status_set_error(F_directory);
if (errno == ELOOP) return F_status_set_error(F_loop);
+ if (errno == ENAMETOOLONG) return F_status_set_error(F_name);
if (errno == ENFILE) return F_status_set_error(F_file_open_max);
- if (errno == EBADF) return F_status_set_error(F_directory_descriptor);
if (errno == ENOENT) return F_status_set_error(F_file_found_not);
- if (errno == ENOTDIR) return F_status_set_error(F_file_type_not_directory);
if (errno == ENOMEM) return F_status_set_error(F_memory_not);
if (errno == ENOSPC) return F_status_set_error(F_space_not);
+ if (errno == ENOTDIR) return F_status_set_error(F_file_type_not_directory);
+ if (errno == EOPNOTSUPP) return F_status_set_error(F_supported_not);
if (errno == EPERM) return F_status_set_error(F_prohibited);
if (errno == EROFS) return F_status_set_error(F_read_only);
if (errno == ETXTBSY) return F_status_set_error(F_busy);
- if (errno == EISDIR) return F_status_set_error(F_directory);
- if (errno == EOPNOTSUPP) return F_status_set_error(F_supported_not);
return F_status_set_error(F_failure);
}
if (result < 0) {
if (errno == EACCES) return F_status_set_error(F_access_denied);
- if (errno == ENAMETOOLONG) return F_status_set_error(F_name);
if (errno == EFAULT) return F_status_set_error(F_buffer);
+ if (errno == EIO) return F_status_set_error(F_input_output);
if (errno == ELOOP) return F_status_set_error(F_loop);
+ if (errno == ENAMETOOLONG) return F_status_set_error(F_name);
if (errno == ENOENT) return F_status_set_error(F_file_found_not);
if (errno == ENOMEM) return F_status_set_error(F_memory_not);
if (errno == ENOTDIR) return F_status_set_error(F_directory);
if (errno == EROFS) return F_status_set_error(F_read_only);
- if (errno == EIO) return F_status_set_error(F_input_output);
return F_status_set_error(F_failure);
}
if (result < 0) {
if (errno == EACCES) return F_status_set_error(F_access_denied);
- if (errno == ENAMETOOLONG) return F_status_set_error(F_name);
+ if (errno == EBADF) return F_status_set_error(F_directory_descriptor);
if (errno == EFAULT) return F_status_set_error(F_buffer);
+ if (errno == EIO) return F_status_set_error(F_input_output);
if (errno == ELOOP) return F_status_set_error(F_loop);
+ if (errno == ENAMETOOLONG) return F_status_set_error(F_name);
if (errno == ENOENT) return F_status_set_error(F_file_found_not);
if (errno == ENOMEM) return F_status_set_error(F_memory_not);
if (errno == ENOTDIR) return F_status_set_error(F_directory);
- if (errno == EBADF) return F_status_set_error(F_directory_descriptor);
if (errno == EROFS) return F_status_set_error(F_read_only);
- if (errno == EIO) return F_status_set_error(F_input_output);
return F_status_set_error(F_failure);
}
f_status_t private_f_file_stat(const f_string_static_t path, const bool dereference, struct stat * const file_stat) {
if ((dereference ? stat(path.string, file_stat) : lstat(path.string, file_stat)) < 0) {
- if (errno == ENAMETOOLONG) return F_status_set_error(F_name);
+ if (errno == EACCES) return F_status_set_error(F_access_denied);
if (errno == EFAULT) return F_status_set_error(F_buffer);
+ if (errno == ELOOP) return F_status_set_error(F_loop);
+ if (errno == ENAMETOOLONG) return F_status_set_error(F_name);
+ if (errno == ENOENT) return F_status_set_error(F_file_found_not);
if (errno == ENOMEM) return F_status_set_error(F_memory_not);
- if (errno == EOVERFLOW) return F_status_set_error(F_number_overflow);
if (errno == ENOTDIR) return F_status_set_error(F_directory);
- if (errno == ENOENT) return F_status_set_error(F_file_found_not);
- if (errno == EACCES) return F_status_set_error(F_access_denied);
- if (errno == ELOOP) return F_status_set_error(F_loop);
+ if (errno == EOVERFLOW) return F_status_set_error(F_number_overflow);
return F_status_set_error(F_file_stat);
}
f_status_t private_f_file_stat_at(const int at_id, const f_string_static_t path, const int flag, struct stat * const file_stat) {
if (fstatat(at_id, path.string, file_stat, flag) < 0) {
- if (errno == ENAMETOOLONG) return F_status_set_error(F_name);
- if (errno == EFAULT) return F_status_set_error(F_buffer);
- if (errno == ENOMEM) return F_status_set_error(F_memory_not);
- if (errno == EOVERFLOW) return F_status_set_error(F_number_overflow);
- if (errno == ENOTDIR) return F_status_set_error(F_directory);
- if (errno == ENOENT) return F_status_set_error(F_file_found_not);
if (errno == EACCES) return F_status_set_error(F_access_denied);
- if (errno == ELOOP) return F_status_set_error(F_loop);
if (errno == EBADF) return F_status_set_error(F_directory_descriptor);
+ if (errno == EFAULT) return F_status_set_error(F_buffer);
+ if (errno == ELOOP) return F_status_set_error(F_loop);
+ if (errno == ENAMETOOLONG) return F_status_set_error(F_name);
if (errno == ENOENT) return F_status_set_error(F_file_found_not);
+ if (errno == ENOMEM) return F_status_set_error(F_memory_not);
+ if (errno == ENOTDIR) return F_status_set_error(F_directory);
+ if (errno == EOVERFLOW) return F_status_set_error(F_number_overflow);
return F_status_set_error(F_file_stat);
}
const int result = fstat(id, file_stat);
if (result < 0) {
- if (errno == ENAMETOOLONG) return F_status_set_error(F_name);
+ if (errno == EACCES) return F_status_set_error(F_access_denied);
if (errno == EFAULT) return F_status_set_error(F_buffer);
+ if (errno == ELOOP) return F_status_set_error(F_loop);
+ if (errno == ENAMETOOLONG) return F_status_set_error(F_name);
+ if (errno == ENOENT) return F_file_found_not;
if (errno == ENOMEM) return F_status_set_error(F_memory_not);
- if (errno == EOVERFLOW) return F_status_set_error(F_number_overflow);
if (errno == ENOTDIR) return F_status_set_error(F_directory);
- if (errno == ENOENT) return F_file_found_not;
- if (errno == EACCES) return F_status_set_error(F_access_denied);
- if (errno == ELOOP) return F_status_set_error(F_loop);
+ if (errno == EOVERFLOW) return F_status_set_error(F_number_overflow);
return F_status_set_error(F_file_stat);
}
--- /dev/null
+# fss-0001
+
+cmocka 1.*
path_sources tests/unit/c
has_path_standard no
-preserve_path_headers no
+preserve_path_headers yes
search_exclusive yes
search_shared yes
path_sources tests/unit/c
has_path_standard no
-preserve_path_headers no
+preserve_path_headers yes
search_exclusive yes
search_shared yes
--- /dev/null
+# fss-0001
+
+cmocka 1.*
path_sources tests/unit/c
has_path_standard no
-preserve_path_headers no
+preserve_path_headers yes
search_exclusive yes
search_shared yes
path_sources tests/unit/c
has_path_standard no
-preserve_path_headers no
+preserve_path_headers yes
search_exclusive yes
search_shared yes
--- /dev/null
+# fss-0001
+
+cmocka 1.*
path_sources tests/unit/c
has_path_standard no
-preserve_path_headers no
+preserve_path_headers yes
search_exclusive yes
search_shared yes