Get more of the unit tests up to date.
I did not finish working on the f_file unit tests.
I specifically stopped on the stream functions, namely the f_stream_write().
Fix the file defaults, such as _di_f_type_file_defaults_ that should be _di_f_type_file_defaults_d_.
The file flags (wrapped by _di_f_file_flag_d_) must be located with the f_type type_file.h file.
#define _di_f_status_t_
#define _di_f_time_spec_t_
#define _di_f_time_t_
-#define _di_f_type_file_defaults_
+#define _di_f_type_file_defaults_d_
#define _di_f_type_input_output_d_
#define _di_f_type_number_64_t_
#define _di_f_type_sizes_d_
#define _di_f_file_descriptor_
//#define _di_f_file_exists_
#define _di_f_file_exists_at_
-//#define _di_f_file_flag_d_
//#define _di_f_file_flush_
//#define _di_f_file_group_read_
//#define _di_f_file_is_
#define _di_f_time_t_
//#define _di_f_type_d_
-//#define _di_f_type_file_defaults_
+//#define _di_f_type_file_defaults_d_
+//#define _di_f_type_file_flag_d_
//#define _di_f_type_number_64_t_
//#define _di_f_type_sizes_d_
void test__f_conversion_number_signed_print__fails(void **state) {
+ const f_file_t output = macro_f_file_t_initialize2(F_type_output_d, F_type_descriptor_output_d, F_file_flag_write_only_d);
+
{
const f_conversion_data_t data = macro_f_conversion_data_t_initialize(10, 0, 1);
will_return(__wrap_fwrite_unlocked, 0);
will_return(__wrap_ferror_unlocked, true);
- const f_status_t status = f_conversion_number_signed_print(1, data, F_type_output_d);
+ const f_status_t status = f_conversion_number_signed_print(1, data, output);
assert_int_equal(status, F_status_set_error(F_output));
}
void test__f_conversion_number_signed_print__fails_for_prepend(void **state) {
+ const f_file_t output = macro_f_file_t_initialize2(F_type_output_d, F_type_descriptor_output_d, F_file_flag_write_only_d);
+
{
const f_conversion_data_t data = macro_f_conversion_data_t_initialize(10, F_conversion_data_flag_base_prepend_d, 0);
will_return(__wrap_fwrite_unlocked, 0);
will_return(__wrap_ferror_unlocked, true);
- const f_status_t status = f_conversion_number_signed_print(1, data, F_type_output_d);
+ const f_status_t status = f_conversion_number_signed_print(1, data, output);
assert_int_equal(status, F_status_set_error(F_output));
}
void test__f_conversion_number_signed_print__fails_for_zero(void **state) {
+ const f_file_t output = macro_f_file_t_initialize2(F_type_output_d, F_type_descriptor_output_d, F_file_flag_write_only_d);
+
{
const f_conversion_data_t data = macro_f_conversion_data_t_initialize(10, 0, 1);
will_return(__wrap_fwrite_unlocked, 0);
will_return(__wrap_ferror_unlocked, true);
- const f_status_t status = f_conversion_number_signed_print(0, data, F_type_output_d);
+ const f_status_t status = f_conversion_number_signed_print(0, data, output);
assert_int_equal(status, F_status_set_error(F_output));
}
void test__f_conversion_number_signed_print__parameter_checking(void **state) {
+ f_file_t output = macro_f_file_t_initialize2(0, F_type_descriptor_output_d, F_file_flag_write_only_d);
+
{
const f_conversion_data_t data = macro_f_conversion_data_t_initialize(2, 0, 0);
- const f_status_t status = f_conversion_number_signed_print(0, data, 0);
+ const f_status_t status = f_conversion_number_signed_print(0, data, output);
assert_int_equal(status, F_status_set_error(F_parameter));
}
{
- FILE *file = 0;
const f_conversion_data_t data = macro_f_conversion_data_t_initialize(1, 0, 0);
- const f_status_t status = f_conversion_number_signed_print(0, data, file);
+ output.stream = F_type_output_d;
+
+ const f_status_t status = f_conversion_number_signed_print(0, data, output);
assert_int_equal(status, F_status_set_error(F_parameter));
}
void test__f_conversion_number_signed_print__works(void **state) {
+ const f_file_t output = macro_f_file_t_initialize2(F_type_output_d, F_type_descriptor_output_d, F_file_flag_write_only_d);
+
{
const f_conversion_data_t data = macro_f_conversion_data_t_initialize(10, 0, 1);
expect_string(__wrap_fwrite_unlocked, ptr, "1");
- const f_status_t status = f_conversion_number_signed_print(1, data, F_type_output_d);
+ const f_status_t status = f_conversion_number_signed_print(1, data, output);
assert_int_equal(status, F_none);
}
void test__f_conversion_number_signed_print__works_for_zero(void **state) {
+ const f_file_t output = macro_f_file_t_initialize2(F_type_output_d, F_type_descriptor_output_d, F_file_flag_write_only_d);
+
{
const f_conversion_data_t data = macro_f_conversion_data_t_initialize(10, 0, 1);
expect_string(__wrap_fwrite_unlocked, ptr, "0");
- const f_status_t status = f_conversion_number_signed_print(0, data, F_type_output_d);
+ const f_status_t status = f_conversion_number_signed_print(0, data, output);
assert_int_equal(status, F_none);
}
void test__f_conversion_number_signed_print__works_for_zero_with_width_zero(void **state) {
+ const f_file_t output = macro_f_file_t_initialize2(F_type_output_d, F_type_descriptor_output_d, F_file_flag_write_only_d);
+
{
const f_conversion_data_t data = macro_f_conversion_data_t_initialize(10, 0, 0);
- const f_status_t status = f_conversion_number_signed_print(0, data, F_type_output_d);
+ const f_status_t status = f_conversion_number_signed_print(0, data, output);
assert_int_equal(status, F_none);
}
void test__f_conversion_number_unsigned_print__fails(void **state) {
+ const f_file_t output = macro_f_file_t_initialize2(F_type_output_d, F_type_descriptor_output_d, F_file_flag_write_only_d);
+
{
const f_conversion_data_t data = macro_f_conversion_data_t_initialize(10, 0, 1);
will_return(__wrap_fwrite_unlocked, 0);
will_return(__wrap_ferror_unlocked, true);
- const f_status_t status = f_conversion_number_unsigned_print(1, data, F_type_output_d);
+ const f_status_t status = f_conversion_number_unsigned_print(1, data, output);
assert_int_equal(status, F_status_set_error(F_output));
}
void test__f_conversion_number_unsigned_print__fails_for_prepend(void **state) {
+ const f_file_t output = macro_f_file_t_initialize2(F_type_output_d, F_type_descriptor_output_d, F_file_flag_write_only_d);
+
{
const f_conversion_data_t data = macro_f_conversion_data_t_initialize(10, F_conversion_data_flag_base_prepend_d, 0);
will_return(__wrap_fwrite_unlocked, 0);
will_return(__wrap_ferror_unlocked, true);
- const f_status_t status = f_conversion_number_unsigned_print(1, data, F_type_output_d);
+ const f_status_t status = f_conversion_number_unsigned_print(1, data, output);
assert_int_equal(status, F_status_set_error(F_output));
}
void test__f_conversion_number_unsigned_print__fails_for_zero(void **state) {
+ const f_file_t output = macro_f_file_t_initialize2(F_type_output_d, F_type_descriptor_output_d, F_file_flag_write_only_d);
+
{
const f_conversion_data_t data = macro_f_conversion_data_t_initialize(10, 0, 1);
will_return(__wrap_fwrite_unlocked, 0);
will_return(__wrap_ferror_unlocked, true);
- const f_status_t status = f_conversion_number_unsigned_print(0, data, F_type_output_d);
+ const f_status_t status = f_conversion_number_unsigned_print(0, data, output);
assert_int_equal(status, F_status_set_error(F_output));
}
void test__f_conversion_number_unsigned_print__parameter_checking(void **state) {
+ f_file_t output = macro_f_file_t_initialize2(0, F_type_descriptor_output_d, F_file_flag_write_only_d);
+
{
const f_conversion_data_t data = macro_f_conversion_data_t_initialize(2, 0, 0);
- const f_status_t status = f_conversion_number_unsigned_print(0, data, 0);
+ const f_status_t status = f_conversion_number_unsigned_print(0, data, output);
assert_int_equal(status, F_status_set_error(F_parameter));
}
{
- FILE *file = 0;
const f_conversion_data_t data = macro_f_conversion_data_t_initialize(1, 0, 0);
- const f_status_t status = f_conversion_number_unsigned_print(0, data, file);
+ output.stream = F_type_output_d;
+
+ const f_status_t status = f_conversion_number_unsigned_print(0, data, output);
assert_int_equal(status, F_status_set_error(F_parameter));
}
void test__f_conversion_number_unsigned_print__works(void **state) {
+ const f_file_t output = macro_f_file_t_initialize2(F_type_output_d, F_type_descriptor_output_d, F_file_flag_write_only_d);
+
{
const f_conversion_data_t data = macro_f_conversion_data_t_initialize(10, 0, 1);
expect_string(__wrap_fwrite_unlocked, ptr, "1");
- const f_status_t status = f_conversion_number_unsigned_print(1, data, F_type_output_d);
+ const f_status_t status = f_conversion_number_unsigned_print(1, data, output);
assert_int_equal(status, F_none);
}
void test__f_conversion_number_unsigned_print__works_for_zero(void **state) {
+ const f_file_t output = macro_f_file_t_initialize2(F_type_output_d, F_type_descriptor_output_d, F_file_flag_write_only_d);
+
{
const f_conversion_data_t data = macro_f_conversion_data_t_initialize(10, 0, 1);
expect_string(__wrap_fwrite_unlocked, ptr, "0");
- const f_status_t status = f_conversion_number_unsigned_print(0, data, F_type_output_d);
+ const f_status_t status = f_conversion_number_unsigned_print(0, data, output);
assert_int_equal(status, F_none);
}
void test__f_conversion_number_unsigned_print__works_for_zero_with_width_zero(void **state) {
+ const f_file_t output = macro_f_file_t_initialize2(F_type_output_d, F_type_descriptor_output_d, F_file_flag_write_only_d);
+
{
const f_conversion_data_t data = macro_f_conversion_data_t_initialize(10, 0, 0);
- const f_status_t status = f_conversion_number_unsigned_print(0, data, F_type_output_d);
+ const f_status_t status = f_conversion_number_unsigned_print(0, data, output);
assert_int_equal(status, F_none);
}
if (F_status_is_error(status)) return status;
}
- return private_f_file_copy_content(source, destination, size_block == 0 ? F_file_default_read_size_d : size_block);
+ return private_f_file_copy_content(source, destination, size_block == 0 ? F_file_default_size_read_d : size_block);
}
if (macro_f_file_type_is_link(source_stat.st_mode)) {
status = private_f_file_mode_set(destination, (~F_file_type_mask_d) & mode.regular);
if (F_status_is_error(status)) return status;
- return private_f_file_copy_content(source, destination, size_block == 0 ? F_file_default_read_size_d : size_block);
+ return private_f_file_copy_content(source, destination, size_block == 0 ? F_file_default_size_read_d : size_block);
}
if (macro_f_file_type_is_directory(source_stat.st_mode)) {
#endif // _di_f_file_at_d_
/**
- * File flag related functionality.
- */
-#ifndef _di_f_file_flag_d_
-
- // file open flags
- #define F_file_flag_append_d O_APPEND
- #define F_file_flag_asynchronous_d O_ASYNC
- #define F_file_flag_create_d O_CREAT
- #define F_file_flag_close_execute_d O_CLOEXEC
- #define F_file_flag_direct_d O_DIRECT
- #define F_file_flag_directory_d O_DIRECTORY
- #define F_file_flag_exclusive_d O_EXCL
- #define F_file_flag_large_file_d O_LARGEFILE
- #define F_file_flag_no_access_time_d O_NOATIME
- #define F_file_flag_no_follow_d O_NOFOLLOW
- #define F_file_flag_no_tty_d O_NOCTTY
- #define F_file_flag_non_blocking_d O_NONBLOCK
- #define F_file_flag_path_d 010000000
- #define F_file_flag_read_only_d O_RDONLY
- #define F_file_flag_read_write_d O_RDWR
- #define F_file_flag_synchronous_d O_SYNC
- #define F_file_flag_synchronous_direct_d O_DSYNC
- #define F_file_flag_temporary_d O_TMPFILE
- #define F_file_flag_truncate_d O_TRUNC
- #define F_file_flag_write_only_d O_WRONLY
-
- // File open flags pre-combined with create.
- #define F_file_flag_create_ro_d (O_CREAT | O_RDONLY)
- #define F_file_flag_create_wo_d (O_CREAT | O_WRONLY)
- #define F_file_flag_create_rw_d (O_CREAT | O_RDRW)
-
- // File open flags pre-combined will fail if file exists.
- #define F_file_flag_create_new_ro_d (O_CREAT | O_EXCL | O_RDONLY)
- #define F_file_flag_create_new_wo_d (O_CREAT | O_EXCL | O_WRONLY)
- #define F_file_flag_create_new_rw_d (O_CREAT | O_EXCL | O_RDRW)
-
- // File open flags pre-combined will truncate any existing files to 0.
- #define F_file_flag_truncate_ro_d (O_CREAT | O_TRUNC | O_RDONLY)
- #define F_file_flag_truncate_rw_d (O_CREAT | O_TRUNC | O_RDRW)
- #define F_file_flag_truncate_wo_d (O_CREAT | O_TRUNC | O_WRONLY)
-
- // File open flags pre-combined will truncate any existing files to 0.
- #define F_file_flag_append_rw_d (O_CREAT | O_APPEND | O_RDRW)
- #define F_file_flag_append_wo_d (O_CREAT | O_APPEND | O_WRONLY)
-
- // File open flags pre-combined with synchronous io.
- #define F_file_flag_sync_ro_d (O_SYNC | O_RDONLY)
- #define F_file_flag_sync_wo_d (O_SYNC | O_WRONLY)
- #define F_file_flag_sync_rw_d (O_SYNC | O_RDRW)
- #define F_file_flag_sync_create_ro_d (O_SYNC | O_CREAT | O_RDONLY)
- #define F_file_flag_sync_create_wo_d (O_SYNC | O_CREAT | O_WRONLY)
- #define F_file_flag_sync_create_rw_d (O_SYNC | O_CREAT | O_RDRW)
- #define F_file_flag_sync_create_new_ro_d (O_SYNC | O_CREAT | O_EXCL | O_RDONLY)
- #define F_file_flag_sync_create_new_wo_d (O_SYNC | O_CREAT | O_EXCL | O_WRONLY)
- #define F_file_flag_sync_create_new_rw_d (O_SYNC | O_CREAT | O_EXCL | O_RDRW)
-
- // File open flags pre-combined with asynchronous io.
- #define F_file_flag_async_ro_d (O_ASYNC | O_RDONLY)
- #define F_file_flag_async_wo_d (O_ASYNC | O_WRONLY)
- #define F_file_flag_async_rw_d (O_ASYNC | O_RDRW)
- #define F_file_flag_async_create_ro_d (O_ASYNC | O_CREAT | O_RDONLY)
- #define F_file_flag_async_create_wo_d (O_ASYNC | O_CREAT | O_WRONLY)
- #define F_file_flag_async_create_rw_d (O_ASYNC | O_CREAT | O_RDRW)
- #define F_file_flag_async_create_new_ro_d (O_ASYNC | O_CREAT | O_EXCL | O_RDONLY)
- #define F_file_flag_async_create_new_wo_d (O_ASYNC | O_CREAT | O_EXCL | O_WRONLY)
- #define F_file_flag_async_create_new_rw_d (O_ASYNC | O_CREAT | O_EXCL | O_RDRW)
-
- // File open flags pre-combined with direct io (which works synchronously).
- #define F_file_flag_direct_ro_d (O_DIRECT | O_RDONLY)
- #define F_file_flag_direct_wo_d (O_DIRECT | O_WRONLY)
- #define F_file_flag_direct_rw_d (O_DIRECT | O_RDRW)
- #define F_file_flag_direct_create_ro_d (O_DIRECT | O_CREAT | O_RDONLY)
- #define F_file_flag_direct_create_wo_d (O_DIRECT | O_CREAT | O_WRONLY)
- #define F_file_flag_direct_create_rw_d (O_DIRECT | O_CREAT | O_RDRW)
- #define F_file_flag_direct_create_new_ro_d (O_DIRECT | O_CREAT | O_EXCL | O_RDONLY)
- #define F_file_flag_direct_create_new_wo_d (O_DIRECT | O_CREAT | O_EXCL | O_WRONLY)
- #define F_file_flag_direct_create_new_rw_d (O_DIRECT | O_CREAT | O_EXCL | O_RDRW)
-
- // File open flags pre-combined with large_file.
- #define F_file_flag_large_ro_d (O_LARGEFILE | O_RDONLY)
- #define F_file_flag_large_wo_d (O_LARGEFILE | O_WRONLY)
- #define F_file_flag_large_rw_d (O_LARGEFILE | O_RDRW)
- #define F_file_flag_large_sync_ro_d (O_LARGEFILE | O_SYNC | O_RDONLY)
- #define F_file_flag_large_sync_wo_d (O_LARGEFILE | O_SYNC | O_WRONLY)
- #define F_file_flag_large_sync_rw_d (O_LARGEFILE | O_SYNC | O_RDRW)
- #define F_file_flag_large_sync_create_ro_d (O_LARGEFILE | O_SYNC | O_CREAT | O_RDONLY)
- #define F_file_flag_large_sync_create_wo_d (O_LARGEFILE | O_SYNC | O_CREAT | O_WRONLY)
- #define F_file_flag_large_sync_create_rw_d (O_LARGEFILE | O_SYNC | O_CREAT | O_RDRW)
- #define F_file_flag_large_sync_create_new_ro_d (O_LARGEFILE | O_SYNC | O_CREAT | O_EXCL | O_RDONLY)
- #define F_file_flag_large_sync_create_new_wo_d (O_LARGEFILE | O_SYNC | O_CREAT | O_EXCL | O_WRONLY)
- #define F_file_flag_large_sync_create_new_rw_d (O_LARGEFILE | O_SYNC | O_CREAT | O_EXCL | O_RDRW)
- #define F_file_flag_large_async_ro_d (O_LARGEFILE | O_ASYNC | O_RDONLY)
- #define F_file_flag_large_async_wo_d (O_LARGEFILE | O_ASYNC | O_WRONLY)
- #define F_file_flag_large_async_rw_d (O_LARGEFILE | O_ASYNC | O_RDRW)
- #define F_file_flag_large_async_create_ro_d (O_LARGEFILE | O_ASYNC | O_CREAT | O_RDONLY)
- #define F_file_flag_large_async_create_wo_d (O_LARGEFILE | O_ASYNC | O_CREAT | O_WRONLY)
- #define F_file_flag_large_async_create_rw_d (O_LARGEFILE | O_ASYNC | O_CREAT | O_RDRW)
- #define F_file_flag_large_async_create_new_ro_d (O_LARGEFILE | O_ASYNC | O_CREAT | O_EXCL | O_RDONLY)
- #define F_file_flag_large_async_create_new_wo_d (O_LARGEFILE | O_ASYNC | O_CREAT | O_EXCL | O_WRONLY)
- #define F_file_flag_large_async_create_new_rw_d (O_LARGEFILE | O_ASYNC | O_CREAT | O_EXCL | O_RDRW)
-#endif // _di_f_file_flag_d_
-
-/**
* File mode related functionality.
*
* There are two types of file modes that the f_file_mode_t macros are associated with.
extern "C" {
#endif
-#if !defined(_di_f_file_clone_) || !defined(_di_f_file_close_) || !defined(_di_f_file_close_flush_) || !defined(_di_f_file_copy_) || !defined(_di_f_file_create_) || !defined(_di_f_file_create_at_) || !defined(_di_f_file_stream_close_)
+#if !defined(_di_f_file_clone_) || !defined(_di_f_file_close_) || !defined(_di_f_file_copy_) || !defined(_di_f_file_create_) || !defined(_di_f_file_create_at_) || !defined(_di_f_file_stream_close_)
f_status_t private_f_file_close(f_file_t * const file) {
if (close(file->id) < 0) {
return F_none;
}
-#endif // !defined(_di_f_file_clone_) || !defined(_di_f_file_close_) || !defined(_di_f_file_close_flush_) || !defined(_di_f_file_copy_) || !defined(_di_f_file_create_) || !defined(_di_f_file_create_at_) || !defined(_di_f_file_stream_close_)
+#endif // !defined(_di_f_file_clone_) || !defined(_di_f_file_close_) || !defined(_di_f_file_copy_) || !defined(_di_f_file_create_) || !defined(_di_f_file_create_at_) || !defined(_di_f_file_stream_close_)
#if !defined(_di_f_file_copy_) || !defined(_di_f_file_clone_)
f_status_t private_f_file_copy_content(const f_string_static_t source, const f_string_static_t destination, const f_number_unsigned_t size_block) {
}
#endif // !defined(_di_f_file_create_device_at_) || !defined(_di_f_file_create_node_at_)
-#if !defined(_di_f_file_clone_) || !defined(_di_f_file_close_) || !defined(_di_f_file_close_flush_) || !defined(_di_f_file_copy_) || !defined(_di_f_file_create_) || !defined(_di_f_file_create_at_) || !defined(_di_f_file_stream_close_)
+#if !defined(_di_f_file_clone_) || !defined(_di_f_file_close_) || !defined(_di_f_file_copy_) || !defined(_di_f_file_create_) || !defined(_di_f_file_create_at_) || !defined(_di_f_file_stream_close_)
f_status_t private_f_file_flush(const f_file_t file) {
if (fsync(file.id) < 0) {
return F_none;
}
-#endif // !defined(_di_f_file_clone_) || !defined(_di_f_file_close_) || !defined(_di_f_file_close_flush_) || !defined(_di_f_file_copy_) || !defined(_di_f_file_create_) || !defined(_di_f_file_create_at_) || !defined(_di_f_file_stream_close_)
+#endif // !defined(_di_f_file_clone_) || !defined(_di_f_file_close_) || !defined(_di_f_file_copy_) || !defined(_di_f_file_create_) || !defined(_di_f_file_create_at_) || !defined(_di_f_file_stream_close_)
#if !defined(_di_f_file_link_) || !defined(_di_f_file_copy_)
f_status_t private_f_file_link(const f_string_static_t target, const f_string_static_t point) {
* @see f_file_clone()
* @see f_file_clone_at()
* @see f_file_close()
- * @see f_file_close_flush()
* @see f_file_copy()
* @see f_file_create()
* @see f_file_create_at()
* @see f_file_stream_close()
*/
-#if !defined(_di_f_file_clone_) || !defined(_di_f_file_close_) || !defined(_di_f_file_close_flush_) || !defined(_di_f_file_copy_) || !defined(_di_f_file_create_) || !defined(_di_f_file_create_at_) || !defined(_di_f_file_stream_close_)
+#if !defined(_di_f_file_clone_) || !defined(_di_f_file_close_) || !defined(_di_f_file_copy_) || !defined(_di_f_file_create_) || !defined(_di_f_file_create_at_) || !defined(_di_f_file_stream_close_)
extern f_status_t private_f_file_close(f_file_t * const file) F_attribute_visibility_internal_d;
-#endif // !defined(_di_f_file_clone_) || !defined(_di_f_file_close_) || !defined(_di_f_file_close_flush_) || !defined(_di_f_file_copy_) || !defined(_di_f_file_create_) || !defined(_di_f_file_create_at_) || !defined(_di_f_file_stream_close_)
+#endif // !defined(_di_f_file_clone_) || !defined(_di_f_file_close_) || !defined(_di_f_file_copy_) || !defined(_di_f_file_create_) || !defined(_di_f_file_create_at_) || !defined(_di_f_file_stream_close_)
/**
* Copy a file.
* @see f_file_clone()
* @see f_file_clone_at()
* @see f_file_close()
- * @see f_file_close_flush()
* @see f_file_copy()
* @see f_file_create()
* @see f_file_create_at()
* @see f_file_stream_close()
*/
-#if !defined(_di_f_file_clone_) || !defined(_di_f_file_close_) || !defined(_di_f_file_close_flush_) || !defined(_di_f_file_copy_) || !defined(_di_f_file_create_) || !defined(_di_f_file_create_at_) || !defined(_di_f_file_stream_close_)
+#if !defined(_di_f_file_clone_) || !defined(_di_f_file_close_) || !defined(_di_f_file_copy_) || !defined(_di_f_file_create_) || !defined(_di_f_file_create_at_) || !defined(_di_f_file_stream_close_)
extern f_status_t private_f_file_flush(const f_file_t file) F_attribute_visibility_internal_d;
-#endif // !defined(_di_f_file_clone_) || !defined(_di_f_file_close_) || !defined(_di_f_file_close_flush_) || !defined(_di_f_file_copy_) || !defined(_di_f_file_create_) || !defined(_di_f_file_create_at_) || !defined(_di_f_file_stream_close_)
+#endif // !defined(_di_f_file_clone_) || !defined(_di_f_file_close_) || !defined(_di_f_file_copy_) || !defined(_di_f_file_create_) || !defined(_di_f_file_create_at_) || !defined(_di_f_file_stream_close_)
/**
* Private implementation of f_file_link().
build_libraries -lc -lcmocka
build_libraries-individual -lf_memory -lf_string -lf_file
-build_sources_program test-file-access.c test-file-access_at.c test-file-clone.c test-file-close.c test-file-close_flush.c test-file-copy.c test-file-create.c test-file-create_at.c test-file-create_device.c test-file-create_device_at.c test-file-create_fifo.c test-file-create_fifo_at.c test-file-create_node.c test-file-create_node_at.c test-file-descriptor.c test-file-exists.c test-file-exists_at.c test-file-flush.c test-file-group_read.c test-file-is.c test-file-is_at.c test-file-is_stat.c test-file-link.c test-file-link_at.c test-file-link_hard.c test-file-link_hard_at.c test-file-link_read.c test-file-link_read_at.c test-file-mode_determine.c test-file-mode_from_string.c test-file-mode_read.c test-file-mode_read_at.c test-file-mode_set.c test-file-mode_set_at.c test-file-mode_to_mode.c test-file-name_base.c test-file-name_directory.c test-file-open.c test-file-open_at.c test-file-owner_read.c test-file-read.c test-file-read_block.c test-file-read_until.c test-file-remove.c test-file-remove_at.c test-file-rename.c test-file-rename_at.c test-file-role_change.c test-file-role_change_at.c test-file-seek.c test-file-size.c test-file-size_at.c test-file-size_by_id.c test-file-stat.c test-file-stat_at.c test-file-stat_by_id.c test-file-stream_close.c test-file-stream_open_descriptor.c test-file-stream_open.c test-file-stream_read.c test-file-stream_read_block.c test-file-stream_read_until.c test-file-stream_reopen.c test-file-stream_write.c test-file-stream_write_block.c test-file-stream_write_until.c test-file-stream_write_range.c test-file-touch.c test-file-touch_at.c test-file-type.c test-file-type_at.c test-file-umask_get.c test-file-umask_set.c test-file-write.c test-file-write_block.c test-file-write_until.c test-file-write_range.c
+build_sources_program test-file-access.c test-file-access_at.c test-file-clone.c test-file-close.c test-file-copy.c test-file-create.c test-file-create_at.c test-file-create_device.c test-file-create_device_at.c test-file-create_fifo.c test-file-create_fifo_at.c test-file-create_node.c test-file-create_node_at.c test-file-descriptor.c test-file-exists.c test-file-exists_at.c test-file-flush.c test-file-group_read.c test-file-is.c test-file-is_at.c test-file-is_stat.c test-file-link.c test-file-link_at.c test-file-link_hard.c test-file-link_hard_at.c test-file-link_read.c test-file-link_read_at.c test-file-mode_determine.c test-file-mode_from_string.c test-file-mode_read.c test-file-mode_read_at.c test-file-mode_set.c test-file-mode_set_at.c test-file-mode_to_mode.c test-file-name_base.c test-file-name_directory.c test-file-open.c test-file-open_at.c test-file-owner_read.c test-file-read.c test-file-read_block.c test-file-read_until.c test-file-remove.c test-file-remove_at.c test-file-rename.c test-file-rename_at.c test-file-role_change.c test-file-role_change_at.c test-file-seek.c test-file-size.c test-file-size_at.c test-file-size_by_id.c test-file-stat.c test-file-stat_at.c test-file-stat_by_id.c test-file-stream_close.c test-file-stream_open_descriptor.c test-file-stream_open.c test-file-stream_read.c test-file-stream_read_block.c test-file-stream_read_until.c test-file-stream_reopen.c test-file-stream_write.c test-file-stream_write_block.c test-file-stream_write_until.c test-file-stream_write_range.c test-file-touch.c test-file-touch_at.c test-file-type.c test-file-type_at.c test-file-umask_get.c test-file-umask_set.c test-file-write.c test-file-write_block.c test-file-write_until.c test-file-write_range.c
build_sources_program test-file.c
build_script no
void test__f_file_access_at__fails(void **state) {
+ const f_file_t file = macro_f_file_t_initialize2(F_type_output_d, F_type_descriptor_output_d, F_file_flag_write_only_d);
const f_string_static_t path = macro_f_string_static_t_initialize("test", 0, 4);
{
will_return(__wrap_faccessat, true);
will_return(__wrap_faccessat, errnos[i]);
- const f_status_t status = f_file_access_at(0, path, F_file_access_mode_exist_d, 0);
+ const f_status_t status = f_file_access_at(file, path, F_file_access_mode_exist_d, 0);
assert_int_equal(status, statuss[i]);
} // for
will_return(__wrap_faccessat, true);
will_return(__wrap_faccessat, errnos[i]);
- const f_status_t status = f_file_access_at(0, path, modes[j], 0);
+ const f_status_t status = f_file_access_at(file, path, modes[j], 0);
assert_int_equal(status, statuss[i]);
} // for
void test__f_file_access_at__returns_data_not(void **state) {
+ const f_file_t file = macro_f_file_t_initialize2(F_type_output_d, F_type_descriptor_output_d, F_file_flag_write_only_d);
+
{
- const f_status_t status = f_file_access_at(0, f_string_empty_s, 0, 0);
+ const f_status_t status = f_file_access_at(file, f_string_empty_s, 0, 0);
assert_int_equal(status, F_data_not);
}
}
+void test__f_file_access_at__returns_file_descriptor_not(void **state) {
+
+ const f_file_t file = macro_f_file_t_initialize2(F_type_output_d, -1, F_file_flag_write_only_d);
+
+ {
+ const f_status_t status = f_file_access_at(file, f_string_empty_s, 0, 0);
+
+ assert_int_equal(status, F_file_descriptor_not);
+ }
+}
+
void test__f_file_access_at__works(void **state) {
+ const f_file_t file = macro_f_file_t_initialize2(F_type_output_d, F_type_descriptor_output_d, F_file_flag_write_only_d);
const f_string_static_t path = macro_f_string_static_t_initialize("test", 0, 4);
{
will_return(__wrap_faccessat, false);
will_return(__wrap_faccessat, 0);
- const f_status_t status = f_file_access_at(0, path, F_file_access_mode_exist_d, 0);
+ const f_status_t status = f_file_access_at(file, path, F_file_access_mode_exist_d, 0);
assert_int_equal(status, F_true);
}
extern void test__f_file_access_at__returns_data_not(void **state);
/**
+ * Test that function works but the descriptor is not valid.
+ *
+ * @see f_file_access_at()
+ */
+extern void test__f_file_access_at__returns_file_descriptor_not(void **state);
+
+/**
* Test that function works.
*
* @see f_file_access_at()
for (int i = 0; i < 6; ++i) {
- int id = 0;
+ f_file_t file = macro_f_file_t_initialize2(F_type_output_d, F_type_descriptor_output_d, F_file_flag_write_only_d);
will_return(__wrap_close, true);
will_return(__wrap_close, errnos[i]);
- const f_status_t status = f_file_close(&id);
+ const f_status_t status = f_file_close(&file);
assert_int_equal(status, F_status_set_error(statuss[i]));
if (errnos[i] == EBADF || errnos[i] == EINTR) {
- assert_int_equal(id, 0);
+ assert_int_equal(file.id, F_type_descriptor_output_d);
}
else {
- assert_int_equal(id, -1);
+ assert_int_equal(file.id, -1);
}
} // for
}
}
}
-void test__f_file_close__works(void **state) {
-
- {
- int id = 0;
+void test__f_file_close__returns_file_descriptor_not(void **state) {
- will_return(__wrap_close, false);
- will_return(__wrap_close, 0);
+ f_file_t file = macro_f_file_t_initialize2(F_type_output_d, -1, F_file_flag_write_only_d);
- const f_status_t status = f_file_close(&id);
+ {
+ const f_status_t status = f_file_close(&file);
- assert_int_equal(status, F_none);
- assert_int_equal(id, -1);
+ assert_int_equal(status, F_file_descriptor_not);
}
}
-void test__f_file_close__works_already_closed(void **state) {
+void test__f_file_close__works(void **state) {
+
+ f_file_t file = macro_f_file_t_initialize2(F_type_output_d, F_type_descriptor_output_d, F_file_flag_write_only_d);
{
- int id = -1;
- const f_status_t status = f_file_close(&id);
+ will_return(__wrap_close, false);
+ will_return(__wrap_close, 0);
+
+ const f_status_t status = f_file_close(&file);
assert_int_equal(status, F_none);
- assert_int_equal(id, -1);
+ assert_int_equal(file.id, -1);
}
}
extern void test__f_file_close__parameter_checking(void **state);
/**
- * Test that function works.
+ * Test that function works but the descriptor is not valid.
*
* @see f_file_close()
*/
-extern void test__f_file_close__works(void **state);
+extern void test__f_file_close__returns_file_descriptor_not(void **state);
/**
- * Test that function works when already closed.
+ * Test that function works.
*
* @see f_file_close()
*/
-extern void test__f_file_close__works_already_closed(void **state);
+extern void test__f_file_close__works(void **state);
#endif // _TEST__F_file_close_h
+++ /dev/null
-#include "test-file.h"
-#include "test-file-close_flush.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-void test__f_file_close_flush__fails(void **state) {
-
- {
- int errnos[] = {
- EBADF,
- EINTR,
- EIO,
- ENOSPC,
- EDQUOT,
- mock_errno_generic,
- };
-
- f_status_t statuss[] = {
- F_file_descriptor,
- F_interrupt,
- F_input_output,
- F_space_not,
- F_filesystem_quota_block,
- F_file_close,
- };
-
- for (int i = 0; i < 6; ++i) {
-
- int id = 0;
-
- will_return(__wrap_fsync, false);
- will_return(__wrap_fsync, 0);
-
- will_return(__wrap_close, true);
- will_return(__wrap_close, errnos[i]);
-
- const f_status_t status = f_file_close_flush(&id);
-
- assert_int_equal(status, F_status_set_error(statuss[i]));
-
- if (errnos[i] == EBADF || errnos[i] == EINTR) {
- assert_int_equal(id, 0);
- }
- else {
- assert_int_equal(id, -1);
- }
- } // for
- }
-}
-
-void test__f_file_close_flush__parameter_checking(void **state) {
-
- {
- const f_status_t status = f_file_close_flush(0);
-
- assert_int_equal(status, F_status_set_error(F_parameter));
- }
-}
-
-void test__f_file_close_flush__works(void **state) {
-
- {
- int id = 0;
-
- will_return(__wrap_fsync, false);
- will_return(__wrap_fsync, 0);
-
- will_return(__wrap_close, false);
- will_return(__wrap_close, 0);
-
- const f_status_t status = f_file_close_flush(&id);
-
- assert_int_equal(status, F_none);
- assert_int_equal(id, -1);
- }
-}
-
-void test__f_file_close_flush__works_already_closed(void **state) {
-
- {
- int id = -1;
-
- const f_status_t status = f_file_close_flush(&id);
-
- assert_int_equal(status, F_none);
- assert_int_equal(id, -1);
- }
-}
-
-#ifdef __cplusplus
-} // extern "C"
-#endif
+++ /dev/null
-/**
- * FLL - Level 0
- *
- * Project: File
- * API Version: 0.7
- * Licenses: lgpl-2.1-or-later
- *
- * Test the file project.
- */
-#ifndef _TEST__F_file_close_flush_h
-#define _TEST__F_file_close_flush_h
-
-/**
- * Test that function fails.
- *
- * @see f_file_close_flush()
- */
-extern void test__f_file_close_flush__fails(void **state);
-
-/**
- * Test that parameter checking works as expected.
- *
- * @see f_file_close_flush()
- */
-extern void test__f_file_close_flush__parameter_checking(void **state);
-
-/**
- * Test that function works.
- *
- * @see f_file_close_flush()
- */
-extern void test__f_file_close_flush__works(void **state);
-
-/**
- * Test that function works.
- *
- * @see f_file_close_flush()
- */
-extern void test__f_file_close_flush__works_already_closed(void **state);
-
-#endif // _TEST__F_file_close_flush_h
void test__f_file_create_at__fails(void **state) {
+ const f_file_t file = macro_f_file_t_initialize2(F_type_output_d, F_type_descriptor_output_d, F_file_flag_write_only_d);
const f_string_static_t path = macro_f_string_static_t_initialize("test", 0, 4);
{
will_return(__wrap_openat, true);
will_return(__wrap_openat, errnos[i]);
- const f_status_t status = f_file_create_at(0, path, 0, F_false);
+ const f_status_t status = f_file_create_at(file, path, 0, F_false);
assert_int_equal(status, F_status_set_error(statuss[i]));
} // for
will_return(__wrap_close, true);
will_return(__wrap_close, errnos[i]);
- const f_status_t status = f_file_create_at(0, path, 0, F_false);
+ const f_status_t status = f_file_create_at(file, path, 0, F_false);
assert_int_equal(status, F_status_set_error(statuss[i]));
} // for
void test__f_file_create_at__returns_data_not(void **state) {
+ const f_file_t file = macro_f_file_t_initialize2(F_type_output_d, F_type_descriptor_output_d, F_file_flag_write_only_d);
+
{
- const f_status_t status = f_file_create_at(0, f_string_empty_s, 0, F_false);
+ const f_status_t status = f_file_create_at(file, f_string_empty_s, 0, F_false);
assert_int_equal(status, F_data_not);
}
}
+void test__f_file_create_at__returns_file_descriptor_not(void **state) {
+
+ const f_file_t file = macro_f_file_t_initialize2(F_type_output_d, -1, F_file_flag_write_only_d);
+
+ {
+ const f_status_t status = f_file_create_at(file, f_string_empty_s, 0, F_false);
+
+ assert_int_equal(status, F_file_descriptor_not);
+ }
+}
+
void test__f_file_create_at__works(void **state) {
+ const f_file_t file = macro_f_file_t_initialize2(F_type_output_d, F_type_descriptor_output_d, F_file_flag_write_only_d);
const f_string_static_t path = macro_f_string_static_t_initialize("test", 0, 4);
{
will_return(__wrap_close, false);
will_return(__wrap_close, 0);
- const f_status_t status = f_file_create_at(0, path, 0, F_false);
+ const f_status_t status = f_file_create_at(file, path, 0, F_false);
assert_int_equal(status, F_none);
}
extern void test__f_file_create_at__returns_data_not(void **state);
/**
+ * Test that function works but the descriptor is not valid.
+ *
+ * @see f_file_create_at()
+ */
+extern void test__f_file_create_at__returns_file_descriptor_not(void **state);
+
+/**
* Test that function works.
*
* @see f_file_create_at()
void test__f_file_create_device_at__fails(void **state) {
+ const f_file_t file = macro_f_file_t_initialize2(F_type_output_d, F_type_descriptor_output_d, F_file_flag_write_only_d);
const f_string_static_t path = macro_f_string_static_t_initialize("test", 0, 4);
{
will_return(__wrap_mknodat, true);
will_return(__wrap_mknodat, errnos[i]);
- const f_status_t status = f_file_create_device_at(0, path, modes[j], 1, 1);
+ const f_status_t status = f_file_create_device_at(file, path, modes[j], 1, 1);
assert_int_equal(status, F_status_set_error(statuss[i]));
} // for
void test__f_file_create_device_at__returns_data_not(void **state) {
+ const f_file_t file = macro_f_file_t_initialize2(F_type_output_d, F_type_descriptor_output_d, F_file_flag_write_only_d);
+
{
- const f_status_t status = f_file_create_device_at(0, f_string_empty_s, 0, 0, 0);
+ const f_status_t status = f_file_create_device_at(file, f_string_empty_s, 0, 0, 0);
assert_int_equal(status, F_data_not);
}
}
+void test__f_file_create_device_at__returns_file_descriptor_not(void **state) {
+
+ const f_file_t file = macro_f_file_t_initialize2(F_type_output_d, -1, F_file_flag_write_only_d);
+
+ {
+ const f_status_t status = f_file_create_device_at(file, f_string_empty_s, 0, 0, 0);
+
+ assert_int_equal(status, F_file_descriptor_not);
+ }
+}
+
void test__f_file_create_device_at__returns_supported_not(void **state) {
+ const f_file_t file = macro_f_file_t_initialize2(F_type_output_d, F_type_descriptor_output_d, F_file_flag_write_only_d);
const f_string_static_t path = macro_f_string_static_t_initialize("test", 0, 4);
const int modes[] = {
{
for (uint8_t i = 0; i < 5; ++i) {
- const f_status_t status = f_file_create_device_at(0, path, modes[i], 0, 0);
+ const f_status_t status = f_file_create_device_at(file, path, modes[i], 0, 0);
assert_int_equal(F_status_set_fine(status), F_support_not);
} // for
void test__f_file_create_device_at__works(void **state) {
+ const f_file_t file = macro_f_file_t_initialize2(F_type_output_d, F_type_descriptor_output_d, F_file_flag_write_only_d);
const f_string_static_t path = macro_f_string_static_t_initialize("test", 0, 4);
const int modes[] = {
will_return(__wrap_mknodat, false);
will_return(__wrap_mknodat, 0);
- const f_status_t status = f_file_create_device_at(0, path, modes[i], 1, 1);
+ const f_status_t status = f_file_create_device_at(file, path, modes[i], 1, 1);
assert_int_equal(status, F_none);
} // for
extern void test__f_file_create_device_at__returns_data_not(void **state);
/**
+ * Test that function works but the descriptor is not valid.
+ *
+ * @see f_file_create_device_at()
+ */
+extern void test__f_file_create_device_at__returns_file_descriptor_not(void **state);
+
+/**
* Test that function works but the file type is not supported (specified via mode).
*
* @see f_file_create_device_at()
void test__f_file_create_fifo_at__fails(void **state) {
+ const f_file_t file = macro_f_file_t_initialize2(F_type_output_d, F_type_descriptor_output_d, F_file_flag_write_only_d);
const f_string_static_t path = macro_f_string_static_t_initialize("test", 0, 4);
{
will_return(__wrap_mkfifoat, true);
will_return(__wrap_mkfifoat, errnos[i]);
- const f_status_t status = f_file_create_fifo_at(0, path, 0);
+ const f_status_t status = f_file_create_fifo_at(file, path, 0);
assert_int_equal(status, F_status_set_error(statuss[i]));
} // for
void test__f_file_create_fifo_at__returns_data_not(void **state) {
+ const f_file_t file = macro_f_file_t_initialize2(F_type_output_d, F_type_descriptor_output_d, F_file_flag_write_only_d);
+
{
- const f_status_t status = f_file_create_fifo_at(0, f_string_empty_s, 0);
+ const f_status_t status = f_file_create_fifo_at(file, f_string_empty_s, 0);
assert_int_equal(status, F_data_not);
}
}
+void test__f_file_create_fifo_at__returns_file_descriptor_not(void **state) {
+
+ const f_file_t file = macro_f_file_t_initialize2(F_type_output_d, -1, F_file_flag_write_only_d);
+
+ {
+ const f_status_t status = f_file_create_fifo_at(file, f_string_empty_s, 0);
+
+ assert_int_equal(status, F_file_descriptor_not);
+ }
+}
+
void test__f_file_create_fifo_at__works(void **state) {
+ const f_file_t file = macro_f_file_t_initialize2(F_type_output_d, F_type_descriptor_output_d, F_file_flag_write_only_d);
const f_string_static_t path = macro_f_string_static_t_initialize("test", 0, 4);
for (uint8_t i = 0; i < 3; ++i) {
will_return(__wrap_mkfifoat, false);
will_return(__wrap_mkfifoat, 0);
- const f_status_t status = f_file_create_fifo_at(0, path, 0);
+ const f_status_t status = f_file_create_fifo_at(file, path, 0);
assert_int_equal(status, F_none);
} // for
extern void test__f_file_create_fifo_at__returns_data_not(void **state);
/**
+ * Test that function works but the descriptor is not valid.
+ *
+ * @see f_file_create_fifo_at()
+ */
+extern void test__f_file_create_fifo_at__returns_file_descriptor_not(void **state);
+
+/**
* Test that function works.
*
* @see f_file_create_fifo_at()
void test__f_file_create_node_at__fails(void **state) {
+ const f_file_t file = macro_f_file_t_initialize2(F_type_output_d, F_type_descriptor_output_d, F_file_flag_write_only_d);
const f_string_static_t path = macro_f_string_static_t_initialize("test", 0, 4);
{
will_return(__wrap_mknodat, true);
will_return(__wrap_mknodat, errnos[i]);
- const f_status_t status = f_file_create_node_at(0, path, modes[j], 1);
+ const f_status_t status = f_file_create_node_at(file, path, modes[j], 1);
assert_int_equal(status, F_status_set_error(statuss[i]));
} // for
void test__f_file_create_node_at__returns_data_not(void **state) {
+ const f_file_t file = macro_f_file_t_initialize2(F_type_output_d, F_type_descriptor_output_d, F_file_flag_write_only_d);
+
{
- const f_status_t status = f_file_create_node_at(0, f_string_empty_s, 0, 0);
+ const f_status_t status = f_file_create_node_at(file, f_string_empty_s, 0, 0);
assert_int_equal(status, F_data_not);
}
}
+void test__f_file_create_node_at__returns_file_descriptor_not(void **state) {
+
+ const f_file_t file = macro_f_file_t_initialize2(F_type_output_d, -1, F_file_flag_write_only_d);
+
+ {
+ const f_status_t status = f_file_create_node_at(file, f_string_empty_s, 0, 0);
+
+ assert_int_equal(status, F_file_descriptor_not);
+ }
+}
+
void test__f_file_create_node_at__returns_supported_not(void **state) {
+ const f_file_t file = macro_f_file_t_initialize2(F_type_output_d, F_type_descriptor_output_d, F_file_flag_write_only_d);
const f_string_static_t path = macro_f_string_static_t_initialize("test", 0, 4);
const int modes[] = {
{
for (uint8_t i = 0; i < 5; ++i) {
- const f_status_t status = f_file_create_node_at(0, path, modes[i], 0);
+ const f_status_t status = f_file_create_node_at(file, path, modes[i], 0);
assert_int_equal(F_status_set_fine(status), F_support_not);
} // for
void test__f_file_create_node_at__works(void **state) {
+ const f_file_t file = macro_f_file_t_initialize2(F_type_output_d, F_type_descriptor_output_d, F_file_flag_write_only_d);
const f_string_static_t path = macro_f_string_static_t_initialize("test", 0, 4);
const int modes[] = {
will_return(__wrap_mknodat, false);
will_return(__wrap_mknodat, 0);
- const f_status_t status = f_file_create_node_at(0, path, modes[i], 1);
+ const f_status_t status = f_file_create_node_at(file, path, modes[i], 1);
assert_int_equal(status, F_none);
} // for
extern void test__f_file_create_node_at__returns_data_not(void **state);
/**
+ * Test that function works but the descriptor is not valid.
+ *
+ * @see f_file_create_node_at()
+ */
+extern void test__f_file_create_node_at__returns_file_descriptor_not(void **state);
+
+/**
* Test that function works but the file type is not supported (specified via mode).
*
* @see f_file_create_node_at()
void test__f_file_descriptor__fails(void **state) {
{
- f_file_t file = f_file_t_initialize;
+ f_file_t file = macro_f_file_t_initialize2(F_type_output_d, F_type_descriptor_output_d, F_file_flag_write_only_d);
will_return(__wrap_fileno, -1);
const f_status_t status = f_file_descriptor(&file);
- assert_int_equal(F_status_set_fine(status), F_stream_not);
+ assert_int_equal(F_status_set_fine(status), F_file_descriptor_not);
}
}
}
}
+void test__f_file_descriptor__returns_stream_not(void **state) {
+
+ f_file_t file = macro_f_file_t_initialize2(0, F_type_descriptor_output_d, F_file_flag_write_only_d);
+
+ {
+ const f_status_t status = f_file_descriptor(&file);
+
+ assert_int_equal(status, F_stream_not);
+ }
+}
+
void test__f_file_descriptor__works(void **state) {
{
- const int id = 1;
- f_file_t file = f_file_t_initialize;
+ f_file_t file = macro_f_file_t_initialize2(F_type_output_d, F_type_descriptor_output_d, F_file_flag_write_only_d);
- will_return(__wrap_fileno, id);
+ will_return(__wrap_fileno, F_type_descriptor_output_d);
const f_status_t status = f_file_descriptor(&file);
assert_int_equal(status, F_none);
- assert_int_equal(file.id, id);
+ assert_int_equal(file.id, F_type_descriptor_output_d);
}
}
extern void test__f_file_descriptor__parameter_checking(void **state);
/**
+ * Test that function works but the stream is not valid.
+ *
+ * @see f_file_descriptor()
+ */
+extern void test__f_file_descriptor__returns_stream_not(void **state);
+
+/**
* Test that function works.
*
* @see f_file_descriptor()
void test__f_file_exists_at__fails(void **state) {
+ const f_file_t file = macro_f_file_t_initialize2(F_type_output_d, F_type_descriptor_output_d, F_file_flag_write_only_d);
const f_string_static_t path = macro_f_string_static_t_initialize("test", 0, 4);
int errnos[] = {
will_return(__wrap_fstatat, true);
will_return(__wrap_fstatat, errnos[i]);
- const f_status_t status = f_file_exists_at(0, path, 0);
+ const f_status_t status = f_file_exists_at(file, path, 0);
assert_int_equal(status, statuss[i]);
} // for
void test__f_file_exists_at__returns_data_not(void **state) {
+ const f_file_t file = macro_f_file_t_initialize2(F_type_output_d, F_type_descriptor_output_d, F_file_flag_write_only_d);
+
{
- const f_status_t status = f_file_exists_at(0, f_string_empty_s, 0);
+ const f_status_t status = f_file_exists_at(file, f_string_empty_s, 0);
assert_int_equal(status, F_data_not);
}
}
+void test__f_file_exists_at__returns_file_descriptor_not(void **state) {
+
+ const f_file_t file = macro_f_file_t_initialize2(F_type_output_d, -1, F_file_flag_write_only_d);
+
+ {
+ const f_status_t status = f_file_exists_at(file, f_string_empty_s, 0);
+
+ assert_int_equal(status, F_file_descriptor_not);
+ }
+}
+
void test__f_file_exists_at__works(void **state) {
+ const f_file_t file = macro_f_file_t_initialize2(F_type_output_d, F_type_descriptor_output_d, F_file_flag_write_only_d);
const f_string_static_t path = macro_f_string_static_t_initialize("test", 0, 4);
struct stat statistics;
will_return(__wrap_fstatat, &statistics);
will_return(__wrap_fstatat, 0);
- const f_status_t status = f_file_exists_at(0, path, 0);
+ const f_status_t status = f_file_exists_at(file, path, 0);
assert_int_equal(status, F_true);
}
extern void test__f_file_exists_at__returns_data_not(void **state);
/**
+ * Test that function works but the descriptor is not valid.
+ *
+ * @see f_file_exists_at()
+ */
+extern void test__f_file_exists_at__returns_file_descriptor_not(void **state);
+
+/**
* Test that function works.
*
* @see f_file_exists_at()
void test__f_file_flush__fails(void **state) {
+ f_file_t file = macro_f_file_t_initialize2(F_type_output_d, F_type_descriptor_output_d, F_file_flag_write_only_d);
+
int errnos[] = {
EBADF,
EDQUOT,
will_return(__wrap_fsync, true);
will_return(__wrap_fsync, errnos[i]);
- const f_status_t status = f_file_flush(0);
+ const f_status_t status = f_file_flush(file);
assert_int_equal(status, F_status_set_error(statuss[i]));
} // for
}
+void test__f_file_flush__returns_file_descriptor_not(void **state) {
+
+ const f_file_t file = macro_f_file_t_initialize2(F_type_output_d, -1, F_file_flag_write_only_d);
+
+ {
+ const f_status_t status = f_file_flush(file);
+
+ assert_int_equal(status, F_file_descriptor_not);
+ }
+}
+
void test__f_file_flush__works(void **state) {
+ f_file_t file = macro_f_file_t_initialize2(F_type_output_d, F_type_descriptor_output_d, F_file_flag_write_only_d);
+
{
will_return(__wrap_fsync, false);
will_return(__wrap_fsync, 0);
- const f_status_t status = f_file_flush(0);
+ const f_status_t status = f_file_flush(file);
assert_int_equal(status, F_none);
}
extern void test__f_file_flush__fails(void **state);
/**
+ * Test that function works but the descriptor is not valid.
+ *
+ * @see f_file_flush()
+ */
+extern void test__f_file_flush__returns_file_descriptor_not(void **state);
+
+/**
* Test that function works.
*
* @see f_file_flush()
void test__f_file_is_at__fails(void **state) {
+ const f_file_t file = macro_f_file_t_initialize2(F_type_output_d, F_type_descriptor_output_d, F_file_flag_write_only_d);
const f_string_static_t path = macro_f_string_static_t_initialize("test", 0, 4);
int errnos[] = {
will_return(__wrap_fstatat, true);
will_return(__wrap_fstatat, errnos[i]);
- const f_status_t status = f_file_is_at(0, path, types[j], 0);
+ const f_status_t status = f_file_is_at(file, path, types[j], 0);
assert_int_equal(status, statuss[i]);
} // for
void test__f_file_is_at__returns_data_not(void **state) {
+ const f_file_t file = macro_f_file_t_initialize2(F_type_output_d, F_type_descriptor_output_d, F_file_flag_write_only_d);
+
{
- const f_status_t status = f_file_is_at(0, f_string_empty_s, 0, 0);
+ const f_status_t status = f_file_is_at(file, f_string_empty_s, 0, 0);
assert_int_equal(status, F_data_not);
}
}
+void test__f_file_is_at__returns_file_descriptor_not(void **state) {
+
+ const f_file_t file = macro_f_file_t_initialize2(F_type_output_d, -1, F_file_flag_write_only_d);
+
+ {
+ const f_status_t status = f_file_is_at(file, f_string_empty_s, 0, 0);
+
+ assert_int_equal(status, F_file_descriptor_not);
+ }
+}
+
void test__f_file_is_at__returns_false(void **state) {
+ const f_file_t file = macro_f_file_t_initialize2(F_type_output_d, F_type_descriptor_output_d, F_file_flag_write_only_d);
const f_string_static_t path = macro_f_string_static_t_initialize("test", 0, 4);
f_status_t types[] = {
will_return(__wrap_fstatat, &statistics);
will_return(__wrap_fstatat, 0);
- const f_status_t status = f_file_is_at(0, path, types[i], 0);
+ const f_status_t status = f_file_is_at(file, path, types[i], 0);
assert_int_equal(status, F_false);
} // for
void test__f_file_is_at__returns_true(void **state) {
+ const f_file_t file = macro_f_file_t_initialize2(F_type_output_d, F_type_descriptor_output_d, F_file_flag_write_only_d);
const f_string_static_t path = macro_f_string_static_t_initialize("test", 0, 4);
f_status_t types[] = {
will_return(__wrap_fstatat, &statistics);
will_return(__wrap_fstatat, 0);
- const f_status_t status = f_file_is_at(0, path, types[i], 0);
+ const f_status_t status = f_file_is_at(file, path, types[i], 0);
assert_int_equal(status, F_true);
} // for
extern void test__f_file_is_at__returns_data_not(void **state);
/**
+ * Test that function works but the path is empty.
+ *
+ * @see f_file_is_at()
+ */
+extern void test__f_file_is_at__returns_file_descriptor_not(void **state);
+
+/**
* Test that function works and returns F_false.
*
* @see f_file_is_at()
#define _TEST__F_file_is_stat_h
/**
- * Test that function fails.
- *
- * @see f_file_is_stat()
- */
-extern void test__f_file_is_stat__fails(void **state);
-
-/**
* Test that function works and returns F_false.
*
* @see f_file_is_stat()
void test__f_file_link_at__fails(void **state) {
+ const f_file_t file = macro_f_file_t_initialize2(F_type_output_d, F_type_descriptor_output_d, F_file_flag_write_only_d);
const f_string_static_t path = macro_f_string_static_t_initialize("test", 0, 4);
int errnos[] = {
will_return(__wrap_symlinkat, true);
will_return(__wrap_symlinkat, errnos[i]);
- const f_status_t status = f_file_link_at(0, path, path);
+ const f_status_t status = f_file_link_at(file, path, path);
assert_int_equal(status, F_status_set_error(statuss[i]));
} // for
void test__f_file_link_at__returns_data_not(void **state) {
+ const f_file_t file = macro_f_file_t_initialize2(F_type_output_d, F_type_descriptor_output_d, F_file_flag_write_only_d);
const f_string_static_t path = macro_f_string_static_t_initialize("test", 0, 4);
{
- const f_status_t status = f_file_link_at(0, f_string_empty_s, f_string_empty_s);
+ const f_status_t status = f_file_link_at(file, f_string_empty_s, f_string_empty_s);
assert_int_equal(status, F_data_not);
}
{
- const f_status_t status = f_file_link_at(0, path, f_string_empty_s);
+ const f_status_t status = f_file_link_at(file, path, f_string_empty_s);
assert_int_equal(status, F_data_not);
}
{
- const f_status_t status = f_file_link_at(0, f_string_empty_s, path);
+ const f_status_t status = f_file_link_at(file, f_string_empty_s, path);
assert_int_equal(status, F_data_not);
}
}
+void test__f_file_link_at__returns_file_descriptor_not(void **state) {
+
+ const f_file_t file = macro_f_file_t_initialize2(F_type_output_d, -1, F_file_flag_write_only_d);
+ const f_string_static_t path = macro_f_string_static_t_initialize("test", 0, 4);
+
+ {
+ const f_status_t status = f_file_link_at(file, path, path);
+
+ assert_int_equal(status, F_file_descriptor_not);
+ }
+}
+
void test__f_file_link_at__works(void **state) {
+ const f_file_t file = macro_f_file_t_initialize2(F_type_output_d, F_type_descriptor_output_d, F_file_flag_write_only_d);
const f_string_static_t path = macro_f_string_static_t_initialize("test", 0, 4);
{
will_return(__wrap_symlinkat, false);
will_return(__wrap_symlinkat, 0);
- const f_status_t status = f_file_link_at(0, path, path);
+ const f_status_t status = f_file_link_at(file, path, path);
assert_int_equal(status, F_none);
}
extern void test__f_file_link_at__returns_data_not(void **state);
/**
+ * Test that function works but the descriptor is not valid.
+ *
+ * @see f_file_link_at()
+ */
+extern void test__f_file_link_at__returns_file_descriptor_not(void **state);
+
+/**
* Test that function works.
*
* @see f_file_link_at()
void test__f_file_link_hard_at__fails(void **state) {
+ const f_file_t target = macro_f_file_t_initialize2(F_type_output_d, F_type_descriptor_output_d, F_file_flag_write_only_d);
+ const f_file_t point = macro_f_file_t_initialize2(F_type_output_d, F_type_descriptor_output_d, F_file_flag_write_only_d);
const f_string_static_t path = macro_f_string_static_t_initialize("test", 0, 4);
int errnos[] = {
will_return(__wrap_linkat, true);
will_return(__wrap_linkat, errnos[i]);
- const f_status_t status = f_file_link_hard_at(0, 0, path, path, 0);
+ const f_status_t status = f_file_link_hard_at(target, point, path, path, 0);
assert_int_equal(status, F_status_set_error(statuss[i]));
} // for
void test__f_file_link_hard_at__returns_data_not(void **state) {
+ const f_file_t target = macro_f_file_t_initialize2(F_type_output_d, F_type_descriptor_output_d, F_file_flag_write_only_d);
+ const f_file_t point = macro_f_file_t_initialize2(F_type_output_d, F_type_descriptor_output_d, F_file_flag_write_only_d);
const f_string_static_t path = macro_f_string_static_t_initialize("test", 0, 4);
{
- const f_status_t status = f_file_link_hard_at(0, 0, f_string_empty_s, f_string_empty_s, 0);
+ const f_status_t status = f_file_link_hard_at(target, point, f_string_empty_s, f_string_empty_s, 0);
assert_int_equal(status, F_data_not);
}
{
- const f_status_t status = f_file_link_hard_at(0, 0, path, f_string_empty_s, 0);
+ const f_status_t status = f_file_link_hard_at(target, point, path, f_string_empty_s, 0);
assert_int_equal(status, F_data_not);
}
{
- const f_status_t status = f_file_link_hard_at(0, 0, f_string_empty_s, path, 0);
+ const f_status_t status = f_file_link_hard_at(target, point, f_string_empty_s, path, 0);
assert_int_equal(status, F_data_not);
}
}
+void test__f_file_link_hard_at__returns_file_descriptor_not(void **state) {
+
+ f_file_t target = macro_f_file_t_initialize2(F_type_output_d, -1, F_file_flag_write_only_d);
+ f_file_t point = macro_f_file_t_initialize2(F_type_output_d, F_type_descriptor_output_d, F_file_flag_write_only_d);
+ const f_string_static_t path = macro_f_string_static_t_initialize("test", 0, 4);
+
+ {
+ const f_status_t status = f_file_link_hard_at(target, point, path, path, 0);
+
+ assert_int_equal(status, F_file_descriptor_not);
+ }
+
+ {
+ target.id = F_type_descriptor_output_d;
+ point.id = -1;
+
+ const f_status_t status = f_file_link_hard_at(target, point, path, path, 0);
+
+ assert_int_equal(status, F_file_descriptor_not);
+ }
+}
+
void test__f_file_link_hard_at__works(void **state) {
+ const f_file_t target = macro_f_file_t_initialize2(F_type_output_d, F_type_descriptor_output_d, F_file_flag_write_only_d);
+ const f_file_t point = macro_f_file_t_initialize2(F_type_output_d, F_type_descriptor_output_d, F_file_flag_write_only_d);
const f_string_static_t path = macro_f_string_static_t_initialize("test", 0, 4);
{
will_return(__wrap_linkat, false);
will_return(__wrap_linkat, 0);
- const f_status_t status = f_file_link_hard_at(0, 0, path, path, 0);
+ const f_status_t status = f_file_link_hard_at(target, point, path, path, 0);
assert_int_equal(status, F_none);
}
extern void test__f_file_link_hard_at__returns_data_not(void **state);
/**
+ * Test that function works but the descriptor is not valid.
+ *
+ * @see f_file_link_hard_at()
+ */
+extern void test__f_file_link_hard_at__returns_file_descriptor_not(void **state);
+
+/**
* Test that function works.
*
* @see f_file_link_hard_at()
void test__f_file_link_read_at__fails(void **state) {
+ const f_file_t file = macro_f_file_t_initialize2(F_type_output_d, F_type_descriptor_output_d, F_file_flag_write_only_d);
const f_string_static_t path = macro_f_string_static_t_initialize("test", 0, 4);
int errnos[] = {
will_return(__wrap_readlinkat, true);
will_return(__wrap_readlinkat, errnos[i]);
- const f_status_t status = f_file_link_read_at(0, path, 0, &buffer);
+ const f_status_t status = f_file_link_read_at(file, path, 0, &buffer);
assert_int_equal(status, F_status_set_error(statuss[i]));
} // for
void test__f_file_link_read_at__parameter_checking(void **state) {
+ const f_file_t file = macro_f_file_t_initialize2(F_type_output_d, F_type_descriptor_output_d, F_file_flag_write_only_d);
f_string_dynamic_t buffer = f_string_dynamic_t_initialize;
{
- const f_status_t status = f_file_link_read_at(0, f_string_empty_s, 0, 0);
+ const f_status_t status = f_file_link_read_at(file, f_string_empty_s, 0, 0);
assert_int_equal(status, F_status_set_error(F_parameter));
}
void test__f_file_link_read_at__returns_data_not(void **state) {
+ const f_file_t file = macro_f_file_t_initialize2(F_type_output_d, F_type_descriptor_output_d, F_file_flag_write_only_d);
f_string_dynamic_t buffer = f_string_dynamic_t_initialize;
{
- const f_status_t status = f_file_link_read_at(0, f_string_empty_s, 0, &buffer);
+ const f_status_t status = f_file_link_read_at(file, f_string_empty_s, 0, &buffer);
assert_int_equal(status, F_data_not);
}
f_string_dynamic_resize(0, &buffer);
}
+void test__f_file_link_read_at__returns_file_descriptor_not(void **state) {
+
+ const f_file_t file = macro_f_file_t_initialize2(F_type_output_d, -1, F_file_flag_write_only_d);
+ f_string_dynamic_t buffer = f_string_dynamic_t_initialize;
+
+ {
+ const f_status_t status = f_file_link_read_at(file, f_string_empty_s, 0, &buffer);
+
+ assert_int_equal(status, F_file_descriptor_not);
+ }
+
+ f_string_dynamic_resize(0, &buffer);
+}
+
void test__f_file_link_read_at__works(void **state) {
+ const f_file_t file = macro_f_file_t_initialize2(F_type_output_d, F_type_descriptor_output_d, F_file_flag_write_only_d);
const f_string_static_t path = macro_f_string_static_t_initialize("test", 0, 4);
struct stat statistics;
will_return(__wrap_readlinkat, source);
will_return(__wrap_readlinkat, 0);
- const f_status_t status = f_file_link_read_at(0, path, 0, &buffer);
+ const f_status_t status = f_file_link_read_at(file, path, 0, &buffer);
assert_int_equal(status, F_none);
}
extern void test__f_file_link_read_at__returns_data_not(void **state);
/**
+ * Test that function works but the descriptor is not valid.
+ *
+ * @see f_file_link_read_at()
+ */
+extern void test__f_file_link_read_at__returns_file_descriptor_not(void **state);
+
+/**
* Test that function works.
*
* @see f_file_link_read_at()
void test__f_file_mode_read_at__fails(void **state) {
+ const f_file_t file = macro_f_file_t_initialize2(F_type_output_d, F_type_descriptor_output_d, F_file_flag_write_only_d);
const f_string_static_t path = macro_f_string_static_t_initialize("test", 0, 4);
int errnos[] = {
will_return(__wrap_fstatat, true);
will_return(__wrap_fstatat, errnos[i]);
- const f_status_t status = f_file_mode_read_at(0, path, 0, &mode);
+ const f_status_t status = f_file_mode_read_at(file, path, 0, &mode);
assert_int_equal(status, F_status_set_error(statuss[i]));
} // for
void test__f_file_mode_read_at__parameter_checking(void **state) {
+ const f_file_t file = macro_f_file_t_initialize2(F_type_output_d, F_type_descriptor_output_d, F_file_flag_write_only_d);
+
{
- const f_status_t status = f_file_mode_read_at(0, f_string_empty_s, 0, 0);
+ const f_status_t status = f_file_mode_read_at(file, f_string_empty_s, 0, 0);
assert_int_equal(status, F_status_set_error(F_parameter));
}
void test__f_file_mode_read_at__returns_data_not(void **state) {
+ const f_file_t file = macro_f_file_t_initialize2(F_type_output_d, F_type_descriptor_output_d, F_file_flag_write_only_d);
+
{
mode_t mode = 0;
- const f_status_t status = f_file_mode_read_at(0, f_string_empty_s, 0, &mode);
+ const f_status_t status = f_file_mode_read_at(file, f_string_empty_s, 0, &mode);
assert_int_equal(status, F_data_not);
}
}
+void test__f_file_mode_read_at__returns_file_descriptor_not(void **state) {
+
+ const f_file_t file = macro_f_file_t_initialize2(F_type_output_d, -1, F_file_flag_write_only_d);
+ const f_string_static_t path = macro_f_string_static_t_initialize("test", 0, 4);
+
+ {
+ mode_t mode = 0;
+
+ const f_status_t status = f_file_mode_read_at(file, path, 0, &mode);
+
+ assert_int_equal(status, F_file_descriptor_not);
+ }
+}
+
void test__f_file_mode_read_at__works(void **state) {
+ const f_file_t file = macro_f_file_t_initialize2(F_type_output_d, F_type_descriptor_output_d, F_file_flag_write_only_d);
const f_string_static_t path = macro_f_string_static_t_initialize("test", 0, 4);
struct stat statistics;
will_return(__wrap_fstatat, &statistics);
will_return(__wrap_fstatat, 0);
- const f_status_t status = f_file_mode_read_at(0, path, 0, &mode);
+ const f_status_t status = f_file_mode_read_at(file, path, 0, &mode);
assert_int_equal(status, F_none);
assert_int_equal(mode, statistics.st_mode);
extern void test__f_file_mode_read_at__returns_data_not(void **state);
/**
+ * Test that function works but the descriptor is not valid.
+ *
+ * @see f_file_mode_read_at()
+ */
+extern void test__f_file_mode_read_at__returns_file_descriptor_not(void **state);
+
+/**
* Test that function works.
*
* @see f_file_mode_read_at()
void test__f_file_mode_set_at__fails(void **state) {
+ const f_file_t file = macro_f_file_t_initialize2(F_type_output_d, F_type_descriptor_output_d, F_file_flag_write_only_d);
const f_string_static_t path = macro_f_string_static_t_initialize("test", 0, 4);
const mode_t mode = 0;
will_return(__wrap_fchmodat, true);
will_return(__wrap_fchmodat, errnos[i]);
- const f_status_t status = f_file_mode_set_at(0, path, mode);
+ const f_status_t status = f_file_mode_set_at(file, path, mode);
assert_int_equal(status, F_status_set_error(statuss[i]));
} // for
void test__f_file_mode_set_at__returns_data_not(void **state) {
+ const f_file_t file = macro_f_file_t_initialize2(F_type_output_d, F_type_descriptor_output_d, F_file_flag_write_only_d);
const mode_t mode = 0;
{
- const f_status_t status = f_file_mode_set_at(0, f_string_empty_s, mode);
+ const f_status_t status = f_file_mode_set_at(file, f_string_empty_s, mode);
assert_int_equal(status, F_data_not);
}
}
+void test__f_file_mode_set_at__returns_file_descriptor_not(void **state) {
+
+ const f_file_t file = macro_f_file_t_initialize2(F_type_output_d, -1, F_file_flag_write_only_d);
+ const mode_t mode = 0;
+
+ {
+ const f_status_t status = f_file_mode_set_at(file, f_string_empty_s, mode);
+
+ assert_int_equal(status, F_file_descriptor_not);
+ }
+}
+
void test__f_file_mode_set_at__works(void **state) {
+ const f_file_t file = macro_f_file_t_initialize2(F_type_output_d, F_type_descriptor_output_d, F_file_flag_write_only_d);
const f_string_static_t path = macro_f_string_static_t_initialize("test", 0, 4);
const mode_t mode = 0;
will_return(__wrap_fchmodat, false);
will_return(__wrap_fchmodat, 5);
- const f_status_t status = f_file_mode_set_at(0, path, mode);
+ const f_status_t status = f_file_mode_set_at(file, path, mode);
assert_int_equal(status, F_none);
}
extern void test__f_file_mode_set_at__returns_data_not(void **state);
/**
+ * Test that function works but the descriptor is not valid.
+ *
+ * @see f_file_mode_set_at()
+ */
+extern void test__f_file_mode_set_at__returns_file_descriptor_not(void **state);
+
+/**
* Test that function works.
*
* @see f_file_mode_set_at()
for (int i = 0; i < 22; ++i) {
- f_file_t file = f_file_t_initialize;
+ f_file_t file = macro_f_file_t_initialize2(F_type_output_d, F_type_descriptor_output_d, F_file_flag_write_only_d);
will_return(__wrap_openat, true);
will_return(__wrap_openat, errnos[i]);
- const f_status_t status = f_file_open_at(0, path, 0, &file);
+ const f_status_t status = f_file_open_at(file, path, 0, &file);
assert_int_equal(status, F_status_set_error(statuss[i]));
} // for
void test__f_file_open_at__parameter_checking(void **state) {
{
- const f_status_t status = f_file_open_at(0, f_string_empty_s, 0, 0);
+ f_file_t file = macro_f_file_t_initialize2(F_type_output_d, F_type_descriptor_output_d, F_file_flag_write_only_d);
+
+ const f_status_t status = f_file_open_at(file, f_string_empty_s, 0, 0);
assert_int_equal(status, F_status_set_error(F_parameter));
}
void test__f_file_open_at__returns_data_not(void **state) {
{
- f_file_t file = f_file_t_initialize;
+ f_file_t file = macro_f_file_t_initialize2(F_type_output_d, F_type_descriptor_output_d, F_file_flag_write_only_d);
- const f_status_t status = f_file_open_at(0, f_string_empty_s, 0, &file);
+ const f_status_t status = f_file_open_at(file, f_string_empty_s, 0, &file);
assert_int_equal(status, F_data_not);
}
}
+void test__f_file_open_at__returns_file_descriptor_not(void **state) {
+
+ {
+ f_file_t file = macro_f_file_t_initialize2(F_type_output_d, -1, F_file_flag_write_only_d);
+
+ const f_status_t status = f_file_open_at(file, f_string_empty_s, 0, &file);
+
+ assert_int_equal(status, F_file_descriptor_not);
+ }
+}
+
void test__f_file_open_at__works(void **state) {
const f_string_static_t path = macro_f_string_static_t_initialize("test", 0, 4);
{
- f_file_t file = f_file_t_initialize;
+ f_file_t file = macro_f_file_t_initialize2(F_type_output_d, F_type_descriptor_output_d, F_file_flag_write_only_d);
will_return(__wrap_openat, false);
will_return(__wrap_openat, 5);
- const f_status_t status = f_file_open_at(0, path, F_false, &file);
+ const f_status_t status = f_file_open_at(file, path, F_false, &file);
assert_int_equal(status, F_none);
assert_int_equal(file.id, 5);
extern void test__f_file_open_at__returns_data_not(void **state);
/**
+ * Test that function works but the descriptor is not valid.
+ *
+ * @see f_file_open_at()
+ */
+extern void test__f_file_open_at__returns_file_descriptor_not(void **state);
+
+/**
* Test that function works.
*
* @see f_file_open_at()
f_string_dynamic_resize(0, &buffer);
}
-void test__f_file_read__returns_file_closed(void **state) {
+void test__f_file_read__returns_file_descriptor_not(void **state) {
f_file_t file = f_file_t_initialize;
f_string_dynamic_t buffer = f_string_dynamic_t_initialize;
{
const f_status_t status = f_file_read(file, &buffer);
- assert_int_equal(F_status_set_fine(status), F_file_closed);
+ assert_int_equal(F_status_set_fine(status), F_file_descriptor_not);
}
f_string_dynamic_resize(0, &buffer);
extern void test__f_file_read__parameter_checking(void **state);
/**
- * Test that function works but the file is closed.
+ * Test that function works but the descriptor is not valid.
*
* @see f_file_read()
*/
-extern void test__f_file_read__returns_file_closed(void **state);
+extern void test__f_file_read__returns_file_descriptor_not(void **state);
/**
* Test that function works.
f_string_dynamic_resize(0, &buffer);
}
-void test__f_file_read_block__returns_file_closed(void **state) {
+void test__f_file_read_block__returns_file_descriptor_not(void **state) {
f_file_t file = f_file_t_initialize;
f_string_dynamic_t buffer = f_string_dynamic_t_initialize;
{
const f_status_t status = f_file_read_block(file, &buffer);
- assert_int_equal(F_status_set_fine(status), F_file_closed);
+ assert_int_equal(F_status_set_fine(status), F_file_descriptor_not);
}
f_string_dynamic_resize(0, &buffer);
extern void test__f_file_read_block__parameter_checking(void **state);
/**
- * Test that function works but the file is closed.
+ * Test that function works but the descriptor is not valid.
*
* @see f_file_read_block()
*/
-extern void test__f_file_read_block__returns_file_closed(void **state);
+extern void test__f_file_read_block__returns_file_descriptor_not(void **state);
/**
* Test that function works.
f_string_dynamic_resize(0, &buffer);
}
-void test__f_file_read_until__returns_file_closed(void **state) {
+void test__f_file_read_until__returns_file_descriptor_not(void **state) {
f_file_t file = f_file_t_initialize;
f_string_dynamic_t buffer = f_string_dynamic_t_initialize;
{
const f_status_t status = f_file_read_until(file, 1, &buffer);
- assert_int_equal(F_status_set_fine(status), F_file_closed);
+ assert_int_equal(F_status_set_fine(status), F_file_descriptor_not);
}
f_string_dynamic_resize(0, &buffer);
extern void test__f_file_read_until__parameter_checking(void **state);
/**
- * Test that function works but the file is closed.
+ * Test that function works but the descriptor is not valid.
*
* @see f_file_read_until()
*/
-extern void test__f_file_read_until__returns_file_closed(void **state);
+extern void test__f_file_read_until__returns_file_descriptor_not(void **state);
/**
* Test that function works.
void test__f_file_remove_at__fails(void **state) {
+ const f_file_t file = macro_f_file_t_initialize2(F_type_output_d, F_type_descriptor_output_d, F_file_flag_write_only_d);
const f_string_static_t path = macro_f_string_static_t_initialize("test", 0, 4);
int errnos[] = {
will_return(__wrap_unlinkat, true);
will_return(__wrap_unlinkat, errnos[i]);
- const f_status_t status = f_file_remove_at(0, path, 0);
+ const f_status_t status = f_file_remove_at(file, path, 0);
assert_int_equal(status, F_status_set_error(statuss[i]));
} // for
void test__f_file_remove_at__returns_data_not(void **state) {
+ const f_file_t file = macro_f_file_t_initialize2(F_type_output_d, F_type_descriptor_output_d, F_file_flag_write_only_d);
+
{
- const f_status_t status = f_file_remove_at(0, f_string_empty_s, 0);
+ const f_status_t status = f_file_remove_at(file, f_string_empty_s, 0);
assert_int_equal(status, F_data_not);
}
}
+void test__f_file_remove_at__returns_file_descriptor_not(void **state) {
+
+ const f_file_t file = macro_f_file_t_initialize2(F_type_output_d, -1, F_file_flag_write_only_d);
+
+ {
+ const f_status_t status = f_file_remove_at(file, f_string_empty_s, 0);
+
+ assert_int_equal(status, F_file_descriptor_not);
+ }
+}
+
void test__f_file_remove_at__works(void **state) {
+ const f_file_t file = macro_f_file_t_initialize2(F_type_output_d, F_type_descriptor_output_d, F_file_flag_write_only_d);
const f_string_static_t path = macro_f_string_static_t_initialize("test", 0, 4);
{
will_return(__wrap_unlinkat, false);
will_return(__wrap_unlinkat, 0);
- const f_status_t status = f_file_remove_at(0, path, 0);
+ const f_status_t status = f_file_remove_at(file, path, 0);
assert_int_equal(status, F_none);
}
extern void test__f_file_remove_at__returns_data_not(void **state);
/**
+ * Test that function works but the descriptor is not valid.
+ *
+ * @see f_file_remove_at()
+ */
+extern void test__f_file_remove_at__returns_file_descriptor_not(void **state);
+
+/**
* Test that function works.
*
* @see f_file_remove_at()
void test__f_file_rename_at__fails(void **state) {
+ const f_file_t source = macro_f_file_t_initialize2(F_type_output_d, F_type_descriptor_output_d, F_file_flag_write_only_d);
+ const f_file_t destination = macro_f_file_t_initialize2(F_type_output_d, F_type_descriptor_output_d, F_file_flag_write_only_d);
const f_string_static_t path = macro_f_string_static_t_initialize("test", 0, 4);
int errnos[] = {
will_return(__wrap_renameat, errnos[i]);
#endif // _f_file_rename_use_renameat2_
- const f_status_t status = f_file_rename_at(0, 0, path, path, 0);
+ const f_status_t status = f_file_rename_at(source, destination, path, path, 0);
assert_int_equal(status, F_status_set_error(statuss[i]));
} // for
void test__f_file_rename_at__returns_data_not(void **state) {
+ const f_file_t source = macro_f_file_t_initialize2(F_type_output_d, F_type_descriptor_output_d, F_file_flag_write_only_d);
+ const f_file_t destination = macro_f_file_t_initialize2(F_type_output_d, F_type_descriptor_output_d, F_file_flag_write_only_d);
const f_string_static_t path = macro_f_string_static_t_initialize("test", 0, 4);
{
- const f_status_t status = f_file_rename_at(0, 0, f_string_empty_s, f_string_empty_s, 0);
+ const f_status_t status = f_file_rename_at(source, destination, f_string_empty_s, f_string_empty_s, 0);
assert_int_equal(status, F_data_not);
}
{
- const f_status_t status = f_file_rename_at(0, 0, path, f_string_empty_s, 0);
+ const f_status_t status = f_file_rename_at(source, destination, path, f_string_empty_s, 0);
assert_int_equal(status, F_data_not);
}
{
- const f_status_t status = f_file_rename_at(0, 0, f_string_empty_s, path, 0);
+ const f_status_t status = f_file_rename_at(source, destination, f_string_empty_s, path, 0);
assert_int_equal(status, F_data_not);
}
}
+void test__f_file_rename_at__returns_file_descriptor_not(void **state) {
+
+ f_file_t source = macro_f_file_t_initialize2(F_type_output_d, -1, F_file_flag_write_only_d);
+ f_file_t destination = macro_f_file_t_initialize2(F_type_output_d, F_type_descriptor_output_d, F_file_flag_write_only_d);
+ const f_string_static_t path = macro_f_string_static_t_initialize("test", 0, 4);
+
+ {
+ const f_status_t status = f_file_rename_at(source, destination, path, path, 0);
+
+ assert_int_equal(status, F_file_descriptor_not);
+ }
+
+ {
+ source.id = F_type_descriptor_output_d;
+ destination.id = -1;
+
+ const f_status_t status = f_file_rename_at(source, destination, path, path, 0);
+
+ assert_int_equal(status, F_file_descriptor_not);
+ }
+}
+
void test__f_file_rename_at__works(void **state) {
+ const f_file_t source = macro_f_file_t_initialize2(F_type_output_d, F_type_descriptor_output_d, F_file_flag_write_only_d);
+ const f_file_t destination = macro_f_file_t_initialize2(F_type_output_d, F_type_descriptor_output_d, F_file_flag_write_only_d);
const f_string_static_t path = macro_f_string_static_t_initialize("test", 0, 4);
{
will_return(__wrap_renameat, 0);
#endif // _f_file_rename_use_renameat2_
- const f_status_t status = f_file_rename_at(0, 0, path, path, 0);
+ const f_status_t status = f_file_rename_at(source, destination, path, path, 0);
assert_int_equal(status, F_none);
}
extern void test__f_file_rename_at__returns_data_not(void **state);
/**
+ * Test that function works but the descriptor is not valid.
+ *
+ * @see f_file_rename_at()
+ */
+extern void test__f_file_rename_at__returns_file_descriptor_not(void **state);
+
+/**
* Test that function works.
*
* @see f_file_rename_at()
void test__f_file_role_change_at__fails_for_dereference(void **state) {
+ const f_file_t file = macro_f_file_t_initialize2(F_type_output_d, F_type_descriptor_output_d, F_file_flag_write_only_d);
const f_string_static_t path = macro_f_string_static_t_initialize("test", 0, 4);
int errnos[] = {
will_return(__wrap_fchownat, true);
will_return(__wrap_fchownat, errnos[i]);
- const f_status_t status = f_file_role_change_at(0, path, 0, 0, 0);
+ const f_status_t status = f_file_role_change_at(file, path, 0, 0, 0);
assert_int_equal(F_status_set_fine(status), status_owners[i]);
} // for
will_return(__wrap_fchownat, true);
will_return(__wrap_fchownat, errnos[i]);
- const f_status_t status = f_file_role_change_at(0, path, 0, 0, 0);
+ const f_status_t status = f_file_role_change_at(file, path, 0, 0, 0);
assert_int_equal(F_status_set_fine(status), status_groups[i]);
} // for
will_return(__wrap_fchownat, true);
will_return(__wrap_fchownat, errnos[i]);
- const f_status_t status = f_file_role_change_at(0, path, -1, 0, 0);
+ const f_status_t status = f_file_role_change_at(file, path, -1, 0, 0);
assert_int_equal(F_status_set_fine(status), status_groups[i]);
} // for
will_return(__wrap_fchownat, true);
will_return(__wrap_fchownat, errnos[i]);
- const f_status_t status = f_file_role_change_at(0, path, 0, -1, 0);
+ const f_status_t status = f_file_role_change_at(file, path, 0, -1, 0);
assert_int_equal(F_status_set_fine(status), status_owners[i]);
} // for
void test__f_file_role_change_at__fails_for_reference(void **state) {
+ const f_file_t file = macro_f_file_t_initialize2(F_type_output_d, F_type_descriptor_output_d, F_file_flag_write_only_d);
const f_string_static_t path = macro_f_string_static_t_initialize("test", 0, 4);
int errnos[] = {
will_return(__wrap_fchownat, true);
will_return(__wrap_fchownat, errnos[i]);
- const f_status_t status = f_file_role_change_at(0, path, 0, 0, F_file_at_symlink_follow_no_d);
+ const f_status_t status = f_file_role_change_at(file, path, 0, 0, F_file_at_symlink_follow_no_d);
assert_int_equal(F_status_set_fine(status), status_owners[i]);
} // for
will_return(__wrap_fchownat, true);
will_return(__wrap_fchownat, errnos[i]);
- const f_status_t status = f_file_role_change_at(0, path, 0, 0, F_file_at_symlink_follow_no_d);
+ const f_status_t status = f_file_role_change_at(file, path, 0, 0, F_file_at_symlink_follow_no_d);
assert_int_equal(F_status_set_fine(status), status_groups[i]);
} // for
will_return(__wrap_fchownat, true);
will_return(__wrap_fchownat, errnos[i]);
- const f_status_t status = f_file_role_change_at(0, path, -1, 0, F_file_at_symlink_follow_no_d);
+ const f_status_t status = f_file_role_change_at(file, path, -1, 0, F_file_at_symlink_follow_no_d);
assert_int_equal(F_status_set_fine(status), status_groups[i]);
} // for
will_return(__wrap_fchownat, true);
will_return(__wrap_fchownat, errnos[i]);
- const f_status_t status = f_file_role_change_at(0, path, 0, -1, F_file_at_symlink_follow_no_d);
+ const f_status_t status = f_file_role_change_at(file, path, 0, -1, F_file_at_symlink_follow_no_d);
assert_int_equal(F_status_set_fine(status), status_owners[i]);
} // for
void test__f_file_role_change_at__returns_data_not(void **state) {
+ const f_file_t file = macro_f_file_t_initialize2(F_type_output_d, F_type_descriptor_output_d, F_file_flag_write_only_d);
const f_string_static_t path = macro_f_string_static_t_initialize("test", 0, 4);
{
- const f_status_t status = f_file_role_change_at(0, f_string_empty_s, -1, -1, 0);
+ const f_status_t status = f_file_role_change_at(file, f_string_empty_s, -1, -1, 0);
assert_int_equal(status, F_data_not);
}
{
- const f_status_t status = f_file_role_change_at(0, path, -1, -1, 0);
+ const f_status_t status = f_file_role_change_at(file, path, -1, -1, 0);
assert_int_equal(status, F_data_not);
}
{
- const f_status_t status = f_file_role_change_at(0, f_string_empty_s, 0, 0, 0);
+ const f_status_t status = f_file_role_change_at(file, f_string_empty_s, 0, 0, 0);
assert_int_equal(status, F_data_not);
}
}
+void test__f_file_role_change_at__returns_file_descriptor_not(void **state) {
+
+ const f_file_t file = macro_f_file_t_initialize2(F_type_output_d, -1, F_file_flag_write_only_d);
+ const f_string_static_t path = macro_f_string_static_t_initialize("test", 0, 4);
+
+ {
+ const f_status_t status = f_file_role_change_at(file, path, 0, 0, 0);
+
+ assert_int_equal(status, F_file_descriptor_not);
+ }
+}
+
void test__f_file_role_change_at__works_for_dereference(void **state) {
+ const f_file_t file = macro_f_file_t_initialize2(F_type_output_d, F_type_descriptor_output_d, F_file_flag_write_only_d);
const f_string_static_t path = macro_f_string_static_t_initialize("test", 0, 4);
{
will_return(__wrap_fchownat, false);
will_return(__wrap_fchownat, 0);
- const f_status_t status = f_file_role_change_at(0, path, 0, 0, 0);
+ const f_status_t status = f_file_role_change_at(file, path, 0, 0, 0);
assert_int_equal(status, F_none);
}
will_return(__wrap_fchownat, false);
will_return(__wrap_fchownat, 0);
- const f_status_t status = f_file_role_change_at(0, path, -1, 0, 0);
+ const f_status_t status = f_file_role_change_at(file, path, -1, 0, 0);
assert_int_equal(status, F_none);
}
will_return(__wrap_fchownat, false);
will_return(__wrap_fchownat, 0);
- const f_status_t status = f_file_role_change_at(0, path, 0, -1, 0);
+ const f_status_t status = f_file_role_change_at(file, path, 0, -1, 0);
assert_int_equal(status, F_none);
}
void test__f_file_role_change_at__works_for_reference(void **state) {
+ const f_file_t file = macro_f_file_t_initialize2(F_type_output_d, F_type_descriptor_output_d, F_file_flag_write_only_d);
const f_string_static_t path = macro_f_string_static_t_initialize("test", 0, 4);
{
will_return(__wrap_fchownat, false);
will_return(__wrap_fchownat, 0);
- const f_status_t status = f_file_role_change_at(0, path, 0, 0, F_file_at_symlink_follow_no_d);
+ const f_status_t status = f_file_role_change_at(file, path, 0, 0, F_file_at_symlink_follow_no_d);
assert_int_equal(status, F_none);
}
will_return(__wrap_fchownat, false);
will_return(__wrap_fchownat, 0);
- const f_status_t status = f_file_role_change_at(0, path, -1, 0, F_file_at_symlink_follow_no_d);
+ const f_status_t status = f_file_role_change_at(file, path, -1, 0, F_file_at_symlink_follow_no_d);
assert_int_equal(status, F_none);
}
will_return(__wrap_fchownat, false);
will_return(__wrap_fchownat, 0);
- const f_status_t status = f_file_role_change_at(0, path, 0, -1, F_file_at_symlink_follow_no_d);
+ const f_status_t status = f_file_role_change_at(file, path, 0, -1, F_file_at_symlink_follow_no_d);
assert_int_equal(status, F_none);
}
extern void test__f_file_role_change_at__returns_data_not(void **state);
/**
+ * Test that function works but the descriptor is not valid.
+ *
+ * @see f_file_role_change_at()
+ */
+extern void test__f_file_role_change_at__returns_file_descriptor_not(void **state);
+
+/**
* Test that function works for dereferenced files.
*
* @see f_file_role_change_at()
void test__f_file_seek__fails(void **state) {
+ const f_file_t file = macro_f_file_t_initialize2(F_type_output_d, F_type_descriptor_output_d, F_file_flag_write_only_d);
+
int errnos[] = {
EBADF,
EINVAL,
will_return(__wrap_lseek, true);
will_return(__wrap_lseek, errnos[i]);
- const f_status_t status = f_file_seek(0, 0, 0, &seeked);
+ const f_status_t status = f_file_seek(file, 0, 0, &seeked);
assert_int_equal(status, F_status_set_error(statuss[i]));
} // for
void test__f_file_seek__parameter_checking(void **state) {
+ const f_file_t file = macro_f_file_t_initialize2(F_type_output_d, F_type_descriptor_output_d, F_file_flag_write_only_d);
off_t seeked = 0;
{
- const f_status_t status = f_file_seek(0, -1, 0, 0);
+ const f_status_t status = f_file_seek(file, -1, 0, 0);
assert_int_equal(status, F_status_set_error(F_parameter));
}
{
- const f_status_t status = f_file_seek(0, -1, 0, &seeked);
+ const f_status_t status = f_file_seek(file, -1, 0, &seeked);
assert_int_equal(status, F_status_set_error(F_parameter));
}
{
- const f_status_t status = f_file_seek(0, 0, 0, 0);
+ const f_status_t status = f_file_seek(file, 0, 0, 0);
assert_int_equal(status, F_status_set_error(F_parameter));
}
}
+void test__f_file_seek__returns_file_descriptor_not(void **state) {
+
+ const f_file_t file = macro_f_file_t_initialize2(F_type_output_d, -1, F_file_flag_write_only_d);
+
+ {
+ off_t seeked = 0;
+
+ const f_status_t status = f_file_seek(file, 0, 0, &seeked);
+
+ assert_int_equal(status, F_file_descriptor_not);
+ }
+}
+
void test__f_file_seek__works(void **state) {
+ const f_file_t file = macro_f_file_t_initialize2(F_type_output_d, F_type_descriptor_output_d, F_file_flag_write_only_d);
+
{
off_t seeked = 0;
will_return(__wrap_lseek, false);
will_return(__wrap_lseek, 0);
- const f_status_t status = f_file_seek(0, 0, 0, &seeked);
+ const f_status_t status = f_file_seek(file, 0, 0, &seeked);
assert_int_equal(status, F_none);
}
extern void test__f_file_seek__parameter_checking(void **state);
/**
+ * Test that function works but the descriptor is not valid.
+ *
+ * @see f_file_seek()
+ */
+extern void test__f_file_seek__returns_file_descriptor_not(void **state);
+
+/**
* Test that function works.
*
* @see f_file_seek()
void test__f_file_size_at__fails(void **state) {
+ const f_file_t file = macro_f_file_t_initialize2(F_type_output_d, F_type_descriptor_output_d, F_file_flag_write_only_d);
const f_string_static_t path = macro_f_string_static_t_initialize("test", 0, 4);
int errnos[] = {
will_return(__wrap_fstatat, true);
will_return(__wrap_fstatat, errnos[i]);
- const f_status_t status = f_file_size_at(0, path, F_false, &size);
+ const f_status_t status = f_file_size_at(file, path, F_false, &size);
assert_int_equal(status, F_status_set_error(statuss[i]));
} // for
void test__f_file_size_at__parameter_checking(void **state) {
+ const f_file_t file = macro_f_file_t_initialize2(F_type_output_d, F_type_descriptor_output_d, F_file_flag_write_only_d);
+
{
- const f_status_t status = f_file_size_at(0, f_string_empty_s, F_false, 0);
+ const f_status_t status = f_file_size_at(file, f_string_empty_s, F_false, 0);
assert_int_equal(status, F_status_set_error(F_parameter));
}
void test__f_file_size_at__returns_data_not(void **state) {
+ const f_file_t file = macro_f_file_t_initialize2(F_type_output_d, F_type_descriptor_output_d, F_file_flag_write_only_d);
+
{
off_t size = 0;
- const f_status_t status = f_file_size_at(0, f_string_empty_s, F_false, &size);
+ const f_status_t status = f_file_size_at(file, f_string_empty_s, F_false, &size);
assert_int_equal(status, F_data_not);
}
}
+void test__f_file_size_at__returns_file_descriptor_not(void **state) {
+
+ const f_file_t file = macro_f_file_t_initialize2(F_type_output_d, -1, F_file_flag_write_only_d);
+
+ {
+ off_t size = 0;
+
+ const f_status_t status = f_file_size_at(file, f_string_empty_s, F_false, &size);
+
+ assert_int_equal(status, F_file_descriptor_not);
+ }
+}
+
void test__f_file_size_at__works(void **state) {
+ const f_file_t file = macro_f_file_t_initialize2(F_type_output_d, F_type_descriptor_output_d, F_file_flag_write_only_d);
const f_string_static_t path = macro_f_string_static_t_initialize("test", 0, 4);
struct stat statistics;
will_return(__wrap_fstatat, &statistics);
will_return(__wrap_fstatat, 0);
- const f_status_t status = f_file_size_at(0, path, F_false, &size);
+ const f_status_t status = f_file_size_at(file, path, F_false, &size);
assert_int_equal(status, F_none);
assert_int_equal(size, statistics.st_size);
will_return(__wrap_fstatat, &statistics);
will_return(__wrap_fstatat, 0);
- const f_status_t status = f_file_size_at(0, path, F_true, &size);
+ const f_status_t status = f_file_size_at(file, path, F_true, &size);
assert_int_equal(status, F_none);
assert_int_equal(size, statistics.st_size);
extern void test__f_file_size_at__returns_data_not(void **state);
/**
+ * Test that function works but the path is empty.
+ *
+ * @see f_file_size_at()
+ */
+extern void test__f_file_size_at__returns_file_descriptor_not(void **state);
+
+/**
* Test that function works.
*
* @see f_file_size_at()
void test__f_file_size_by_id__fails(void **state) {
+ const f_file_t file = macro_f_file_t_initialize2(F_type_output_d, F_type_descriptor_output_d, F_file_flag_write_only_d);
+
int errnos[] = {
EACCES,
EBADF,
will_return(__wrap_fstat, true);
will_return(__wrap_fstat, errnos[i]);
- const f_status_t status = f_file_size_by_id(0, &size);
+ const f_status_t status = f_file_size_by_id(file, &size);
assert_int_equal(status, F_status_set_error(statuss[i]));
} // for
void test__f_file_size_by_id__parameter_checking(void **state) {
+ const f_file_t file = macro_f_file_t_initialize2(F_type_output_d, F_type_descriptor_output_d, F_file_flag_write_only_d);
+
{
- const f_status_t status = f_file_size_by_id(0, 0);
+ const f_status_t status = f_file_size_by_id(file, 0);
assert_int_equal(status, F_status_set_error(F_parameter));
}
}
-void test__f_file_size_by_id__returns_file_closed(void **state) {
+void test__f_file_size_by_id__returns_file_descriptor_not(void **state) {
+
+ const f_file_t file = macro_f_file_t_initialize2(F_type_output_d, -1, F_file_flag_write_only_d);
{
off_t size = 0;
- const f_status_t status = f_file_size_by_id(-1, &size);
+ const f_status_t status = f_file_size_by_id(file, &size);
- assert_int_equal(F_status_set_fine(status), F_file_closed);
- } // for
+ assert_int_equal(status, F_file_descriptor_not);
+ }
}
void test__f_file_size_by_id__works(void **state) {
+ const f_file_t file = macro_f_file_t_initialize2(F_type_output_d, F_type_descriptor_output_d, F_file_flag_write_only_d);
+
struct stat statistics;
memset(&statistics, 0, sizeof(struct stat));
will_return(__wrap_fstat, &statistics);
will_return(__wrap_fstat, 0);
- const f_status_t status = f_file_size_by_id(0, &size);
+ const f_status_t status = f_file_size_by_id(file, &size);
assert_int_equal(status, F_none);
assert_int_equal(size, statistics.st_size);
extern void test__f_file_size_by_id__parameter_checking(void **state);
/**
- * Test that function works but the file is closed.
+ * Test that function works but the path is empty.
*
* @see f_file_size_by_id()
*/
-extern void test__f_file_size_by_id__returns_file_closed(void **state);
+extern void test__f_file_size_by_id__returns_file_descriptor_not(void **state);
/**
* Test that function works.
void test__f_file_stat_at__fails(void **state) {
+ const f_file_t file = macro_f_file_t_initialize2(F_type_output_d, F_type_descriptor_output_d, F_file_flag_write_only_d);
const f_string_static_t path = macro_f_string_static_t_initialize("test", 0, 4);
int errnos[] = {
will_return(__wrap_fstatat, true);
will_return(__wrap_fstatat, errnos[i]);
- const f_status_t status = f_file_stat_at(0, path, F_false, &result);
+ const f_status_t status = f_file_stat_at(file, path, F_false, &result);
assert_int_equal(status, F_status_set_error(statuss[i]));
} // for
void test__f_file_stat_at__parameter_checking(void **state) {
+ const f_file_t file = macro_f_file_t_initialize2(F_type_output_d, F_type_descriptor_output_d, F_file_flag_write_only_d);
+
{
- const f_status_t status = f_file_stat_at(0, f_string_empty_s, F_false, 0);
+ const f_status_t status = f_file_stat_at(file, f_string_empty_s, F_false, 0);
assert_int_equal(status, F_status_set_error(F_parameter));
}
void test__f_file_stat_at__returns_data_not(void **state) {
+ const f_file_t file = macro_f_file_t_initialize2(F_type_output_d, F_type_descriptor_output_d, F_file_flag_write_only_d);
+
{
struct stat result;
memset(&result, 0, sizeof(struct stat));
- const f_status_t status = f_file_stat_at(0, f_string_empty_s, F_false, &result);
+ const f_status_t status = f_file_stat_at(file, f_string_empty_s, F_false, &result);
assert_int_equal(status, F_data_not);
}
}
+void test__f_file_stat_at__returns_file_descriptor_not(void **state) {
+
+ const f_file_t file = macro_f_file_t_initialize2(F_type_output_d, -1, F_file_flag_write_only_d);
+
+ {
+ struct stat result;
+
+ memset(&result, 0, sizeof(struct stat));
+
+ const f_status_t status = f_file_stat_at(file, f_string_empty_s, F_false, &result);
+
+ assert_int_equal(status, F_file_descriptor_not);
+ }
+}
+
void test__f_file_stat_at__works(void **state) {
+ const f_file_t file = macro_f_file_t_initialize2(F_type_output_d, F_type_descriptor_output_d, F_file_flag_write_only_d);
const f_string_static_t path = macro_f_string_static_t_initialize("test", 0, 4);
struct stat statistics;
will_return(__wrap_fstatat, &statistics);
will_return(__wrap_fstatat, 0);
- const f_status_t status = f_file_stat_at(0, path, F_false, &result);
+ const f_status_t status = f_file_stat_at(file, path, F_false, &result);
assert_int_equal(status, F_none);
assert_int_equal(result.st_mode, statistics.st_mode);
will_return(__wrap_fstatat, &statistics);
will_return(__wrap_fstatat, 0);
- const f_status_t status = f_file_stat_at(0, path, F_true, &result);
+ const f_status_t status = f_file_stat_at(file, path, F_true, &result);
assert_int_equal(status, F_none);
assert_int_equal(result.st_mode, statistics.st_mode);
extern void test__f_file_stat_at__returns_data_not(void **state);
/**
+ * Test that function works but the descriptor is not valid.
+ *
+ * @see f_file_stat_at()
+ */
+extern void test__f_file_stat_at__returns_file_descriptor_not(void **state);
+
+/**
* Test that function works.
*
* @see f_file_stat_at()
void test__f_file_stat_by_id__fails(void **state) {
+ const f_file_t file = macro_f_file_t_initialize2(F_type_output_d, F_type_descriptor_output_d, F_file_flag_write_only_d);
+
int errnos[] = {
EACCES,
EBADF,
will_return(__wrap_fstat, true);
will_return(__wrap_fstat, errnos[i]);
- const f_status_t status = f_file_stat_by_id(0, &result);
+ const f_status_t status = f_file_stat_by_id(file, &result);
assert_int_equal(status, F_status_set_error(statuss[i]));
} // for
void test__f_file_stat_by_id__parameter_checking(void **state) {
+ const f_file_t file = macro_f_file_t_initialize2(F_type_output_d, F_type_descriptor_output_d, F_file_flag_write_only_d);
+
{
- const f_status_t status = f_file_stat_by_id(0, 0);
+ const f_status_t status = f_file_stat_by_id(file, 0);
assert_int_equal(status, F_status_set_error(F_parameter));
}
}
-void test__f_file_stat_by_id__returns_file_closed(void **state) {
+void test__f_file_stat_by_id__returns_file_descriptor_not(void **state) {
+
+ const f_file_t file = macro_f_file_t_initialize2(F_type_output_d, -1, F_file_flag_write_only_d);
{
struct stat result;
memset(&result, 0, sizeof(struct stat));
- const f_status_t status = f_file_stat_by_id(-1, &result);
+ const f_status_t status = f_file_stat_by_id(file, &result);
- assert_int_equal(F_status_set_fine(status), F_file_closed);
- } // for
+ assert_int_equal(status, F_file_descriptor_not);
+ }
}
void test__f_file_stat_by_id__works(void **state) {
+ const f_file_t file = macro_f_file_t_initialize2(F_type_output_d, F_type_descriptor_output_d, F_file_flag_write_only_d);
+
struct stat statistics;
memset(&statistics, 0, sizeof(struct stat));
will_return(__wrap_fstat, &statistics);
will_return(__wrap_fstat, 0);
- const f_status_t status = f_file_stat_by_id(0, &result);
+ const f_status_t status = f_file_stat_by_id(file, &result);
assert_int_equal(status, F_none);
assert_int_equal(result.st_mode, statistics.st_mode);
extern void test__f_file_stat_by_id__parameter_checking(void **state);
/**
- * Test that function works but the file is closed.
+ * Test that function works but the descriptor is not valid.
*
* @see f_file_stat_by_id()
*/
-extern void test__f_file_stat_by_id__returns_file_closed(void **state);
+extern void test__f_file_stat_by_id__returns_file_descriptor_not(void **state);
/**
* Test that function works.
extern "C" {
#endif
-void test__f_file_stream_close__fails_for_file_descriptor(void **state) {
-
- int errno_flushs[] = {
- EBADF,
- EDQUOT,
- EINVAL,
- EIO,
- ENOSPC,
- EROFS,
- };
-
- int errno_closes[] = {
- EBADF,
- EDQUOT,
- EINTR,
- EIO,
- ENOSPC,
- mock_errno_generic,
- };
-
- f_status_t status_closes[] = {
- F_file_descriptor,
- F_filesystem_quota_block,
- F_interrupt,
- F_input_output,
- F_space_not,
- F_file_close,
- };
-
- for (uint8_t flush = 0; flush < 2; ++flush) {
-
- for (int i = 0; i < 6; ++i) {
-
- f_file_t file = f_file_t_initialize;
- file.id = 0;
- file.stream = 0;
-
- if (flush) {
- if (flush == 1) {
- will_return(__wrap_fsync, true);
- will_return(__wrap_fsync, errno_flushs[i]);
- }
- else {
- will_return(__wrap_fsync, false);
- will_return(__wrap_fsync, 0);
- }
-
- will_return(__wrap_close, true);
- will_return(__wrap_close, errno_closes[i]);
- }
- else {
- will_return(__wrap_close, true);
- will_return(__wrap_close, errno_closes[i]);
- }
-
- const f_status_t status = f_file_stream_close(flush, &file);
-
- assert_int_equal(F_status_set_fine(status), status_closes[i]);
-
- assert_int_equal(file.id, -1);
- assert_int_equal(file.stream, 0);
- } // for
- } // for
-}
-
-void test__f_file_stream_close__fails_for_stream(void **state) {
+void test__f_file_stream_close__fails(void **state) {
int errnos[] = {
EACCES,
F_file_close,
};
- for (uint8_t flush = 0; flush < 2; ++flush) {
-
- for (int i = 0; i < 19; ++i) {
-
- f_file_t file = f_file_t_initialize;
- file.id = 0;
- file.stream = F_type_input_d;
-
- if (flush) {
- if (flush == 1) {
- will_return(__wrap_fflush, true);
- will_return(__wrap_fflush, errnos[i]);
- }
- else {
- will_return(__wrap_fflush, false);
- will_return(__wrap_fflush, 0);
- }
-
- will_return(__wrap_fclose, true);
- will_return(__wrap_fclose, errnos[i]);
- }
- else {
- will_return(__wrap_fclose, true);
- will_return(__wrap_fclose, errnos[i]);
- }
-
- const f_status_t status = f_file_stream_close(flush, &file);
-
- assert_int_equal(F_status_set_fine(status), status_closes[i]);
- assert_int_equal(file.id, -1);
- assert_int_equal(file.stream, 0);
- } // for
+ for (int i = 0; i < 19; ++i) {
+
+ f_file_t file = macro_f_file_t_initialize2(F_type_output_d, F_type_descriptor_output_d, F_file_flag_write_only_d);
+
+ will_return(__wrap_fclose, true);
+ will_return(__wrap_fclose, errnos[i]);
+
+ const f_status_t status = f_file_stream_close(&file);
+
+ assert_int_equal(F_status_set_fine(status), status_closes[i]);
+ assert_int_equal(file.stream, 0);
} // for
}
void test__f_file_stream_close__parameter_checking(void **state) {
{
- const f_status_t status = f_file_stream_close(F_false, 0);
+ const f_status_t status = f_file_stream_close(0);
assert_int_equal(status, F_status_set_error(F_parameter));
}
}
-void test__f_file_stream_close__works(void **state) {
-
- {
- f_file_t file = f_file_t_initialize;
-
- file.id = 0;
- file.stream = F_type_input_d;
-
- will_return(__wrap_fclose, false);
- will_return(__wrap_fclose, 0);
+void test__f_file_stream_close__returns_stream_not(void **state) {
- const f_status_t status = f_file_stream_close(F_false, &file);
-
- assert_int_equal(status, F_none);
- assert_int_equal(file.id, -1);
- assert_int_equal(file.stream, 0);
- }
+ f_file_t file = macro_f_file_t_initialize2(0, F_type_descriptor_output_d, F_file_flag_write_only_d);
{
- f_file_t file = f_file_t_initialize;
-
- file.id = 0;
- file.stream = 0;
-
- will_return(__wrap_close, false);
- will_return(__wrap_close, 0);
+ const f_status_t status = f_file_stream_close(&file);
- const f_status_t status = f_file_stream_close(F_false, &file);
-
- assert_int_equal(status, F_none);
- assert_int_equal(file.id, -1);
- assert_int_equal(file.stream, 0);
+ assert_int_equal(status, F_stream_not);
}
+}
+
+void test__f_file_stream_close__works(void **state) {
{
- f_file_t file = f_file_t_initialize;
+ f_file_t file = macro_f_file_t_initialize2(F_type_output_d, F_type_descriptor_output_d, F_file_flag_write_only_d);
file.id = 0;
file.stream = F_type_input_d;
- will_return(__wrap_fflush, false);
- will_return(__wrap_fflush, 0);
-
will_return(__wrap_fclose, false);
will_return(__wrap_fclose, 0);
- const f_status_t status = f_file_stream_close(F_true, &file);
-
- assert_int_equal(status, F_none);
- assert_int_equal(file.id, -1);
- assert_int_equal(file.stream, 0);
- }
-
- {
- f_file_t file = f_file_t_initialize;
-
- file.id = 0;
- file.stream = 0;
-
- will_return(__wrap_fsync, false);
- will_return(__wrap_fsync, 0);
-
- will_return(__wrap_close, false);
- will_return(__wrap_close, 0);
-
- const f_status_t status = f_file_stream_close(F_true, &file);
+ const f_status_t status = f_file_stream_close(&file);
assert_int_equal(status, F_none);
- assert_int_equal(file.id, -1);
assert_int_equal(file.stream, 0);
}
}
#define _TEST__F_file_stream_close_h
/**
- * Test that function fails for a file using the file descriptor.
+ * Test that function fails.
*
* @see f_file_stream_close()
*/
-extern void test__f_file_stream_close__fails_for_file_descriptor(void **state);
+extern void test__f_file_stream_close__fails(void **state);
/**
- * Test that function fails for a file stream.
+ * Test that parameter checking works as expected.
*
* @see f_file_stream_close()
*/
-extern void test__f_file_stream_close__fails_for_stream(void **state);
+extern void test__f_file_stream_close__parameter_checking(void **state);
/**
- * Test that parameter checking works as expected.
+ * Test that function works but the stream is not valid.
*
* @see f_file_stream_close()
*/
-extern void test__f_file_stream_close__parameter_checking(void **state);
+extern void test__f_file_stream_close__returns_stream_not(void **state);
/**
* Test that function works.
void test__f_file_stream_open__works(void **state) {
const f_string_static_t path = macro_f_string_static_t_initialize("test", 0, 4);
- const int id = 1;
{
f_file_t file = f_file_t_initialize;
will_return(__wrap_fopen, false);
will_return(__wrap_fopen, F_type_output_d);
- will_return(__wrap_fileno, id);
-
const f_status_t status = f_file_stream_open(path, path, &file);
assert_int_equal(status, F_none);
will_return(__wrap_fopen, false);
will_return(__wrap_fopen, F_type_output_d);
- will_return(__wrap_fileno, id);
-
const f_status_t status = f_file_stream_open(path, f_string_empty_s, &file);
assert_int_equal(status, F_none);
}
}
-void test__f_file_stream_read__returns_file_closed(void **state) {
+void test__f_file_stream_read__returns_stream_not(void **state) {
const f_file_t file = f_file_t_initialize;
f_string_dynamic_t buffer = f_string_dynamic_t_initialize;
{
const f_status_t status = f_file_stream_read(file, &buffer);
- assert_int_equal(F_status_set_fine(status), F_file_closed);
+ assert_int_equal(F_status_set_fine(status), F_stream_not);
}
f_string_dynamic_resize(0, &buffer);
extern void test__f_file_stream_read__parameter_checking(void **state);
/**
- * Test that function works but the file stream is closed.
+ * Test that function works but the stream is not valid.
*
* @see f_file_stream_read()
*/
-extern void test__f_file_stream_read__returns_file_closed(void **state);
+extern void test__f_file_stream_read__returns_stream_not(void **state);
/**
* Test that function works.
}
}
-void test__f_file_stream_read_block__returns_file_closed(void **state) {
+void test__f_file_stream_read_block__returns_stream_not(void **state) {
const f_file_t file = f_file_t_initialize;
const f_status_t status = f_file_stream_read_block(file, &string);
- assert_int_equal(F_status_set_fine(status), F_file_closed);
+ assert_int_equal(F_status_set_fine(status), F_stream_not);
}
}
extern void test__f_file_stream_read_block__parameter_checking(void **state);
/**
- * Test that function works but the file stream is closed.
+ * Test that function works but the stream is not valid.
*
* @see f_file_stream_read_block()
*/
-extern void test__f_file_stream_read_block__returns_file_closed(void **state);
+extern void test__f_file_stream_read_block__returns_stream_not(void **state);
/**
* Test that function works.
}
}
-void test__f_file_stream_read_until__returns_file_closed(void **state) {
+void test__f_file_stream_read_until__returns_stream_not(void **state) {
f_file_t file = f_file_t_initialize;
f_string_dynamic_t buffer = f_string_dynamic_t_initialize;
{
const f_status_t status = f_file_stream_read_until(file, 0, &buffer);
- assert_int_equal(F_status_set_fine(status), F_file_closed);
+ assert_int_equal(F_status_set_fine(status), F_stream_not);
}
f_string_dynamic_resize(0, &buffer);
extern void test__f_file_stream_read_until__parameter_checking(void **state);
/**
- * Test that function works but the file stream is closed.
+ * Test that function works but the stream is not valid.
*
* @see f_file_stream_read_until()
*/
-extern void test__f_file_stream_read_until__returns_file_closed(void **state);
+extern void test__f_file_stream_read_until__returns_stream_not(void **state);
/**
* Test that function works.
void test__f_file_stream_reopen__works(void **state) {
const f_string_static_t path = macro_f_string_static_t_initialize("test", 0, 4);
- const int id = 1;
{
f_file_t file = f_file_t_initialize;
will_return(__wrap_freopen, false);
will_return(__wrap_freopen, F_type_input_d);
- will_return(__wrap_fileno, id);
-
const f_status_t status = f_file_stream_reopen(path, path, &file);
assert_int_equal(status, F_none);
will_return(__wrap_freopen, false);
will_return(__wrap_freopen, F_type_input_d);
- will_return(__wrap_fileno, id);
-
const f_status_t status = f_file_stream_reopen(path, f_string_empty_s, &file);
assert_int_equal(status, F_none);
const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4);
{
- f_file_t file = f_file_t_initialize;
+ f_file_t file = macro_f_file_t_initialize2(F_type_output_d, F_type_descriptor_output_d, F_file_flag_write_only_d);
file.size_read = 1;
- file.stream = F_type_input_d;
+ file.size_write = 1;
- will_return(__wrap_fwrite_unlocked, true);
- will_return(__wrap_fwrite_unlocked, 0);
- will_return(__wrap_ferror_unlocked, true);
+ will_return(__wrap_write, 0);
const f_status_t status = f_file_stream_write(file, test, 0);
void test__f_file_stream_write__parameter_checking(void **state) {
- f_file_t file = f_file_t_initialize;
+ f_file_t file = macro_f_file_t_initialize2(F_type_output_d, F_type_descriptor_output_d, F_file_flag_write_only_d);
file.size_write = 0;
{
}
}
-void test__f_file_stream_write__returns_file_closed(void **state) {
+void test__f_file_stream_write__returns_stream_not(void **state) {
const f_file_t file = f_file_t_initialize;
{
const f_status_t status = f_file_stream_write(file, f_string_empty_s, 0);
- assert_int_equal(F_status_set_fine(status), F_file_closed);
+ assert_int_equal(F_status_set_fine(status), F_stream_not);
}
}
void test__f_file_stream_write__returns_data_not(void **state) {
- f_file_t file = f_file_t_initialize;
- file.stream = F_type_input_d;
+ f_file_t file = macro_f_file_t_initialize2(F_type_output_d, F_type_descriptor_output_d, F_file_flag_write_only_d);
{
const f_status_t status = f_file_stream_write(file, f_string_empty_s, 0);
const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4);
{
- f_file_t file = f_file_t_initialize;
+ f_file_t file = macro_f_file_t_initialize2(F_type_output_d, F_type_descriptor_output_d, F_file_flag_write_only_d);
file.size_write = test.used;
- file.stream = F_type_input_d;
will_return(__wrap_fwrite_unlocked, false);
will_return(__wrap_fwrite_unlocked, test.used);
extern void test__f_file_stream_write__parameter_checking(void **state);
/**
- * Test that function works but the file stream is closed.
+ * Test that function works but the stream is not valid.
*
* @see f_file_stream_write()
*/
-extern void test__f_file_stream_write__returns_file_closed(void **state);
+extern void test__f_file_stream_write__returns_stream_not(void **state);
/**
* Test that function works but the path is empty.
void test__f_file_stream_write_block__parameter_checking(void **state) {
- f_file_t file = f_file_t_initialize;
+ f_file_t file = macro_f_file_t_initialize2(F_type_output_d, F_type_descriptor_output_d, F_file_flag_write_only_d);
file.size_write = 0;
{
}
}
-void test__f_file_stream_write_block__returns_file_closed(void **state) {
+void test__f_file_stream_write_block__returns_stream_not(void **state) {
const f_file_t file = f_file_t_initialize;
{
const f_status_t status = f_file_stream_write_block(file, f_string_empty_s, 0);
- assert_int_equal(F_status_set_fine(status), F_file_closed);
+ assert_int_equal(F_status_set_fine(status), F_stream_not);
}
}
void test__f_file_stream_write_block__returns_data_not(void **state) {
- f_file_t file = f_file_t_initialize;
- file.stream = F_type_input_d;
+ f_file_t file = macro_f_file_t_initialize2(F_type_output_d, F_type_descriptor_output_d, F_file_flag_write_only_d);
{
const f_status_t status = f_file_stream_write_block(file, f_string_empty_s, 0);
{
f_array_length_t written = 0;
- f_file_t file = f_file_t_initialize;
+ f_file_t file = macro_f_file_t_initialize2(F_type_output_d, F_type_descriptor_output_d, F_file_flag_write_only_d);
file.size_write = 1;
- file.stream = F_type_input_d;
// The letter 't'.
will_return(__wrap_fwrite_unlocked, false);
}
{
- f_file_t file = f_file_t_initialize;
+ f_file_t file = macro_f_file_t_initialize2(F_type_output_d, F_type_descriptor_output_d, F_file_flag_write_only_d);
file.size_write = test.used;
- file.stream = F_type_input_d;
will_return(__wrap_fwrite_unlocked, false);
will_return(__wrap_fwrite_unlocked, test.used);
extern void test__f_file_stream_write_block__parameter_checking(void **state);
/**
- * Test that function works but the file stream is closed.
+ * Test that function works but the stream is not valid.
*
* @see f_file_stream_write_block()
*/
-extern void test__f_file_stream_write_block__returns_file_closed(void **state);
+extern void test__f_file_stream_write_block__returns_stream_not(void **state);
/**
* Test that function works but the path is empty.
const f_string_range_t range = macro_f_string_range_t_initialize(0, 0);
{
-
- f_file_t file = f_file_t_initialize;
+ f_file_t file = macro_f_file_t_initialize2(F_type_output_d, F_type_descriptor_output_d, F_file_flag_write_only_d);
file.size_read = 1;
- file.stream = F_type_input_d;
will_return(__wrap_fwrite_unlocked, true);
will_return(__wrap_fwrite_unlocked, 0);
void test__f_file_stream_write_range__parameter_checking(void **state) {
- f_file_t file = f_file_t_initialize;
+ f_file_t file = macro_f_file_t_initialize2(F_type_output_d, F_type_descriptor_output_d, F_file_flag_write_only_d);
file.size_write = 0;
const f_string_range_t range = f_string_range_t_initialize;
}
}
-void test__f_file_stream_write_range__returns_file_closed(void **state) {
+void test__f_file_stream_write_range__returns_stream_not(void **state) {
const f_file_t file = f_file_t_initialize;
const f_string_range_t range = f_string_range_t_initialize;
{
const f_status_t status = f_file_stream_write_range(file, f_string_empty_s, range, 0);
- assert_int_equal(F_status_set_fine(status), F_file_closed);
+ assert_int_equal(F_status_set_fine(status), F_stream_not);
}
}
void test__f_file_stream_write_range__returns_data_not(void **state) {
- f_file_t file = f_file_t_initialize;
- file.stream = F_type_input_d;
+ f_file_t file = macro_f_file_t_initialize2(F_type_output_d, F_type_descriptor_output_d, F_file_flag_write_only_d);
{
const f_string_range_t range = f_string_range_t_initialize;
const f_string_range_t range = macro_f_string_range_t_initialize(0, 0);
{
- f_file_t file = f_file_t_initialize;
+ f_file_t file = macro_f_file_t_initialize2(F_type_output_d, F_type_descriptor_output_d, F_file_flag_write_only_d);
file.size_write = 1;
- file.stream = F_type_input_d;
will_return(__wrap_fwrite_unlocked, false);
will_return(__wrap_fwrite_unlocked, 1);
}
{
- f_file_t file = f_file_t_initialize;
+ f_file_t file = macro_f_file_t_initialize2(F_type_output_d, F_type_descriptor_output_d, F_file_flag_write_only_d);
file.size_write = test.used;
- file.stream = F_type_input_d;
will_return(__wrap_fwrite_unlocked, false);
will_return(__wrap_fwrite_unlocked, test.used);
extern void test__f_file_stream_write_range__parameter_checking(void **state);
/**
- * Test that function works but the file stream is closed.
+ * Test that function works but the stream is not valid.
*
* @see f_file_stream_write_range()
*/
-extern void test__f_file_stream_write_range__returns_file_closed(void **state);
+extern void test__f_file_stream_write_range__returns_stream_not(void **state);
/**
* Test that function works but the path is empty.
const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4);
{
-
- f_file_t file = f_file_t_initialize;
+ f_file_t file = macro_f_file_t_initialize2(F_type_output_d, F_type_descriptor_output_d, F_file_flag_write_only_d);
file.size_read = 1;
- file.stream = F_type_input_d;
will_return(__wrap_fwrite_unlocked, true);
will_return(__wrap_fwrite_unlocked, 0);
void test__f_file_stream_write_until__parameter_checking(void **state) {
- f_file_t file = f_file_t_initialize;
+ f_file_t file = macro_f_file_t_initialize2(F_type_output_d, F_type_descriptor_output_d, F_file_flag_write_only_d);
file.size_write = 0;
{
}
}
-void test__f_file_stream_write_until__returns_file_closed(void **state) {
+void test__f_file_stream_write_until__returns_stream_not(void **state) {
f_file_t file = f_file_t_initialize;
file.stream = 0;
{
const f_status_t status = f_file_stream_write_until(file, f_string_empty_s, 0, 0);
- assert_int_equal(F_status_set_fine(status), F_file_closed);
+ assert_int_equal(F_status_set_fine(status), F_stream_not);
}
}
const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4);
- f_file_t file = f_file_t_initialize;
- file.stream = F_type_input_d;
+ f_file_t file = macro_f_file_t_initialize2(F_type_output_d, F_type_descriptor_output_d, F_file_flag_write_only_d);
{
const f_status_t status = f_file_stream_write_until(file, f_string_empty_s, 0, 0);
const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4);
{
- f_file_t file = f_file_t_initialize;
+ f_file_t file = macro_f_file_t_initialize2(F_type_output_d, F_type_descriptor_output_d, F_file_flag_write_only_d);
file.size_write = 1;
- file.stream = F_type_input_d;
// The letter 't'.
will_return(__wrap_fwrite_unlocked, false);
}
{
- f_file_t file = f_file_t_initialize;
+ f_file_t file = macro_f_file_t_initialize2(F_type_output_d, F_type_descriptor_output_d, F_file_flag_write_only_d);
file.size_write = test.used;
- file.stream = F_type_input_d;
will_return(__wrap_fwrite_unlocked, false);
will_return(__wrap_fwrite_unlocked, test.used);
extern void test__f_file_stream_write_until__parameter_checking(void **state);
/**
- * Test that function works but the file stream is closed.
+ * Test that function works but the stream is not valid.
*
* @see f_file_stream_write_until()
*/
-extern void test__f_file_stream_write_until__returns_file_closed(void **state);
+extern void test__f_file_stream_write_until__returns_stream_not(void **state);
/**
* Test that function works but the path is empty.
void test__f_file_touch_at__fails(void **state) {
+ const f_file_t file = macro_f_file_t_initialize2(F_type_output_d, F_type_descriptor_output_d, F_file_flag_write_only_d);
const f_string_static_t path = macro_f_string_static_t_initialize("test", 0, 4);
const mode_t mode = 0;
will_return(__wrap_close, 0);
}
- const f_status_t status = f_file_touch_at(1, path, mode, 0);
+ const f_status_t status = f_file_touch_at(file, path, mode, 0);
if (statuss[i] == F_file_found_not) {
assert_int_equal(status, F_none);
will_return(__wrap_utimensat, true);
will_return(__wrap_utimensat, errnos[i]);
- const f_status_t status = f_file_touch_at(1, path, mode, 0);
+ const f_status_t status = f_file_touch_at(file, path, mode, 0);
assert_int_equal(status, F_status_set_error(statuss[i]));
} // for
void test__f_file_touch_at__returns_data_not(void **state) {
+ const f_file_t file = macro_f_file_t_initialize2(F_type_output_d, F_type_descriptor_output_d, F_file_flag_write_only_d);
const mode_t mode = 0;
{
- const f_status_t status = f_file_touch_at(1, f_string_empty_s, mode, 0);
+ const f_status_t status = f_file_touch_at(file, f_string_empty_s, mode, 0);
assert_int_equal(status, F_data_not);
}
}
+void test__f_file_touch_at__returns_file_descriptor_not(void **state) {
+
+ const f_file_t file = macro_f_file_t_initialize2(F_type_output_d, -1, F_file_flag_write_only_d);
+ const mode_t mode = 0;
+
+ {
+ const f_status_t status = f_file_touch_at(file, f_string_empty_s, mode, 0);
+
+ assert_int_equal(status, F_file_descriptor_not);
+ }
+}
+
void test__f_file_touch_at__works(void **state) {
+ const f_file_t file = macro_f_file_t_initialize2(F_type_output_d, F_type_descriptor_output_d, F_file_flag_write_only_d);
const f_string_static_t path = macro_f_string_static_t_initialize("test", 0, 4);
const mode_t mode = 0;
will_return(__wrap_utimensat, false);
will_return(__wrap_utimensat, 0);
- const f_status_t status = f_file_touch_at(1, path, mode, 0);
+ const f_status_t status = f_file_touch_at(file, path, mode, 0);
assert_int_equal(status, F_none);
}
extern void test__f_file_touch_at__returns_data_not(void **state);
/**
+ * Test that function works but the descriptor is not valid.
+ *
+ * @see f_file_touch_at()
+ */
+extern void test__f_file_touch_at__returns_file_descriptor_not(void **state);
+
+/**
* Test that function works.
*
* @see f_file_touch_at()
void test__f_file_type_at__fails(void **state) {
+ const f_file_t file = macro_f_file_t_initialize2(F_type_output_d, F_type_descriptor_output_d, F_file_flag_write_only_d);
const f_string_static_t path = macro_f_string_static_t_initialize("test", 0, 4);
int errnos[] = {
will_return(__wrap_fstatat, true);
will_return(__wrap_fstatat, errnos[i]);
- const f_status_t status = f_file_type_at(0, path, 0, &mode);
+ const f_status_t status = f_file_type_at(file, path, 0, &mode);
assert_int_equal(status, F_status_set_error(statuss[i]));
} // for
void test__f_file_type_at__parameter_checking(void **state) {
+ const f_file_t file = macro_f_file_t_initialize2(F_type_output_d, F_type_descriptor_output_d, F_file_flag_write_only_d);
+
{
- const f_status_t status = f_file_type_at(0, f_string_empty_s, 0, 0);
+ const f_status_t status = f_file_type_at(file, f_string_empty_s, 0, 0);
assert_int_equal(status, F_status_set_error(F_parameter));
}
void test__f_file_type_at__returns_data_not(void **state) {
+ const f_file_t file = macro_f_file_t_initialize2(F_type_output_d, F_type_descriptor_output_d, F_file_flag_write_only_d);
+
{
int type = 0;
- const f_status_t status = f_file_type_at(0, f_string_empty_s, 0, &type);
+ const f_status_t status = f_file_type_at(file, f_string_empty_s, 0, &type);
assert_int_equal(status, F_data_not);
}
}
+void test__f_file_type_at__returns_file_descriptor_not(void **state) {
+
+ const f_file_t file = macro_f_file_t_initialize2(F_type_output_d, -1, F_file_flag_write_only_d);
+
+ {
+ int type = 0;
+
+ const f_status_t status = f_file_type_at(file, f_string_empty_s, 0, &type);
+
+ assert_int_equal(status, F_file_descriptor_not);
+ }
+}
+
void test__f_file_type_at__works(void **state) {
+ const f_file_t file = macro_f_file_t_initialize2(F_type_output_d, F_type_descriptor_output_d, F_file_flag_write_only_d);
const f_string_static_t path = macro_f_string_static_t_initialize("test", 0, 4);
{
will_return(__wrap_fstatat, &statistics);
will_return(__wrap_fstatat, 0);
- const f_status_t status = f_file_type_at(0, path, 0, &type);
+ const f_status_t status = f_file_type_at(file, path, 0, &type);
assert_int_equal(status, F_none);
assert_int_equal(type, F_file_type_link_d);
will_return(__wrap_fstatat, &statistics);
will_return(__wrap_fstatat, 0);
- const f_status_t status = f_file_type_at(0, path, 0, &type);
+ const f_status_t status = f_file_type_at(file, path, 0, &type);
assert_int_equal(status, F_none);
assert_int_equal(type, F_file_type_regular_d);
extern void test__f_file_type_at__returns_data_not(void **state);
/**
+ * Test that function works but the descriptor is not valid.
+ *
+ * @see f_file_type_at()
+ */
+extern void test__f_file_type_at__returns_file_descriptor_not(void **state);
+
+/**
* Test that function works.
*
* @see f_file_type_at()
void test__f_file_write__parameter_checking(void **state) {
- f_file_t file = f_file_t_initialize;
+ f_file_t file = macro_f_file_t_initialize2(F_type_output_d, F_type_descriptor_output_d, F_file_flag_write_only_d);
file.size_write = 0;
{
}
}
-void test__f_file_write__returns_file_closed(void **state) {
+void test__f_file_write__returns_file_descriptor_not(void **state) {
const f_file_t file = f_file_t_initialize;
{
const f_status_t status = f_file_write(file, f_string_empty_s, 0);
- assert_int_equal(F_status_set_fine(status), F_file_closed);
+ assert_int_equal(F_status_set_fine(status), F_file_descriptor_not);
}
}
extern void test__f_file_write__parameter_checking(void **state);
/**
- * Test that function works but the file is closed.
+ * Test that function works but the descriptor is not valid.
*
* @see f_file_write()
*/
-extern void test__f_file_write__returns_file_closed(void **state);
+extern void test__f_file_write__returns_file_descriptor_not(void **state);
/**
* Test that function works but the path is empty.
void test__f_file_write_block__parameter_checking(void **state) {
- f_file_t file = f_file_t_initialize;
+ f_file_t file = macro_f_file_t_initialize2(F_type_output_d, F_type_descriptor_output_d, F_file_flag_write_only_d);
file.size_write = 0;
{
}
}
-void test__f_file_write_block__returns_file_closed(void **state) {
+void test__f_file_write_block__returns_file_descriptor_not(void **state) {
f_file_t file = f_file_t_initialize;
file.size_write = 1;
{
const f_status_t status = f_file_write_block(file, f_string_empty_s, 0);
- assert_int_equal(F_status_set_fine(status), F_file_closed);
+ assert_int_equal(F_status_set_fine(status), F_file_descriptor_not);
}
}
extern void test__f_file_write_block__parameter_checking(void **state);
/**
- * Test that function works but the file is closed.
+ * Test that function works but the descriptor is not valid.
*
* @see f_file_write_block()
*/
-extern void test__f_file_write_block__returns_file_closed(void **state);
+extern void test__f_file_write_block__returns_file_descriptor_not(void **state);
/**
* Test that function works but the path is empty.
void test__f_file_write_range__parameter_checking(void **state) {
- f_file_t file = f_file_t_initialize;
+ f_file_t file = macro_f_file_t_initialize2(F_type_output_d, F_type_descriptor_output_d, F_file_flag_write_only_d);
file.size_write = 0;
const f_string_range_t range = f_string_range_t_initialize;
}
}
-void test__f_file_write_range__returns_file_closed(void **state) {
+void test__f_file_write_range__returns_file_descriptor_not(void **state) {
f_file_t file = f_file_t_initialize;
const f_string_range_t range = f_string_range_t_initialize;
{
const f_status_t status = f_file_write_range(file, f_string_empty_s, range, 0);
- assert_int_equal(F_status_set_fine(status), F_file_closed);
+ assert_int_equal(F_status_set_fine(status), F_file_descriptor_not);
}
}
void test__f_file_write_range__returns_data_not(void **state) {
- f_file_t file = f_file_t_initialize;
- file.id = 0;
+ const f_file_t file = macro_f_file_t_initialize2(F_type_output_d, F_type_descriptor_output_d, F_file_flag_write_only_d);
{
const f_string_range_t range = f_string_range_t_initialize;
extern void test__f_file_write_range__parameter_checking(void **state);
/**
- * Test that function works but the file is closed.
+ * Test that function works but the descriptor is not valid.
*
* @see f_file_write_range()
*/
-extern void test__f_file_write_range__returns_file_closed(void **state);
+extern void test__f_file_write_range__returns_file_descriptor_not(void **state);
/**
* Test that function works but the path is empty.
void test__f_file_write_until__parameter_checking(void **state) {
- f_file_t file = f_file_t_initialize;
+ f_file_t file = macro_f_file_t_initialize2(F_type_output_d, F_type_descriptor_output_d, F_file_flag_write_only_d);
file.size_write = 0;
{
}
}
-void test__f_file_write_until__returns_file_closed(void **state) {
+void test__f_file_write_until__returns_file_descriptor_not(void **state) {
f_file_t file = f_file_t_initialize;
file.size_write = 1;
{
const f_status_t status = f_file_write_until(file, f_string_empty_s, 1, 0);
- assert_int_equal(F_status_set_fine(status), F_file_closed);
+ assert_int_equal(F_status_set_fine(status), F_file_descriptor_not);
}
}
extern void test__f_file_write_until__parameter_checking(void **state);
/**
- * Test that function works but the file is closed.
+ * Test that function works but the descriptor is not valid.
*
* @see f_file_write_until()
*/
-extern void test__f_file_write_until__returns_file_closed(void **state);
+extern void test__f_file_write_until__returns_file_descriptor_not(void **state);
/**
* Test that function works but the path is empty.
cmocka_unit_test(test__f_file_access_at__fails),
cmocka_unit_test(test__f_file_access_at__returns_data_not),
+ cmocka_unit_test(test__f_file_access_at__returns_file_descriptor_not),
cmocka_unit_test(test__f_file_access_at__works),
cmocka_unit_test(test__f_file_clone__fails_during_read_write),
cmocka_unit_test(test__f_file_clone__works_for_link),
cmocka_unit_test(test__f_file_close__fails),
+ cmocka_unit_test(test__f_file_close__returns_file_descriptor_not),
cmocka_unit_test(test__f_file_close__works),
- cmocka_unit_test(test__f_file_close__works_already_closed),
-
- cmocka_unit_test(test__f_file_close_flush__fails),
- cmocka_unit_test(test__f_file_close_flush__works),
- cmocka_unit_test(test__f_file_close_flush__works_already_closed),
cmocka_unit_test(test__f_file_copy__fails_during_read_write),
cmocka_unit_test(test__f_file_copy__fails_for_block),
cmocka_unit_test(test__f_file_create_at__fails),
cmocka_unit_test(test__f_file_create_at__returns_data_not),
+ cmocka_unit_test(test__f_file_create_at__returns_file_descriptor_not),
cmocka_unit_test(test__f_file_create_at__works),
cmocka_unit_test(test__f_file_create_device__fails),
cmocka_unit_test(test__f_file_create_device_at__fails),
cmocka_unit_test(test__f_file_create_device_at__returns_data_not),
+ cmocka_unit_test(test__f_file_create_device_at__returns_file_descriptor_not),
cmocka_unit_test(test__f_file_create_device_at__returns_supported_not),
cmocka_unit_test(test__f_file_create_device_at__works),
cmocka_unit_test(test__f_file_create_fifo_at__fails),
cmocka_unit_test(test__f_file_create_fifo_at__returns_data_not),
+ cmocka_unit_test(test__f_file_create_fifo_at__returns_file_descriptor_not),
cmocka_unit_test(test__f_file_create_fifo_at__works),
cmocka_unit_test(test__f_file_create_node__fails),
cmocka_unit_test(test__f_file_create_node_at__fails),
cmocka_unit_test(test__f_file_create_node_at__returns_data_not),
+ cmocka_unit_test(test__f_file_create_node_at__returns_file_descriptor_not),
cmocka_unit_test(test__f_file_create_node_at__returns_supported_not),
cmocka_unit_test(test__f_file_create_node_at__works),
cmocka_unit_test(test__f_file_descriptor__fails),
+ cmocka_unit_test(test__f_file_descriptor__returns_stream_not),
cmocka_unit_test(test__f_file_descriptor__works),
cmocka_unit_test(test__f_file_exists__fails),
cmocka_unit_test(test__f_file_exists_at__fails),
cmocka_unit_test(test__f_file_exists_at__returns_data_not),
+ cmocka_unit_test(test__f_file_exists_at__returns_file_descriptor_not),
cmocka_unit_test(test__f_file_exists_at__works),
cmocka_unit_test(test__f_file_flush__fails),
+ cmocka_unit_test(test__f_file_flush__returns_file_descriptor_not),
cmocka_unit_test(test__f_file_flush__works),
cmocka_unit_test(test__f_file_group_read__fails),
cmocka_unit_test(test__f_file_is_at__fails),
cmocka_unit_test(test__f_file_is_at__returns_data_not),
+ cmocka_unit_test(test__f_file_is_at__returns_file_descriptor_not),
cmocka_unit_test(test__f_file_is_at__returns_false),
cmocka_unit_test(test__f_file_is_at__returns_true),
- cmocka_unit_test(test__f_file_is_stat__fails),
cmocka_unit_test(test__f_file_is_stat__returns_false),
cmocka_unit_test(test__f_file_is_stat__returns_true),
cmocka_unit_test(test__f_file_link_at__fails),
cmocka_unit_test(test__f_file_link_at__returns_data_not),
+ cmocka_unit_test(test__f_file_link_at__returns_file_descriptor_not),
cmocka_unit_test(test__f_file_link_at__works),
cmocka_unit_test(test__f_file_link_hard__fails),
cmocka_unit_test(test__f_file_link_hard_at__fails),
cmocka_unit_test(test__f_file_link_hard_at__returns_data_not),
+ cmocka_unit_test(test__f_file_link_hard_at__returns_file_descriptor_not),
cmocka_unit_test(test__f_file_link_hard_at__works),
cmocka_unit_test(test__f_file_link_read__fails),
cmocka_unit_test(test__f_file_link_read_at__fails),
cmocka_unit_test(test__f_file_link_read_at__returns_data_not),
+ cmocka_unit_test(test__f_file_link_read_at__returns_file_descriptor_not),
cmocka_unit_test(test__f_file_link_read_at__works),
cmocka_unit_test(test__f_file_mode_determine__works_basic),
cmocka_unit_test(test__f_file_mode_read_at__fails),
cmocka_unit_test(test__f_file_mode_read_at__returns_data_not),
+ cmocka_unit_test(test__f_file_mode_read_at__returns_file_descriptor_not),
cmocka_unit_test(test__f_file_mode_read_at__works),
cmocka_unit_test(test__f_file_mode_set__fails),
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__returns_file_descriptor_not),
cmocka_unit_test(test__f_file_mode_set_at__works),
cmocka_unit_test(test__f_file_mode_to_mode__works),
cmocka_unit_test(test__f_file_open_at__fails),
cmocka_unit_test(test__f_file_open_at__returns_data_not),
+ cmocka_unit_test(test__f_file_open_at__returns_file_descriptor_not),
cmocka_unit_test(test__f_file_open_at__works),
cmocka_unit_test(test__f_file_owner_read__fails),
cmocka_unit_test(test__f_file_owner_read__works),
cmocka_unit_test(test__f_file_read__fails),
- cmocka_unit_test(test__f_file_read__returns_file_closed),
+ cmocka_unit_test(test__f_file_read__returns_file_descriptor_not),
cmocka_unit_test(test__f_file_read__works),
cmocka_unit_test(test__f_file_read_block__fails),
- cmocka_unit_test(test__f_file_read_block__returns_file_closed),
+ cmocka_unit_test(test__f_file_read_block__returns_file_descriptor_not),
cmocka_unit_test(test__f_file_read_block__works),
cmocka_unit_test(test__f_file_read_until__fails),
- cmocka_unit_test(test__f_file_read_until__returns_file_closed),
+ cmocka_unit_test(test__f_file_read_until__returns_file_descriptor_not),
cmocka_unit_test(test__f_file_read_until__works),
cmocka_unit_test(test__f_file_remove__fails),
cmocka_unit_test(test__f_file_remove_at__fails),
cmocka_unit_test(test__f_file_remove_at__returns_data_not),
+ cmocka_unit_test(test__f_file_remove_at__returns_file_descriptor_not),
cmocka_unit_test(test__f_file_remove_at__works),
cmocka_unit_test(test__f_file_rename__fails),
cmocka_unit_test(test__f_file_rename_at__fails),
cmocka_unit_test(test__f_file_rename_at__returns_data_not),
+ cmocka_unit_test(test__f_file_rename_at__returns_file_descriptor_not),
cmocka_unit_test(test__f_file_rename_at__works),
cmocka_unit_test(test__f_file_role_change__fails_for_dereference),
cmocka_unit_test(test__f_file_role_change_at__fails_for_dereference),
cmocka_unit_test(test__f_file_role_change_at__fails_for_reference),
cmocka_unit_test(test__f_file_role_change_at__returns_data_not),
+ cmocka_unit_test(test__f_file_role_change_at__returns_file_descriptor_not),
cmocka_unit_test(test__f_file_role_change_at__works_for_dereference),
cmocka_unit_test(test__f_file_role_change_at__works_for_reference),
cmocka_unit_test(test__f_file_seek__fails),
+ cmocka_unit_test(test__f_file_seek__returns_file_descriptor_not),
cmocka_unit_test(test__f_file_seek__works),
cmocka_unit_test(test__f_file_size__fails),
cmocka_unit_test(test__f_file_size_at__fails),
cmocka_unit_test(test__f_file_size_at__returns_data_not),
+ cmocka_unit_test(test__f_file_size_at__returns_file_descriptor_not),
cmocka_unit_test(test__f_file_size_at__works),
- cmocka_unit_test(test__f_file_size_by_id__fails),
- cmocka_unit_test(test__f_file_size_by_id__returns_file_closed),
+ cmocka_unit_test(test__f_file_stat_by_id__fails),
+ cmocka_unit_test(test__f_file_size_by_id__returns_file_descriptor_not),
cmocka_unit_test(test__f_file_size_by_id__works),
cmocka_unit_test(test__f_file_stat__fails),
cmocka_unit_test(test__f_file_stat_at__fails),
cmocka_unit_test(test__f_file_stat_at__returns_data_not),
+ cmocka_unit_test(test__f_file_stat_at__returns_file_descriptor_not),
cmocka_unit_test(test__f_file_stat_at__works),
cmocka_unit_test(test__f_file_stat_by_id__fails),
- cmocka_unit_test(test__f_file_stat_by_id__returns_file_closed),
+ cmocka_unit_test(test__f_file_stat_by_id__returns_file_descriptor_not),
cmocka_unit_test(test__f_file_stat_by_id__works),
- cmocka_unit_test(test__f_file_stream_close__fails_for_file_descriptor),
- cmocka_unit_test(test__f_file_stream_close__fails_for_stream),
+ cmocka_unit_test(test__f_file_stream_close__fails),
+ cmocka_unit_test(test__f_file_stream_close__returns_stream_not),
cmocka_unit_test(test__f_file_stream_close__works),
// __wrap_fdopen does not appear to be working.
cmocka_unit_test(test__f_file_stream_open__works),
cmocka_unit_test(test__f_file_stream_read__fails),
- cmocka_unit_test(test__f_file_stream_read__returns_file_closed),
+ cmocka_unit_test(test__f_file_stream_read__returns_stream_not),
cmocka_unit_test(test__f_file_stream_read__works),
cmocka_unit_test(test__f_file_stream_read_block__fails),
- cmocka_unit_test(test__f_file_stream_read_block__returns_file_closed),
+ cmocka_unit_test(test__f_file_stream_read_block__returns_stream_not),
cmocka_unit_test(test__f_file_stream_read_block__works),
cmocka_unit_test(test__f_file_stream_read_until__fails),
- cmocka_unit_test(test__f_file_stream_read_until__returns_file_closed),
+ cmocka_unit_test(test__f_file_stream_read_until__returns_stream_not),
cmocka_unit_test(test__f_file_stream_read_until__works),
cmocka_unit_test(test__f_file_stream_reopen__fails),
cmocka_unit_test(test__f_file_stream_reopen__works),
cmocka_unit_test(test__f_file_stream_write__fails),
- cmocka_unit_test(test__f_file_stream_write__returns_file_closed),
cmocka_unit_test(test__f_file_stream_write__returns_data_not),
+ cmocka_unit_test(test__f_file_stream_write__returns_stream_not),
cmocka_unit_test(test__f_file_stream_write__works),
cmocka_unit_test(test__f_file_stream_write_block__fails),
- cmocka_unit_test(test__f_file_stream_write_block__returns_file_closed),
cmocka_unit_test(test__f_file_stream_write_block__returns_data_not),
+ cmocka_unit_test(test__f_file_stream_write_block__returns_stream_not),
cmocka_unit_test(test__f_file_stream_write_block__works),
cmocka_unit_test(test__f_file_stream_write_range__fails),
- cmocka_unit_test(test__f_file_stream_write_range__returns_file_closed),
cmocka_unit_test(test__f_file_stream_write_range__returns_data_not),
+ cmocka_unit_test(test__f_file_stream_write_range__returns_stream_not),
cmocka_unit_test(test__f_file_stream_write_range__works),
cmocka_unit_test(test__f_file_stream_write_until__fails),
- cmocka_unit_test(test__f_file_stream_write_until__returns_file_closed),
cmocka_unit_test(test__f_file_stream_write_until__returns_data_not),
+ cmocka_unit_test(test__f_file_stream_write_until__returns_stream_not),
cmocka_unit_test(test__f_file_stream_write_until__works),
cmocka_unit_test(test__f_file_touch__fails),
cmocka_unit_test(test__f_file_touch_at__fails),
cmocka_unit_test(test__f_file_touch_at__returns_data_not),
+ cmocka_unit_test(test__f_file_touch_at__returns_file_descriptor_not),
cmocka_unit_test(test__f_file_touch_at__works),
cmocka_unit_test(test__f_file_type__fails),
cmocka_unit_test(test__f_file_type_at__fails),
cmocka_unit_test(test__f_file_type_at__returns_data_not),
+ cmocka_unit_test(test__f_file_type_at__returns_file_descriptor_not),
cmocka_unit_test(test__f_file_type_at__works),
cmocka_unit_test(test__f_file_umask_get__works),
cmocka_unit_test(test__f_file_umask_set__works),
cmocka_unit_test(test__f_file_write__fails),
- cmocka_unit_test(test__f_file_write__returns_file_closed),
+ cmocka_unit_test(test__f_file_write__returns_file_descriptor_not),
cmocka_unit_test(test__f_file_write__returns_data_not),
cmocka_unit_test(test__f_file_write__works),
cmocka_unit_test(test__f_file_write_block__fails),
- cmocka_unit_test(test__f_file_write_block__returns_file_closed),
+ cmocka_unit_test(test__f_file_write_block__returns_file_descriptor_not),
cmocka_unit_test(test__f_file_write_block__returns_data_not),
cmocka_unit_test(test__f_file_write_block__works),
cmocka_unit_test(test__f_file_write_range__fails),
- cmocka_unit_test(test__f_file_write_range__returns_file_closed),
+ cmocka_unit_test(test__f_file_write_range__returns_file_descriptor_not),
cmocka_unit_test(test__f_file_write_range__returns_data_not),
cmocka_unit_test(test__f_file_write_range__works),
cmocka_unit_test(test__f_file_write_until__fails),
- cmocka_unit_test(test__f_file_write_until__returns_file_closed),
+ cmocka_unit_test(test__f_file_write_until__returns_file_descriptor_not),
cmocka_unit_test(test__f_file_write_until__returns_data_not),
cmocka_unit_test(test__f_file_write_until__works),
// f_file_access_at() doesn't use parameter checking.
// f_file_clone() doesn't use parameter checking.
cmocka_unit_test(test__f_file_close__parameter_checking),
- cmocka_unit_test(test__f_file_close_flush__parameter_checking),
// f_file_copy() doesn't use parameter checking.
// f_file_create() doesn't use parameter checking.
// f_file_create_at() doesn't use parameter checking.
#include "test-file-access_at.h"
#include "test-file-clone.h"
#include "test-file-close.h"
-#include "test-file-close_flush.h"
#include "test-file-copy.h"
#include "test-file-create.h"
#include "test-file-create_at.h"
// Libc includes.
#include <stdio.h>
+#include <fcntl.h>
#ifdef __cplusplus
extern "C" {
* - read_size: Default read size in bytes.
* - write_size: Default write size in bytes.
*/
-#ifndef _di_f_type_file_defaults_
- #define F_file_default_read_size_d 8192
- #define F_file_default_write_size_d 8192
-#endif // _di_f_type_file_defaults_
+#ifndef _di_f_type_file_defaults_d_
+ #define F_file_default_size_read_d 8192
+ #define F_file_default_size_write_d 8192
+#endif // _di_f_type_file_defaults_d_
+
+/**
+ * File flag related functionality.
+ */
+#ifndef _di_f_type_file_flag_d_
+
+ // This is not always defined, so ensure it is defined.
+ #ifndef O_PATH
+ #define O_PATH 010000000
+ #endif // O_PATH
+
+ // File open flags.
+ #define F_file_flag_append_d O_APPEND
+ #define F_file_flag_asynchronous_d O_ASYNC
+ #define F_file_flag_create_d O_CREAT
+ #define F_file_flag_close_execute_d O_CLOEXEC
+ #define F_file_flag_direct_d O_DIRECT
+ #define F_file_flag_directory_d O_DIRECTORY
+ #define F_file_flag_exclusive_d O_EXCL
+ #define F_file_flag_large_file_d O_LARGEFILE
+ #define F_file_flag_no_access_time_d O_NOATIME
+ #define F_file_flag_no_follow_d O_NOFOLLOW
+ #define F_file_flag_no_tty_d O_NOCTTY
+ #define F_file_flag_non_blocking_d O_NONBLOCK
+ #define F_file_flag_path_d O_PATH
+ #define F_file_flag_read_only_d O_RDONLY
+ #define F_file_flag_read_write_d O_RDWR
+ #define F_file_flag_synchronous_d O_SYNC
+ #define F_file_flag_synchronous_direct_d O_DSYNC
+ #define F_file_flag_temporary_d O_TMPFILE
+ #define F_file_flag_truncate_d O_TRUNC
+ #define F_file_flag_write_only_d O_WRONLY
+
+ // File open flags pre-combined with create.
+ #define F_file_flag_create_ro_d (O_CREAT | O_RDONLY)
+ #define F_file_flag_create_wo_d (O_CREAT | O_WRONLY)
+ #define F_file_flag_create_rw_d (O_CREAT | O_RDRW)
+
+ // File open flags pre-combined will fail if file exists.
+ #define F_file_flag_create_new_ro_d (O_CREAT | O_EXCL | O_RDONLY)
+ #define F_file_flag_create_new_wo_d (O_CREAT | O_EXCL | O_WRONLY)
+ #define F_file_flag_create_new_rw_d (O_CREAT | O_EXCL | O_RDRW)
+
+ // File open flags pre-combined will truncate any existing files to 0.
+ #define F_file_flag_truncate_ro_d (O_CREAT | O_TRUNC | O_RDONLY)
+ #define F_file_flag_truncate_rw_d (O_CREAT | O_TRUNC | O_RDRW)
+ #define F_file_flag_truncate_wo_d (O_CREAT | O_TRUNC | O_WRONLY)
+
+ // File open flags pre-combined will truncate any existing files to 0.
+ #define F_file_flag_append_rw_d (O_CREAT | O_APPEND | O_RDRW)
+ #define F_file_flag_append_wo_d (O_CREAT | O_APPEND | O_WRONLY)
+
+ // File open flags pre-combined with synchronous io.
+ #define F_file_flag_sync_ro_d (O_SYNC | O_RDONLY)
+ #define F_file_flag_sync_wo_d (O_SYNC | O_WRONLY)
+ #define F_file_flag_sync_rw_d (O_SYNC | O_RDRW)
+ #define F_file_flag_sync_create_ro_d (O_SYNC | O_CREAT | O_RDONLY)
+ #define F_file_flag_sync_create_wo_d (O_SYNC | O_CREAT | O_WRONLY)
+ #define F_file_flag_sync_create_rw_d (O_SYNC | O_CREAT | O_RDRW)
+ #define F_file_flag_sync_create_new_ro_d (O_SYNC | O_CREAT | O_EXCL | O_RDONLY)
+ #define F_file_flag_sync_create_new_wo_d (O_SYNC | O_CREAT | O_EXCL | O_WRONLY)
+ #define F_file_flag_sync_create_new_rw_d (O_SYNC | O_CREAT | O_EXCL | O_RDRW)
+
+ // File open flags pre-combined with asynchronous io.
+ #define F_file_flag_async_ro_d (O_ASYNC | O_RDONLY)
+ #define F_file_flag_async_wo_d (O_ASYNC | O_WRONLY)
+ #define F_file_flag_async_rw_d (O_ASYNC | O_RDRW)
+ #define F_file_flag_async_create_ro_d (O_ASYNC | O_CREAT | O_RDONLY)
+ #define F_file_flag_async_create_wo_d (O_ASYNC | O_CREAT | O_WRONLY)
+ #define F_file_flag_async_create_rw_d (O_ASYNC | O_CREAT | O_RDRW)
+ #define F_file_flag_async_create_new_ro_d (O_ASYNC | O_CREAT | O_EXCL | O_RDONLY)
+ #define F_file_flag_async_create_new_wo_d (O_ASYNC | O_CREAT | O_EXCL | O_WRONLY)
+ #define F_file_flag_async_create_new_rw_d (O_ASYNC | O_CREAT | O_EXCL | O_RDRW)
+
+ // File open flags pre-combined with direct io (which works synchronously).
+ #define F_file_flag_direct_ro_d (O_DIRECT | O_RDONLY)
+ #define F_file_flag_direct_wo_d (O_DIRECT | O_WRONLY)
+ #define F_file_flag_direct_rw_d (O_DIRECT | O_RDRW)
+ #define F_file_flag_direct_create_ro_d (O_DIRECT | O_CREAT | O_RDONLY)
+ #define F_file_flag_direct_create_wo_d (O_DIRECT | O_CREAT | O_WRONLY)
+ #define F_file_flag_direct_create_rw_d (O_DIRECT | O_CREAT | O_RDRW)
+ #define F_file_flag_direct_create_new_ro_d (O_DIRECT | O_CREAT | O_EXCL | O_RDONLY)
+ #define F_file_flag_direct_create_new_wo_d (O_DIRECT | O_CREAT | O_EXCL | O_WRONLY)
+ #define F_file_flag_direct_create_new_rw_d (O_DIRECT | O_CREAT | O_EXCL | O_RDRW)
+
+ // File open flags pre-combined with large_file.
+ #define F_file_flag_large_ro_d (O_LARGEFILE | O_RDONLY)
+ #define F_file_flag_large_wo_d (O_LARGEFILE | O_WRONLY)
+ #define F_file_flag_large_rw_d (O_LARGEFILE | O_RDRW)
+ #define F_file_flag_large_sync_ro_d (O_LARGEFILE | O_SYNC | O_RDONLY)
+ #define F_file_flag_large_sync_wo_d (O_LARGEFILE | O_SYNC | O_WRONLY)
+ #define F_file_flag_large_sync_rw_d (O_LARGEFILE | O_SYNC | O_RDRW)
+ #define F_file_flag_large_sync_create_ro_d (O_LARGEFILE | O_SYNC | O_CREAT | O_RDONLY)
+ #define F_file_flag_large_sync_create_wo_d (O_LARGEFILE | O_SYNC | O_CREAT | O_WRONLY)
+ #define F_file_flag_large_sync_create_rw_d (O_LARGEFILE | O_SYNC | O_CREAT | O_RDRW)
+ #define F_file_flag_large_sync_create_new_ro_d (O_LARGEFILE | O_SYNC | O_CREAT | O_EXCL | O_RDONLY)
+ #define F_file_flag_large_sync_create_new_wo_d (O_LARGEFILE | O_SYNC | O_CREAT | O_EXCL | O_WRONLY)
+ #define F_file_flag_large_sync_create_new_rw_d (O_LARGEFILE | O_SYNC | O_CREAT | O_EXCL | O_RDRW)
+ #define F_file_flag_large_async_ro_d (O_LARGEFILE | O_ASYNC | O_RDONLY)
+ #define F_file_flag_large_async_wo_d (O_LARGEFILE | O_ASYNC | O_WRONLY)
+ #define F_file_flag_large_async_rw_d (O_LARGEFILE | O_ASYNC | O_RDRW)
+ #define F_file_flag_large_async_create_ro_d (O_LARGEFILE | O_ASYNC | O_CREAT | O_RDONLY)
+ #define F_file_flag_large_async_create_wo_d (O_LARGEFILE | O_ASYNC | O_CREAT | O_WRONLY)
+ #define F_file_flag_large_async_create_rw_d (O_LARGEFILE | O_ASYNC | O_CREAT | O_RDRW)
+ #define F_file_flag_large_async_create_new_ro_d (O_LARGEFILE | O_ASYNC | O_CREAT | O_EXCL | O_RDONLY)
+ #define F_file_flag_large_async_create_new_wo_d (O_LARGEFILE | O_ASYNC | O_CREAT | O_EXCL | O_WRONLY)
+ #define F_file_flag_large_async_create_new_rw_d (O_LARGEFILE | O_ASYNC | O_CREAT | O_EXCL | O_RDRW)
+#endif // _di_f_type_file_flag_d_
/**
* Commonly used file related properties.
size_t size_write;
} f_file_t;
- #define f_file_t_initialize { 0, -1, O_RDONLY, F_file_default_read_size_d, F_file_default_write_size_d }
+ #define f_file_t_initialize { 0, -1, O_RDONLY, F_file_default_size_read_d, F_file_default_size_write_d }
#define macro_f_file_t_initialize(stream, id, flag, read_size, write_size) { stream, id, flag, read_size, write_size }
- #define macro_f_file_t_initialize2(stream, id, flag) { stream, id, flag, F_file_default_read_size_d, F_file_default_write_size_d }
- #define macro_f_file_t_initialize_id(id) { 0, id, O_RDONLY, F_file_default_read_size_d, F_file_default_write_size_d }
- #define macro_f_file_t_initialize_stream(stream) { stream, -1, O_RDONLY, F_file_default_read_size_d, F_file_default_write_size_d }
+ #define macro_f_file_t_initialize2(stream, id, flag) { stream, id, flag, F_file_default_size_read_d, F_file_default_size_write_d }
+ #define macro_f_file_t_initialize_id(id) { 0, id, O_RDONLY, F_file_default_size_read_d, F_file_default_size_write_d }
+ #define macro_f_file_t_initialize_stream(stream) { stream, -1, O_RDONLY, F_file_default_size_read_d, F_file_default_size_write_d }
#define macro_f_file_t_clear(file) \
file.stream = 0; \
file.stream = 0; \
file.id = -1; \
file.flag = O_RDONLY; \
- file.size_read = F_file_default_read_size_d; \
- file.size_write = F_file_default_write_size_d;
+ file.size_read = F_file_default_size_read_d; \
+ file.size_write = F_file_default_size_write_d;
#endif // _di_f_file_t_
#ifdef __cplusplus
fake_print_verbose_copying(&main->program.message, main->cache_2, main->cache_map.value);
- main->setting.state.status = f_file_copy(main->cache_2, main->cache_map.value, mode, F_file_default_read_size_d, f_file_stat_flag_reference_e);
+ main->setting.state.status = f_file_copy(main->cache_2, main->cache_map.value, mode, F_file_default_size_read_d, f_file_stat_flag_reference_e);
if (F_status_is_error(main->setting.state.status)) {
fake_print_error_build_operation_file(&main->program.error, macro_fake_f(f_file_copy), f_file_operation_copy_s, main->cache_2, main->cache_map.value, f_file_operation_to_s, F_true);
if (recurse->state.code & fake_state_code_clone_e) {
fake_print_verbose_cloning(&local->main->program.message, *recurse->path_top, map->name);
- recurse->state.status = f_file_clone(*recurse->path_top, map->name, F_file_default_write_size_d, f_file_stat_flag_group_e | f_file_stat_flag_owner_e | (f_directory_recurse_do_flag_dereference_e ? 0 : f_file_stat_flag_reference_e));
+ recurse->state.status = f_file_clone(*recurse->path_top, map->name, F_file_default_size_write_d, f_file_stat_flag_group_e | f_file_stat_flag_owner_e | (f_directory_recurse_do_flag_dereference_e ? 0 : f_file_stat_flag_reference_e));
}
else {
fake_print_verbose_copying(&local->main->program.message, *recurse->path_top, map->name);
- recurse->state.status = f_file_copy(*recurse->path_top, map->name, recurse->mode, F_file_default_write_size_d, f_directory_recurse_do_flag_dereference_e ? 0 : f_file_stat_flag_reference_e);
+ recurse->state.status = f_file_copy(*recurse->path_top, map->name, recurse->mode, F_file_default_size_write_d, f_directory_recurse_do_flag_dereference_e ? 0 : f_file_stat_flag_reference_e);
}
if (F_status_is_error(recurse->state.status)) {
if (recurse->state.code & fake_state_code_clone_e) {
fake_print_verbose_cloning(&local->main->program.message, recurse->path, recurse->path_cache);
- recurse->state.status = f_file_clone(recurse->path, recurse->path_cache, F_file_default_write_size_d, f_file_stat_flag_group_e | f_file_stat_flag_owner_e | (f_directory_recurse_do_flag_dereference_e ? 0 : f_file_stat_flag_reference_e));
+ recurse->state.status = f_file_clone(recurse->path, recurse->path_cache, F_file_default_size_write_d, f_file_stat_flag_group_e | f_file_stat_flag_owner_e | (f_directory_recurse_do_flag_dereference_e ? 0 : f_file_stat_flag_reference_e));
}
else {
fake_print_verbose_copying(&local->main->program.message, recurse->path, recurse->path_cache);
- recurse->state.status = f_file_copy(recurse->path, recurse->path_cache, recurse->mode, F_file_default_write_size_d, f_directory_recurse_do_flag_dereference_e ? 0 : f_file_stat_flag_reference_e);
+ recurse->state.status = f_file_copy(recurse->path, recurse->path_cache, recurse->mode, F_file_default_size_write_d, f_directory_recurse_do_flag_dereference_e ? 0 : f_file_stat_flag_reference_e);
}
if (F_status_is_error(recurse->state.status)) {
if (recurse->state.code & fake_state_code_clone_e) {
fake_print_verbose_cloning(&local->main->program.message, recurse->path, map->value);
- recurse->state.status = f_file_clone(recurse->path, map->value, F_file_default_write_size_d, f_file_stat_flag_group_e | f_file_stat_flag_owner_e | (f_directory_recurse_do_flag_dereference_e ? 0 : f_file_stat_flag_reference_e));
+ recurse->state.status = f_file_clone(recurse->path, map->value, F_file_default_size_write_d, f_file_stat_flag_group_e | f_file_stat_flag_owner_e | (f_directory_recurse_do_flag_dereference_e ? 0 : f_file_stat_flag_reference_e));
}
else {
fake_print_verbose_copying(&local->main->program.message, recurse->path, map->value);
- recurse->state.status = f_file_copy(recurse->path, map->value, recurse->mode, F_file_default_write_size_d, f_directory_recurse_do_flag_dereference_e ? 0 : f_file_stat_flag_reference_e);
+ recurse->state.status = f_file_copy(recurse->path, map->value, recurse->mode, F_file_default_size_write_d, f_directory_recurse_do_flag_dereference_e ? 0 : f_file_stat_flag_reference_e);
}
if (F_status_is_error(recurse->state.status)) {
}
else if (main->setting.state.status == F_false) {
if (clone) {
- main->setting.state.status = f_file_clone(main->cache_arguments.array[i], main->cache_map.name, F_file_default_write_size_d, f_file_stat_flag_group_e | f_file_stat_flag_owner_e | (f_directory_recurse_do_flag_dereference_e ? 0 : f_file_stat_flag_reference_e));
+ main->setting.state.status = f_file_clone(main->cache_arguments.array[i], main->cache_map.name, F_file_default_size_write_d, f_file_stat_flag_group_e | f_file_stat_flag_owner_e | (f_directory_recurse_do_flag_dereference_e ? 0 : f_file_stat_flag_reference_e));
}
else {
- main->setting.state.status = f_file_copy(main->cache_arguments.array[i], main->cache_map.name, main->cache_recurse_do.mode, F_file_default_write_size_d, f_directory_recurse_do_flag_dereference_e ? 0 : f_file_stat_flag_reference_e);
+ main->setting.state.status = f_file_copy(main->cache_arguments.array[i], main->cache_map.name, main->cache_recurse_do.mode, F_file_default_size_write_d, f_directory_recurse_do_flag_dereference_e ? 0 : f_file_stat_flag_reference_e);
}
if (F_status_is_error(main->setting.state.status)) {
f_status_t valid = F_true;
if (main->program.pipe & fll_program_data_pipe_input_e) {
- const f_file_t file = macro_f_file_t_initialize(F_type_input_d, F_type_descriptor_input_d, F_file_flag_read_only_d, 32768, F_file_default_write_size_d);
+ const f_file_t file = macro_f_file_t_initialize(F_type_input_d, F_type_descriptor_input_d, F_file_flag_read_only_d, 32768, F_file_default_size_write_d);
utf8_print_data_section_header_pipe(&main->program.output);
// Process "from" files.
if (F_status_is_error_not(main->setting.state.status) && (main->setting.flag & utf8_main_flag_file_from_e)) {
- f_file_t file = macro_f_file_t_initialize(0, -1, F_file_flag_read_only_d, 32768, F_file_default_write_size_d);
+ f_file_t file = macro_f_file_t_initialize(0, -1, F_file_flag_read_only_d, 32768, F_file_default_size_write_d);
for (f_array_length_t i = 0; i < main->setting.path_files_from.used && F_status_is_error_not(main->setting.state.status); ++i) {