void test__f_file_mode_set__fails(void **state) {
+ const f_string_static_t path = macro_f_string_static_t_initialize("test", 0, 4);
+
+ const mode_t mode = 0;
+
int errnos[] = {
+ EACCES,
+ EFAULT,
+ EIO,
+ ELOOP,
+ ENAMETOOLONG,
+ ENOENT,
+ ENOMEM,
+ ENOTDIR,
+ EPERM,
+ EROFS,
mock_errno_generic,
};
f_status_t statuss[] = {
+ F_access_denied,
+ F_buffer,
+ F_input_output,
+ F_loop,
+ F_name,
+ F_file_found_not,
+ F_memory_not,
+ F_directory_not,
+ F_access_mode,
+ F_read_only,
F_failure,
};
- for (int i = 0; i < 1; ++i) {
+ for (int i = 0; i < 11; ++i) {
- //will_return(__wrap_open, true);
- //will_return(__wrap_open, errnos[i]);
+ will_return(__wrap_chmod, true);
+ will_return(__wrap_chmod, errnos[i]);
- //const f_status_t status = f_file_mode_set(path, F_false, &id);
+ const f_status_t status = f_file_mode_set(path, mode);
- //assert_int_equal(F_status_set_fine(status), statuss[i]);
+ assert_int_equal(F_status_set_fine(status), statuss[i]);
} // for
}
void test__f_file_mode_set__returns_data_not(void **state) {
+ const mode_t mode = 0;
+
{
- //const f_status_t status = f_file_mode_set(f_string_empty_s);
+ const f_status_t status = f_file_mode_set(f_string_empty_s, mode);
- //assert_int_equal(status, F_data_not);
+ assert_int_equal(status, F_data_not);
}
}
void test__f_file_mode_set__works(void **state) {
+ const f_string_static_t path = macro_f_string_static_t_initialize("test", 0, 4);
+
+ const mode_t mode = 0;
+
{
- //will_return(__wrap_open, false);
- //will_return(__wrap_open, 5);
+ will_return(__wrap_chmod, false);
+ will_return(__wrap_chmod, 0);
- //const f_status_t status = f_file_mode_set();
+ const f_status_t status = f_file_mode_set(path, mode);
- //assert_int_equal(status, F_none);
- //assert_int_equal(id, 5);
+ assert_int_equal(status, F_none);
}
}
void test__f_file_mode_set_at__fails(void **state) {
+ const f_string_static_t path = macro_f_string_static_t_initialize("test", 0, 4);
+
+ const mode_t mode = 0;
+
int errnos[] = {
+ EACCES,
+ EBADF,
+ EFAULT,
+ EIO,
+ ELOOP,
+ ENAMETOOLONG,
+ ENOENT,
+ ENOMEM,
+ ENOTDIR,
+ EPERM,
+ EROFS,
mock_errno_generic,
};
f_status_t statuss[] = {
+ F_access_denied,
+ F_directory_descriptor,
+ F_buffer,
+ F_input_output,
+ F_loop,
+ F_name,
+ F_file_found_not,
+ F_memory_not,
+ F_directory_not,
+ F_access_mode,
+ F_read_only,
F_failure,
};
- for (int i = 0; i < 1; ++i) {
+ for (int i = 0; i < 12; ++i) {
- //will_return(__wrap_open, true);
- //will_return(__wrap_open, errnos[i]);
+ will_return(__wrap_fchmodat, true);
+ will_return(__wrap_fchmodat, errnos[i]);
- //const f_status_t status = f_file_mode_set_at(path, F_false, &id);
+ const f_status_t status = f_file_mode_set_at(0, path, mode);
- //assert_int_equal(F_status_set_fine(status), statuss[i]);
+ assert_int_equal(F_status_set_fine(status), statuss[i]);
} // for
}
void test__f_file_mode_set_at__returns_data_not(void **state) {
+ const mode_t mode = 0;
+
{
- //const f_status_t status = f_file_mode_set_at(f_string_empty_s);
+ const f_status_t status = f_file_mode_set_at(0, f_string_empty_s, mode);
- //assert_int_equal(status, F_data_not);
+ assert_int_equal(status, F_data_not);
}
}
void test__f_file_mode_set_at__works(void **state) {
+ const f_string_static_t path = macro_f_string_static_t_initialize("test", 0, 4);
+
+ const mode_t mode = 0;
+
{
- //will_return(__wrap_open, false);
- //will_return(__wrap_open, 5);
+ will_return(__wrap_fchmodat, false);
+ will_return(__wrap_fchmodat, 5);
- //const f_status_t status = f_file_mode_set_at();
+ const f_status_t status = f_file_mode_set_at(0, path, mode);
- //assert_int_equal(status, F_none);
- //assert_int_equal(id, 5);
+ assert_int_equal(status, F_none);
}
}
cmocka_unit_test(test__f_file_mode_read_at__returns_data_not),
cmocka_unit_test(test__f_file_mode_read_at__works),
- // f_file_mode_set
+ cmocka_unit_test(test__f_file_mode_set__fails),
+ cmocka_unit_test(test__f_file_mode_set__returns_data_not),
+ cmocka_unit_test(test__f_file_mode_set__works),
- // f_file_mode_set_at
+ cmocka_unit_test(test__f_file_mode_set_at__fails),
+ cmocka_unit_test(test__f_file_mode_set_at__returns_data_not),
+ cmocka_unit_test(test__f_file_mode_set_at__works),
// f_file_mode_to_mode