flags -Wl,--wrap=faccessat
flags -Wl,--wrap=fchmodat
flags -Wl,--wrap=fchownat
+flags -Wl,--wrap=fclose
+flags -Wl,--wrap=fdopen
flags -Wl,--wrap=feof
flags -Wl,--wrap=ferror
+flags -Wl,--wrap=fflush
flags -Wl,--wrap=fileno
flags -Wl,--wrap=flockfile
+flags -Wl,--wrap=fopen
flags -Wl,--wrap=fread_unlocked
+flags -Wl,--wrap=freopen
flags -Wl,--wrap=fstat
flags -Wl,--wrap=fstatat
flags -Wl,--wrap=fsync
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-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_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-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-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
return mock_type(int);
}
+int __wrap_fclose(FILE *stream) {
+
+ const bool failure = mock_type(bool);
+
+ if (failure) {
+ errno = mock_type(int);
+
+ return EOF;
+ }
+
+ return mock_type(int);
+}
+
+FILE *__wrap_fopen(const char *pathname, const char *mode) {
+
+ const bool failure = mock_type(bool);
+
+ if (failure) {
+ errno = mock_type(int);
+
+ return 0;
+ }
+
+ return mock_type(FILE *);
+}
+
+FILE *__wrap_fdopen(int fd, const char *mode) {
+
+ const bool failure = mock_type(bool);
+
+ if (failure) {
+ errno = mock_type(int);
+
+ return 0;
+ }
+
+ return mock_type(FILE *);
+}
+
+FILE *__wrap_freopen(const char *pathname, const char *mode, FILE *stream) {
+
+ const bool failure = mock_type(bool);
+
+ if (failure) {
+ errno = mock_type(int);
+
+ return 0;
+ }
+
+ return mock_type(FILE *);
+}
+
int __wrap_feof_unlocked(FILE *stream) {
const bool failure = mock_type(bool);
return mock_type(int);
}
+int __wrap_fflush(FILE *stream) {
+
+ const bool failure = mock_type(bool);
+
+ if (failure) {
+ errno = mock_type(int);
+
+ return EOF;
+ }
+
+ return mock_type(int);
+}
+
int __wrap_fileno(FILE *stream) {
return mock_type(int);
}
extern int __wrap_fchmodat(int dirfd, const char *pathname, mode_t mode, int flags);
extern int __wrap_fchown(int fd, uid_t owner, gid_t group);
extern int __wrap_fchownat(int dirfd, const char *pathname, uid_t owner, gid_t group, int flags);
+extern int __wrap_fclose(FILE *stream);
+extern FILE *__wrap_fopen(const char *pathname, const char *mode);
+extern FILE *__wrap_fdopen(int fd, const char *mode);
+extern FILE *__wrap_freopen(const char *pathname, const char *mode, FILE *stream);
extern int __wrap_feof_unlocked(FILE *stream);
extern int __wrap_ferror_unlocked(FILE *stream);
+extern int __wrap_fflush(FILE *stream);
extern int __wrap_fileno(FILE *stream);
extern void __wrap_flockfile(FILE *filehandle);
extern size_t __wrap_fread_unlocked(void *ptr, size_t size, size_t nmemb, FILE *stream);
int errnos[] = {
EBADF,
EDQUOT,
- EIO,
- ENOSPC,
- EROFS,
- mock_errno_generic,
- };
-
- f_status_t statuss[] = {
- F_file_synchronize,
- F_file_synchronize,
- F_file_synchronize,
- F_file_synchronize,
- F_file_synchronize,
- F_file_synchronize,
- };
-
- struct stat statistics;
-
- memset(&statistics, 0, sizeof(struct stat));
-
- statistics.st_mode = 1 | F_file_type_regular_d;
-
- for (int i = 0; i < 6; ++i) {
-
- will_return(__wrap_stat, false);
- will_return(__wrap_stat, &statistics);
- will_return(__wrap_stat, 0);
-
- will_return(__wrap_open, false);
- will_return(__wrap_open, 0);
-
- will_return(__wrap_fsync, true);
- will_return(__wrap_fsync, errnos[i]);
-
- const f_status_t status = f_file_clone(path, path, 0, 0);
-
- assert_int_equal(F_status_set_fine(status), statuss[i]);
- } // for
- }
-
- {
- int errnos[] = {
- EBADF,
- EDQUOT,
EINTR,
EIO,
ENOSPC,
{
int errnos[] = {
EBADF,
- EDQUOT,
- EIO,
- ENOSPC,
- EROFS,
- mock_errno_generic,
- };
-
- f_status_t statuss[] = {
- F_file_synchronize,
- F_file_synchronize,
- F_file_synchronize,
- F_file_synchronize,
- F_file_synchronize,
- F_file_synchronize,
- };
-
- struct stat statistics;
-
- memset(&statistics, 0, sizeof(struct stat));
-
- statistics.st_mode = 1 | F_file_type_regular_d;
- statistics.st_size = 1;
-
- for (int i = 0; i < 6; ++i) {
-
- will_return(__wrap_stat, false);
- will_return(__wrap_stat, &statistics);
- will_return(__wrap_stat, 0);
-
- will_return(__wrap_open, false);
- will_return(__wrap_open, 0);
-
- will_return(__wrap_fsync, true);
- will_return(__wrap_fsync, errnos[i]);
-
- const f_status_t status = f_file_copy(path, path, mode, 0, 0);
-
- assert_int_equal(F_status_set_fine(status), statuss[i]);
- } // for
- }
-
- {
- int errnos[] = {
- EBADF,
EINTR,
EIO,
ENOSPC,
int errnos[] = {
EBADF,
EDQUOT,
- EIO,
- ENOSPC,
- EROFS,
- mock_errno_generic,
- };
-
- f_status_t statuss[] = {
- F_file_synchronize,
- F_file_synchronize,
- F_file_synchronize,
- F_file_synchronize,
- F_file_synchronize,
- F_file_synchronize,
- };
-
- for (int i = 0; i < 6; ++i) {
-
- will_return(__wrap_open, false);
- will_return(__wrap_open, 0);
-
- will_return(__wrap_fsync, true);
- will_return(__wrap_fsync, errnos[i]);
-
- const f_status_t status = f_file_create(path, 0, F_false);
-
- assert_int_equal(F_status_set_fine(status), statuss[i]);
- } // for
- }
-
- {
- int errnos[] = {
- EBADF,
- EDQUOT,
EINTR,
EIO,
ENOSPC,
{
int errnos[] = {
EBADF,
- EDQUOT,
- EIO,
- ENOSPC,
- EROFS,
- mock_errno_generic,
- };
-
- f_status_t statuss[] = {
- F_file_synchronize,
- F_file_synchronize,
- F_file_synchronize,
- F_file_synchronize,
- F_file_synchronize,
- F_file_synchronize,
- };
-
- for (int i = 0; i < 6; ++i) {
-
- will_return(__wrap_openat, false);
- will_return(__wrap_openat, 0);
-
- will_return(__wrap_fsync, true);
- will_return(__wrap_fsync, errnos[i]);
-
- const f_status_t status = f_file_create_at(0, path, 0, F_false);
-
- assert_int_equal(F_status_set_fine(status), statuss[i]);
- } // for
- }
-
- {
- int errnos[] = {
- EBADF,
EINTR,
EIO,
ENOSPC,
int errnos[] = {
EBADF,
EDQUOT,
+ EINVAL,
EIO,
ENOSPC,
EROFS,
f_status_t statuss[] = {
F_file_descriptor,
F_filesystem_quota_block,
+ F_supported_not,
F_input_output,
F_space_not,
F_supported_not,
- F_failure,
+ F_file_synchronize,
};
- for (int i = 0; i < 6; ++i) {
+ for (int i = 0; i < 7; ++i) {
will_return(__wrap_fsync, true);
will_return(__wrap_fsync, errnos[i]);
off_t size = 0;
- printf("\nDEBUG: i=%d\n", i);
-
will_return(__wrap_fstat, true);
will_return(__wrap_fstat, errnos[i]);
memset(&result, 0, sizeof(struct stat));
- printf("\nDEBUG: i=%d\n", i);
-
will_return(__wrap_fstat, true);
will_return(__wrap_fstat, errnos[i]);
extern "C" {
#endif
-void test__f_file_stream_close__fails(void **state) {
+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_flushs[] = {
+ F_file_descriptor,
+ F_filesystem_quota_block,
+ F_supported_not,
+ F_input_output,
+ F_space_not,
+ F_supported_not,
+ };
+
+ 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) {
int errnos[] = {
+ EACCES,
+ EAGAIN,
+ EBADF,
+ EFBIG,
+ EDEADLK,
+ EDESTADDRREQ,
+ EDQUOT,
+ EFAULT,
+ EINTR,
+ EINVAL,
+ EIO,
+ EMFILE,
+ ENOLCK,
+ ENOSPC,
+ ENOTDIR,
+ EPERM,
+ EPIPE,
+ EWOULDBLOCK,
mock_errno_generic,
};
- f_status_t statuss[] = {
- F_failure,
+ f_status_t status_flushs[] = {
+ F_access_denied,
+ F_block,
+ F_file_descriptor,
+ F_file_overflow,
+ F_deadlock,
+ F_socket_not,
+ F_space_not,
+ F_buffer,
+ F_interrupt,
+ F_parameter,
+ F_input_output,
+ F_file_descriptor_max,
+ F_lock,
+ F_space_not,
+ F_file_type_not_directory,
+ F_prohibited,
+ F_pipe_not,
+ F_block,
+ F_file_synchronize,
+ };
+
+ f_status_t status_closes[] = {
+ F_access_denied,
+ F_block,
+ F_file_descriptor,
+ F_file_overflow,
+ F_deadlock,
+ F_socket_not,
+ F_space_not,
+ F_buffer,
+ F_interrupt,
+ F_parameter,
+ F_input_output,
+ F_file_descriptor_max,
+ F_lock,
+ F_space_not,
+ F_file_type_not_directory,
+ F_prohibited,
+ F_pipe_not,
+ F_block,
+ F_file_close,
};
- for (int i = 0; i < 1; ++i) {
+ 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 = stdout;
+
+ 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_open, true);
- //will_return(__wrap_open, errnos[i]);
+ 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(path, F_false, &id);
+ const f_status_t status = f_file_stream_close(flush, &file);
- //assert_int_equal(F_status_set_fine(status), statuss[i]);
+ 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__works(void **state) {
{
- //will_return(__wrap_open, false);
- //will_return(__wrap_open, 5);
+ f_file_t file = f_file_t_initialize;
+
+ file.id = 0;
+ file.stream = stdout;
+
+ will_return(__wrap_fclose, false);
+ will_return(__wrap_fclose, 0);
+
+ 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 = 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(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 = f_file_t_initialize;
+
+ file.id = 0;
+ file.stream = stdout;
+
+ 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();
+ const f_status_t status = f_file_stream_close(F_true, &file);
- //assert_int_equal(status, F_none);
- //assert_int_equal(id, 5);
+ 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.
+ * Test that function fails for a file using the file descriptor.
*
* @see f_file_stream_close()
*/
-extern void test__f_file_stream_close__fails(void **state);
+extern void test__f_file_stream_close__fails_for_file_descriptor(void **state);
+
+/**
+ * Test that function fails for a file stream.
+ *
+ * @see f_file_stream_close()
+ */
+extern void test__f_file_stream_close__fails_for_stream(void **state);
/**
* Test that parameter checking works as expected.
+++ /dev/null
-#include "test-file.h"
-#include "test-file-stream_descriptor.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-void test__f_file_stream_descriptor__fails(void **state) {
-
- int errnos[] = {
- mock_errno_generic,
- };
-
- f_status_t statuss[] = {
- F_failure,
- };
-
- for (int i = 0; i < 1; ++i) {
-
- //will_return(__wrap_open, true);
- //will_return(__wrap_open, errnos[i]);
-
- //const f_status_t status = f_file_stream_descriptor(path, F_false, &id);
-
- //assert_int_equal(F_status_set_fine(status), statuss[i]);
- } // for
-}
-
-#ifndef _di_level_0_parameter_checking_
- void test__f_file_stream_descriptor__parameter_checking(void **state) {
-
- {
- const f_status_t status = f_file_stream_descriptor(f_string_empty_s, 0);
-
- assert_int_equal(F_status_set_fine(status), F_parameter);
- }
- }
-#endif // _di_level_0_parameter_checking_
-
-void test__f_file_stream_descriptor__returns_data_not(void **state) {
-
- {
- f_file_t file = f_file_t_initialize;
-
- const f_status_t status = f_file_stream_descriptor(f_string_empty_s, &file);
-
- assert_int_equal(status, F_data_not);
- }
-}
-
-void test__f_file_stream_descriptor__works(void **state) {
-
- {
- //will_return(__wrap_open, false);
- //will_return(__wrap_open, 5);
-
- //const f_status_t status = f_file_stream_descriptor();
-
- //assert_int_equal(status, F_none);
- //assert_int_equal(id, 5);
- }
-}
-
-#ifdef __cplusplus
-} // extern "C"
-#endif
+++ /dev/null
-/**
- * FLL - Level 0
- *
- * Project: File
- * API Version: 0.5
- * Licenses: lgpl-2.1-or-later
- *
- * Test the file project.
- */
-#ifndef _TEST__F_file_stream_descriptor_h
-#define _TEST__F_file_stream_descriptor_h
-
-/**
- * Test that function fails.
- *
- * @see f_file_stream_descriptor()
- */
-extern void test__f_file_stream_descriptor__fails(void **state);
-
-/**
- * Test that parameter checking works as expected.
- *
- * @see f_file_stream_descriptor()
- */
-#ifndef _di_level_0_parameter_checking_
- extern void test__f_file_stream_descriptor__parameter_checking(void **state);
-#endif // _di_level_0_parameter_checking_
-
-/**
- * Test that function works but the path is empty.
- *
- * @see f_file_stream_descriptor()
- */
-extern void test__f_file_stream_descriptor__returns_data_not(void **state);
-
-/**
- * Test that function works.
- *
- * @see f_file_stream_descriptor()
- */
-extern void test__f_file_stream_descriptor__works(void **state);
-
-#endif // _TEST__F_file_stream_descriptor_h
--- /dev/null
+#include "test-file.h"
+#include "test-file-stream_open_descriptor.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void test__f_file_stream_open_descriptor__fails(void **state) {
+
+ const f_string_static_t path = macro_f_string_static_t_initialize("test", 0, 4);
+
+ int errnos[] = {
+ EACCES,
+ EAGAIN,
+ EBADF,
+ EFBIG,
+ EDEADLK,
+ EDESTADDRREQ,
+ EDQUOT,
+ EFAULT,
+ EINTR,
+ EINVAL,
+ EIO,
+ EMFILE,
+ ENOLCK,
+ ENOMEM,
+ ENOSPC,
+ ENOTDIR,
+ EPERM,
+ EPIPE,
+ EWOULDBLOCK,
+ mock_errno_generic,
+ };
+
+ f_status_t statuss[] = {
+ F_access_denied,
+ F_block,
+ F_file_descriptor,
+ F_file_overflow,
+ F_deadlock,
+ F_socket_not,
+ F_space_not,
+ F_buffer,
+ F_interrupt,
+ F_parameter,
+ F_input_output,
+ F_file_descriptor_max,
+ F_lock,
+ F_memory_not,
+ F_space_not,
+ F_file_type_not_directory,
+ F_prohibited,
+ F_pipe_not,
+ F_block,
+ F_failure,
+ };
+
+ for (int i = 0; i < 20; ++i) {
+
+ f_file_t file = f_file_t_initialize;
+
+ will_return(__wrap_fdopen, true);
+ will_return(__wrap_fdopen, errnos[i]);
+
+ const f_status_t status = f_file_stream_open_descriptor(path, &file);
+
+ assert_int_equal(F_status_set_fine(status), statuss[i]);
+ } // for
+
+ for (int i = 0; i < 20; ++i) {
+
+ f_file_t file = f_file_t_initialize;
+
+ will_return(__wrap_fdopen, true);
+ will_return(__wrap_fdopen, errnos[i]);
+
+ const f_status_t status = f_file_stream_open_descriptor(f_string_empty_s, &file);
+
+ assert_int_equal(F_status_set_fine(status), statuss[i]);
+ } // for
+}
+
+#ifndef _di_level_0_parameter_checking_
+ void test__f_file_stream_open_descriptor__parameter_checking(void **state) {
+
+ {
+ const f_status_t status = f_file_stream_open_descriptor(f_string_empty_s, 0);
+
+ assert_int_equal(F_status_set_fine(status), F_parameter);
+ }
+ }
+#endif // _di_level_0_parameter_checking_
+
+void test__f_file_stream_open_descriptor__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_fdopen, false);
+ will_return(__wrap_fdopen, id);
+
+ const f_status_t status = f_file_stream_open_descriptor(path, &file);
+
+ assert_int_equal(status, F_none);
+ assert_int_equal(file.id, id);
+ }
+
+ {
+ f_file_t file = f_file_t_initialize;
+
+ will_return(__wrap_fdopen, false);
+ will_return(__wrap_fdopen, id);
+
+ const f_status_t status = f_file_stream_open_descriptor(f_string_empty_s, &file);
+
+ assert_int_equal(status, F_none);
+ assert_int_equal(file.id, id);
+ }
+}
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
--- /dev/null
+/**
+ * FLL - Level 0
+ *
+ * Project: File
+ * API Version: 0.5
+ * Licenses: lgpl-2.1-or-later
+ *
+ * Test the file project.
+ */
+#ifndef _TEST__F_file_stream_open_descriptor_h
+#define _TEST__F_file_stream_open_descriptor_h
+
+/**
+ * Test that function fails.
+ *
+ * @see f_file_stream_open_descriptor()
+ */
+extern void test__f_file_stream_open_descriptor__fails(void **state);
+
+/**
+ * Test that parameter checking works as expected.
+ *
+ * @see f_file_stream_open_descriptor()
+ */
+#ifndef _di_level_0_parameter_checking_
+ extern void test__f_file_stream_open_descriptor__parameter_checking(void **state);
+#endif // _di_level_0_parameter_checking_
+
+/**
+ * Test that function works.
+ *
+ * @see f_file_stream_open_descriptor()
+ */
+extern void test__f_file_stream_open_descriptor__works(void **state);
+
+#endif // _TEST__F_file_stream_open_descriptor_h
cmocka_unit_test(test__f_file_stat_by_id__returns_file_closed),
cmocka_unit_test(test__f_file_stat_by_id__works),
-/*
-
- // f_file_stream_close
+ 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__works),
- // f_file_stream_descriptor
+ // __wrap_fdopen does not appear to be working.
+ //cmocka_unit_test(test__f_file_stream_open_descriptor__fails),
+ //cmocka_unit_test(test__f_file_stream_open_descriptor__works),
+/*
// f_file_stream_open
// f_file_stream_read
cmocka_unit_test(test__f_file_stat_at__parameter_checking),
cmocka_unit_test(test__f_file_stat_by_id__parameter_checking),
cmocka_unit_test(test__f_file_stream_close__parameter_checking),
- cmocka_unit_test(test__f_file_stream_descriptor__parameter_checking),
+ cmocka_unit_test(test__f_file_stream_open_descriptor__parameter_checking),
cmocka_unit_test(test__f_file_stream_open__parameter_checking),
cmocka_unit_test(test__f_file_stream_read__parameter_checking),
cmocka_unit_test(test__f_file_stream_read_block__parameter_checking),
#include "test-file-stat_at.h"
#include "test-file-stat_by_id.h"
#include "test-file-stream_close.h"
-#include "test-file-stream_descriptor.h"
+#include "test-file-stream_open_descriptor.h"
#include "test-file-stream_open.h"
#include "test-file-stream_read.h"
#include "test-file-stream_read_block.h"