Simplify the process of determining if the directory is empty.
The entire list of directories do not need to be processed in this case.
Only check if the first child in the directory exists.
}
#endif // _di_f_directory_create_at_
+#ifndef _di_f_directory_empty_
+ f_status_t f_directory_empty(const f_string_static_t path) {
+
+ if (!path.used) return F_data_not;
+
+ f_status_t status = F_true;
+
+ DIR *parent = opendir(path.string);
+
+ if (!parent) {
+ if (errno == ENOMEM) return F_status_set_error(F_memory_not);
+ if (errno == EMFILE) return F_status_set_error(F_file_descriptor_max);
+ if (errno == ENFILE) return F_status_set_error(F_file_open_max);
+ if (errno == ENOTDIR) return F_status_set_error(F_directory);
+ if (errno == ENOENT) return F_status_set_error(F_directory_found_not);
+ if (errno == EACCES) return F_status_set_error(F_access_denied);
+
+ return F_status_set_error(F_directory_open);
+ }
+
+ errno = 0;
+
+ // The '.' and '..' paths must not be counted, so check at most 3 dirents.
+ struct dirent * dir = readdir(parent);
+
+ if (dir) {
+ errno = 0;
+
+ if (!strncmp(f_directory_current_s.string, dir->d_name, f_directory_current_s.used + 1) || !strncmp(f_directory_back_s.string, dir->d_name, f_directory_back_s.used + 1)) {
+ dir = readdir(parent);
+
+ if (dir) {
+ errno = 0;
+
+ if (!strncmp(f_directory_current_s.string, dir->d_name, f_directory_current_s.used + 1) || !strncmp(f_directory_back_s.string, dir->d_name, f_directory_back_s.used + 1)) {
+ status = readdir(parent) ? F_false : F_true;
+ }
+ else {
+ status = F_false;
+ }
+ }
+ }
+ else {
+ status = F_false;
+ }
+ }
+
+ if (errno) {
+ status = errno == EBADF ? F_status_set_error(F_directory_descriptor) : F_status_set_error(F_directory_read);
+ }
+
+ closedir(parent);
+
+ return status;
+ }
+#endif // _di_f_directory_empty_
+
#ifndef _di_f_directory_exists_
f_status_t f_directory_exists(const f_string_static_t path) {
#endif // _di_f_directory_create_at_
/**
+ * For some given path, check to see if is a directory and if the directory is empty.
+ *
+ *
+ * @param path
+ * Filesystem path to the directory.
+ *
+ * @return
+ * F_okay on success.
+ * F_data_not if source.used or destination.used is 0.
+ *
+ * F_directory (with error bit) if the path is not a directory.
+ * F_directory_descriptor (with error bit) for bad directory descriptor after opening the path.
+ * F_directory_found_not (with error bit) if there is not file at the path.
+ * F_directory_read (with error bit) if there is an error while reading the directory.
+ * F_failure (with error bit) if failed to read directory information.
+ * F_file_descriptor_max (with error bit) if max file descriptors is reached.
+ * F_file_open_max (with error bit) too many open files.
+ * F_memory_not (with error bit) on out of memory.
+ * F_parameter (with error bit) if a parameter is invalid.
+ *
+ * Errors (with error bit) from: f_file_stat_at().
+ *
+ * @see opendir()
+ * @see scandir()
+ *
+ * @see f_file_stat_at()
+ */
+#ifndef _di_f_directory_empty_
+ extern f_status_t f_directory_empty(const f_string_static_t path);
+#endif // _di_f_directory_empty_
+
+/**
* Identify whether or not a file exists at the given path and if that file is a directory or a symlink to a directory.
*
* @param path
flags -Wl,--wrap=f_memory_arrays_adjust
flags -Wl,--wrap=f_memory_arrays_resize
flags -Wl,--wrap=alphasort
+flags -Wl,--wrap=closedir
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=opendir
+flags -Wl,--wrap=readdir
flags -Wl,--wrap=remove
flags -Wl,--wrap=scandir
flags -Wl,--wrap=stat
build_libraries -lc -lcmocka
build_libraries-individual -lf_memory -lf_string -lf_directory
-build_sources_program test-directory.c 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
+build_sources_program test-directory.c test-directory-create.c test-directory-create_at.c test-directory-empty.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
build_sources_program test-directory-listings_destroy_callback.c test-directory-listings_delete_callback.c test-directory-listingss_destroy_callback.c test-directory-listingss_delete_callback.c
build_sources_program test-directory-recurse_dos_destroy_callback.c test-directory-recurse_dos_delete_callback.c test-directory-recurse_doss_destroy_callback.c test-directory-recurse_doss_delete_callback.c
build_sources_program test-directory-statuss_destroy_callback.c test-directory-statuss_delete_callback.c test-directory-statusss_destroy_callback.c test-directory-statusss_delete_callback.c
int __wrap_alphasort(const struct dirent **a, const struct dirent **b) {
+ if (mock_unwrap) {
+ return __real_alphasort(a, b);
+ }
+
+ const bool failure = mock_type(bool);
+
+ if (failure) {
+ errno = mock_type(int);
+
+ return -1;
+ }
+
+ return mock_type(int);
+}
+
+int __wrap_closedir(DIR *dirp) {
+
+ if (mock_unwrap) {
+ return __real_closedir(dirp);
+ }
+
const bool failure = mock_type(bool);
if (failure) {
int __wrap_fstatat(int dirfd, const char *pathname, struct stat *statbuf, int flags) {
+ if (mock_unwrap) {
+ return __real_fstatat(dirfd, pathname, statbuf, flags);
+ }
+
const bool failure = mock_type(bool);
if (failure) {
int __wrap_mkdir(const char *pathname, mode_t mode) {
+ if (mock_unwrap) {
+ return __real_mkdir(pathname, mode);
+ }
+
const bool failure = mock_type(bool);
if (failure) {
int __wrap_mkdirat(int dirfd, const char *pathname, mode_t mode) {
+ if (mock_unwrap) {
+ return __real_mkdirat(dirfd, pathname, mode);
+ }
+
const bool failure = mock_type(bool);
if (failure) {
int __wrap_nftw(const char *dirpath, int (*fn) (const char *fpath, const struct stat *sb, int typeflag, struct FTW *ftwbuf), int nopenfd, int flags) {
+ if (mock_unwrap) {
+ return __real_nftw(dirpath, fn, nopenfd, flags);
+ }
+
const bool failure = mock_type(bool);
if (failure) {
int __wrap_open(const char *pathname, int flags) {
+ if (mock_unwrap) {
+ return __real_open(pathname, flags);
+ }
+
const bool failure = mock_type(bool);
if (failure) {
int __wrap_openat(int dirfd, const char *pathname, int flags) {
+ if (mock_unwrap) {
+ return __real_openat(dirfd, pathname, flags);
+ }
+
const bool failure = mock_type(bool);
if (failure) {
return mock_type(int);
}
+DIR *__wrap_opendir(const char *name) {
+
+ if (mock_unwrap) {
+ return __real_opendir(name);
+ }
+
+ const bool failure = mock_type(bool);
+
+ if (failure) {
+ errno = mock_type(int);
+
+ return 0;
+ }
+
+ return mock_type(DIR *);
+}
+
+struct dirent *__wrap_readdir(DIR *dirp) {
+
+ if (mock_unwrap) {
+ return __real_readdir(dirp);
+ }
+
+ const bool failure = mock_type(bool);
+
+ if (failure) {
+ errno = mock_type(int);
+
+ return 0;
+ }
+
+ return mock_type(struct dirent *);
+}
+
int __wrap_remove(const char *pathname) {
+ if (mock_unwrap) {
+ return __real_remove(pathname);
+ }
+
const bool failure = mock_type(bool);
if (failure) {
int __wrap_scandir(const char *dirp, struct dirent ***namelist, int (*filter)(const struct dirent *), int (*compar)(const struct dirent **, const struct dirent **)) {
+ if (mock_unwrap) {
+ return __real_scandir(dirp, namelist, filter, compar);
+ }
+
const bool failure = mock_type(bool);
if (failure) {
int __wrap_stat(const char *pathname, struct stat *statbuf) {
+ if (mock_unwrap) {
+ return __real_stat(pathname, statbuf);
+ }
+
const bool failure = mock_type(bool);
if (failure) {
int __wrap_utimensat(int dirfd, const char *pathname, const struct timespec times[2], int flags) {
+ if (mock_unwrap) {
+ return __real_utimensat(dirfd, pathname, times, flags);
+ }
+
const bool failure = mock_type(bool);
if (failure) {
int __wrap_versionsort(const struct dirent **a, const struct dirent **b) {
+ if (mock_unwrap) {
+ return __real_versionsort(a, b);
+ }
+
const bool failure = mock_type(bool);
if (failure) {
extern f_status_t __wrap_f_memory_arrays_adjust(const f_number_unsigned_t length, const size_t width, void ** const array, f_number_unsigned_t * const used, f_number_unsigned_t * const size, f_status_t (*callback)(const f_number_unsigned_t start, const f_number_unsigned_t size, void * const array));
extern f_status_t __wrap_f_memory_arrays_resize(const f_number_unsigned_t length, const size_t width, void ** const array, f_number_unsigned_t * const used, f_number_unsigned_t * const size, f_status_t (*callback)(const f_number_unsigned_t start, const f_number_unsigned_t size, void * const array));
+extern int __real_alphasort(const struct dirent **a, const struct dirent **b);
+extern int __real_closedir(DIR *dirp);
+extern int __real_fstatat(int dirfd, const char *pathname, struct stat *statbuf, int flags);
+extern int __real_mkdir(const char *pathname, mode_t mode);
+extern int __real_mkdirat(int dirfd, const char *pathname, mode_t mode);
+extern int __real_nftw(const char *dirpath, int (*fn) (const char *fpath, const struct stat *sb, int typeflag, struct FTW *ftwbuf), int nopenfd, int flags);
+extern int __real_open(const char *pathname, int flags);
+extern int __real_openat(int dirfd, const char *pathname, int flags);
+extern DIR *__real_opendir(const char *name);
+extern struct dirent *__real_readdir(DIR *dirp);
+extern int __real_remove(const char *pathname);
+extern int __real_scandir(const char *dirp, struct dirent ***namelist, int (*filter)(const struct dirent *), int (*compar)(const struct dirent **, const struct dirent **));
+extern int __real_stat(const char *pathname, struct stat *statbuf);
+extern int __real_utimensat(int dirfd, const char *pathname, const struct timespec times[2], int flags);
+extern int __real_versionsort(const struct dirent **a, const struct dirent **b);
+
extern int __wrap_alphasort(const struct dirent **a, const struct dirent **b);
+extern int __wrap_closedir(DIR *dirp);
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 DIR *__wrap_opendir(const char *name);
+extern struct dirent *__wrap_readdir(DIR *dirp);
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);
void test__f_directory_create__fails(void **state) {
+ mock_unwrap = 0;
+ mock_unwrap_f_memory = 1;
+
const f_string_static_t path = macro_f_string_static_t_initialize_1("test", 0, 4);
int errnos[] = {
void test__f_directory_create__returns_data_not(void **state) {
+ mock_unwrap = 0;
+ mock_unwrap_f_memory = 1;
+
{
const f_status_t status = f_directory_create(f_string_empty_s, 0);
void test__f_directory_create__works(void **state) {
+ mock_unwrap = 0;
+ mock_unwrap_f_memory = 1;
+
const f_string_static_t path = macro_f_string_static_t_initialize_1("test", 0, 4);
{
void test__f_directory_create_at__fails(void **state) {
+ mock_unwrap = 0;
+ mock_unwrap_f_memory = 1;
+
const f_string_static_t path = macro_f_string_static_t_initialize_1("test", 0, 4);
int errnos[] = {
void test__f_directory_create_at__returns_data_not(void **state) {
+ mock_unwrap = 0;
+ mock_unwrap_f_memory = 1;
+
{
const f_status_t status = f_directory_create_at(0, f_string_empty_s, 0);
void test__f_directory_create_at__works(void **state) {
+ mock_unwrap = 0;
+ mock_unwrap_f_memory = 1;
+
const f_string_static_t path = macro_f_string_static_t_initialize_1("test", 0, 4);
{
--- /dev/null
+#include "test-directory.h"
+#include "test-directory-empty.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void test__f_directory_empty__fails(void **state) {
+
+ mock_unwrap = 0;
+ mock_unwrap_f_memory = 1;
+
+ {
+ int errnos[] = {
+ EACCES,
+ EMFILE,
+ ENFILE,
+ ENOTDIR,
+ ENOENT,
+ ENOMEM,
+ mock_errno_generic,
+ };
+
+ f_status_t statuss[] = {
+ F_status_set_error(F_access_denied),
+ F_status_set_error(F_file_descriptor_max),
+ F_status_set_error(F_file_open_max),
+ F_status_set_error(F_directory),
+ F_status_set_error(F_directory_found_not),
+ F_status_set_error(F_memory_not),
+ F_status_set_error(F_directory_open),
+ };
+
+ for (int i = 0; i < 7; ++i) {
+
+ will_return(__wrap_opendir, true);
+ will_return(__wrap_opendir, errnos[i]);
+
+ const f_status_t status = f_directory_empty(f_directory_current_s);
+
+ assert_int_equal(status, statuss[i]);
+ } // for
+ }
+
+ mock_unwrap = 1;
+ DIR *directory = opendir(f_directory_current_s.string);
+ mock_unwrap = 0;
+
+ int errnos[] = {
+ EBADF,
+ mock_errno_generic,
+ };
+
+ f_status_t statuss[] = {
+ F_status_set_error(F_directory_descriptor),
+ F_status_set_error(F_directory_read),
+ };
+
+ for (int i = 0; i < 2; ++i) {
+
+ will_return(__wrap_opendir, false);
+ will_return(__wrap_opendir, directory);
+ will_return(__wrap_readdir, true);
+ will_return(__wrap_readdir, errnos[i]);
+ will_return(__wrap_closedir, false);
+ will_return(__wrap_closedir, 0);
+
+ const f_status_t status = f_directory_empty(f_directory_current_s);
+
+ assert_int_equal(status, statuss[i]);
+ } // for
+
+ mock_unwrap = 1;
+ closedir(directory);
+}
+
+void test__f_directory_empty__returns_data_not(void **state) {
+
+ mock_unwrap = 0;
+ mock_unwrap_f_memory = 1;
+
+ {
+ const f_status_t status = f_directory_empty(f_string_empty_s);
+
+ assert_int_equal(status, F_data_not);
+ }
+}
+
+void test__f_directory_empty__returns_false(void **state) {
+
+ mock_unwrap = 0;
+ mock_unwrap_f_memory = 1;
+
+ const f_string_static_t path_other = macro_f_string_static_t_initialize_1("other", 0, 5);
+
+ // The "DIR" structure cannot be easily instantiated so just use a real call to PWD.
+ mock_unwrap = 1;
+ DIR *directory = opendir(f_directory_current_s.string);
+ mock_unwrap = 0;
+
+ struct dirent entity_1;
+ struct dirent entity_2;
+ struct dirent entity_3;
+
+ memset(&entity_1, 0, sizeof(struct dirent));
+ memset(&entity_2, 0, sizeof(struct dirent));
+ memset(&entity_3, 0, sizeof(struct dirent));
+
+ memcpy(entity_1.d_name, path_other.string, path_other.used + 1);
+
+ {
+ will_return(__wrap_opendir, false);
+ will_return(__wrap_opendir, directory);
+ will_return(__wrap_readdir, false);
+ will_return(__wrap_readdir, &entity_1);
+ will_return(__wrap_closedir, false);
+ will_return(__wrap_closedir, 0);
+
+ const f_status_t status = f_directory_empty(f_directory_current_s);
+
+ assert_int_equal(status, F_false);
+ }
+
+ memcpy(entity_1.d_name, f_directory_current_s.string, f_directory_current_s.used + 1);
+ memcpy(entity_2.d_name, path_other.string, path_other.used + 1);
+
+ {
+ will_return(__wrap_opendir, false);
+ will_return(__wrap_opendir, directory);
+ will_return(__wrap_readdir, false);
+ will_return(__wrap_readdir, &entity_1);
+ will_return(__wrap_readdir, false);
+ will_return(__wrap_readdir, &entity_2);
+ will_return(__wrap_closedir, false);
+ will_return(__wrap_closedir, 0);
+
+ const f_status_t status = f_directory_empty(f_directory_current_s);
+
+ assert_int_equal(status, F_false);
+ }
+
+ memcpy(entity_1.d_name, f_directory_current_s.string, f_directory_current_s.used + 1);
+ memcpy(entity_2.d_name, f_directory_back_s.string, f_directory_back_s.used + 1);
+ memcpy(entity_3.d_name, path_other.string, path_other.used + 1);
+
+ {
+ will_return(__wrap_opendir, false);
+ will_return(__wrap_opendir, directory);
+ will_return(__wrap_readdir, false);
+ will_return(__wrap_readdir, &entity_1);
+ will_return(__wrap_readdir, false);
+ will_return(__wrap_readdir, &entity_2);
+ will_return(__wrap_readdir, false);
+ will_return(__wrap_readdir, &entity_3);
+ will_return(__wrap_closedir, false);
+ will_return(__wrap_closedir, 0);
+
+ const f_status_t status = f_directory_empty(f_directory_current_s);
+
+ assert_int_equal(status, F_false);
+ }
+
+ mock_unwrap = 1;
+ closedir(directory);
+}
+
+void test__f_directory_empty__returns_true(void **state) {
+
+ mock_unwrap = 0;
+ mock_unwrap_f_memory = 1;
+
+ // The "DIR" structure cannot be easily instantiated so just use a real call to PWD.
+ mock_unwrap = 1;
+ DIR *directory = opendir(f_directory_current_s.string);
+ mock_unwrap = 0;
+
+ struct dirent entity_1;
+ struct dirent entity_2;
+
+ memset(&entity_1, 0, sizeof(struct dirent));
+ memset(&entity_2, 0, sizeof(struct dirent));
+
+ memcpy(entity_1.d_name, f_directory_current_s.string, f_directory_current_s.used + 1);
+ memcpy(entity_2.d_name, f_directory_back_s.string, f_directory_back_s.used + 1);
+
+ {
+ will_return(__wrap_opendir, false);
+ will_return(__wrap_opendir, directory);
+ will_return(__wrap_readdir, false);
+ will_return(__wrap_readdir, 0);
+ will_return(__wrap_closedir, false);
+ will_return(__wrap_closedir, 0);
+
+ const f_status_t status = f_directory_empty(f_directory_current_s);
+
+ assert_int_equal(status, F_true);
+ }
+
+ {
+ will_return(__wrap_opendir, false);
+ will_return(__wrap_opendir, directory);
+ will_return(__wrap_readdir, false);
+ will_return(__wrap_readdir, &entity_1);
+ will_return(__wrap_readdir, false);
+ will_return(__wrap_readdir, 0);
+ will_return(__wrap_closedir, false);
+ will_return(__wrap_closedir, 0);
+
+ const f_status_t status = f_directory_empty(f_directory_current_s);
+
+ assert_int_equal(status, F_true);
+ }
+
+ {
+ will_return(__wrap_opendir, false);
+ will_return(__wrap_opendir, directory);
+ will_return(__wrap_readdir, false);
+ will_return(__wrap_readdir, &entity_1);
+ will_return(__wrap_readdir, false);
+ will_return(__wrap_readdir, &entity_2);
+ will_return(__wrap_readdir, false);
+ will_return(__wrap_readdir, 0);
+ will_return(__wrap_closedir, false);
+ will_return(__wrap_closedir, 0);
+
+ const f_status_t status = f_directory_empty(f_directory_current_s);
+
+ assert_int_equal(status, F_true);
+ }
+
+ mock_unwrap = 1;
+ closedir(directory);
+}
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
--- /dev/null
+/**
+ * FLL - Level 0
+ *
+ * Project: Directory
+ * API Version: 0.7
+ * Licenses: lgpl-2.1-or-later
+ *
+ * Test the directory project.
+ */
+#ifndef _TEST__F_directory_empty_h
+#define _TEST__F_directory_empty_h
+
+/**
+ * Test that function fails.
+ *
+ * @see f_directory_empty()
+ */
+extern void test__f_directory_empty__fails(void **state);
+
+/**
+ * Test that function works but the path is empty.
+ *
+ * @see f_directory_empty()
+ */
+extern void test__f_directory_empty__returns_data_not(void **state);
+
+/**
+ * Test that function works and returns F_false.
+ *
+ * @see f_directory_empty()
+ */
+extern void test__f_directory_empty__returns_false(void **state);
+
+/**
+ * Test that function works and returns F_true.
+ *
+ * @see f_directory_empty()
+ */
+extern void test__f_directory_empty__returns_true(void **state);
+
+#endif // _TEST__F_directory_empty_h
void test__f_directory_exists__fails(void **state) {
+ mock_unwrap = 0;
+ mock_unwrap_f_memory = 1;
+
const f_string_static_t path = macro_f_string_static_t_initialize_1("test", 0, 4);
int errnos[] = {
void test__f_directory_exists__returns_data_not(void **state) {
+ mock_unwrap = 0;
+ mock_unwrap_f_memory = 1;
+
{
const f_status_t status = f_directory_exists(f_string_empty_s);
void test__f_directory_exists__returns_false(void **state) {
+ mock_unwrap = 0;
+ mock_unwrap_f_memory = 1;
+
const f_string_static_t path = macro_f_string_static_t_initialize_1("test", 0, 4);
struct stat statistics;
void test__f_directory_exists__returns_true(void **state) {
+ mock_unwrap = 0;
+ mock_unwrap_f_memory = 1;
+
const f_string_static_t path = macro_f_string_static_t_initialize_1("test", 0, 4);
struct stat statistics;
void test__f_directory_exists_at__fails(void **state) {
+ mock_unwrap = 0;
+ mock_unwrap_f_memory = 1;
+
const f_string_static_t path = macro_f_string_static_t_initialize_1("test", 0, 4);
int errnos[] = {
void test__f_directory_exists_at__returns_data_not(void **state) {
+ mock_unwrap = 0;
+ mock_unwrap_f_memory = 1;
+
{
const f_status_t status = f_directory_exists_at(0, f_string_empty_s, 0);
void test__f_directory_exists_at__returns_false(void **state) {
+ mock_unwrap = 0;
+ mock_unwrap_f_memory = 1;
+
const f_string_static_t path = macro_f_string_static_t_initialize_1("test", 0, 4);
struct stat statistics;
void test__f_directory_exists_at__returns_true(void **state) {
+ mock_unwrap = 0;
+ mock_unwrap_f_memory = 1;
+
const f_string_static_t path = macro_f_string_static_t_initialize_1("test", 0, 4);
struct stat statistics;
void test__f_directory_is__fails(void **state) {
+ mock_unwrap = 0;
+ mock_unwrap_f_memory = 1;
+
const f_string_static_t path = macro_f_string_static_t_initialize_1("test", 0, 4);
int errnos[] = {
void test__f_directory_is__returns_data_not(void **state) {
+ mock_unwrap = 0;
+ mock_unwrap_f_memory = 1;
+
{
const f_status_t status = f_directory_is(f_string_empty_s);
void test__f_directory_is__returns_false(void **state) {
+ mock_unwrap = 0;
+ mock_unwrap_f_memory = 1;
+
const f_string_static_t path = macro_f_string_static_t_initialize_1("test", 0, 4);
struct stat statistics;
void test__f_directory_is__returns_true(void **state) {
+ mock_unwrap = 0;
+ mock_unwrap_f_memory = 1;
+
const f_string_static_t path = macro_f_string_static_t_initialize_1("test", 0, 4);
struct stat statistics;
void test__f_directory_is_at__fails(void **state) {
+ mock_unwrap = 0;
+ mock_unwrap_f_memory = 1;
+
const f_string_static_t path = macro_f_string_static_t_initialize_1("test", 0, 4);
int errnos[] = {
void test__f_directory_is_at__returns_data_not(void **state) {
+ mock_unwrap = 0;
+ mock_unwrap_f_memory = 1;
+
{
const f_status_t status = f_directory_is_at(0, f_string_empty_s, 0);
void test__f_directory_is_at__returns_false(void **state) {
+ mock_unwrap = 0;
+ mock_unwrap_f_memory = 1;
+
const f_string_static_t path = macro_f_string_static_t_initialize_1("test", 0, 4);
struct stat statistics;
void test__f_directory_is_at__returns_true(void **state) {
+ mock_unwrap = 0;
+ mock_unwrap_f_memory = 1;
+
const f_string_static_t path = macro_f_string_static_t_initialize_1("test", 0, 4);
struct stat statistics;
void test__f_directory_list__fails(void **state) {
+ mock_unwrap = 0;
+ mock_unwrap_f_memory = 1;
+
const f_string_static_t path = macro_f_string_static_t_initialize_1("test", 0, 4);
f_string_dynamics_t names = f_string_dynamics_t_initialize;
void test__f_directory_list__parameter_checking(void **state) {
+ mock_unwrap = 0;
+ mock_unwrap_f_memory = 1;
+
const f_string_static_t path = macro_f_string_static_t_initialize_1("test", 0, 4);
{
void test__f_directory_list__returns_data_not(void **state) {
+ mock_unwrap = 0;
+ mock_unwrap_f_memory = 1;
+
f_string_dynamics_t names = f_string_dynamics_t_initialize;
{
void test__f_directory_list__returns_directory_empty(void **state) {
+ mock_unwrap = 0;
+ mock_unwrap_f_memory = 1;
+
f_string_dynamics_t names = f_string_dynamics_t_initialize;
const f_string_static_t path = macro_f_string_static_t_initialize_1("test", 0, 4);
void test__f_directory_list__works(void **state) {
+ mock_unwrap = 0;
+ mock_unwrap_f_memory = 1;
+
f_string_dynamics_t names = f_string_dynamics_t_initialize;
const f_string_static_t path = macro_f_string_static_t_initialize_1("test", 0, 4);
void test__f_directory_open__fails(void **state) {
+ mock_unwrap = 0;
+ mock_unwrap_f_memory = 1;
+
const f_string_static_t path = macro_f_string_static_t_initialize_1("test", 0, 4);
int errnos[] = {
void test__f_directory_open__parameter_checking(void **state) {
+ mock_unwrap = 0;
+ mock_unwrap_f_memory = 1;
+
const f_string_static_t path = macro_f_string_static_t_initialize_1("test", 0, 4);
{
void test__f_directory_open__returns_data_not(void **state) {
+ mock_unwrap = 0;
+ mock_unwrap_f_memory = 1;
+
{
int id = 0;
void test__f_directory_open__works(void **state) {
+ mock_unwrap = 0;
+ mock_unwrap_f_memory = 1;
+
const f_string_static_t path = macro_f_string_static_t_initialize_1("test", 0, 4);
{
void test__f_directory_open_at__fails(void **state) {
+ mock_unwrap = 0;
+ mock_unwrap_f_memory = 1;
+
const int at = 1;
const f_string_static_t path = macro_f_string_static_t_initialize_1("test", 0, 4);
void test__f_directory_open_at__parameter_checking(void **state) {
+ mock_unwrap = 0;
+ mock_unwrap_f_memory = 1;
+
const f_string_static_t path = macro_f_string_static_t_initialize_1("test", 0, 4);
{
void test__f_directory_open_at__returns_data_not(void **state) {
+ mock_unwrap = 0;
+ mock_unwrap_f_memory = 1;
+
const int at = 1;
{
void test__f_directory_open_at__works(void **state) {
+ mock_unwrap = 0;
+ mock_unwrap_f_memory = 1;
+
const int at = 1;
const f_string_static_t path = macro_f_string_static_t_initialize_1("test", 0, 4);
void test__f_directory_remove__fails(void **state) {
+ mock_unwrap = 0;
+ mock_unwrap_f_memory = 1;
+
const f_string_static_t path = macro_f_string_static_t_initialize_1("test", 0, 4);
int errnos[] = {
void test__f_directory_remove__parameter_checking(void **state) {
+ mock_unwrap = 0;
+ mock_unwrap_f_memory = 1;
+
const f_string_static_t path = macro_f_string_static_t_initialize_1("test", 0, 4);
{
void test__f_directory_remove__returns_data_not(void **state) {
+ mock_unwrap = 0;
+ mock_unwrap_f_memory = 1;
+
{
const f_status_t status = f_directory_remove(f_string_empty_s, 0, F_false);
void test__f_directory_remove__works(void **state) {
+ mock_unwrap = 0;
+ mock_unwrap_f_memory = 1;
+
const f_string_static_t path = macro_f_string_static_t_initialize_1("test", 0, 4);
{
void test__f_directory_remove_custom__fails(void **state) {
+ mock_unwrap = 0;
+ mock_unwrap_f_memory = 1;
+
const f_string_static_t path = macro_f_string_static_t_initialize_1("test", 0, 4);
int errnos[] = {
void test__f_directory_remove_custom__parameter_checking(void **state) {
+ mock_unwrap = 0;
+ mock_unwrap_f_memory = 1;
+
const f_string_static_t path = macro_f_string_static_t_initialize_1("test", 0, 4);
{
void test__f_directory_remove_custom__returns_data_not(void **state) {
+ mock_unwrap = 0;
+ mock_unwrap_f_memory = 1;
+
{
const f_status_t status = f_directory_remove_custom(f_string_empty_s, 0, F_false, 0);
void test__f_directory_remove_custom__works(void **state) {
+ mock_unwrap = 0;
+ mock_unwrap_f_memory = 1;
+
const f_string_static_t path = macro_f_string_static_t_initialize_1("test", 0, 4);
{
void test__f_directory_touch__fails(void **state) {
+ mock_unwrap = 0;
+ mock_unwrap_f_memory = 1;
+
const f_string_static_t path = macro_f_string_static_t_initialize_1("test", 0, 4);
{
void test__f_directory_touch__returns_data_not(void **state) {
+ mock_unwrap = 0;
+ mock_unwrap_f_memory = 1;
+
{
const f_status_t status = f_directory_touch(f_string_empty_s, 0);
void test__f_directory_touch__works(void **state) {
+ mock_unwrap = 0;
+ mock_unwrap_f_memory = 1;
+
const f_string_static_t path = macro_f_string_static_t_initialize_1("test", 0, 4);
{
void test__f_directory_touch_at__fails(void **state) {
+ mock_unwrap = 0;
+ mock_unwrap_f_memory = 1;
+
const f_string_static_t path = macro_f_string_static_t_initialize_1("test", 0, 4);
{
void test__f_directory_touch_at__returns_data_not(void **state) {
+ mock_unwrap = 0;
+ mock_unwrap_f_memory = 1;
+
{
const f_status_t status = f_directory_touch_at(1, f_string_empty_s, 0, 0);
void test__f_directory_touch_at__works(void **state) {
+ mock_unwrap = 0;
+ mock_unwrap_f_memory = 1;
+
const f_string_static_t path = macro_f_string_static_t_initialize_1("test", 0, 4);
{
cmocka_unit_test(test__f_directory_create_at__returns_data_not),
cmocka_unit_test(test__f_directory_create_at__works),
+ cmocka_unit_test(test__f_directory_empty__fails),
+ cmocka_unit_test(test__f_directory_empty__returns_data_not),
+ cmocka_unit_test(test__f_directory_empty__returns_false),
+ cmocka_unit_test(test__f_directory_empty__returns_true),
+
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),
// Test includes.
#include "test-directory-create.h"
#include "test-directory-create_at.h"
+#include "test-directory-empty.h"
#include "test-directory-exists.h"
#include "test-directory-exists_at.h"
#include "test-directory-is.h"