extern "C" {
#endif
-void test__kt_remove__directory_no_args__empty_exists_link(void **state) {
+void test__kt_remove__directory_no_args__one_empty_exists_link(void **state) {
mock_unwrap = 0;
mock_directory_call_action = F_true;
}
}
-void test__kt_remove__directory_no_args__empty_exists_link_not(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;
}
}
-void test__kt_remove__directory_no_args__empty_exists_not(void **state) {
+void test__kt_remove__directory_no_args__one_empty_exists_not(void **state) {
mock_unwrap = 0;
}
}
+void test__kt_remove__directory_no_args__one_empty_not_exists_link(void **state) {
+
+ mock_unwrap = 0;
+ mock_directory_call_action = F_true;
+
+ struct stat statistics;
+ struct stat statistics_regular;
+
+ {
+ const f_string_t argv[] = { "mocked_main", "to_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.
+
+ memset(&statistics_regular, 0, sizeof(struct stat));
+ statistics_regular.st_mode = F_file_mode_all_d | F_file_type_regular_d; // Should result in kt_remove_flag_file_operate_remove_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, &statistics);
+ will_return(__wrap_f_file_stat, F_false);
+
+ // 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);
+
+ // 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);
+
+ const int result = kt_main_test__remove(2, argv, 0);
+
+ assert_int_equal(result, 0);
+ }
+
+ {
+ const f_string_t argv[] = { "mocked_main", "to_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.
+
+ memset(&statistics_regular, 0, sizeof(struct stat));
+ statistics_regular.st_mode = F_file_mode_all_d | F_file_type_regular_d; // Should result in kt_remove_flag_file_operate_remove_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, &statistics);
+ will_return(__wrap_f_file_stat, F_false);
+
+ // 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);
+
+ // 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);
+
+ const int result = kt_main_test__remove(3, argv, 0);
+
+ assert_int_equal(result, 0);
+ }
+
+ {
+ const f_string_t argv[] = { "mocked_main", "to_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.
+
+ memset(&statistics_regular, 0, sizeof(struct stat));
+ statistics_regular.st_mode = F_file_mode_all_d | F_file_type_regular_d; // Should result in kt_remove_flag_file_operate_remove_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, &statistics);
+ will_return(__wrap_f_file_stat, F_false);
+
+ // 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);
+
+ // 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);
+
+ const int result = kt_main_test__remove(3, argv, 0);
+
+ assert_int_equal(result, 0);
+ }
+}
+
+void test__kt_remove__directory_no_args__one_empty_not_exists_link_not(void **state) {
+
+ mock_unwrap = 0;
+ mock_directory_call_action = F_true;
+
+ struct stat statistics;
+ struct stat statistics_regular;
+
+ {
+ const f_string_t argv[] = { "mocked_main", "to_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.
+
+ memset(&statistics_regular, 0, sizeof(struct stat));
+ statistics_regular.st_mode = F_file_mode_all_d | F_file_type_regular_d; // Should result in kt_remove_flag_file_operate_remove_d.
+
+ // Pre-process file.
+ 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);
+
+ // 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);
+
+ // 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);
+
+ const int result = kt_main_test__remove(2, argv, 0);
+
+ assert_int_equal(result, 0);
+ }
+
+ {
+ const f_string_t argv[] = { "mocked_main", "to_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.
+
+ memset(&statistics_regular, 0, sizeof(struct stat));
+ statistics_regular.st_mode = F_file_mode_all_d | F_file_type_regular_d; // Should result in kt_remove_flag_file_operate_remove_d.
+
+ // Pre-process file.
+ 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);
+
+ // 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);
+
+ // 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);
+
+ const int result = kt_main_test__remove(3, argv, 0);
+
+ assert_int_equal(result, 0);
+ }
+
+ {
+ const f_string_t argv[] = { "mocked_main", "to_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.
+
+ memset(&statistics_regular, 0, sizeof(struct stat));
+ statistics_regular.st_mode = F_file_mode_all_d | F_file_type_regular_d; // Should result in kt_remove_flag_file_operate_remove_d.
+
+ // Pre-process file.
+ 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);
+
+ // 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);
+
+ // 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);
+
+ const int result = kt_main_test__remove(3, argv, 0);
+
+ assert_int_equal(result, 0);
+ }
+}
+
+void test__kt_remove__directory_no_args__two_empty_exists_and_not(void **state) {
+
+ mock_unwrap = 0;
+ mock_directory_call_action = F_true;
+
+ struct stat statistics;
+
+ {
+ const f_string_t argv[] = { "mocked_main", "to_remove", "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.
+
+ // Pre-process file 1.
+ will_return(__wrap_f_file_exists, F_false);
+
+ // Pre-process file 2.
+ 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);
+
+ // 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);
+
+ // 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);
+
+ const int result = kt_main_test__remove(3, argv, 0);
+
+ assert_int_equal(result, 0);
+ }
+
+ {
+ const f_string_t argv[] = { "mocked_main", "to_remove", "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.
+
+ // Pre-process file 1.
+ will_return(__wrap_f_file_exists, F_false);
+
+ // Pre-process file 2.
+ 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);
+
+ // 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);
+
+ // 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);
+
+ const int result = kt_main_test__remove(4, argv, 0);
+
+ assert_int_equal(result, 0);
+ }
+
+ {
+ const f_string_t argv[] = { "mocked_main", "to_remove", "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.
+
+ // Pre-process file 1.
+ will_return(__wrap_f_file_exists, F_false);
+
+ // Pre-process file 2.
+ 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);
+
+ // 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);
+
+ // 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);
+
+ const int result = kt_main_test__remove(4, argv, 0);
+
+ assert_int_equal(result, 0);
+ }
+}
+
+void test__kt_remove__directory_no_args__two_empty_exists_link(void **state) {
+
+ mock_unwrap = 0;
+ mock_directory_call_action = F_true;
+
+ struct stat statistics;
+
+ {
+ const f_string_t argv[] = { "mocked_main", "to_remove", "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.
+
+ // Pre-process file 1.
+ 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);
+
+ // 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);
+
+ // 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);
+
+ // Pre-process file 2.
+ 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);
+
+ // 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);
+
+ // 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);
+
+ const int result = kt_main_test__remove(3, argv, 0);
+
+ assert_int_equal(result, 0);
+ }
+
+ {
+ const f_string_t argv[] = { "mocked_main", "to_remove", "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.
+
+ // Pre-process file 1.
+ 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);
+
+ // 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);
+
+ // 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);
+
+ // Pre-process file 2.
+ 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);
+
+ // 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);
+
+ // 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);
+
+ const int result = kt_main_test__remove(4, argv, 0);
+
+ assert_int_equal(result, 0);
+ }
+
+ {
+ const f_string_t argv[] = { "mocked_main", "to_remove", "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.
+
+ // Pre-process file 1.
+ 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);
+
+ // 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);
+
+ // 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);
+
+ // Pre-process file 2.
+ 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);
+
+ // 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);
+
+ // 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);
+
+ const int result = kt_main_test__remove(4, argv, 0);
+
+ assert_int_equal(result, 0);
+ }
+}
+
+void test__kt_remove__directory_no_args__two_empty_exists_link_not(void **state) {
+
+ mock_unwrap = 0;
+ mock_directory_call_action = F_true;
+
+ struct stat statistics;
+
+ {
+ const f_string_t argv[] = { "mocked_main", "to_remove", "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.
+
+ // Pre-process file 1.
+ 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);
+
+ // 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);
+
+ // 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);
+
+ // Pre-process file 2.
+ 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);
+
+ // 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);
+
+ // 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);
+
+ const int result = kt_main_test__remove(4, argv, 0);
+
+ assert_int_equal(result, 0);
+ }
+
+ {
+ const f_string_t argv[] = { "mocked_main", "to_remove", "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.
+
+ // Pre-process file 1.
+ 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);
+
+ // 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);
+
+ // 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);
+
+ // Pre-process file 2.
+ 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);
+
+ // 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);
+
+ // 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);
+
+ const int result = kt_main_test__remove(4, argv, 0);
+
+ assert_int_equal(result, 0);
+ }
+
+ {
+ const f_string_t argv[] = { "mocked_main", "to_remove", "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.
+
+ // Pre-process file 1.
+ 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);
+
+ // 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);
+
+ // 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);
+
+ // Pre-process file 2.
+ 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);
+
+ // 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);
+
+ // 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);
+
+ const int result = kt_main_test__remove(4, argv, 0);
+
+ assert_int_equal(result, 0);
+ }
+}
+
+void test__kt_remove__directory_no_args__two_empty_exists_not(void **state) {
+
+ mock_unwrap = 0;
+
+ {
+ const f_string_t argv[] = { "mocked_main", "to_remove", "also/remove", 0 };
+
+ will_return(__wrap_f_file_exists, F_false);
+ will_return(__wrap_f_file_exists, F_false);
+
+ const int result = kt_main_test__remove(3, argv, 0);
+
+ assert_int_equal(result, 0);
+ }
+
+ {
+ const f_string_t argv[] = { "mocked_main", "to_remove", "also/remove", "+V", 0 };
+
+ will_return(__wrap_f_file_exists, F_false);
+ will_return(__wrap_f_file_exists, F_false);
+
+ const int result = kt_main_test__remove(4, argv, 0);
+
+ assert_int_equal(result, 0);
+ }
+
+ {
+ const f_string_t argv[] = { "mocked_main", "to_remove", "also/remove", "+D", 0 };
+
+ will_return(__wrap_f_file_exists, F_false);
+ will_return(__wrap_f_file_exists, F_false);
+
+ const int result = kt_main_test__remove(4, argv, 0);
+
+ assert_int_equal(result, 0);
+ }
+}
+
#ifdef __cplusplus
} // extern "C"
#endif
extern "C" {
#endif
-void test__kt_remove__regular_no_args__exists_link(void **state) {
+void test__kt_remove__regular_no_args__one_exists_link(void **state) {
mock_unwrap = 0;
// 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);
- const int result = kt_main_test__remove(2, argv, 0);
+ const int result = kt_main_test__remove(3, argv, 0);
assert_int_equal(result, 0);
}
// 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);
- const int result = kt_main_test__remove(3, argv, 0);
+ const int result = kt_main_test__remove(4, argv, 0);
assert_int_equal(result, 0);
}
// 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);
- const int result = kt_main_test__remove(3, argv, 0);
+ const int result = kt_main_test__remove(4, argv, 0);
assert_int_equal(result, 0);
}
}
-void test__kt_remove__regular_no_args__exists_link_not(void **state) {
+void test__kt_remove__regular_no_args__one_exists_link_not(void **state) {
mock_unwrap = 0;
// 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);
- const int result = kt_main_test__remove(3, argv, 0);
+ const int result = kt_main_test__remove(4, argv, 0);
assert_int_equal(result, 0);
}
// 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);
- const int result = kt_main_test__remove(3, argv, 0);
+ const int result = kt_main_test__remove(4, argv, 0);
assert_int_equal(result, 0);
}
// 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);
- const int result = kt_main_test__remove(3, argv, 0);
+ const int result = kt_main_test__remove(4, argv, 0);
assert_int_equal(result, 0);
}
}
-void test__kt_remove__regular_no_args__exists_not(void **state) {
+void test__kt_remove__regular_no_args__one_exists_not(void **state) {
mock_unwrap = 0;
will_return(__wrap_f_file_exists, F_false);
- const int result = kt_main_test__remove(2, argv, 0);
+ const int result = kt_main_test__remove(3, argv, 0);
assert_int_equal(result, 0);
}
will_return(__wrap_f_file_exists, F_false);
- const int result = kt_main_test__remove(3, argv, 0);
+ const int result = kt_main_test__remove(4, argv, 0);
assert_int_equal(result, 0);
}
will_return(__wrap_f_file_exists, F_false);
+ const int result = kt_main_test__remove(4, argv, 0);
+
+ assert_int_equal(result, 0);
+ }
+}
+
+void test__kt_remove__regular_no_args__two_exists_and_not(void **state) {
+
+ mock_unwrap = 0;
+
+ struct stat statistics;
+
+ {
+ const f_string_t argv[] = { "mocked_main", "to_remove", "also/remove", 0 };
+
+ memset(&statistics, 0, sizeof(struct stat));
+ statistics.st_mode = F_file_mode_all_d | F_file_type_regular_d; // Should result in kt_remove_flag_file_operate_remove_d.
+
+ // Pre-process file 1.
+ will_return(__wrap_f_file_exists, F_false);
+
+ // Pre-process file 2.
+ 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);
+
+ // 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);
+
+ const int result = kt_main_test__remove(3, argv, 0);
+
+ assert_int_equal(result, 0);
+ }
+
+ {
+ const f_string_t argv[] = { "mocked_main", "to_remove", "also/remove", "+V", 0 };
+
+ memset(&statistics, 0, sizeof(struct stat));
+ statistics.st_mode = F_file_mode_all_d | F_file_type_regular_d; // Should result in kt_remove_flag_file_operate_remove_d.
+
+ // Pre-process file 1.
+ will_return(__wrap_f_file_exists, F_false);
+
+ // Pre-process file 2.
+ 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);
+
+ // 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);
+
+ const int result = kt_main_test__remove(4, argv, 0);
+
+ assert_int_equal(result, 0);
+ }
+
+ {
+ const f_string_t argv[] = { "mocked_main", "to_remove", "also/remove", "+D", 0 };
+
+ memset(&statistics, 0, sizeof(struct stat));
+ statistics.st_mode = F_file_mode_all_d | F_file_type_regular_d; // Should result in kt_remove_flag_file_operate_remove_d.
+
+ // Pre-process file 1.
+ will_return(__wrap_f_file_exists, F_false);
+
+ // Pre-process file 2.
+ 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);
+
+ // 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);
+
+ const int result = kt_main_test__remove(4, argv, 0);
+
+ assert_int_equal(result, 0);
+ }
+}
+
+void test__kt_remove__regular_no_args__two_exists_link(void **state) {
+
+ mock_unwrap = 0;
+
+ struct stat statistics;
+
+ {
+ const f_string_t argv[] = { "mocked_main", "to_remove", "also/remove", 0 };
+
+ memset(&statistics, 0, sizeof(struct stat));
+ statistics.st_mode = F_file_mode_all_d | F_file_type_regular_d; // Should result in kt_remove_flag_file_operate_remove_d.
+
+ // Pre-process file 1.
+ 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);
+
+ // 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);
+
+ // Pre-process file 2.
+ 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);
+
+ // 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);
+
+ const int result = kt_main_test__remove(3, argv, 0);
+
+ assert_int_equal(result, 0);
+ }
+
+ {
+ const f_string_t argv[] = { "mocked_main", "to_remove", "also/remove", "+V", 0 };
+
+ memset(&statistics, 0, sizeof(struct stat));
+ statistics.st_mode = F_file_mode_all_d | F_file_type_regular_d; // Should result in kt_remove_flag_file_operate_remove_d.
+
+ // Pre-process file 1.
+ 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);
+
+ // 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);
+
+ // Pre-process file 2.
+ 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);
+
+ // 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);
+
+ const int result = kt_main_test__remove(4, argv, 0);
+
+ assert_int_equal(result, 0);
+ }
+
+ {
+ const f_string_t argv[] = { "mocked_main", "to_remove", "also/remove", "+D", 0 };
+
+ memset(&statistics, 0, sizeof(struct stat));
+ statistics.st_mode = F_file_mode_all_d | F_file_type_regular_d; // Should result in kt_remove_flag_file_operate_remove_d.
+
+ // Pre-process file 1.
+ 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);
+
+ // 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);
+
+ // Pre-process file 2.
+ 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);
+
+ // 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);
+
+ const int result = kt_main_test__remove(4, argv, 0);
+
+ assert_int_equal(result, 0);
+ }
+}
+
+void test__kt_remove__regular_no_args__two_exists_link_not(void **state) {
+
+ mock_unwrap = 0;
+
+ struct stat statistics;
+
+ {
+ const f_string_t argv[] = { "mocked_main", "to_remove", "also/remove", 0 };
+
+ memset(&statistics, 0, sizeof(struct stat));
+ statistics.st_mode = F_file_mode_all_d | F_file_type_regular_d; // Should result in kt_remove_flag_file_operate_remove_d.
+
+ // Pre-process file 1.
+ 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);
+
+ // 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);
+
+ // Pre-process file 2.
+ 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);
+
+ // 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);
+
+ const int result = kt_main_test__remove(4, argv, 0);
+
+ assert_int_equal(result, 0);
+ }
+
+ {
+ const f_string_t argv[] = { "mocked_main", "to_remove", "also/remove", "+V", 0 };
+
+ memset(&statistics, 0, sizeof(struct stat));
+ statistics.st_mode = F_file_mode_all_d | F_file_type_regular_d; // Should result in kt_remove_flag_file_operate_remove_d.
+
+ // Pre-process file 1.
+ 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);
+
+ // 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);
+
+ // Pre-process file 2.
+ 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);
+
+ // 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);
+
+ const int result = kt_main_test__remove(4, argv, 0);
+
+ assert_int_equal(result, 0);
+ }
+
+ {
+ const f_string_t argv[] = { "mocked_main", "to_remove", "also/remove", "+D", 0 };
+
+ memset(&statistics, 0, sizeof(struct stat));
+ statistics.st_mode = F_file_mode_all_d | F_file_type_regular_d; // Should result in kt_remove_flag_file_operate_remove_d.
+
+ // Pre-process file 1.
+ 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);
+
+ // 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);
+
+ // Pre-process file 2.
+ 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);
+
+ // 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);
+
+ const int result = kt_main_test__remove(4, argv, 0);
+
+ assert_int_equal(result, 0);
+ }
+}
+
+void test__kt_remove__regular_no_args__two_exists_not(void **state) {
+
+ mock_unwrap = 0;
+
+ {
+ const f_string_t argv[] = { "mocked_main", "to_remove", "also/remove", 0 };
+
+ will_return(__wrap_f_file_exists, F_false);
+ will_return(__wrap_f_file_exists, F_false);
+
const int result = kt_main_test__remove(3, argv, 0);
assert_int_equal(result, 0);
}
+
+ {
+ const f_string_t argv[] = { "mocked_main", "to_remove", "also/remove", "+V", 0 };
+
+ will_return(__wrap_f_file_exists, F_false);
+ will_return(__wrap_f_file_exists, F_false);
+
+ const int result = kt_main_test__remove(4, argv, 0);
+
+ assert_int_equal(result, 0);
+ }
+
+ {
+ const f_string_t argv[] = { "mocked_main", "to_remove", "also/remove", "+D", 0 };
+
+ will_return(__wrap_f_file_exists, F_false);
+ will_return(__wrap_f_file_exists, F_false);
+
+ const int result = kt_main_test__remove(4, argv, 0);
+
+ assert_int_equal(result, 0);
+ }
}
#ifdef __cplusplus