From 46ddf8b97c4c459b42476c0d0a22d8b074859ed5 Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Sun, 16 Mar 2025 22:55:14 -0500 Subject: [PATCH] Progress: Continue working on completing the remove program. Add the first more complex file removal runtime unit tests. I may start calling these "program unit tests" as that sounds more accurate than "runtime unit tests". The `f_directory_is()` should not be needed because the `fl_directory_do()` already passed a flag designating that the path is or is not a directory. Remove the calls to `f_directory_is()` and instead use the appropriate flag. Add `directory_parent` helper flag. Report whether or not the path is a parent path when using tree mode. The tree mode has changes in this commit that are not yet tested and need to be tested. I should write a program unit test for this as well. The "list" flag is not needed for the `fl_diectory_do()` processing. The `parent` and `child` flags are now used differently. The `parent` flag is now used to represent a parent directory only in the case where tree mode is enabled and the directory is only a parent directory do to parent tree traversal. The `child` flag is now used to represent recursion from some directory. The recursion cannot happen on a `parent` as the tree mode does not support recursion on a parent. The `child` is passed to any directory or file that is being recursed into. The lack of the `child` flag should designate that this is a top-level directory as far as recursion is concerned. Fix an issue where the wrong flag is being used for the `flag_operate` `directory` flag. Both the `kt_remove_operate_file_directory()` and the `kt_remove_preprocess_file()` should have the directory and parent flags cleared when called via pre-process recursion. The pre-process recursion does not need to pass any flags to the recursion callback (via the `recurse.flag`). The operate recursion does not need to pass the list flag to the recursion callback (via the `recurse.flag`). Make sure the directory state is preserved by mapping the flag from the `fl_directory_do()` to a flag for the kt_remove file operations. --- data/build/remove/settings-mocks.remove | 1 - data/build/stand_alone/configs/remove-config.h | 2 +- .../kevux/tools/remove/main/common/define.h | 54 +++-- .../kevux/tools/remove/main/common/string.c | 1 + .../kevux/tools/remove/main/common/string.h | 3 + .../c/program/kevux/tools/remove/main/operate.c | 19 +- .../c/program/kevux/tools/remove/main/preprocess.c | 91 ++++--- tests/unit/remove/c/mock-remove.c | 22 +- tests/unit/remove/c/mock-remove.h | 3 - .../unit/remove/c/test-remove-directory_no_args.c | 266 ++++++++++++--------- .../c/test-remove-directory_recurse_simple.c | 40 ++-- tests/unit/remove/c/test-remove-regular_no_args.c | 42 ++-- 12 files changed, 308 insertions(+), 236 deletions(-) diff --git a/data/build/remove/settings-mocks.remove b/data/build/remove/settings-mocks.remove index 44e30b6..779abd9 100644 --- a/data/build/remove/settings-mocks.remove +++ b/data/build/remove/settings-mocks.remove @@ -86,7 +86,6 @@ flags_program-android -fPIE -Wl,-z,relro # Inject mocks. flags -Wl,--wrap=f_directory_empty -flags -Wl,--wrap=f_directory_is flags -Wl,--wrap=f_directory_remove flags -Wl,--wrap=f_file_exists flags -Wl,--wrap=f_file_is diff --git a/data/build/stand_alone/configs/remove-config.h b/data/build/stand_alone/configs/remove-config.h index b8425b8..fb6cb48 100644 --- a/data/build/stand_alone/configs/remove-config.h +++ b/data/build/stand_alone/configs/remove-config.h @@ -240,7 +240,7 @@ //#define _di_f_directory_exists_ #define _di_f_directory_exists_at_ //#define _di_f_directory_flag_d_ -//#define _di_f_directory_is_ +#define _di_f_directory_is_ #define _di_f_directory_is_at_ #define _di_f_directory_list_ #define _di_f_directory_listing_delete_ diff --git a/sources/c/program/kevux/tools/remove/main/common/define.h b/sources/c/program/kevux/tools/remove/main/common/define.h index 2e02941..b246ee6 100644 --- a/sources/c/program/kevux/tools/remove/main/common/define.h +++ b/sources/c/program/kevux/tools/remove/main/common/define.h @@ -143,34 +143,36 @@ extern "C" { * Flags associated with performing an operation on a file. * * kt_remove_flag_file_operate_*_d: - * - none: No flags set. - * - child: This is a child of a file for some other file operation process. - * - directory: Is a directory. - * - empty: Is an empty directory. - * - follow: Follow the symbolic link. - * - link: The file being operated on is a link or is a followed link. - * - parent: This is a parent of a file for some other file operation process. - * - processed: This path is already processed. - * - recurse: Perform recursively (only on directories). - * - remove: Perform remove. - * - remove_fail: Cannot perform remove due to failure. - * - remove_not: Do not remove, but not a failure. - * - remove_not_fail: Helper used to designate both remove_fail and remove_not being set. + * - none: No flags set. + * - child: This is a child of a file for some other file recurse operation process. + * - directory: Is a directory. + * - directory_parent: Helper used to designate directory and parent being set. + * - empty: Is an empty directory. + * - follow: Follow the symbolic link. + * - link: The file being operated on is a link or is a followed link. + * - parent: This is a parent of a file for some other file tree operation process. + * - processed: This path is already processed. + * - recurse: Perform recursively (only on directories). + * - remove: Perform remove. + * - remove_fail: Cannot perform remove due to failure. + * - remove_not: Do not remove, but not a failure. + * - remove_not_fail: Helper used to designate both remove_fail and remove_not being set. */ #ifndef _di_kt_remove_flag_file_operate_d_ - #define kt_remove_flag_file_operate_none_d 0x0 - #define kt_remove_flag_file_operate_child_d 0x1 - #define kt_remove_flag_file_operate_directory_d 0x2 - #define kt_remove_flag_file_operate_empty_d 0x4 - #define kt_remove_flag_file_operate_follow_d 0x8 - #define kt_remove_flag_file_operate_link_d 0x10 - #define kt_remove_flag_file_operate_parent_d 0x20 - #define kt_remove_flag_file_operate_processed_d 0x40 - #define kt_remove_flag_file_operate_recurse_d 0x80 - #define kt_remove_flag_file_operate_remove_d 0x100 - #define kt_remove_flag_file_operate_remove_fail_d 0x200 - #define kt_remove_flag_file_operate_remove_not_d 0x400 - #define kt_remove_flag_file_operate_remove_not_fail_d 0x800 + #define kt_remove_flag_file_operate_none_d 0x0 + #define kt_remove_flag_file_operate_child_d 0x1 + #define kt_remove_flag_file_operate_directory_d 0x2 + #define kt_remove_flag_file_operate_directory_parent_d 0x22 + #define kt_remove_flag_file_operate_empty_d 0x4 + #define kt_remove_flag_file_operate_follow_d 0x8 + #define kt_remove_flag_file_operate_link_d 0x10 + #define kt_remove_flag_file_operate_parent_d 0x20 + #define kt_remove_flag_file_operate_processed_d 0x40 + #define kt_remove_flag_file_operate_recurse_d 0x80 + #define kt_remove_flag_file_operate_remove_d 0x100 + #define kt_remove_flag_file_operate_remove_fail_d 0x200 + #define kt_remove_flag_file_operate_remove_not_d 0x400 + #define kt_remove_flag_file_operate_remove_not_fail_d 0x800 #endif // _di_kt_remove_flag_file_operate_d_ /** diff --git a/sources/c/program/kevux/tools/remove/main/common/string.c b/sources/c/program/kevux/tools/remove/main/common/string.c index 7d23da0..f7dfc94 100644 --- a/sources/c/program/kevux/tools/remove/main/common/string.c +++ b/sources/c/program/kevux/tools/remove/main/common/string.c @@ -26,6 +26,7 @@ extern "C" { const f_string_static_t kt_remove_once_s = macro_f_string_static_t_initialize_1(KT_REMOVE_once_s, 0, KT_REMOVE_once_s_length); const f_string_static_t kt_remove_only_s = macro_f_string_static_t_initialize_1(KT_REMOVE_only_s, 0, KT_REMOVE_only_s_length); const f_string_static_t kt_remove_only_fail_s = macro_f_string_static_t_initialize_1(KT_REMOVE_only_fail_s, 0, KT_REMOVE_only_fail_s_length); + const f_string_static_t kt_remove_parent_s = macro_f_string_static_t_initialize_1(KT_REMOVE_parent_s, 0, KT_REMOVE_parent_s_length); const f_string_static_t kt_remove_prompt_s = macro_f_string_static_t_initialize_1(KT_REMOVE_prompt_s, 0, KT_REMOVE_prompt_s_length); const f_string_static_t kt_remove_recurse_s = macro_f_string_static_t_initialize_1(KT_REMOVE_recurse_s, 0, KT_REMOVE_recurse_s_length); const f_string_static_t kt_remove_remove_s = macro_f_string_static_t_initialize_1(KT_REMOVE_remove_s, 0, KT_REMOVE_remove_s_length); diff --git a/sources/c/program/kevux/tools/remove/main/common/string.h b/sources/c/program/kevux/tools/remove/main/common/string.h index 45ee648..dc155f3 100644 --- a/sources/c/program/kevux/tools/remove/main/common/string.h +++ b/sources/c/program/kevux/tools/remove/main/common/string.h @@ -82,6 +82,7 @@ extern "C" { #define KT_REMOVE_once_s "once" #define KT_REMOVE_only_s "only" #define KT_REMOVE_only_fail_s "only_fail" + #define KT_REMOVE_parent_s "parent" #define KT_REMOVE_prompt_s "prompt" #define KT_REMOVE_recurse_s "recurse" #define KT_REMOVE_remove_s "remove" @@ -106,6 +107,7 @@ extern "C" { #define KT_REMOVE_once_s_length 4 #define KT_REMOVE_only_s_length 4 #define KT_REMOVE_only_fail_s_length 9 + #define KT_REMOVE_parent_s_length 6 #define KT_REMOVE_prompt_s_length 6 #define KT_REMOVE_recurse_s_length 7 #define KT_REMOVE_remove_s_length 6 @@ -130,6 +132,7 @@ extern "C" { extern const f_string_static_t kt_remove_once_s; extern const f_string_static_t kt_remove_only_s; extern const f_string_static_t kt_remove_only_fail_s; + extern const f_string_static_t kt_remove_parent_s; extern const f_string_static_t kt_remove_prompt_s; extern const f_string_static_t kt_remove_recurse_s; extern const f_string_static_t kt_remove_remove_s; diff --git a/sources/c/program/kevux/tools/remove/main/operate.c b/sources/c/program/kevux/tools/remove/main/operate.c index 1e6056a..9964e16 100644 --- a/sources/c/program/kevux/tools/remove/main/operate.c +++ b/sources/c/program/kevux/tools/remove/main/operate.c @@ -46,12 +46,13 @@ extern "C" { f_directory_recurse_do_t recurse = f_directory_recurse_do_t_initialize; - recurse.state.custom = (void *) main; + // The recurse.state.code flags represent the top-level directory being recursed on. recurse.state.code = flag_operate; + recurse.state.custom = (void *) main; recurse.state.interrupt = &kt_remove_signal_check_recurse; recurse.depth_max = main->setting.flag & kt_remove_main_flag_recurse_d ? kt_remove_depth_max_d : 0; - recurse.flag = f_directory_recurse_do_flag_list_e | f_directory_recurse_do_flag_top_after_e; + recurse.flag = f_directory_recurse_do_flag_top_after_e; recurse.path_top = &path; recurse.action = &kt_remove_operate_file_directory_action; @@ -84,9 +85,11 @@ extern "C" { recurse->state.status = kt_remove_operate_file_remove( (kt_remove_main_t *) recurse->state.custom, path, - f_directory_is(path) == F_true - ? recurse->state.code | f_directory_recurse_do_flag_directory_e - : recurse->state.code & ~f_directory_recurse_do_flag_directory_e + flag & f_directory_recurse_do_flag_top_after_e + ? recurse->state.code + : flag & f_directory_recurse_do_flag_directory_e + ? (recurse->state.code | kt_remove_flag_file_operate_child_d | kt_remove_flag_file_operate_directory_d) & ~kt_remove_flag_file_operate_parent_d + : (recurse->state.code | kt_remove_flag_file_operate_child_d) & ~kt_remove_flag_file_operate_directory_parent_d ); } #endif // _di_kt_remove_operate_file_directory_action_ @@ -151,21 +154,21 @@ extern "C" { } } - status = flag_operate & f_directory_recurse_do_flag_directory_e + status = flag_operate & kt_remove_flag_file_operate_directory_d ? f_directory_remove((flag_operate & kt_remove_flag_file_operate_follow_d) ? main->cache.buffer : path, 0, F_false) : f_file_remove((flag_operate & kt_remove_flag_file_operate_follow_d) ? main->cache.buffer : path); if (F_status_is_error(status)) { kt_remove_print_error_file_status( &main->program.error, - flag_operate & f_directory_recurse_do_flag_directory_e + flag_operate & kt_remove_flag_file_operate_directory_d ? macro_kt_remove_f(f_directory_remove) : macro_kt_remove_f(f_file_remove), flag_operate & kt_remove_flag_file_operate_follow_d ? main->cache.buffer : path, f_file_operation_delete_s, - flag_operate & f_directory_recurse_do_flag_directory_e + flag_operate & kt_remove_flag_file_operate_directory_d ? fll_error_file_type_directory_e : fll_error_file_type_file_e, status diff --git a/sources/c/program/kevux/tools/remove/main/preprocess.c b/sources/c/program/kevux/tools/remove/main/preprocess.c index c23eaf1..4f843ad 100644 --- a/sources/c/program/kevux/tools/remove/main/preprocess.c +++ b/sources/c/program/kevux/tools/remove/main/preprocess.c @@ -243,6 +243,10 @@ extern "C" { kt_remove_print_simulate_operate_boolean(&main->program.output, kt_remove_recurse_s, (main->setting.flag & kt_remove_main_flag_recurse_d) && !(flag_operate & kt_remove_flag_file_operate_parent_d)); } + if (main->setting.flag & kt_remove_main_flag_tree_d) { + kt_remove_print_simulate_operate_boolean(&main->program.output, kt_remove_parent_s, flag_operate & kt_remove_flag_file_operate_parent_d); + } + if (main->setting.flag & kt_remove_main_flag_prompt_all_d) { if (main->setting.flag & (kt_remove_main_flag_prompt_each_d | kt_remove_main_flag_prompt_never_d)) { kt_remove_print_simulate_operate_boolean(&main->program.output, kt_remove_prompt_s, main->setting.flag & kt_remove_main_flag_prompt_each_d); @@ -274,59 +278,62 @@ extern "C" { } } - // At this point, the remove situation should be known so recurse into parent or child paths as appropriate before returning. - if (flag_out & kt_remove_flag_file_operate_directory_d) { - main->setting.state.status = F_okay; + // Only apply tree operations on non-child paths when the tree flag is set. + if ((main->setting.flag & kt_remove_main_flag_tree_d) && !(flag_operate & kt_remove_flag_file_operate_child_d)) { + f_range_t range = macro_f_range_t_initialize_2(path.used); - if (main->setting.flag & kt_remove_main_flag_tree_d) { - f_range_t range = macro_f_range_t_initialize_2(path.used); + if (range.stop > range.start) { + main->setting.state.status = f_string_dynamic_seek_to_back(path, f_string_ascii_slash_forward_s.string[0], &range); - if (range.stop > range.start) { - main->setting.state.status = f_string_dynamic_seek_to_back(path, f_string_ascii_slash_forward_s.string[0], &range); + if (F_status_is_error_not(main->setting.state.status) && F_status_set_fine(main->setting.state.status) == F_okay && range.stop > range.start) { + --range.stop; - if (F_status_is_error_not(main->setting.state.status) && F_status_set_fine(main->setting.state.status) == F_okay && range.stop > range.start) { - --range.stop; + for (i = 0; i < main->cache.tree.used; ++i) { + if (f_compare_dynamic_partial_dynamic(main->cache.tree.array[i], path, range) == F_equal_to) break; + } // for - for (i = 0; i < main->cache.tree.used; ++i) { - if (f_compare_dynamic_partial_dynamic(main->cache.tree.array[i], path, range) == F_equal_to) break; - } // for + if (i == main->cache.tree.used) { + main->setting.state.status = f_memory_array_increase(kt_remove_allocation_small_d, sizeof(f_string_dynamic_t), (void **) &main->cache.tree.array, &main->cache.tree.used, &main->cache.tree.size); - if (i == main->cache.tree.used) { - main->setting.state.status = f_memory_array_increase(kt_remove_allocation_small_d, sizeof(f_string_dynamic_t), (void **) &main->cache.tree.array, &main->cache.tree.used, &main->cache.tree.size); + if (F_status_is_error(main->setting.state.status)) { + kt_remove_print_error(&main->program.error, macro_kt_remove_f(f_memory_array_increase)); - if (F_status_is_error(main->setting.state.status)) { - kt_remove_print_error(&main->program.error, macro_kt_remove_f(f_memory_array_increase)); - - return flag_out; - } + return flag_out; + } - main->cache.tree.array[main->cache.tree.used].used = 0; + main->cache.tree.array[main->cache.tree.used].used = 0; - main->setting.state.status = f_string_dynamic_partial_append(path, range, &main->cache.tree.array[main->cache.tree.used]); + main->setting.state.status = f_string_dynamic_partial_append(path, range, &main->cache.tree.array[main->cache.tree.used]); - if (F_status_is_error(main->setting.state.status)) { - kt_remove_print_error(&main->program.error, macro_kt_remove_f(f_string_dynamic_partial_append)); + if (F_status_is_error(main->setting.state.status)) { + kt_remove_print_error(&main->program.error, macro_kt_remove_f(f_string_dynamic_partial_append)); - return flag_out; - } + return flag_out; + } - ++main->cache.tree.used; + ++main->cache.tree.used; - f_print_dynamic(f_string_eol_s, main->program.output.to); + f_print_dynamic(f_string_eol_s, main->program.output.to); - kt_remove_preprocess_file(main, main->cache.tree.array[main->cache.tree.used - 1], kt_remove_flag_file_operate_parent_d); - } + // Pre-process parent directories and set parent flag to prevent potential recursion. + kt_remove_preprocess_file(main, main->cache.tree.array[main->cache.tree.used - 1], kt_remove_flag_file_operate_parent_d); } - else if (F_status_is_error(main->setting.state.status)) { - kt_remove_print_error_file(&main->program.error, macro_kt_remove_f(f_string_dynamic_seek_to_back), path, f_file_operation_process_s, fll_error_file_type_path_e); + } + else if (F_status_is_error(main->setting.state.status)) { + kt_remove_print_error_file(&main->program.error, macro_kt_remove_f(f_string_dynamic_seek_to_back), path, f_file_operation_process_s, fll_error_file_type_path_e); - return flag_out; - } + return flag_out; } } + } - if (main->setting.flag & kt_remove_main_flag_recurse_d && !(flag_operate & kt_remove_flag_file_operate_parent_d)) { - main->setting.state.status = kt_remove_preprocess_file_recurse(main, path, flag_out | kt_remove_flag_file_operate_child_d); + // At this point, the remove situation should be known so recurse into parent or child paths as appropriate before returning. + if (flag_out & kt_remove_flag_file_operate_directory_d) { + main->setting.state.status = F_okay; + + // Recurse only on non-parent directories. + if ((main->setting.flag & kt_remove_main_flag_recurse_d) && !(flag_operate & kt_remove_flag_file_operate_parent_d)) { + main->setting.state.status = kt_remove_preprocess_file_recurse(main, path, flag_out); } } @@ -345,12 +352,14 @@ extern "C" { f_directory_recurse_do_t recurse = f_directory_recurse_do_t_initialize; - recurse.state.custom = (void *) main; + // The recurse.state.code flags represent the top-level directory being recursed on. recurse.state.code = flag_operate; + recurse.state.custom = (void *) main; recurse.state.interrupt = &kt_remove_signal_check_recurse; + // The pre-process does not need the fl_directory_do() to operate on the top-level because it is already doing this and so the top_after recurse.flag must not be set. recurse.depth_max = main->setting.flag & kt_remove_main_flag_recurse_d ? kt_remove_depth_max_d : 0; - recurse.flag = f_directory_recurse_do_flag_list_e | f_directory_recurse_do_flag_top_after_e; + recurse.flag = 0; recurse.path_top = &path; recurse.action = &kt_remove_preprocess_file_recurse_action; @@ -374,7 +383,13 @@ extern "C" { if (!recurse || !recurse->state.custom || F_status_set_fine(recurse->state.status) == F_interrupt) return; if (flag & f_directory_recurse_do_flag_action_e) { - kt_remove_preprocess_file((kt_remove_main_t *) recurse->state.custom, recurse->path, recurse->state.code); + kt_remove_preprocess_file( + (kt_remove_main_t *) recurse->state.custom, + recurse->path, + flag & f_directory_recurse_do_flag_directory_e + ? (recurse->state.code | kt_remove_flag_file_operate_child_d | kt_remove_flag_file_operate_directory_d) & ~kt_remove_flag_file_operate_parent_d + : (recurse->state.code | kt_remove_flag_file_operate_child_d) & ~kt_remove_flag_file_operate_directory_parent_d + ); } } #endif // _di_kt_remove_preprocess_file_recurse_action_ diff --git a/tests/unit/remove/c/mock-remove.c b/tests/unit/remove/c/mock-remove.c index 6bc4c70..1c6decd 100644 --- a/tests/unit/remove/c/mock-remove.c +++ b/tests/unit/remove/c/mock-remove.c @@ -7,17 +7,12 @@ extern "C" { int mock_unwrap = 0; int mock_unwrap_fl_directory_do = 0; -f_status_t mock_directory_call_action = 0; f_status_t mock_status = 0; f_status_t __wrap_f_directory_empty(const f_string_static_t path) { return mock_type(f_status_t); } -f_status_t __wrap_f_directory_is(const f_string_static_t path) { - return mock_type(f_status_t); -} - f_status_t __wrap_f_directory_remove(const f_string_static_t path, const int depth_max, const bool preserve) { return mock_type(f_status_t); } @@ -45,12 +40,19 @@ f_status_t __wrap_f_file_stat(const f_string_static_t path, const bool dereferen void __wrap_fl_directory_do(const f_string_static_t path, f_directory_recurse_do_t * const recurse) { - if (mock_unwrap_fl_directory_do) { - return __real_fl_directory_do(path, recurse); - } + if (!recurse) return; + + const uint32_t total = mock_type(uint32_t); + + if (total) { + for (uint32_t i = 0; i < total; ++i) { + + f_string_static_t * const child_path = mock_ptr_type(f_string_static_t *); + + recurse->path = child_path ? *child_path : f_string_empty_s; - if (mock_directory_call_action) { - recurse->action(recurse, path, mock_type(uint32_t)); + recurse->action(recurse, recurse->path, mock_type(uint32_t)); + } // for } else { recurse->state.status = mock_type(f_status_t); diff --git a/tests/unit/remove/c/mock-remove.h b/tests/unit/remove/c/mock-remove.h index 0cd04ef..9fa4ede 100644 --- a/tests/unit/remove/c/mock-remove.h +++ b/tests/unit/remove/c/mock-remove.h @@ -30,15 +30,12 @@ extern "C" { const static int mock_errno_generic = 32767; extern int mock_unwrap; -extern int mock_unwrap_fl_directory_do; -extern f_status_t mock_directory_call_action; extern f_status_t mock_status; extern void __real_fl_directory_do(const f_string_static_t path, f_directory_recurse_do_t * const recurse); extern f_status_t __wrap_f_directory_empty(const f_string_static_t path); -extern f_status_t __wrap_f_directory_is(const f_string_static_t path); extern f_status_t __wrap_f_directory_remove(const f_string_static_t path, const int depth_max, const bool preserve); extern f_status_t __wrap_f_file_exists(const f_string_static_t path, const bool dereference); diff --git a/tests/unit/remove/c/test-remove-directory_no_args.c b/tests/unit/remove/c/test-remove-directory_no_args.c index b693f51..ea1cdc9 100644 --- a/tests/unit/remove/c/test-remove-directory_no_args.c +++ b/tests/unit/remove/c/test-remove-directory_no_args.c @@ -10,12 +10,13 @@ extern "C" { void test__kt_remove__directory_no_args__one_empty_exists_link(void **state) { mock_unwrap = 0; - mock_directory_call_action = F_true; + + const f_string_static_t file = macro_f_string_static_t_initialize_1("to_remove", 0, 9); struct stat statistics; { - const f_string_t argv[] = { "mocked_main", "to_remove", 0 }; + const f_string_t argv[] = { "mocked_main", file.string, 0 }; memset(&statistics, 0, sizeof(struct stat)); statistics.st_mode = F_file_mode_all_d | F_file_type_directory_d; // Should result in kt_remove_flag_file_operate_remove_d. @@ -24,12 +25,13 @@ void test__kt_remove__directory_no_args__one_empty_exists_link(void **state) { will_return(__wrap_f_file_exists, F_true); will_return(__wrap_f_file_is, F_true); // A link, kt_remove_flag_file_operate_link_d is set. will_return(__wrap_f_file_stat, &statistics); - will_return(__wrap_f_file_stat, F_false); + will_return(__wrap_f_file_stat, F_okay); // Directory processing. will_return(__wrap_f_directory_empty, F_true); + will_return(__wrap_fl_directory_do, 1); + will_return(__wrap_fl_directory_do, &file); will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_e | f_directory_recurse_do_flag_top_after_e); - will_return(__wrap_f_directory_is, F_true); // This will fail if f_directory_remove() is not called, therefore success here means f_directory_remove has been called. will_return(__wrap_f_directory_remove, F_okay); @@ -40,7 +42,7 @@ void test__kt_remove__directory_no_args__one_empty_exists_link(void **state) { } { - const f_string_t argv[] = { "mocked_main", "to_remove", "+V", 0 }; + const f_string_t argv[] = { "mocked_main", file.string, "+V", 0 }; memset(&statistics, 0, sizeof(struct stat)); statistics.st_mode = F_file_mode_all_d | F_file_type_directory_d; // Should result in kt_remove_flag_file_operate_remove_d. @@ -49,12 +51,13 @@ void test__kt_remove__directory_no_args__one_empty_exists_link(void **state) { will_return(__wrap_f_file_exists, F_true); will_return(__wrap_f_file_is, F_true); // A link, kt_remove_flag_file_operate_link_d is set. will_return(__wrap_f_file_stat, &statistics); - will_return(__wrap_f_file_stat, F_false); + will_return(__wrap_f_file_stat, F_okay); // Directory processing. will_return(__wrap_f_directory_empty, F_true); - will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_e | f_directory_recurse_do_flag_top_after_e); - will_return(__wrap_f_directory_is, F_true); + will_return(__wrap_fl_directory_do, 1); + will_return(__wrap_fl_directory_do, &file); + will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_e | f_directory_recurse_do_flag_directory_e | f_directory_recurse_do_flag_top_after_e); // This will fail if f_directory_remove() is not called, therefore success here means f_directory_remove has been called. will_return(__wrap_f_directory_remove, F_okay); @@ -65,7 +68,7 @@ void test__kt_remove__directory_no_args__one_empty_exists_link(void **state) { } { - const f_string_t argv[] = { "mocked_main", "to_remove", "+D", 0 }; + const f_string_t argv[] = { "mocked_main", file.string, "+D", 0 }; memset(&statistics, 0, sizeof(struct stat)); statistics.st_mode = F_file_mode_all_d | F_file_type_directory_d; // Should result in kt_remove_flag_file_operate_remove_d. @@ -74,12 +77,13 @@ void test__kt_remove__directory_no_args__one_empty_exists_link(void **state) { will_return(__wrap_f_file_exists, F_true); will_return(__wrap_f_file_is, F_true); // A link, kt_remove_flag_file_operate_link_d is set. will_return(__wrap_f_file_stat, &statistics); - will_return(__wrap_f_file_stat, F_false); + will_return(__wrap_f_file_stat, F_okay); // Directory processing. will_return(__wrap_f_directory_empty, F_true); - will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_e | f_directory_recurse_do_flag_top_after_e); - will_return(__wrap_f_directory_is, F_true); + will_return(__wrap_fl_directory_do, 1); + will_return(__wrap_fl_directory_do, &file); + will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_e | f_directory_recurse_do_flag_directory_e | f_directory_recurse_do_flag_top_after_e); // This will fail if f_directory_remove() is not called, therefore success here means f_directory_remove has been called. will_return(__wrap_f_directory_remove, F_okay); @@ -93,12 +97,13 @@ void test__kt_remove__directory_no_args__one_empty_exists_link(void **state) { void test__kt_remove__directory_no_args__one_empty_exists_link_not(void **state) { mock_unwrap = 0; - mock_directory_call_action = F_true; + + const f_string_static_t file = macro_f_string_static_t_initialize_1("to_remove", 0, 9); struct stat statistics; { - const f_string_t argv[] = { "mocked_main", "to_remove", 0 }; + const f_string_t argv[] = { "mocked_main", file.string, 0 }; memset(&statistics, 0, sizeof(struct stat)); statistics.st_mode = F_file_mode_all_d | F_file_type_directory_d; // Should result in kt_remove_flag_file_operate_remove_d. @@ -107,12 +112,13 @@ void test__kt_remove__directory_no_args__one_empty_exists_link_not(void **state) will_return(__wrap_f_file_exists, F_true); will_return(__wrap_f_file_is, F_false); // A link, kt_remove_flag_file_operate_link_d is not set. will_return(__wrap_f_file_stat, &statistics); - will_return(__wrap_f_file_stat, F_false); + will_return(__wrap_f_file_stat, F_okay); // Directory processing. will_return(__wrap_f_directory_empty, F_true); - will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_e | f_directory_recurse_do_flag_top_after_e); - will_return(__wrap_f_directory_is, F_true); + will_return(__wrap_fl_directory_do, 1); + will_return(__wrap_fl_directory_do, &file); + will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_e | f_directory_recurse_do_flag_directory_e | f_directory_recurse_do_flag_top_after_e); // This will fail if f_directory_remove() is not called, therefore success here means f_directory_remove has been called. will_return(__wrap_f_directory_remove, F_okay); @@ -123,7 +129,7 @@ void test__kt_remove__directory_no_args__one_empty_exists_link_not(void **state) } { - const f_string_t argv[] = { "mocked_main", "to_remove", "+V", 0 }; + const f_string_t argv[] = { "mocked_main", file.string, "+V", 0 }; memset(&statistics, 0, sizeof(struct stat)); statistics.st_mode = F_file_mode_all_d | F_file_type_directory_d; // Should result in kt_remove_flag_file_operate_remove_d. @@ -132,12 +138,13 @@ void test__kt_remove__directory_no_args__one_empty_exists_link_not(void **state) will_return(__wrap_f_file_exists, F_true); will_return(__wrap_f_file_is, F_false); // A link, kt_remove_flag_file_operate_link_d is not set. will_return(__wrap_f_file_stat, &statistics); - will_return(__wrap_f_file_stat, F_false); + will_return(__wrap_f_file_stat, F_okay); // Directory processing. will_return(__wrap_f_directory_empty, F_true); - will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_e | f_directory_recurse_do_flag_top_after_e); - will_return(__wrap_f_directory_is, F_true); + will_return(__wrap_fl_directory_do, 1); + will_return(__wrap_fl_directory_do, &file); + will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_e | f_directory_recurse_do_flag_directory_e | f_directory_recurse_do_flag_top_after_e); // This will fail if f_directory_remove() is not called, therefore success here means f_directory_remove has been called. will_return(__wrap_f_directory_remove, F_okay); @@ -148,7 +155,7 @@ void test__kt_remove__directory_no_args__one_empty_exists_link_not(void **state) } { - const f_string_t argv[] = { "mocked_main", "to_remove", "+D", 0 }; + const f_string_t argv[] = { "mocked_main", file.string, "+D", 0 }; memset(&statistics, 0, sizeof(struct stat)); statistics.st_mode = F_file_mode_all_d | F_file_type_directory_d; // Should result in kt_remove_flag_file_operate_remove_d. @@ -157,12 +164,13 @@ void test__kt_remove__directory_no_args__one_empty_exists_link_not(void **state) will_return(__wrap_f_file_exists, F_true); will_return(__wrap_f_file_is, F_false); // A link, kt_remove_flag_file_operate_link_d is not set. will_return(__wrap_f_file_stat, &statistics); - will_return(__wrap_f_file_stat, F_false); + will_return(__wrap_f_file_stat, F_okay); // Directory processing. will_return(__wrap_f_directory_empty, F_true); - will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_e | f_directory_recurse_do_flag_top_after_e); - will_return(__wrap_f_directory_is, F_true); + will_return(__wrap_fl_directory_do, 1); + will_return(__wrap_fl_directory_do, &file); + will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_e | f_directory_recurse_do_flag_directory_e | f_directory_recurse_do_flag_top_after_e); // This will fail if f_directory_remove() is not called, therefore success here means f_directory_remove has been called. will_return(__wrap_f_directory_remove, F_okay); @@ -177,8 +185,10 @@ void test__kt_remove__directory_no_args__one_empty_exists_not(void **state) { mock_unwrap = 0; + const f_string_static_t file = macro_f_string_static_t_initialize_1("to_remove", 0, 9); + { - const f_string_t argv[] = { "mocked_main", "to_remove", 0 }; + const f_string_t argv[] = { "mocked_main", file.string, 0 }; will_return(__wrap_f_file_exists, F_false); @@ -188,7 +198,7 @@ void test__kt_remove__directory_no_args__one_empty_exists_not(void **state) { } { - const f_string_t argv[] = { "mocked_main", "to_remove", "+V", 0 }; + const f_string_t argv[] = { "mocked_main", file.string, "+V", 0 }; will_return(__wrap_f_file_exists, F_false); @@ -198,7 +208,7 @@ void test__kt_remove__directory_no_args__one_empty_exists_not(void **state) { } { - const f_string_t argv[] = { "mocked_main", "to_remove", "+D", 0 }; + const f_string_t argv[] = { "mocked_main", file.string, "+D", 0 }; will_return(__wrap_f_file_exists, F_false); @@ -211,13 +221,14 @@ void test__kt_remove__directory_no_args__one_empty_exists_not(void **state) { void test__kt_remove__directory_no_args__one_empty_not_exists_link(void **state) { mock_unwrap = 0; - mock_directory_call_action = F_true; + + const f_string_static_t file = macro_f_string_static_t_initialize_1("to_remove", 0, 9); struct stat statistics; struct stat statistics_regular; { - const f_string_t argv[] = { "mocked_main", "to_remove", 0 }; + const f_string_t argv[] = { "mocked_main", file.string, 0 }; memset(&statistics, 0, sizeof(struct stat)); statistics.st_mode = F_file_mode_all_d | F_file_type_directory_d; // Should result in kt_remove_flag_file_operate_remove_d. @@ -229,12 +240,13 @@ void test__kt_remove__directory_no_args__one_empty_not_exists_link(void **state) will_return(__wrap_f_file_exists, F_true); will_return(__wrap_f_file_is, F_true); // A link, kt_remove_flag_file_operate_link_d is set. will_return(__wrap_f_file_stat, &statistics); - will_return(__wrap_f_file_stat, F_false); + will_return(__wrap_f_file_stat, F_okay); // Directory processing. will_return(__wrap_f_directory_empty, F_false); // kt_remove_flag_file_operate_empty_d is set. - will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_e | f_directory_recurse_do_flag_top_after_e); - will_return(__wrap_f_directory_is, F_true); + will_return(__wrap_fl_directory_do, 1); + will_return(__wrap_fl_directory_do, &file); + will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_e | f_directory_recurse_do_flag_directory_e | f_directory_recurse_do_flag_top_after_e); // This will fail if f_directory_remove() is not called, therefore success here means f_directory_remove has been called. will_return(__wrap_f_directory_remove, F_okay); @@ -245,7 +257,7 @@ void test__kt_remove__directory_no_args__one_empty_not_exists_link(void **state) } { - const f_string_t argv[] = { "mocked_main", "to_remove", "+V", 0 }; + const f_string_t argv[] = { "mocked_main", file.string, "+V", 0 }; memset(&statistics, 0, sizeof(struct stat)); statistics.st_mode = F_file_mode_all_d | F_file_type_directory_d; // Should result in kt_remove_flag_file_operate_remove_d. @@ -257,12 +269,13 @@ void test__kt_remove__directory_no_args__one_empty_not_exists_link(void **state) will_return(__wrap_f_file_exists, F_true); will_return(__wrap_f_file_is, F_true); // A link, kt_remove_flag_file_operate_link_d is set. will_return(__wrap_f_file_stat, &statistics); - will_return(__wrap_f_file_stat, F_false); + will_return(__wrap_f_file_stat, F_okay); // Directory processing. will_return(__wrap_f_directory_empty, F_false); // kt_remove_flag_file_operate_empty_d is set. - will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_e | f_directory_recurse_do_flag_top_after_e); - will_return(__wrap_f_directory_is, F_true); + will_return(__wrap_fl_directory_do, 1); + will_return(__wrap_fl_directory_do, &file); + will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_e | f_directory_recurse_do_flag_directory_e | f_directory_recurse_do_flag_top_after_e); // This will fail if f_directory_remove() is not called, therefore success here means f_directory_remove has been called. will_return(__wrap_f_directory_remove, F_okay); @@ -273,7 +286,7 @@ void test__kt_remove__directory_no_args__one_empty_not_exists_link(void **state) } { - const f_string_t argv[] = { "mocked_main", "to_remove", "+D", 0 }; + const f_string_t argv[] = { "mocked_main", file.string, "+D", 0 }; memset(&statistics, 0, sizeof(struct stat)); statistics.st_mode = F_file_mode_all_d | F_file_type_directory_d; // Should result in kt_remove_flag_file_operate_remove_d. @@ -285,12 +298,13 @@ void test__kt_remove__directory_no_args__one_empty_not_exists_link(void **state) will_return(__wrap_f_file_exists, F_true); will_return(__wrap_f_file_is, F_true); // A link, kt_remove_flag_file_operate_link_d is set. will_return(__wrap_f_file_stat, &statistics); - will_return(__wrap_f_file_stat, F_false); + will_return(__wrap_f_file_stat, F_okay); // Directory processing. will_return(__wrap_f_directory_empty, F_false); // kt_remove_flag_file_operate_empty_d is set. - will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_e | f_directory_recurse_do_flag_top_after_e); - will_return(__wrap_f_directory_is, F_true); + will_return(__wrap_fl_directory_do, 1); + will_return(__wrap_fl_directory_do, &file); + will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_e | f_directory_recurse_do_flag_directory_e | f_directory_recurse_do_flag_top_after_e); // This will fail if f_directory_remove() is not called, therefore success here means f_directory_remove has been called. will_return(__wrap_f_directory_remove, F_okay); @@ -304,13 +318,14 @@ void test__kt_remove__directory_no_args__one_empty_not_exists_link(void **state) void test__kt_remove__directory_no_args__one_empty_not_exists_link_not(void **state) { mock_unwrap = 0; - mock_directory_call_action = F_true; + + const f_string_static_t file = macro_f_string_static_t_initialize_1("to_remove", 0, 9); struct stat statistics; struct stat statistics_regular; { - const f_string_t argv[] = { "mocked_main", "to_remove", 0 }; + const f_string_t argv[] = { "mocked_main", file.string, 0 }; memset(&statistics, 0, sizeof(struct stat)); statistics.st_mode = F_file_mode_all_d | F_file_type_directory_d; // Should result in kt_remove_flag_file_operate_remove_d. @@ -322,12 +337,13 @@ void test__kt_remove__directory_no_args__one_empty_not_exists_link_not(void **st will_return(__wrap_f_file_exists, F_true); will_return(__wrap_f_file_is, F_false); // A link, kt_remove_flag_file_operate_link_d is not set. will_return(__wrap_f_file_stat, &statistics); - will_return(__wrap_f_file_stat, F_false); + will_return(__wrap_f_file_stat, F_okay); // Directory processing. will_return(__wrap_f_directory_empty, F_false); // kt_remove_flag_file_operate_empty_d is set. - will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_e | f_directory_recurse_do_flag_top_after_e); - will_return(__wrap_f_directory_is, F_true); + will_return(__wrap_fl_directory_do, 1); + will_return(__wrap_fl_directory_do, &file); + will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_e | f_directory_recurse_do_flag_directory_e | f_directory_recurse_do_flag_top_after_e); // This will fail if f_directory_remove() is not called, therefore success here means f_directory_remove has been called. will_return(__wrap_f_directory_remove, F_okay); @@ -338,7 +354,7 @@ void test__kt_remove__directory_no_args__one_empty_not_exists_link_not(void **st } { - const f_string_t argv[] = { "mocked_main", "to_remove", "+V", 0 }; + const f_string_t argv[] = { "mocked_main", file.string, "+V", 0 }; memset(&statistics, 0, sizeof(struct stat)); statistics.st_mode = F_file_mode_all_d | F_file_type_directory_d; // Should result in kt_remove_flag_file_operate_remove_d. @@ -350,12 +366,13 @@ void test__kt_remove__directory_no_args__one_empty_not_exists_link_not(void **st will_return(__wrap_f_file_exists, F_true); will_return(__wrap_f_file_is, F_false); // A link, kt_remove_flag_file_operate_link_d is not set. will_return(__wrap_f_file_stat, &statistics); - will_return(__wrap_f_file_stat, F_false); + will_return(__wrap_f_file_stat, F_okay); // Directory processing. will_return(__wrap_f_directory_empty, F_false); // kt_remove_flag_file_operate_empty_d is set. - will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_e | f_directory_recurse_do_flag_top_after_e); - will_return(__wrap_f_directory_is, F_true); + will_return(__wrap_fl_directory_do, 1); + will_return(__wrap_fl_directory_do, &file); + will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_e | f_directory_recurse_do_flag_directory_e | f_directory_recurse_do_flag_top_after_e); // This will fail if f_directory_remove() is not called, therefore success here means f_directory_remove has been called. will_return(__wrap_f_directory_remove, F_okay); @@ -366,7 +383,7 @@ void test__kt_remove__directory_no_args__one_empty_not_exists_link_not(void **st } { - const f_string_t argv[] = { "mocked_main", "to_remove", "+D", 0 }; + const f_string_t argv[] = { "mocked_main", file.string, "+D", 0 }; memset(&statistics, 0, sizeof(struct stat)); statistics.st_mode = F_file_mode_all_d | F_file_type_directory_d; // Should result in kt_remove_flag_file_operate_remove_d. @@ -378,12 +395,13 @@ void test__kt_remove__directory_no_args__one_empty_not_exists_link_not(void **st will_return(__wrap_f_file_exists, F_true); will_return(__wrap_f_file_is, F_false); // A link, kt_remove_flag_file_operate_link_d is not set. will_return(__wrap_f_file_stat, &statistics); - will_return(__wrap_f_file_stat, F_false); + will_return(__wrap_f_file_stat, F_okay); // Directory processing. will_return(__wrap_f_directory_empty, F_false); // kt_remove_flag_file_operate_empty_d is set. - will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_e | f_directory_recurse_do_flag_top_after_e); - will_return(__wrap_f_directory_is, F_true); + will_return(__wrap_fl_directory_do, 1); + will_return(__wrap_fl_directory_do, &file); + will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_e | f_directory_recurse_do_flag_directory_e | f_directory_recurse_do_flag_top_after_e); // This will fail if f_directory_remove() is not called, therefore success here means f_directory_remove has been called. will_return(__wrap_f_directory_remove, F_okay); @@ -397,12 +415,13 @@ void test__kt_remove__directory_no_args__one_empty_not_exists_link_not(void **st void test__kt_remove__directory_no_args__two_empty_exists_and_not(void **state) { mock_unwrap = 0; - mock_directory_call_action = F_true; + + const f_string_static_t file = macro_f_string_static_t_initialize_1("to_remove", 0, 9); struct stat statistics; { - const f_string_t argv[] = { "mocked_main", "to_remove", "also/remove", 0 }; + const f_string_t argv[] = { "mocked_main", file.string, "also/remove", 0 }; memset(&statistics, 0, sizeof(struct stat)); statistics.st_mode = F_file_mode_all_d | F_file_type_directory_d; // Should result in kt_remove_flag_file_operate_remove_d. @@ -414,12 +433,13 @@ void test__kt_remove__directory_no_args__two_empty_exists_and_not(void **state) will_return(__wrap_f_file_exists, F_true); will_return(__wrap_f_file_is, F_false); // A link, kt_remove_flag_file_operate_link_d is not set. will_return(__wrap_f_file_stat, &statistics); - will_return(__wrap_f_file_stat, F_false); + will_return(__wrap_f_file_stat, F_okay); // Directory processing. will_return(__wrap_f_directory_empty, F_true); - will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_e | f_directory_recurse_do_flag_top_after_e); - will_return(__wrap_f_directory_is, F_true); + will_return(__wrap_fl_directory_do, 1); + will_return(__wrap_fl_directory_do, &file); + will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_e | f_directory_recurse_do_flag_directory_e | f_directory_recurse_do_flag_top_after_e); // This will fail if f_directory_remove() is not called, therefore success here means f_directory_remove has been called. will_return(__wrap_f_directory_remove, F_okay); @@ -430,7 +450,7 @@ void test__kt_remove__directory_no_args__two_empty_exists_and_not(void **state) } { - const f_string_t argv[] = { "mocked_main", "to_remove", "also/remove", "+V", 0 }; + const f_string_t argv[] = { "mocked_main", file.string, "also/remove", "+V", 0 }; memset(&statistics, 0, sizeof(struct stat)); statistics.st_mode = F_file_mode_all_d | F_file_type_directory_d; // Should result in kt_remove_flag_file_operate_remove_d. @@ -442,12 +462,13 @@ void test__kt_remove__directory_no_args__two_empty_exists_and_not(void **state) will_return(__wrap_f_file_exists, F_true); will_return(__wrap_f_file_is, F_false); // A link, kt_remove_flag_file_operate_link_d is not set. will_return(__wrap_f_file_stat, &statistics); - will_return(__wrap_f_file_stat, F_false); + will_return(__wrap_f_file_stat, F_okay); // Directory processing. will_return(__wrap_f_directory_empty, F_true); - will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_e | f_directory_recurse_do_flag_top_after_e); - will_return(__wrap_f_directory_is, F_true); + will_return(__wrap_fl_directory_do, 1); + will_return(__wrap_fl_directory_do, &file); + will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_e | f_directory_recurse_do_flag_directory_e | f_directory_recurse_do_flag_top_after_e); // This will fail if f_directory_remove() is not called, therefore success here means f_directory_remove has been called. will_return(__wrap_f_directory_remove, F_okay); @@ -458,7 +479,7 @@ void test__kt_remove__directory_no_args__two_empty_exists_and_not(void **state) } { - const f_string_t argv[] = { "mocked_main", "to_remove", "also/remove", "+D", 0 }; + const f_string_t argv[] = { "mocked_main", file.string, "also/remove", "+D", 0 }; memset(&statistics, 0, sizeof(struct stat)); statistics.st_mode = F_file_mode_all_d | F_file_type_directory_d; // Should result in kt_remove_flag_file_operate_remove_d. @@ -470,12 +491,13 @@ void test__kt_remove__directory_no_args__two_empty_exists_and_not(void **state) will_return(__wrap_f_file_exists, F_true); will_return(__wrap_f_file_is, F_false); // A link, kt_remove_flag_file_operate_link_d is not set. will_return(__wrap_f_file_stat, &statistics); - will_return(__wrap_f_file_stat, F_false); + will_return(__wrap_f_file_stat, F_okay); // Directory processing. will_return(__wrap_f_directory_empty, F_true); - will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_e | f_directory_recurse_do_flag_top_after_e); - will_return(__wrap_f_directory_is, F_true); + will_return(__wrap_fl_directory_do, 1); + will_return(__wrap_fl_directory_do, &file); + will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_e | f_directory_recurse_do_flag_directory_e | f_directory_recurse_do_flag_top_after_e); // This will fail if f_directory_remove() is not called, therefore success here means f_directory_remove has been called. will_return(__wrap_f_directory_remove, F_okay); @@ -489,12 +511,13 @@ void test__kt_remove__directory_no_args__two_empty_exists_and_not(void **state) void test__kt_remove__directory_no_args__two_empty_exists_link(void **state) { mock_unwrap = 0; - mock_directory_call_action = F_true; + + const f_string_static_t file = macro_f_string_static_t_initialize_1("to_remove", 0, 9); struct stat statistics; { - const f_string_t argv[] = { "mocked_main", "to_remove", "also/remove", 0 }; + const f_string_t argv[] = { "mocked_main", file.string, "also/remove", 0 }; memset(&statistics, 0, sizeof(struct stat)); statistics.st_mode = F_file_mode_all_d | F_file_type_directory_d; // Should result in kt_remove_flag_file_operate_remove_d. @@ -503,12 +526,13 @@ void test__kt_remove__directory_no_args__two_empty_exists_link(void **state) { will_return(__wrap_f_file_exists, F_true); will_return(__wrap_f_file_is, F_true); // A link, kt_remove_flag_file_operate_link_d is set. will_return(__wrap_f_file_stat, &statistics); - will_return(__wrap_f_file_stat, F_false); + will_return(__wrap_f_file_stat, F_okay); // Directory processing. will_return(__wrap_f_directory_empty, F_true); - will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_e | f_directory_recurse_do_flag_top_after_e); - will_return(__wrap_f_directory_is, F_true); + will_return(__wrap_fl_directory_do, 1); + will_return(__wrap_fl_directory_do, &file); + will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_e | f_directory_recurse_do_flag_directory_e | f_directory_recurse_do_flag_top_after_e); // This will fail if f_directory_remove() is not called, therefore success here means f_directory_remove has been called. will_return(__wrap_f_directory_remove, F_okay); @@ -517,12 +541,13 @@ void test__kt_remove__directory_no_args__two_empty_exists_link(void **state) { will_return(__wrap_f_file_exists, F_true); will_return(__wrap_f_file_is, F_true); // A link, kt_remove_flag_file_operate_link_d is set. will_return(__wrap_f_file_stat, &statistics); - will_return(__wrap_f_file_stat, F_false); + will_return(__wrap_f_file_stat, F_okay); // Directory processing. will_return(__wrap_f_directory_empty, F_true); - will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_e | f_directory_recurse_do_flag_top_after_e); - will_return(__wrap_f_directory_is, F_true); + will_return(__wrap_fl_directory_do, 1); + will_return(__wrap_fl_directory_do, &file); + will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_e | f_directory_recurse_do_flag_directory_e | f_directory_recurse_do_flag_top_after_e); // This will fail if f_directory_remove() is not called, therefore success here means f_directory_remove has been called. will_return(__wrap_f_directory_remove, F_okay); @@ -533,7 +558,7 @@ void test__kt_remove__directory_no_args__two_empty_exists_link(void **state) { } { - const f_string_t argv[] = { "mocked_main", "to_remove", "also/remove", "+V", 0 }; + const f_string_t argv[] = { "mocked_main", file.string, "also/remove", "+V", 0 }; memset(&statistics, 0, sizeof(struct stat)); statistics.st_mode = F_file_mode_all_d | F_file_type_directory_d; // Should result in kt_remove_flag_file_operate_remove_d. @@ -542,12 +567,13 @@ void test__kt_remove__directory_no_args__two_empty_exists_link(void **state) { will_return(__wrap_f_file_exists, F_true); will_return(__wrap_f_file_is, F_true); // A link, kt_remove_flag_file_operate_link_d is set. will_return(__wrap_f_file_stat, &statistics); - will_return(__wrap_f_file_stat, F_false); + will_return(__wrap_f_file_stat, F_okay); // Directory processing. will_return(__wrap_f_directory_empty, F_true); - will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_e | f_directory_recurse_do_flag_top_after_e); - will_return(__wrap_f_directory_is, F_true); + will_return(__wrap_fl_directory_do, 1); + will_return(__wrap_fl_directory_do, &file); + will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_e | f_directory_recurse_do_flag_directory_e | f_directory_recurse_do_flag_top_after_e); // This will fail if f_directory_remove() is not called, therefore success here means f_directory_remove has been called. will_return(__wrap_f_directory_remove, F_okay); @@ -556,12 +582,13 @@ void test__kt_remove__directory_no_args__two_empty_exists_link(void **state) { will_return(__wrap_f_file_exists, F_true); will_return(__wrap_f_file_is, F_true); // A link, kt_remove_flag_file_operate_link_d is set. will_return(__wrap_f_file_stat, &statistics); - will_return(__wrap_f_file_stat, F_false); + will_return(__wrap_f_file_stat, F_okay); // Directory processing. will_return(__wrap_f_directory_empty, F_true); - will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_e | f_directory_recurse_do_flag_top_after_e); - will_return(__wrap_f_directory_is, F_true); + will_return(__wrap_fl_directory_do, 1); + will_return(__wrap_fl_directory_do, &file); + will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_e | f_directory_recurse_do_flag_directory_e | f_directory_recurse_do_flag_top_after_e); // This will fail if f_directory_remove() is not called, therefore success here means f_directory_remove has been called. will_return(__wrap_f_directory_remove, F_okay); @@ -572,7 +599,7 @@ void test__kt_remove__directory_no_args__two_empty_exists_link(void **state) { } { - const f_string_t argv[] = { "mocked_main", "to_remove", "also/remove", "+D", 0 }; + const f_string_t argv[] = { "mocked_main", file.string, "also/remove", "+D", 0 }; memset(&statistics, 0, sizeof(struct stat)); statistics.st_mode = F_file_mode_all_d | F_file_type_directory_d; // Should result in kt_remove_flag_file_operate_remove_d. @@ -581,12 +608,13 @@ void test__kt_remove__directory_no_args__two_empty_exists_link(void **state) { will_return(__wrap_f_file_exists, F_true); will_return(__wrap_f_file_is, F_true); // A link, kt_remove_flag_file_operate_link_d is set. will_return(__wrap_f_file_stat, &statistics); - will_return(__wrap_f_file_stat, F_false); + will_return(__wrap_f_file_stat, F_okay); // Directory processing. will_return(__wrap_f_directory_empty, F_true); - will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_e | f_directory_recurse_do_flag_top_after_e); - will_return(__wrap_f_directory_is, F_true); + will_return(__wrap_fl_directory_do, 1); + will_return(__wrap_fl_directory_do, &file); + will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_e | f_directory_recurse_do_flag_directory_e | f_directory_recurse_do_flag_top_after_e); // This will fail if f_directory_remove() is not called, therefore success here means f_directory_remove has been called. will_return(__wrap_f_directory_remove, F_okay); @@ -595,12 +623,13 @@ void test__kt_remove__directory_no_args__two_empty_exists_link(void **state) { will_return(__wrap_f_file_exists, F_true); will_return(__wrap_f_file_is, F_true); // A link, kt_remove_flag_file_operate_link_d is set. will_return(__wrap_f_file_stat, &statistics); - will_return(__wrap_f_file_stat, F_false); + will_return(__wrap_f_file_stat, F_okay); // Directory processing. will_return(__wrap_f_directory_empty, F_true); - will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_e | f_directory_recurse_do_flag_top_after_e); - will_return(__wrap_f_directory_is, F_true); + will_return(__wrap_fl_directory_do, 1); + will_return(__wrap_fl_directory_do, &file); + will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_e | f_directory_recurse_do_flag_directory_e | f_directory_recurse_do_flag_top_after_e); // This will fail if f_directory_remove() is not called, therefore success here means f_directory_remove has been called. will_return(__wrap_f_directory_remove, F_okay); @@ -614,12 +643,13 @@ void test__kt_remove__directory_no_args__two_empty_exists_link(void **state) { void test__kt_remove__directory_no_args__two_empty_exists_link_not(void **state) { mock_unwrap = 0; - mock_directory_call_action = F_true; + + const f_string_static_t file = macro_f_string_static_t_initialize_1("to_remove", 0, 9); struct stat statistics; { - const f_string_t argv[] = { "mocked_main", "to_remove", "also/remove", 0 }; + const f_string_t argv[] = { "mocked_main", file.string, "also/remove", 0 }; memset(&statistics, 0, sizeof(struct stat)); statistics.st_mode = F_file_mode_all_d | F_file_type_directory_d; // Should result in kt_remove_flag_file_operate_remove_d. @@ -628,12 +658,13 @@ void test__kt_remove__directory_no_args__two_empty_exists_link_not(void **state) will_return(__wrap_f_file_exists, F_true); will_return(__wrap_f_file_is, F_false); // A link, kt_remove_flag_file_operate_link_d is not set. will_return(__wrap_f_file_stat, &statistics); - will_return(__wrap_f_file_stat, F_false); + will_return(__wrap_f_file_stat, F_okay); // Directory processing. will_return(__wrap_f_directory_empty, F_true); - will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_e | f_directory_recurse_do_flag_top_after_e); - will_return(__wrap_f_directory_is, F_true); + will_return(__wrap_fl_directory_do, 1); + will_return(__wrap_fl_directory_do, &file); + will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_e | f_directory_recurse_do_flag_directory_e | f_directory_recurse_do_flag_top_after_e); // This will fail if f_directory_remove() is not called, therefore success here means f_directory_remove has been called. will_return(__wrap_f_directory_remove, F_okay); @@ -642,12 +673,13 @@ void test__kt_remove__directory_no_args__two_empty_exists_link_not(void **state) will_return(__wrap_f_file_exists, F_true); will_return(__wrap_f_file_is, F_true); // A link, kt_remove_flag_file_operate_link_d is set. will_return(__wrap_f_file_stat, &statistics); - will_return(__wrap_f_file_stat, F_false); + will_return(__wrap_f_file_stat, F_okay); // Directory processing. will_return(__wrap_f_directory_empty, F_true); - will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_e | f_directory_recurse_do_flag_top_after_e); - will_return(__wrap_f_directory_is, F_true); + will_return(__wrap_fl_directory_do, 1); + will_return(__wrap_fl_directory_do, &file); + will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_e | f_directory_recurse_do_flag_directory_e | f_directory_recurse_do_flag_top_after_e); // This will fail if f_directory_remove() is not called, therefore success here means f_directory_remove has been called. will_return(__wrap_f_directory_remove, F_okay); @@ -658,7 +690,7 @@ void test__kt_remove__directory_no_args__two_empty_exists_link_not(void **state) } { - const f_string_t argv[] = { "mocked_main", "to_remove", "also/remove", "+V", 0 }; + const f_string_t argv[] = { "mocked_main", file.string, "also/remove", "+V", 0 }; memset(&statistics, 0, sizeof(struct stat)); statistics.st_mode = F_file_mode_all_d | F_file_type_directory_d; // Should result in kt_remove_flag_file_operate_remove_d. @@ -667,12 +699,13 @@ void test__kt_remove__directory_no_args__two_empty_exists_link_not(void **state) will_return(__wrap_f_file_exists, F_true); will_return(__wrap_f_file_is, F_false); // A link, kt_remove_flag_file_operate_link_d is not set. will_return(__wrap_f_file_stat, &statistics); - will_return(__wrap_f_file_stat, F_false); + will_return(__wrap_f_file_stat, F_okay); // Directory processing. will_return(__wrap_f_directory_empty, F_true); - will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_e | f_directory_recurse_do_flag_top_after_e); - will_return(__wrap_f_directory_is, F_true); + will_return(__wrap_fl_directory_do, 1); + will_return(__wrap_fl_directory_do, &file); + will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_e | f_directory_recurse_do_flag_directory_e | f_directory_recurse_do_flag_top_after_e); // This will fail if f_directory_remove() is not called, therefore success here means f_directory_remove has been called. will_return(__wrap_f_directory_remove, F_okay); @@ -681,12 +714,13 @@ void test__kt_remove__directory_no_args__two_empty_exists_link_not(void **state) will_return(__wrap_f_file_exists, F_true); will_return(__wrap_f_file_is, F_true); // A link, kt_remove_flag_file_operate_link_d is set. will_return(__wrap_f_file_stat, &statistics); - will_return(__wrap_f_file_stat, F_false); + will_return(__wrap_f_file_stat, F_okay); // Directory processing. will_return(__wrap_f_directory_empty, F_true); - will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_e | f_directory_recurse_do_flag_top_after_e); - will_return(__wrap_f_directory_is, F_true); + will_return(__wrap_fl_directory_do, 1); + will_return(__wrap_fl_directory_do, &file); + will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_e | f_directory_recurse_do_flag_directory_e | f_directory_recurse_do_flag_top_after_e); // This will fail if f_directory_remove() is not called, therefore success here means f_directory_remove has been called. will_return(__wrap_f_directory_remove, F_okay); @@ -697,7 +731,7 @@ void test__kt_remove__directory_no_args__two_empty_exists_link_not(void **state) } { - const f_string_t argv[] = { "mocked_main", "to_remove", "also/remove", "+D", 0 }; + const f_string_t argv[] = { "mocked_main", file.string, "also/remove", "+D", 0 }; memset(&statistics, 0, sizeof(struct stat)); statistics.st_mode = F_file_mode_all_d | F_file_type_directory_d; // Should result in kt_remove_flag_file_operate_remove_d. @@ -706,12 +740,13 @@ void test__kt_remove__directory_no_args__two_empty_exists_link_not(void **state) will_return(__wrap_f_file_exists, F_true); will_return(__wrap_f_file_is, F_false); // A link, kt_remove_flag_file_operate_link_d is not set. will_return(__wrap_f_file_stat, &statistics); - will_return(__wrap_f_file_stat, F_false); + will_return(__wrap_f_file_stat, F_okay); // Directory processing. will_return(__wrap_f_directory_empty, F_true); - will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_e | f_directory_recurse_do_flag_top_after_e); - will_return(__wrap_f_directory_is, F_true); + will_return(__wrap_fl_directory_do, 1); + will_return(__wrap_fl_directory_do, &file); + will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_e | f_directory_recurse_do_flag_directory_e | f_directory_recurse_do_flag_top_after_e); // This will fail if f_directory_remove() is not called, therefore success here means f_directory_remove has been called. will_return(__wrap_f_directory_remove, F_okay); @@ -720,12 +755,13 @@ void test__kt_remove__directory_no_args__two_empty_exists_link_not(void **state) will_return(__wrap_f_file_exists, F_true); will_return(__wrap_f_file_is, F_true); // A link, kt_remove_flag_file_operate_link_d is set. will_return(__wrap_f_file_stat, &statistics); - will_return(__wrap_f_file_stat, F_false); + will_return(__wrap_f_file_stat, F_okay); // Directory processing. will_return(__wrap_f_directory_empty, F_true); - will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_e | f_directory_recurse_do_flag_top_after_e); - will_return(__wrap_f_directory_is, F_true); + will_return(__wrap_fl_directory_do, 1); + will_return(__wrap_fl_directory_do, &file); + will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_e | f_directory_recurse_do_flag_directory_e | f_directory_recurse_do_flag_top_after_e); // This will fail if f_directory_remove() is not called, therefore success here means f_directory_remove has been called. will_return(__wrap_f_directory_remove, F_okay); @@ -740,8 +776,10 @@ void test__kt_remove__directory_no_args__two_empty_exists_not(void **state) { mock_unwrap = 0; + const f_string_static_t file = macro_f_string_static_t_initialize_1("to_remove", 0, 9); + { - const f_string_t argv[] = { "mocked_main", "to_remove", "also/remove", 0 }; + const f_string_t argv[] = { "mocked_main", file.string, "also/remove", 0 }; will_return(__wrap_f_file_exists, F_false); will_return(__wrap_f_file_exists, F_false); @@ -752,7 +790,7 @@ void test__kt_remove__directory_no_args__two_empty_exists_not(void **state) { } { - const f_string_t argv[] = { "mocked_main", "to_remove", "also/remove", "+V", 0 }; + const f_string_t argv[] = { "mocked_main", file.string, "also/remove", "+V", 0 }; will_return(__wrap_f_file_exists, F_false); will_return(__wrap_f_file_exists, F_false); @@ -763,7 +801,7 @@ void test__kt_remove__directory_no_args__two_empty_exists_not(void **state) { } { - const f_string_t argv[] = { "mocked_main", "to_remove", "also/remove", "+D", 0 }; + const f_string_t argv[] = { "mocked_main", file.string, "also/remove", "+D", 0 }; will_return(__wrap_f_file_exists, F_false); will_return(__wrap_f_file_exists, F_false); diff --git a/tests/unit/remove/c/test-remove-directory_recurse_simple.c b/tests/unit/remove/c/test-remove-directory_recurse_simple.c index 35be553..2ff097d 100644 --- a/tests/unit/remove/c/test-remove-directory_recurse_simple.c +++ b/tests/unit/remove/c/test-remove-directory_recurse_simple.c @@ -10,39 +10,51 @@ extern "C" { void test__kt_remove__directory_recurse_simple__one_child_one_exists_link(void **state) { mock_unwrap = 0; - mock_directory_call_action = F_true; + + const f_string_static_t parent = macro_f_string_static_t_initialize_1("to_remove", 0, 9); + const f_string_static_t child_1 = macro_f_string_static_t_initialize_1("child_1", 0, 7); struct stat stat_parent; struct stat stat_regular; - //const f_string_static_t child_1 = macro_f_string_static_t_initialize_1("child_1", 0, 7); @todo use this. - { - const f_string_t argv[] = { "mocked_main", "to_remove", "-r", 0 }; + const f_string_t argv[] = { "mocked_main", parent.string, "-r", 0 }; memset(&stat_parent, 0, sizeof(struct stat)); - stat_parent.st_mode = F_file_mode_all_d | F_file_type_directory_d; // Should result in kt_remove_flag_file_operate_remove_d. - memset(&stat_regular, 0, sizeof(struct stat)); - stat_regular.st_mode = F_file_mode_all_d | F_file_type_regular_d; // Should result in kt_remove_flag_file_operate_remove_d. + + stat_parent.st_mode = F_file_mode_all_d | F_file_type_directory_d; + stat_regular.st_mode = F_file_mode_all_d | F_file_type_regular_d; // Pre-process file. will_return(__wrap_f_file_exists, F_true); will_return(__wrap_f_file_is, F_true); // A link, kt_remove_flag_file_operate_link_d is set. will_return(__wrap_f_file_stat, &stat_parent); - will_return(__wrap_f_file_stat, F_false); + will_return(__wrap_f_file_stat, F_okay); - // Parent Directory processing, beging. + // Parent Directory pre-processing, begin, perform directory listing action. will_return(__wrap_f_directory_empty, F_false); + will_return(__wrap_fl_directory_do, 1); - // Child file processing. @todo the __wrap_fl_directory_do mock will need to be unwrapped and then individual parts must be mocked. + // The first child pre-processing. + will_return(__wrap_fl_directory_do, &child_1); will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_e | f_directory_recurse_do_flag_regular_e); + will_return(__wrap_f_file_exists, F_true); + will_return(__wrap_f_file_is, F_false); // Not a link, kt_remove_flag_file_operate_link_d is not set. + will_return(__wrap_f_file_stat, &stat_regular); + will_return(__wrap_f_file_stat, F_okay); - // Parent Directory processing, continue. - will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_e | f_directory_recurse_do_flag_top_after_e); - will_return(__wrap_f_directory_is, F_true); + // Parent Directory processing, begin. + will_return(__wrap_fl_directory_do, 2); + + // The first child processing. + will_return(__wrap_fl_directory_do, &child_1); + will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_e | f_directory_recurse_do_flag_regular_e); + will_return(__wrap_f_file_remove, F_okay); - // This will fail if f_directory_remove() is not called, therefore success here means f_directory_remove has been called. + // Parent Directory processing, continue. + will_return(__wrap_fl_directory_do, &parent); + will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_e | f_directory_recurse_do_flag_directory_e | f_directory_recurse_do_flag_top_after_e); will_return(__wrap_f_directory_remove, F_okay); const int result = kt_main_test__remove(3, argv, 0); diff --git a/tests/unit/remove/c/test-remove-regular_no_args.c b/tests/unit/remove/c/test-remove-regular_no_args.c index 1ab1a97..b099e85 100644 --- a/tests/unit/remove/c/test-remove-regular_no_args.c +++ b/tests/unit/remove/c/test-remove-regular_no_args.c @@ -23,7 +23,7 @@ void test__kt_remove__regular_no_args__one_exists_link(void **state) { will_return(__wrap_f_file_exists, F_true); will_return(__wrap_f_file_is, F_true); // A link, kt_remove_flag_file_operate_link_d is set. will_return(__wrap_f_file_stat, &statistics); - will_return(__wrap_f_file_stat, F_false); + will_return(__wrap_f_file_stat, F_okay); // This will fail if f_file_remove() is not called, therefore success here means f_file_remove has been called. will_return(__wrap_f_file_remove, F_okay); @@ -43,7 +43,7 @@ void test__kt_remove__regular_no_args__one_exists_link(void **state) { will_return(__wrap_f_file_exists, F_true); will_return(__wrap_f_file_is, F_true); // A link, kt_remove_flag_file_operate_link_d is set. will_return(__wrap_f_file_stat, &statistics); - will_return(__wrap_f_file_stat, F_false); + will_return(__wrap_f_file_stat, F_okay); // This will fail if f_file_remove() is not called, therefore success here means f_file_remove has been called. will_return(__wrap_f_file_remove, F_okay); @@ -63,7 +63,7 @@ void test__kt_remove__regular_no_args__one_exists_link(void **state) { will_return(__wrap_f_file_exists, F_true); will_return(__wrap_f_file_is, F_true); // A link, kt_remove_flag_file_operate_link_d is set. will_return(__wrap_f_file_stat, &statistics); - will_return(__wrap_f_file_stat, F_false); + will_return(__wrap_f_file_stat, F_okay); // This will fail if f_file_remove() is not called, therefore success here means f_file_remove has been called. will_return(__wrap_f_file_remove, F_okay); @@ -90,7 +90,7 @@ void test__kt_remove__regular_no_args__one_exists_link_not(void **state) { will_return(__wrap_f_file_exists, F_true); will_return(__wrap_f_file_is, F_false); // A link, kt_remove_flag_file_operate_link_d is not set. will_return(__wrap_f_file_stat, &statistics); - will_return(__wrap_f_file_stat, F_false); + will_return(__wrap_f_file_stat, F_okay); // This will fail if f_file_remove() is not called, therefore success here means f_file_remove has been called. will_return(__wrap_f_file_remove, F_okay); @@ -110,7 +110,7 @@ void test__kt_remove__regular_no_args__one_exists_link_not(void **state) { will_return(__wrap_f_file_exists, F_true); will_return(__wrap_f_file_is, F_false); // A link, kt_remove_flag_file_operate_link_d is not set. will_return(__wrap_f_file_stat, &statistics); - will_return(__wrap_f_file_stat, F_false); + will_return(__wrap_f_file_stat, F_okay); // This will fail if f_file_remove() is not called, therefore success here means f_file_remove has been called. will_return(__wrap_f_file_remove, F_okay); @@ -130,7 +130,7 @@ void test__kt_remove__regular_no_args__one_exists_link_not(void **state) { will_return(__wrap_f_file_exists, F_true); will_return(__wrap_f_file_is, F_false); // A link, kt_remove_flag_file_operate_link_d is not set. will_return(__wrap_f_file_stat, &statistics); - will_return(__wrap_f_file_stat, F_false); + will_return(__wrap_f_file_stat, F_okay); // This will fail if f_file_remove() is not called, therefore success here means f_file_remove has been called. will_return(__wrap_f_file_remove, F_okay); @@ -195,7 +195,7 @@ void test__kt_remove__regular_no_args__two_exists_and_not(void **state) { will_return(__wrap_f_file_exists, F_true); will_return(__wrap_f_file_is, F_false); // A link, kt_remove_flag_file_operate_link_d is not set. will_return(__wrap_f_file_stat, &statistics); - will_return(__wrap_f_file_stat, F_false); + will_return(__wrap_f_file_stat, F_okay); // This will fail if f_file_remove() is not called, therefore success here means f_file_remove has been called. will_return(__wrap_f_file_remove, F_okay); @@ -218,7 +218,7 @@ void test__kt_remove__regular_no_args__two_exists_and_not(void **state) { will_return(__wrap_f_file_exists, F_true); will_return(__wrap_f_file_is, F_false); // A link, kt_remove_flag_file_operate_link_d is not set. will_return(__wrap_f_file_stat, &statistics); - will_return(__wrap_f_file_stat, F_false); + will_return(__wrap_f_file_stat, F_okay); // This will fail if f_file_remove() is not called, therefore success here means f_file_remove has been called. will_return(__wrap_f_file_remove, F_okay); @@ -241,7 +241,7 @@ void test__kt_remove__regular_no_args__two_exists_and_not(void **state) { will_return(__wrap_f_file_exists, F_true); will_return(__wrap_f_file_is, F_false); // A link, kt_remove_flag_file_operate_link_d is not set. will_return(__wrap_f_file_stat, &statistics); - will_return(__wrap_f_file_stat, F_false); + will_return(__wrap_f_file_stat, F_okay); // This will fail if f_file_remove() is not called, therefore success here means f_file_remove has been called. will_return(__wrap_f_file_remove, F_okay); @@ -268,7 +268,7 @@ void test__kt_remove__regular_no_args__two_exists_link(void **state) { will_return(__wrap_f_file_exists, F_true); will_return(__wrap_f_file_is, F_true); // A link, kt_remove_flag_file_operate_link_d is set. will_return(__wrap_f_file_stat, &statistics); - will_return(__wrap_f_file_stat, F_false); + will_return(__wrap_f_file_stat, F_okay); // This will fail if f_file_remove() is not called, therefore success here means f_file_remove has been called. will_return(__wrap_f_file_remove, F_okay); @@ -277,7 +277,7 @@ void test__kt_remove__regular_no_args__two_exists_link(void **state) { will_return(__wrap_f_file_exists, F_true); will_return(__wrap_f_file_is, F_true); // A link, kt_remove_flag_file_operate_link_d is set. will_return(__wrap_f_file_stat, &statistics); - will_return(__wrap_f_file_stat, F_false); + will_return(__wrap_f_file_stat, F_okay); // This will fail if f_file_remove() is not called, therefore success here means f_file_remove has been called. will_return(__wrap_f_file_remove, F_okay); @@ -297,7 +297,7 @@ void test__kt_remove__regular_no_args__two_exists_link(void **state) { will_return(__wrap_f_file_exists, F_true); will_return(__wrap_f_file_is, F_true); // A link, kt_remove_flag_file_operate_link_d is set. will_return(__wrap_f_file_stat, &statistics); - will_return(__wrap_f_file_stat, F_false); + will_return(__wrap_f_file_stat, F_okay); // This will fail if f_file_remove() is not called, therefore success here means f_file_remove has been called. will_return(__wrap_f_file_remove, F_okay); @@ -306,7 +306,7 @@ void test__kt_remove__regular_no_args__two_exists_link(void **state) { will_return(__wrap_f_file_exists, F_true); will_return(__wrap_f_file_is, F_true); // A link, kt_remove_flag_file_operate_link_d is set. will_return(__wrap_f_file_stat, &statistics); - will_return(__wrap_f_file_stat, F_false); + will_return(__wrap_f_file_stat, F_okay); // This will fail if f_file_remove() is not called, therefore success here means f_file_remove has been called. will_return(__wrap_f_file_remove, F_okay); @@ -326,7 +326,7 @@ void test__kt_remove__regular_no_args__two_exists_link(void **state) { will_return(__wrap_f_file_exists, F_true); will_return(__wrap_f_file_is, F_true); // A link, kt_remove_flag_file_operate_link_d is set. will_return(__wrap_f_file_stat, &statistics); - will_return(__wrap_f_file_stat, F_false); + will_return(__wrap_f_file_stat, F_okay); // This will fail if f_file_remove() is not called, therefore success here means f_file_remove has been called. will_return(__wrap_f_file_remove, F_okay); @@ -335,7 +335,7 @@ void test__kt_remove__regular_no_args__two_exists_link(void **state) { will_return(__wrap_f_file_exists, F_true); will_return(__wrap_f_file_is, F_true); // A link, kt_remove_flag_file_operate_link_d is set. will_return(__wrap_f_file_stat, &statistics); - will_return(__wrap_f_file_stat, F_false); + will_return(__wrap_f_file_stat, F_okay); // This will fail if f_file_remove() is not called, therefore success here means f_file_remove has been called. will_return(__wrap_f_file_remove, F_okay); @@ -362,7 +362,7 @@ void test__kt_remove__regular_no_args__two_exists_link_not(void **state) { will_return(__wrap_f_file_exists, F_true); will_return(__wrap_f_file_is, F_false); // A link, kt_remove_flag_file_operate_link_d is not set. will_return(__wrap_f_file_stat, &statistics); - will_return(__wrap_f_file_stat, F_false); + will_return(__wrap_f_file_stat, F_okay); // This will fail if f_file_remove() is not called, therefore success here means f_file_remove has been called. will_return(__wrap_f_file_remove, F_okay); @@ -371,7 +371,7 @@ void test__kt_remove__regular_no_args__two_exists_link_not(void **state) { will_return(__wrap_f_file_exists, F_true); will_return(__wrap_f_file_is, F_false); // A link, kt_remove_flag_file_operate_link_d is not set. will_return(__wrap_f_file_stat, &statistics); - will_return(__wrap_f_file_stat, F_false); + will_return(__wrap_f_file_stat, F_okay); // This will fail if f_file_remove() is not called, therefore success here means f_file_remove has been called. will_return(__wrap_f_file_remove, F_okay); @@ -391,7 +391,7 @@ void test__kt_remove__regular_no_args__two_exists_link_not(void **state) { will_return(__wrap_f_file_exists, F_true); will_return(__wrap_f_file_is, F_false); // A link, kt_remove_flag_file_operate_link_d is not set. will_return(__wrap_f_file_stat, &statistics); - will_return(__wrap_f_file_stat, F_false); + will_return(__wrap_f_file_stat, F_okay); // This will fail if f_file_remove() is not called, therefore success here means f_file_remove has been called. will_return(__wrap_f_file_remove, F_okay); @@ -400,7 +400,7 @@ void test__kt_remove__regular_no_args__two_exists_link_not(void **state) { will_return(__wrap_f_file_exists, F_true); will_return(__wrap_f_file_is, F_false); // A link, kt_remove_flag_file_operate_link_d is not set. will_return(__wrap_f_file_stat, &statistics); - will_return(__wrap_f_file_stat, F_false); + will_return(__wrap_f_file_stat, F_okay); // This will fail if f_file_remove() is not called, therefore success here means f_file_remove has been called. will_return(__wrap_f_file_remove, F_okay); @@ -420,7 +420,7 @@ void test__kt_remove__regular_no_args__two_exists_link_not(void **state) { will_return(__wrap_f_file_exists, F_true); will_return(__wrap_f_file_is, F_false); // A link, kt_remove_flag_file_operate_link_d is not set. will_return(__wrap_f_file_stat, &statistics); - will_return(__wrap_f_file_stat, F_false); + will_return(__wrap_f_file_stat, F_okay); // This will fail if f_file_remove() is not called, therefore success here means f_file_remove has been called. will_return(__wrap_f_file_remove, F_okay); @@ -429,7 +429,7 @@ void test__kt_remove__regular_no_args__two_exists_link_not(void **state) { will_return(__wrap_f_file_exists, F_true); will_return(__wrap_f_file_is, F_false); // A link, kt_remove_flag_file_operate_link_d is not set. will_return(__wrap_f_file_stat, &statistics); - will_return(__wrap_f_file_stat, F_false); + will_return(__wrap_f_file_stat, F_okay); // This will fail if f_file_remove() is not called, therefore success here means f_file_remove has been called. will_return(__wrap_f_file_remove, F_okay); -- 1.8.3.1