]> Kevux Git Server - fll/commitdiff
Progress: Continue witing f_file unit tests.
authorKevin Day <thekevinday@gmail.com>
Thu, 21 Apr 2022 03:56:00 +0000 (22:56 -0500)
committerKevin Day <thekevinday@gmail.com>
Thu, 21 Apr 2022 03:56:00 +0000 (22:56 -0500)
Almost there.
Just a few more functions to write tests for left.

17 files changed:
level_0/f_file/data/build/settings-mocks
level_0/f_file/tests/unit/c/mock-file.c
level_0/f_file/tests/unit/c/mock-file.h
level_0/f_file/tests/unit/c/test-file-stream_open.c
level_0/f_file/tests/unit/c/test-file-stream_read.c
level_0/f_file/tests/unit/c/test-file-stream_read_block.c
level_0/f_file/tests/unit/c/test-file-stream_read_until.c
level_0/f_file/tests/unit/c/test-file-stream_reopen.c
level_0/f_file/tests/unit/c/test-file-stream_write.c
level_0/f_file/tests/unit/c/test-file-stream_write_block.c
level_0/f_file/tests/unit/c/test-file-stream_write_range.c
level_0/f_file/tests/unit/c/test-file-stream_write_until.c
level_0/f_file/tests/unit/c/test-file-touch.c
level_0/f_file/tests/unit/c/test-file-touch_at.c
level_0/f_file/tests/unit/c/test-file-type.c
level_0/f_file/tests/unit/c/test-file-type_at.c
level_0/f_file/tests/unit/c/test-file.c

index c566667a2c18059a8bca976b2be8f9985614bc80..59a86e732292a5df771d4a9180abf4edcd02d7bc 100644 (file)
@@ -67,8 +67,8 @@ 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=feof_unlocked
+flags -Wl,--wrap=ferror_unlocked
 flags -Wl,--wrap=fflush
 flags -Wl,--wrap=fileno
 flags -Wl,--wrap=flockfile
@@ -79,7 +79,7 @@ flags -Wl,--wrap=fstat
 flags -Wl,--wrap=fstatat
 flags -Wl,--wrap=fsync
 flags -Wl,--wrap=funlockfile
-flags -Wl,--wrap=fwrite
+flags -Wl,--wrap=fwrite_unlocked
 flags -Wl,--wrap=lchown
 flags -Wl,--wrap=link
 flags -Wl,--wrap=linkat
@@ -106,4 +106,5 @@ flags -Wl,--wrap=symlink
 flags -Wl,--wrap=symlinkat
 flags -Wl,--wrap=unlink
 flags -Wl,--wrap=unlinkat
+flags -Wl,--wrap=utimensat
 flags -Wl,--wrap=write
index d976f429632bcbc69780bda14024558380a34007..992b19dd3fed5a328d3e42ed0296a14e58b2f6be 100644 (file)
@@ -680,6 +680,19 @@ int __wrap_unlinkat(int dirfd, const char *pathname, int flags) {
   return mock_type(int);
 }
 
+int __wrap_utimensat(int dirfd, const char *pathname, const struct timespec times[2], int flags) {
+
+  const bool failure = mock_type(bool);
+
+  if (failure) {
+    errno = mock_type(int);
+
+    return -1;
+  }
+
+  return mock_type(int);
+}
+
 ssize_t __wrap_write(int fd, const void *buf, size_t count) {
 
   const bool failure = mock_type(bool);
index 6a0bd9817e7893735efc0300e58db8108df661ad..955978459ab654fe3449dfe4d7cf985c8e3f191e 100644 (file)
@@ -76,6 +76,7 @@ extern int __wrap_symlink(const char *target, const char *linkpath);
 extern int __wrap_symlinkat(const char *target, int newdirfd, const char *linkpath);
 extern int __wrap_unlink(const char *pathname);
 extern int __wrap_unlinkat(int dirfd, const char *pathname, int flags);
+extern int __wrap_utimensat(int dirfd, const char *pathname, const struct timespec times[2], int flags);
 extern ssize_t __wrap_write(int fd, const void *buf, size_t count);
 
 #ifdef __cplusplus
index 67ba5edf2fba06c38527c7fd372187109223aa73..1c72251345ec1081f3e775da7d366f643bb95db8 100644 (file)
@@ -7,22 +7,78 @@ extern "C" {
 
 void test__f_file_stream_open__fails(void **state) {
 
+  const f_string_static_t path = macro_f_string_static_t_initialize("test", 0, 4);
+
   int errnos[] = {
+    EACCES,
+    EDQUOT,
+    EEXIST,
+    ENAMETOOLONG,
+    EFAULT,
+    EFBIG,
+    EINTR,
+    EINVAL,
+    ELOOP,
+    ENFILE,
+    ENOENT,
+    ENOTDIR,
+    ENOMEM,
+    ENOSPC,
+    EPERM,
+    EROFS,
+    ETXTBSY,
+    EISDIR,
+    EOPNOTSUPP,
+    EOVERFLOW,
     mock_errno_generic,
   };
 
   f_status_t statuss[] = {
+    F_access_denied,
+    F_filesystem_quota_block,
+    F_file_found,
+    F_name,
+    F_buffer,
+    F_number_overflow,
+    F_interrupt,
+    F_parameter,
+    F_loop,
+    F_file_open_max,
+    F_file_found_not,
+    F_file_type_not_directory,
+    F_memory_not,
+    F_space_not,
+    F_prohibited,
+    F_read_only,
+    F_busy,
+    F_directory,
+    F_supported_not,
+    F_number_overflow,
     F_failure,
   };
 
-  for (int i = 0; i < 1; ++i) {
+  for (int i = 0; i < 21; ++i) {
+
+    f_file_t file = f_file_t_initialize;
+
+    will_return(__wrap_fopen, true);
+    will_return(__wrap_fopen, errnos[i]);
+
+    const f_status_t status = f_file_stream_open(path, path, &file);
+
+    assert_int_equal(F_status_set_fine(status), statuss[i]);
+  } // for
+
+  for (int i = 0; i < 21; ++i) {
+
+    f_file_t file = f_file_t_initialize;
 
-    //will_return(__wrap_open, true);
-    //will_return(__wrap_open, errnos[i]);
+    will_return(__wrap_fopen, true);
+    will_return(__wrap_fopen, errnos[i]);
 
-    //const f_status_t status = f_file_stream_open(path, F_false, &id);
+    const f_status_t status = f_file_stream_open(path, f_string_empty_s, &file);
 
-    //assert_int_equal(F_status_set_fine(status), statuss[i]);
+    assert_int_equal(F_status_set_fine(status), statuss[i]);
   } // for
 }
 
@@ -44,38 +100,44 @@ void test__f_file_stream_open__returns_data_not(void **state) {
   {
     f_file_t file = f_file_t_initialize;
 
-    const f_status_t status = f_file_stream_open(f_string_empty_s, f_string_empty_s, &file);
+    const f_status_t status = f_file_stream_open(f_string_empty_s, path, &file);
 
     assert_int_equal(status, F_data_not);
   }
+}
+
+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;
+  FILE *file_pointer = stdout;
 
   {
     f_file_t file = f_file_t_initialize;
 
-    const f_status_t status = f_file_stream_open(path, f_string_empty_s, &file);
+    will_return(__wrap_fopen, false);
+    will_return(__wrap_fopen, file_pointer);
 
-    assert_int_equal(status, F_data_not);
+    will_return(__wrap_fileno, id);
+
+    const f_status_t status = f_file_stream_open(path, path, &file);
+
+    assert_int_equal(status, F_none);
+    assert_int_equal(file.stream, file_pointer);
   }
 
   {
     f_file_t file = f_file_t_initialize;
 
-    const f_status_t status = f_file_stream_open(f_string_empty_s, path, &file);
+    will_return(__wrap_fopen, false);
+    will_return(__wrap_fopen, file_pointer);
 
-    assert_int_equal(status, F_data_not);
-  }
-}
-
-void test__f_file_stream_open__works(void **state) {
+    will_return(__wrap_fileno, id);
 
-  {
-    //will_return(__wrap_open, false);
-    //will_return(__wrap_open, 5);
-
-    //const f_status_t status = f_file_stream_open();
+    const f_status_t status = f_file_stream_open(path, f_string_empty_s, &file);
 
-    //assert_int_equal(status, F_none);
-    //assert_int_equal(id, 5);
+    assert_int_equal(status, F_none);
+    assert_int_equal(file.stream, file_pointer);
   }
 }
 
index 797d96ffec8169cb2bf2ab657e4d8e0e7e6f3dd6..556f9b22d3672be5170f8fe3ce0406bed558b7ff 100644 (file)
@@ -7,23 +7,58 @@ extern "C" {
 
 void test__f_file_stream_read__fails(void **state) {
 
+  const f_string_static_t path = macro_f_string_static_t_initialize("test", 0, 4);
+
   int errnos[] = {
+    EAGAIN,
+    EBADF,
+    EFAULT,
+    EINTR,
+    EINVAL,
+    EIO,
+    EISDIR,
+    EWOULDBLOCK,
     mock_errno_generic,
   };
 
   f_status_t statuss[] = {
+    F_block,
+    F_file_descriptor,
+    F_buffer,
+    F_interrupt,
+    F_parameter,
+    F_input_output,
+    F_file_type_directory,
+    F_block,
     F_failure,
   };
 
-  for (int i = 0; i < 1; ++i) {
+  f_string_dynamic_t buffer = f_string_dynamic_t_initialize;
+
+  for (int i = 0; i < 9; ++i) {
+
+    f_file_t file = f_file_t_initialize;
+    file.size_read = 1;
+    file.stream = stdout;
+
+    will_return(__wrap_feof_unlocked, false);
+    will_return(__wrap_feof_unlocked, 0);
+
+    will_return(__wrap_ferror_unlocked, false);
+    will_return(__wrap_ferror_unlocked, 0);
 
-    //will_return(__wrap_open, true);
-    //will_return(__wrap_open, errnos[i]);
+    will_return(__wrap_fread_unlocked, true);
+    will_return(__wrap_fread_unlocked, errnos[i]);
 
-    //const f_status_t status = f_file_stream_read(path, F_false, &id);
+    will_return(__wrap_ferror_unlocked, false);
+    will_return(__wrap_ferror_unlocked, 1);
 
-    //assert_int_equal(F_status_set_fine(status), statuss[i]);
+    const f_status_t status = f_file_stream_read(file, &buffer);
+
+    assert_int_equal(F_status_set_fine(status), statuss[i]);
   } // for
+
+  f_string_dynamic_resize(0, &buffer);
 }
 
 #ifndef _di_level_0_parameter_checking_
@@ -57,28 +92,56 @@ void test__f_file_stream_read__fails(void **state) {
 
 void test__f_file_stream_read__returns_file_closed(void **state) {
 
-    const f_file_t file = f_file_t_initialize;
+  const f_file_t file = f_file_t_initialize;
+  f_string_dynamic_t buffer = f_string_dynamic_t_initialize;
 
   {
-    f_string_dynamic_t string = f_string_dynamic_t_initialize;
-
-    const f_status_t status = f_file_stream_read(file, &string);
+    const f_status_t status = f_file_stream_read(file, &buffer);
 
     assert_int_equal(F_status_set_fine(status), F_file_closed);
   }
+
+  f_string_dynamic_resize(0, &buffer);
 }
 
 void test__f_file_stream_read__works(void **state) {
 
+  const f_string_static_t path = macro_f_string_static_t_initialize("test", 0, 4);
+
+  f_string_dynamic_t buffer = f_string_dynamic_t_initialize;
+
   {
-    //will_return(__wrap_open, false);
-    //will_return(__wrap_open, 5);
+    f_file_t file = f_file_t_initialize;
+    file.size_read = 1;
+    file.stream = stdout;
+
+    will_return(__wrap_feof_unlocked, false);
+    will_return(__wrap_feof_unlocked, 0);
+
+    will_return(__wrap_ferror_unlocked, false);
+    will_return(__wrap_ferror_unlocked, 0);
+
+    will_return(__wrap_fread_unlocked, false);
+    will_return(__wrap_fread_unlocked, file.size_read);
 
-    //const f_status_t status = f_file_stream_read();
+    will_return(__wrap_ferror_unlocked, false);
+    will_return(__wrap_ferror_unlocked, 0);
 
-    //assert_int_equal(status, F_none);
-    //assert_int_equal(id, 5);
+    will_return(__wrap_feof_unlocked, false);
+    will_return(__wrap_feof_unlocked, 0);
+
+    will_return(__wrap_fread_unlocked, false);
+    will_return(__wrap_fread_unlocked, 0);
+
+    will_return(__wrap_ferror_unlocked, false);
+    will_return(__wrap_ferror_unlocked, 0);
+
+    const f_status_t status = f_file_stream_read(file, &buffer);
+
+    assert_int_equal(status, F_none_eof);
   }
+
+  f_string_dynamic_resize(0, &buffer);
 }
 
 #ifdef __cplusplus
index c1e6a98d16b7a0bb1e200d7cd61f8804390a7f24..5a6a05e7c9d7c5250fa369d91f07f053c1caa197 100644 (file)
@@ -7,23 +7,58 @@ extern "C" {
 
 void test__f_file_stream_read_block__fails(void **state) {
 
+  const f_string_static_t path = macro_f_string_static_t_initialize("test", 0, 4);
+
   int errnos[] = {
+    EAGAIN,
+    EBADF,
+    EFAULT,
+    EINTR,
+    EINVAL,
+    EIO,
+    EISDIR,
+    EWOULDBLOCK,
     mock_errno_generic,
   };
 
   f_status_t statuss[] = {
+    F_block,
+    F_file_descriptor,
+    F_buffer,
+    F_interrupt,
+    F_parameter,
+    F_input_output,
+    F_file_type_directory,
+    F_block,
     F_failure,
   };
 
-  for (int i = 0; i < 1; ++i) {
+  f_string_dynamic_t buffer = f_string_dynamic_t_initialize;
+
+  for (int i = 0; i < 9; ++i) {
+
+    f_file_t file = f_file_t_initialize;
+    file.size_read = 1;
+    file.stream = stdout;
+
+    will_return(__wrap_feof_unlocked, false);
+    will_return(__wrap_feof_unlocked, 0);
 
-    //will_return(__wrap_open, true);
-    //will_return(__wrap_open, errnos[i]);
+    will_return(__wrap_ferror_unlocked, false);
+    will_return(__wrap_ferror_unlocked, 0);
 
-    //const f_status_t status = f_file_stream_read_block(path, F_false, &id);
+    will_return(__wrap_fread_unlocked, true);
+    will_return(__wrap_fread_unlocked, errnos[i]);
 
-    //assert_int_equal(F_status_set_fine(status), statuss[i]);
+    will_return(__wrap_ferror_unlocked, false);
+    will_return(__wrap_ferror_unlocked, 1);
+
+    const f_status_t status = f_file_stream_read_block(file, &buffer);
+
+    assert_int_equal(F_status_set_fine(status), statuss[i]);
   } // for
+
+  f_string_dynamic_resize(0, &buffer);
 }
 
 #ifndef _di_level_0_parameter_checking_
@@ -70,15 +105,36 @@ void test__f_file_stream_read_block__returns_file_closed(void **state) {
 
 void test__f_file_stream_read_block__works(void **state) {
 
+  const f_string_static_t path = macro_f_string_static_t_initialize("test", 0, 4);
+
+  f_string_dynamic_t buffer = f_string_dynamic_t_initialize;
+
   {
-    //will_return(__wrap_open, false);
-    //will_return(__wrap_open, 5);
+    f_file_t file = f_file_t_initialize;
+    file.size_read = 1;
+    file.stream = stdout;
+
+    will_return(__wrap_feof_unlocked, false);
+    will_return(__wrap_feof_unlocked, 0);
+
+    will_return(__wrap_ferror_unlocked, false);
+    will_return(__wrap_ferror_unlocked, 0);
 
-    //const f_status_t status = f_file_stream_read_block();
+    will_return(__wrap_fread_unlocked, false);
+    will_return(__wrap_fread_unlocked, file.size_read);
 
-    //assert_int_equal(status, F_none);
-    //assert_int_equal(id, 5);
+    will_return(__wrap_ferror_unlocked, false);
+    will_return(__wrap_ferror_unlocked, 0);
+
+    will_return(__wrap_feof_unlocked, false);
+    will_return(__wrap_feof_unlocked, 0);
+
+    const f_status_t status = f_file_stream_read_block(file, &buffer);
+
+    assert_int_equal(status, F_none);
   }
+
+  f_string_dynamic_resize(0, &buffer);
 }
 
 #ifdef __cplusplus
index 4a1f318c640c1223dc89c4c5d05706712860fcd2..c316d6d0fbdcbeb4e725d6046aa538f11fb66d76 100644 (file)
@@ -7,23 +7,58 @@ extern "C" {
 
 void test__f_file_stream_read_until__fails(void **state) {
 
+  const f_string_static_t path = macro_f_string_static_t_initialize("test", 0, 4);
+
   int errnos[] = {
+    EAGAIN,
+    EBADF,
+    EFAULT,
+    EINTR,
+    EINVAL,
+    EIO,
+    EISDIR,
+    EWOULDBLOCK,
     mock_errno_generic,
   };
 
   f_status_t statuss[] = {
+    F_block,
+    F_file_descriptor,
+    F_buffer,
+    F_interrupt,
+    F_parameter,
+    F_input_output,
+    F_file_type_directory,
+    F_block,
     F_failure,
   };
 
-  for (int i = 0; i < 1; ++i) {
+  f_string_dynamic_t buffer = f_string_dynamic_t_initialize;
+
+  for (int i = 0; i < 9; ++i) {
+
+    f_file_t file = f_file_t_initialize;
+    file.size_read = 1;
+    file.stream = stdout;
+
+    will_return(__wrap_feof_unlocked, false);
+    will_return(__wrap_feof_unlocked, 0);
+
+    will_return(__wrap_ferror_unlocked, false);
+    will_return(__wrap_ferror_unlocked, 0);
 
-    //will_return(__wrap_open, true);
-    //will_return(__wrap_open, errnos[i]);
+    will_return(__wrap_fread_unlocked, true);
+    will_return(__wrap_fread_unlocked, errnos[i]);
 
-    //const f_status_t status = f_file_stream_read_until(path, F_false, &id);
+    will_return(__wrap_ferror_unlocked, false);
+    will_return(__wrap_ferror_unlocked, 1);
 
-    //assert_int_equal(F_status_set_fine(status), statuss[i]);
+    const f_status_t status = f_file_stream_read_until(file, 1, &buffer);
+
+    assert_int_equal(F_status_set_fine(status), statuss[i]);
   } // for
+
+  f_string_dynamic_resize(0, &buffer);
 }
 
 #ifndef _di_level_0_parameter_checking_
@@ -57,28 +92,52 @@ void test__f_file_stream_read_until__fails(void **state) {
 
 void test__f_file_stream_read_until__returns_file_closed(void **state) {
 
-  const f_file_t file = f_file_t_initialize;
+  f_file_t file = f_file_t_initialize;
+  f_string_dynamic_t buffer = f_string_dynamic_t_initialize;
 
-  {
-    f_string_dynamic_t string = f_string_dynamic_t_initialize;
+  file.size_read = 1;
 
-    const f_status_t status = f_file_stream_read_until(file, 0, &string);
+  {
+    const f_status_t status = f_file_stream_read_until(file, 0, &buffer);
 
-    assert_int_equal(status, F_data_not);
+    assert_int_equal(F_status_set_fine(status), F_file_closed);
   }
+
+  f_string_dynamic_resize(0, &buffer);
 }
 
 void test__f_file_stream_read_until__works(void **state) {
 
+  const f_string_static_t path = macro_f_string_static_t_initialize("test", 0, 4);
+
+  f_string_dynamic_t buffer = f_string_dynamic_t_initialize;
+
   {
-    //will_return(__wrap_open, false);
-    //will_return(__wrap_open, 5);
+    f_file_t file = f_file_t_initialize;
+    file.size_read = 1;
+    file.stream = stdout;
+
+    will_return(__wrap_feof_unlocked, false);
+    will_return(__wrap_feof_unlocked, 0);
+
+    will_return(__wrap_ferror_unlocked, false);
+    will_return(__wrap_ferror_unlocked, 0);
 
-    //const f_status_t status = f_file_stream_read_until();
+    will_return(__wrap_fread_unlocked, false);
+    will_return(__wrap_fread_unlocked, file.size_read);
 
-    //assert_int_equal(status, F_none);
-    //assert_int_equal(id, 5);
+    will_return(__wrap_ferror_unlocked, false);
+    will_return(__wrap_ferror_unlocked, 0);
+
+    will_return(__wrap_feof_unlocked, false);
+    will_return(__wrap_feof_unlocked, 0);
+
+    const f_status_t status = f_file_stream_read_until(file, 1, &buffer);
+
+    assert_int_equal(status, F_none_stop);
   }
+
+  f_string_dynamic_resize(0, &buffer);
 }
 
 #ifdef __cplusplus
index cf55fe77f47e7e2c69eb56ba16abdc049fbcc983..5cffff635bd15e2c3f5d4fc816242d32be4f898b 100644 (file)
@@ -7,22 +7,74 @@ extern "C" {
 
 void test__f_file_stream_reopen__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,
+    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_space_not,
+    F_file_type_not_directory,
+    F_prohibited,
+    F_pipe_not,
+    F_block,
     F_failure,
   };
 
-  for (int i = 0; i < 1; ++i) {
+  for (int i = 0; i < 19; ++i) {
+
+    f_file_t file = f_file_t_initialize;
 
-    //will_return(__wrap_open, true);
-    //will_return(__wrap_open, errnos[i]);
+    will_return(__wrap_freopen, true);
+    will_return(__wrap_freopen, errnos[i]);
 
-    //const f_status_t status = f_file_stream_reopen(path, F_false, &id);
+    const f_status_t status = f_file_stream_reopen(path, path, &file);
 
-    //assert_int_equal(F_status_set_fine(status), statuss[i]);
+    assert_int_equal(F_status_set_fine(status), statuss[i]);
+  } // for
+
+  for (int i = 0; i < 19; ++i) {
+
+    f_file_t file = f_file_t_initialize;
+
+    will_return(__wrap_freopen, true);
+    will_return(__wrap_freopen, errnos[i]);
+
+    const f_status_t status = f_file_stream_reopen(path, f_string_empty_s, &file);
+
+    assert_int_equal(F_status_set_fine(status), statuss[i]);
   } // for
 }
 
@@ -48,34 +100,41 @@ void test__f_file_stream_reopen__returns_data_not(void **state) {
 
     assert_int_equal(status, F_data_not);
   }
+}
+
+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;
+  FILE *file_pointer = stdout;
 
   {
     f_file_t file = f_file_t_initialize;
+    file.stream = file_pointer;
 
-    const f_status_t status = f_file_stream_reopen(path, f_string_empty_s, &file);
+    will_return(__wrap_freopen, false);
+    will_return(__wrap_freopen, file_pointer);
 
-    assert_int_equal(status, F_data_not);
+    will_return(__wrap_fileno, id);
+
+    const f_status_t status = f_file_stream_reopen(path, path, &file);
+
+    assert_int_equal(status, F_none);
+    assert_int_equal(file.stream, file_pointer);
   }
 
   {
     f_file_t file = f_file_t_initialize;
 
-    const f_status_t status = f_file_stream_reopen(f_string_empty_s, path, &file);
-
-    assert_int_equal(status, F_data_not);
-  }
-}
+    will_return(__wrap_freopen, false);
+    will_return(__wrap_freopen, file_pointer);
 
-void test__f_file_stream_reopen__works(void **state) {
+    will_return(__wrap_fileno, id);
 
-  {
-    //will_return(__wrap_open, false);
-    //will_return(__wrap_open, 5);
-
-    //const f_status_t status = f_file_stream_reopen();
+    const f_status_t status = f_file_stream_reopen(path, f_string_empty_s, &file);
 
-    //assert_int_equal(status, F_none);
-    //assert_int_equal(id, 5);
+    assert_int_equal(status, F_none);
+    assert_int_equal(file.stream, file_pointer);
   }
 }
 
index c2475bb5016e578c12c4a7085b53fce4f64bbeec..355b6aae28a2cc3bc08b88a31d6d1ff66da2c29a 100644 (file)
@@ -7,22 +7,47 @@ extern "C" {
 
 void test__f_file_stream_write__fails(void **state) {
 
+  const f_string_static_t path = macro_f_string_static_t_initialize("test", 0, 4);
+
   int errnos[] = {
+    EAGAIN,
+    EBADF,
+    EFAULT,
+    EINTR,
+    EINVAL,
+    EIO,
+    EISDIR,
+    EWOULDBLOCK,
     mock_errno_generic,
   };
 
   f_status_t statuss[] = {
-    F_failure,
+    F_block,
+    F_file_descriptor,
+    F_buffer,
+    F_interrupt,
+    F_parameter,
+    F_input_output,
+    F_file_type_directory,
+    F_block,
+    F_file_write,
   };
 
-  for (int i = 0; i < 1; ++i) {
+  for (int i = 0; i < 9; ++i) {
+
+    f_file_t file = f_file_t_initialize;
+    file.size_read = 1;
+    file.stream = stdout;
+
+    will_return(__wrap_fwrite_unlocked, true);
+    will_return(__wrap_fwrite_unlocked, errnos[i]);
 
-    //will_return(__wrap_open, true);
-    //will_return(__wrap_open, errnos[i]);
+    will_return(__wrap_ferror_unlocked, false);
+    will_return(__wrap_ferror_unlocked, 1);
 
-    //const f_status_t status = f_file_stream_write(path, F_false, &id);
+    const f_status_t status = f_file_stream_write(file, path, 0);
 
-    //assert_int_equal(F_status_set_fine(status), statuss[i]);
+    assert_int_equal(F_status_set_fine(status), statuss[i]);
   } // for
 }
 
@@ -75,14 +100,22 @@ void test__f_file_stream_write__returns_data_not(void **state) {
 
 void test__f_file_stream_write__works(void **state) {
 
+  const f_string_static_t path = macro_f_string_static_t_initialize("test", 0, 4);
+
   {
-    //will_return(__wrap_open, false);
-    //will_return(__wrap_open, 5);
+    f_file_t file = f_file_t_initialize;
+    file.size_write = path.used;
+    file.stream = stdout;
+
+    will_return(__wrap_fwrite_unlocked, false);
+    will_return(__wrap_fwrite_unlocked, file.size_write);
+
+    will_return(__wrap_ferror_unlocked, false);
+    will_return(__wrap_ferror_unlocked, 0);
 
-    //const f_status_t status = f_file_stream_write();
+    const f_status_t status = f_file_stream_write(file, path, 0);
 
-    //assert_int_equal(status, F_none);
-    //assert_int_equal(id, 5);
+    assert_int_equal(status, F_none_eos);
   }
 }
 
index 7f1a142eaea6d897a79256ce3cdc5c1c5f3e1d94..7b392201a2098de142184999c799db025f615dee 100644 (file)
@@ -7,22 +7,47 @@ extern "C" {
 
 void test__f_file_stream_write_block__fails(void **state) {
 
+  const f_string_static_t path = macro_f_string_static_t_initialize("test", 0, 4);
+
   int errnos[] = {
+    EAGAIN,
+    EBADF,
+    EFAULT,
+    EINTR,
+    EINVAL,
+    EIO,
+    EISDIR,
+    EWOULDBLOCK,
     mock_errno_generic,
   };
 
   f_status_t statuss[] = {
-    F_failure,
+    F_block,
+    F_file_descriptor,
+    F_buffer,
+    F_interrupt,
+    F_parameter,
+    F_input_output,
+    F_file_type_directory,
+    F_block,
+    F_file_write,
   };
 
-  for (int i = 0; i < 1; ++i) {
+  for (int i = 0; i < 9; ++i) {
+
+    f_file_t file = f_file_t_initialize;
+    file.size_read = 1;
+    file.stream = stdout;
+
+    will_return(__wrap_fwrite_unlocked, true);
+    will_return(__wrap_fwrite_unlocked, errnos[i]);
 
-    //will_return(__wrap_open, true);
-    //will_return(__wrap_open, errnos[i]);
+    will_return(__wrap_ferror_unlocked, false);
+    will_return(__wrap_ferror_unlocked, 1);
 
-    //const f_status_t status = f_file_stream_write_block(path, F_false, &id);
+    const f_status_t status = f_file_stream_write_block(file, path, 0);
 
-    //assert_int_equal(F_status_set_fine(status), statuss[i]);
+    assert_int_equal(F_status_set_fine(status), statuss[i]);
   } // for
 }
 
@@ -75,14 +100,38 @@ void test__f_file_stream_write_block__returns_data_not(void **state) {
 
 void test__f_file_stream_write_block__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;
+    file.size_write = 1;
+    file.stream = stdout;
+
+    will_return(__wrap_fwrite_unlocked, false);
+    will_return(__wrap_fwrite_unlocked, file.size_write);
+
+    will_return(__wrap_ferror_unlocked, false);
+    will_return(__wrap_ferror_unlocked, 0);
+
+    const f_status_t status = f_file_stream_write_block(file, path, 0);
+
+    assert_int_equal(status, F_none_stop);
+  }
+
   {
-    //will_return(__wrap_open, false);
-    //will_return(__wrap_open, 5);
+    f_file_t file = f_file_t_initialize;
+    file.size_write = path.used;
+    file.stream = stdout;
+
+    will_return(__wrap_fwrite_unlocked, false);
+    will_return(__wrap_fwrite_unlocked, file.size_write);
+
+    will_return(__wrap_ferror_unlocked, false);
+    will_return(__wrap_ferror_unlocked, 0);
 
-    //const f_status_t status = f_file_stream_write_block();
+    const f_status_t status = f_file_stream_write_block(file, path, 0);
 
-    //assert_int_equal(status, F_none);
-    //assert_int_equal(id, 5);
+    assert_int_equal(status, F_none_eos);
   }
 }
 
index 0307e2407d03ff4c7e0ad077de78d55c7322088b..2a6da07c4643419455346678f8754bfb167fa62f 100644 (file)
@@ -7,22 +7,48 @@ extern "C" {
 
 void test__f_file_stream_write_range__fails(void **state) {
 
+  const f_string_static_t path = macro_f_string_static_t_initialize("test", 0, 4);
+  const f_string_range_t range = macro_f_string_range_t_initialize(0, 0);
+
   int errnos[] = {
+    EAGAIN,
+    EBADF,
+    EFAULT,
+    EINTR,
+    EINVAL,
+    EIO,
+    EISDIR,
+    EWOULDBLOCK,
     mock_errno_generic,
   };
 
   f_status_t statuss[] = {
-    F_failure,
+    F_block,
+    F_file_descriptor,
+    F_buffer,
+    F_interrupt,
+    F_parameter,
+    F_input_output,
+    F_file_type_directory,
+    F_block,
+    F_file_write,
   };
 
-  for (int i = 0; i < 1; ++i) {
+  for (int i = 0; i < 9; ++i) {
+
+    f_file_t file = f_file_t_initialize;
+    file.size_read = 1;
+    file.stream = stdout;
 
-    //will_return(__wrap_open, true);
-    //will_return(__wrap_open, errnos[i]);
+    will_return(__wrap_fwrite_unlocked, true);
+    will_return(__wrap_fwrite_unlocked, errnos[i]);
 
-    //const f_status_t status = f_file_stream_write_range(path, F_false, &id);
+    will_return(__wrap_ferror_unlocked, false);
+    will_return(__wrap_ferror_unlocked, 1);
+
+    const f_status_t status = f_file_stream_write_range(file, path, range, 0);
 
-    //assert_int_equal(F_status_set_fine(status), statuss[i]);
+    assert_int_equal(F_status_set_fine(status), statuss[i]);
   } // for
 }
 
@@ -122,14 +148,39 @@ void test__f_file_stream_write_range__returns_data_not(void **state) {
 
 void test__f_file_stream_write_range__works(void **state) {
 
+  const f_string_static_t path = macro_f_string_static_t_initialize("test", 0, 4);
+  const f_string_range_t range = macro_f_string_range_t_initialize(0, 0);
+
   {
-    //will_return(__wrap_open, false);
-    //will_return(__wrap_open, 5);
+    f_file_t file = f_file_t_initialize;
+    file.size_write = 1;
+    file.stream = stdout;
+
+    will_return(__wrap_fwrite_unlocked, false);
+    will_return(__wrap_fwrite_unlocked, file.size_write);
 
-    //const f_status_t status = f_file_stream_write_range();
+    will_return(__wrap_ferror_unlocked, false);
+    will_return(__wrap_ferror_unlocked, 0);
+
+    const f_status_t status = f_file_stream_write_range(file, path, range, 0);
+
+    assert_int_equal(status, F_none_stop);
+  }
+
+  {
+    f_file_t file = f_file_t_initialize;
+    file.size_write = path.used;
+    file.stream = stdout;
+
+    will_return(__wrap_fwrite_unlocked, false);
+    will_return(__wrap_fwrite_unlocked, file.size_write);
+
+    will_return(__wrap_ferror_unlocked, false);
+    will_return(__wrap_ferror_unlocked, 0);
+
+    const f_status_t status = f_file_stream_write_range(file, path, range, 0);
 
-    //assert_int_equal(status, F_none);
-    //assert_int_equal(id, 5);
+    assert_int_equal(status, F_none_eos);
   }
 }
 
index 873ef8e5ed22e1766ff4eedbe77e44167173b302..6112a840025845287805e804b8af0aa53fdce266 100644 (file)
@@ -7,22 +7,47 @@ extern "C" {
 
 void test__f_file_stream_write_until__fails(void **state) {
 
+  const f_string_static_t path = macro_f_string_static_t_initialize("test", 0, 4);
+
   int errnos[] = {
+    EAGAIN,
+    EBADF,
+    EFAULT,
+    EINTR,
+    EINVAL,
+    EIO,
+    EISDIR,
+    EWOULDBLOCK,
     mock_errno_generic,
   };
 
   f_status_t statuss[] = {
-    F_failure,
+    F_block,
+    F_file_descriptor,
+    F_buffer,
+    F_interrupt,
+    F_parameter,
+    F_input_output,
+    F_file_type_directory,
+    F_block,
+    F_file_write,
   };
 
-  for (int i = 0; i < 1; ++i) {
+  for (int i = 0; i < 9; ++i) {
+
+    f_file_t file = f_file_t_initialize;
+    file.size_read = 1;
+    file.stream = stdout;
+
+    will_return(__wrap_fwrite_unlocked, true);
+    will_return(__wrap_fwrite_unlocked, errnos[i]);
 
-    //will_return(__wrap_open, true);
-    //will_return(__wrap_open, errnos[i]);
+    will_return(__wrap_ferror_unlocked, false);
+    will_return(__wrap_ferror_unlocked, 1);
 
-    //const f_status_t status = f_file_stream_write_until(path, F_false, &id);
+    const f_status_t status = f_file_stream_write_until(file, path, 1, 0);
 
-    //assert_int_equal(F_status_set_fine(status), statuss[i]);
+    assert_int_equal(F_status_set_fine(status), statuss[i]);
   } // for
 }
 
@@ -108,14 +133,56 @@ void test__f_file_stream_write_until__returns_data_not(void **state) {
 
 void test__f_file_stream_write_until__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;
+    file.size_write = 1;
+    file.stream = stdout;
+
+    will_return(__wrap_fwrite_unlocked, false);
+    will_return(__wrap_fwrite_unlocked, file.size_write);
+
+    will_return(__wrap_ferror_unlocked, false);
+    will_return(__wrap_ferror_unlocked, 0);
+
+    will_return(__wrap_fwrite_unlocked, false);
+    will_return(__wrap_fwrite_unlocked, file.size_write);
+
+    will_return(__wrap_ferror_unlocked, false);
+    will_return(__wrap_ferror_unlocked, 0);
+
+    will_return(__wrap_fwrite_unlocked, false);
+    will_return(__wrap_fwrite_unlocked, file.size_write);
+
+    will_return(__wrap_ferror_unlocked, false);
+    will_return(__wrap_ferror_unlocked, 0);
+
+    will_return(__wrap_fwrite_unlocked, false);
+    will_return(__wrap_fwrite_unlocked, file.size_write);
+
+    will_return(__wrap_ferror_unlocked, false);
+    will_return(__wrap_ferror_unlocked, 0);
+
+    const f_status_t status = f_file_stream_write_until(file, path, path.used, 0);
+
+    assert_int_equal(status, F_none_eos);
+  }
+
   {
-    //will_return(__wrap_open, false);
-    //will_return(__wrap_open, 5);
+    f_file_t file = f_file_t_initialize;
+    file.size_write = path.used;
+    file.stream = stdout;
+
+    will_return(__wrap_fwrite_unlocked, false);
+    will_return(__wrap_fwrite_unlocked, file.size_write);
+
+    will_return(__wrap_ferror_unlocked, false);
+    will_return(__wrap_ferror_unlocked, 0);
 
-    //const f_status_t status = f_file_stream_write_until();
+    const f_status_t status = f_file_stream_write_until(file, path, path.used, 0);
 
-    //assert_int_equal(status, F_none);
-    //assert_int_equal(id, 5);
+    assert_int_equal(status, F_none_eos);
   }
 }
 
index 673452e3066ed2b8d1ac534490ec46140c827afe..90fbea6d043f2585a3f17cdc05348143408327f1 100644 (file)
@@ -6,15 +6,18 @@ extern "C" {
 #endif
 
 void test__f_file_touch__fails(void **state) {
-/*
+
   const f_string_static_t path = macro_f_string_static_t_initialize("test", 0, 4);
+  const mode_t mode = 0;
 
   {
     int errnos[] = {
       EACCES,
       EFAULT,
+      EINVAL,
       ELOOP,
       ENAMETOOLONG,
+      ENOENT,
       ENOMEM,
       ENOTDIR,
       EOVERFLOW,
@@ -24,74 +27,42 @@ void test__f_file_touch__fails(void **state) {
     f_status_t statuss[] = {
       F_access_denied,
       F_buffer,
+      F_parameter,
       F_loop,
       F_name,
+      F_file_found_not,
       F_memory_not,
-      F_file_not,
+      F_directory_not,
       F_number_overflow,
       F_file_stat,
     };
 
-    for (int i = 0; i < 8; ++i) {
+    for (int i = 0; i < 10; ++i) {
 
       will_return(__wrap_stat, true);
       will_return(__wrap_stat, errnos[i]);
 
-      const f_status_t status = f_file_touch(path, 0);
+      if (statuss[i] == F_file_found_not) {
+        will_return(__wrap_open, false);
+        will_return(__wrap_open, 0);
 
-      assert_int_equal(F_status_set_fine(status), statuss[i]);
-    } // for
-  }
+        will_return(__wrap_fsync, false);
+        will_return(__wrap_fsync, 0);
 
-  {
-    int errnos[] = {
-      EACCES,
-      EDQUOT,
-      EEXIST,
-      EFAULT,
-      EINVAL,
-      ELOOP,
-      EMLINK,
-      ENAMETOOLONG,
-      ENOENT,
-      ENOMEM,
-      ENOSPC,
-      ENOTDIR,
-      EPERM,
-      EROFS,
-      mock_errno_generic,
-    };
+        will_return(__wrap_close, false);
+        will_return(__wrap_close, 0);
+      }
 
-    f_status_t statuss[] = {
-      F_access_denied,
-      F_filesystem_quota_block,
-      F_file_found,
-      F_buffer,
-      F_parameter,
-      F_loop,
-      F_file_link_max,
-      F_name,
-      F_file_found_not,
-      F_memory_not,
-      F_space_not,
-      F_file_not,
-      F_prohibited,
-      F_read_only,
-      F_failure,
-    };
-
-    for (int i = 0; i < 15; ++i) {
-
-      will_return(__wrap_stat, true);
-      will_return(__wrap_stat, ENOENT);
-      will_return(__wrap_mkdir, true);
-      will_return(__wrap_mkdir, errnos[i]);
-
-      const f_status_t status = f_file_touch(path, 0);
+      const f_status_t status = f_file_touch(path, mode, F_true);
 
-      assert_int_equal(F_status_set_fine(status), statuss[i]);
+      if (statuss[i] == F_file_found_not) {
+        assert_int_equal(status, F_none);
+      }
+      else {
+        assert_int_equal(F_status_set_fine(status), statuss[i]);
+      }
     } // for
-  } // for
+  }
 
   {
     int errnos[] = {
@@ -111,13 +82,13 @@ void test__f_file_touch__fails(void **state) {
 
     f_status_t statuss[] = {
       F_access_denied,
-      F_file_descriptor,
+      F_directory_descriptor,
       F_buffer,
       F_parameter,
       F_loop,
       F_name,
       F_file_found_not,
-      F_file_not,
+      F_directory_not,
       F_prohibited,
       F_read_only,
       F_search,
@@ -135,30 +106,32 @@ void test__f_file_touch__fails(void **state) {
       will_return(__wrap_stat, false);
       will_return(__wrap_stat, &statistics);
       will_return(__wrap_stat, 0);
+
       will_return(__wrap_utimensat, true);
       will_return(__wrap_utimensat, errnos[i]);
 
-      const f_status_t status = f_file_touch(path, 0);
+      const f_status_t status = f_file_touch(path, mode, F_true);
 
       assert_int_equal(F_status_set_fine(status), statuss[i]);
     } // for
   }
-  */
 }
 
 void test__f_file_touch__returns_data_not(void **state) {
-/*
+
+  const mode_t mode = 0;
+
   {
-    const f_status_t status = f_file_touch(f_string_empty_s, 0);
+    const f_status_t status = f_file_touch(f_string_empty_s, mode, F_true);
 
     assert_int_equal(status, F_data_not);
   }
-  */
 }
 
 void test__f_file_touch__works(void **state) {
-/*
+
   const f_string_static_t path = macro_f_string_static_t_initialize("test", 0, 4);
+  const mode_t mode = 0;
 
   {
     struct stat statistics;
@@ -170,25 +143,14 @@ void test__f_file_touch__works(void **state) {
     will_return(__wrap_stat, false);
     will_return(__wrap_stat, &statistics);
     will_return(__wrap_stat, 0);
+
     will_return(__wrap_utimensat, false);
     will_return(__wrap_utimensat, 0);
 
-    const f_status_t status = f_file_touch(path, 0);
-
-    assert_int_equal(status, F_none);
-  }
-
-  {
-    will_return(__wrap_stat, true);
-    will_return(__wrap_stat, ENOENT);
-    will_return(__wrap_mkdir, false);
-    will_return(__wrap_mkdir, 0);
-
-    const f_status_t status = f_file_touch(path, 0);
+    const f_status_t status = f_file_touch(path, mode, F_true);
 
     assert_int_equal(status, F_none);
   }
-  */
 }
 
 #ifdef __cplusplus
index de78a2af3db6092923705efa3954d49eeeba6e06..59fbe26f374df4c43b3d4ef90db65c3fcd26f711 100644 (file)
@@ -6,15 +6,19 @@ extern "C" {
 #endif
 
 void test__f_file_touch_at__fails(void **state) {
-/*
+
   const f_string_static_t path = macro_f_string_static_t_initialize("test", 0, 4);
+  const mode_t mode = 0;
 
   {
     int errnos[] = {
       EACCES,
+      EBADF,
       EFAULT,
+      EINVAL,
       ELOOP,
       ENAMETOOLONG,
+      ENOENT,
       ENOMEM,
       ENOTDIR,
       EOVERFLOW,
@@ -23,75 +27,44 @@ void test__f_file_touch_at__fails(void **state) {
 
     f_status_t statuss[] = {
       F_access_denied,
+      F_directory_descriptor,
       F_buffer,
+      F_parameter,
       F_loop,
       F_name,
+      F_file_found_not,
       F_memory_not,
-      F_file_not,
+      F_directory_not,
       F_number_overflow,
       F_file_stat,
     };
 
-    for (int i = 0; i < 8; ++i) {
+    for (int i = 0; i < 11; ++i) {
 
       will_return(__wrap_fstatat, true);
       will_return(__wrap_fstatat, errnos[i]);
 
-      const f_status_t status = f_file_touch_at(1, path, 0, 0);
-
-      assert_int_equal(F_status_set_fine(status), statuss[i]);
-    } // for
-  }
-
-  {
-    int errnos[] = {
-      EACCES,
-      EDQUOT,
-      EEXIST,
-      EFAULT,
-      EINVAL,
-      ELOOP,
-      EMLINK,
-      ENAMETOOLONG,
-      ENOENT,
-      ENOMEM,
-      ENOSPC,
-      ENOTDIR,
-      EPERM,
-      EROFS,
-      mock_errno_generic,
-    };
-
-    f_status_t statuss[] = {
-      F_access_denied,
-      F_filesystem_quota_block,
-      F_file_found,
-      F_buffer,
-      F_parameter,
-      F_loop,
-      F_file_link_max,
-      F_name,
-      F_file_found_not,
-      F_memory_not,
-      F_space_not,
-      F_file_not,
-      F_prohibited,
-      F_read_only,
-      F_failure,
-    };
+      if (statuss[i] == F_file_found_not) {
+        will_return(__wrap_openat, false);
+        will_return(__wrap_openat, 0);
 
-    for (int i = 0; i < 15; ++i) {
+        will_return(__wrap_fsync, false);
+        will_return(__wrap_fsync, 0);
 
-      will_return(__wrap_fstatat, true);
-      will_return(__wrap_fstatat, ENOENT);
-      will_return(__wrap_mkdirat, true);
-      will_return(__wrap_mkdirat, errnos[i]);
+        will_return(__wrap_close, false);
+        will_return(__wrap_close, 0);
+      }
 
-      const f_status_t status = f_file_touch_at(1, path, 0, 0);
+      const f_status_t status = f_file_touch_at(1, path, mode, 0);
 
-      assert_int_equal(F_status_set_fine(status), statuss[i]);
+      if (statuss[i] == F_file_found_not) {
+        assert_int_equal(status, F_none);
+      }
+      else {
+        assert_int_equal(F_status_set_fine(status), statuss[i]);
+      }
     } // for
-  } // for
+  }
 
   {
     int errnos[] = {
@@ -111,13 +84,13 @@ void test__f_file_touch_at__fails(void **state) {
 
     f_status_t statuss[] = {
       F_access_denied,
-      F_file_descriptor,
+      F_directory_descriptor,
       F_buffer,
       F_parameter,
       F_loop,
       F_name,
       F_file_found_not,
-      F_file_not,
+      F_directory_not,
       F_prohibited,
       F_read_only,
       F_search,
@@ -135,30 +108,32 @@ void test__f_file_touch_at__fails(void **state) {
       will_return(__wrap_fstatat, false);
       will_return(__wrap_fstatat, &statistics);
       will_return(__wrap_fstatat, 0);
+
       will_return(__wrap_utimensat, true);
       will_return(__wrap_utimensat, errnos[i]);
 
-      const f_status_t status = f_file_touch_at(1, path, 0, 0);
+      const f_status_t status = f_file_touch_at(1, path, mode, 0);
 
       assert_int_equal(F_status_set_fine(status), statuss[i]);
     } // for
   }
-  */
 }
 
 void test__f_file_touch_at__returns_data_not(void **state) {
-/*
+
+  const mode_t mode = 0;
+
   {
-    const f_status_t status = f_file_touch_at(1, f_string_empty_s, 0, 0);
+    const f_status_t status = f_file_touch_at(1, f_string_empty_s, mode, 0);
 
     assert_int_equal(status, F_data_not);
   }
-  */
 }
 
 void test__f_file_touch_at__works(void **state) {
-/*
+
   const f_string_static_t path = macro_f_string_static_t_initialize("test", 0, 4);
+  const mode_t mode = 0;
 
   {
     struct stat statistics;
@@ -170,25 +145,14 @@ void test__f_file_touch_at__works(void **state) {
     will_return(__wrap_fstatat, false);
     will_return(__wrap_fstatat, &statistics);
     will_return(__wrap_fstatat, 0);
+
     will_return(__wrap_utimensat, false);
     will_return(__wrap_utimensat, 0);
 
-    const f_status_t status = f_file_touch_at(1, path, 0, 0);
-
-    assert_int_equal(status, F_none);
-  }
-
-  {
-    will_return(__wrap_fstatat, true);
-    will_return(__wrap_fstatat, ENOENT);
-    will_return(__wrap_mkdirat, false);
-    will_return(__wrap_mkdirat, 0);
-
-    const f_status_t status = f_file_touch_at(1, path, 0, 0);
+    const f_status_t status = f_file_touch_at(1, path, mode, 0);
 
     assert_int_equal(status, F_none);
   }
-  */
 }
 
 #ifdef __cplusplus
index 19dd55497b7faa667aa4682384122d7dd6994a1d..cb57a60363062e2d61818524b36698e5b19c341e 100644 (file)
@@ -7,22 +7,44 @@ extern "C" {
 
 void test__f_file_type__fails(void **state) {
 
+  const f_string_static_t path = macro_f_string_static_t_initialize("test", 0, 4);
+
   int errnos[] = {
+    EACCES,
+    EFAULT,
+    EINVAL,
+    ELOOP,
+    ENAMETOOLONG,
+    ENOENT,
+    ENOMEM,
+    ENOTDIR,
+    EOVERFLOW,
     mock_errno_generic,
   };
 
   f_status_t statuss[] = {
-    F_failure,
+    F_access_denied,
+    F_buffer,
+    F_parameter,
+    F_loop,
+    F_name,
+    F_file_found_not,
+    F_memory_not,
+    F_directory_not,
+    F_number_overflow,
+    F_file_stat,
   };
 
-  for (int i = 0; i < 1; ++i) {
+  for (int i = 0; i < 10; ++i) {
+
+    mode_t mode = 0;
 
-    //will_return(__wrap_open, true);
-    //will_return(__wrap_open, errnos[i]);
+    will_return(__wrap_lstat, true);
+    will_return(__wrap_lstat, errnos[i]);
 
-    //const f_status_t status = f_file_type(path, F_false, &id);
+    const f_status_t status = f_file_type(path, F_false, &mode);
 
-    //assert_int_equal(F_status_set_fine(status), statuss[i]);
+    assert_int_equal(F_status_set_fine(status), statuss[i]);
   } // for
 }
 
@@ -30,7 +52,7 @@ void test__f_file_type__fails(void **state) {
   void test__f_file_type__parameter_checking(void **state) {
 
     {
-      const f_status_t status = f_file_type(f_string_empty_s, 0);
+      const f_status_t status = f_file_type(f_string_empty_s, F_true, 0);
 
       assert_int_equal(F_status_set_fine(status), F_parameter);
     }
@@ -42,7 +64,7 @@ void test__f_file_type__returns_data_not(void **state) {
   {
     int type = 0;
 
-    const f_status_t status = f_file_type(f_string_empty_s, &type);
+    const f_status_t status = f_file_type(f_string_empty_s, F_true, &type);
 
     assert_int_equal(status, F_data_not);
   }
@@ -50,14 +72,40 @@ void test__f_file_type__returns_data_not(void **state) {
 
 void test__f_file_type__works(void **state) {
 
+  const f_string_static_t path = macro_f_string_static_t_initialize("test", 0, 4);
+
+  struct stat statistics;
+
+  memset(&statistics, 0, sizeof(struct stat));
+
+  {
+    int type = 0;
+
+    statistics.st_mode = 1 | F_file_type_link_d;
+
+    will_return(__wrap_lstat, false);
+    will_return(__wrap_lstat, &statistics);
+    will_return(__wrap_lstat, 0);
+
+    const f_status_t status = f_file_type(path, F_false, &type);
+
+    assert_int_equal(status, F_none);
+    assert_int_equal(type, F_file_type_link_d);
+  }
+
   {
-    //will_return(__wrap_open, false);
-    //will_return(__wrap_open, 5);
+    int type = 0;
+
+    statistics.st_mode = 1 | F_file_type_regular_d;
+
+    will_return(__wrap_stat, false);
+    will_return(__wrap_stat, &statistics);
+    will_return(__wrap_stat, 0);
 
-    //const f_status_t status = f_file_type();
+    const f_status_t status = f_file_type(path, F_true, &type);
 
-    //assert_int_equal(status, F_none);
-    //assert_int_equal(id, 5);
+    assert_int_equal(status, F_none);
+    assert_int_equal(type, F_file_type_regular_d);
   }
 }
 
index bf9d70055af9409ded5944edfea6c30c733fcb47..d4eab0093ef9e43142814d5056d818abc37dbacf 100644 (file)
@@ -7,22 +7,44 @@ extern "C" {
 
 void test__f_file_type_at__fails(void **state) {
 
+  const f_string_static_t path = macro_f_string_static_t_initialize("test", 0, 4);
+
   int errnos[] = {
+    EACCES,
+    EBADF,
+    EFAULT,
+    ELOOP,
+    ENAMETOOLONG,
+    ENOENT,
+    ENOMEM,
+    ENOTDIR,
+    EOVERFLOW,
     mock_errno_generic,
   };
 
   f_status_t statuss[] = {
-    F_failure,
+    F_access_denied,
+    F_directory_descriptor,
+    F_buffer,
+    F_loop,
+    F_name,
+    F_file_found_not,
+    F_memory_not,
+    F_directory_not,
+    F_number_overflow,
+    F_file_stat,
   };
 
-  for (int i = 0; i < 1; ++i) {
+  for (int i = 0; i < 10; ++i) {
+
+    mode_t mode = 0;
 
-    //will_return(__wrap_open, true);
-    //will_return(__wrap_open, errnos[i]);
+    will_return(__wrap_fstatat, true);
+    will_return(__wrap_fstatat, errnos[i]);
 
-    //const f_status_t status = f_file_type_at(path, F_false, &id);
+    const f_status_t status = f_file_type_at(0, path, 0, &mode);
 
-    //assert_int_equal(F_status_set_fine(status), statuss[i]);
+    assert_int_equal(F_status_set_fine(status), statuss[i]);
   } // for
 }
 
@@ -50,14 +72,44 @@ void test__f_file_type_at__returns_data_not(void **state) {
 
 void test__f_file_type_at__works(void **state) {
 
+  const f_string_static_t path = macro_f_string_static_t_initialize("test", 0, 4);
+
+  {
+    int type = 0;
+
+    struct stat statistics;
+
+    memset(&statistics, 0, sizeof(struct stat));
+
+    statistics.st_mode = 1 | F_file_type_link_d;
+
+    will_return(__wrap_fstatat, false);
+    will_return(__wrap_fstatat, &statistics);
+    will_return(__wrap_fstatat, 0);
+
+    const f_status_t status = f_file_type_at(0, path, 0, &type);
+
+    assert_int_equal(status, F_none);
+    assert_int_equal(type, F_file_type_link_d);
+  }
+
   {
-    //will_return(__wrap_open, false);
-    //will_return(__wrap_open, 5);
+    int type = 0;
+
+    struct stat statistics;
+
+    memset(&statistics, 0, sizeof(struct stat));
+
+    statistics.st_mode = 1 | F_file_type_regular_d;
+
+    will_return(__wrap_fstatat, false);
+    will_return(__wrap_fstatat, &statistics);
+    will_return(__wrap_fstatat, 0);
 
-    //const f_status_t status = f_file_type_at();
+    const f_status_t status = f_file_type_at(0, path, 0, &type);
 
-    //assert_int_equal(status, F_none);
-    //assert_int_equal(id, 5);
+    assert_int_equal(status, F_none);
+    assert_int_equal(type, F_file_type_regular_d);
   }
 }
 
index 6ef4f47c7a2897f9addafc149d76c2eeec2cdc37..774047026020e9f61829174e9db5826a65505d13 100644 (file)
@@ -267,24 +267,45 @@ int main(void) {
     //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
-
-    // f_file_stream_read_block
-
-    // f_file_stream_read_until
-
-    // f_file_stream_reopen
-
-    // f_file_stream_write
-
-    // f_file_stream_write_block
-
-    // f_file_stream_write_until
-
-    // f_file_stream_write_range
+    cmocka_unit_test(test__f_file_stream_open__fails),
+    cmocka_unit_test(test__f_file_stream_open__returns_data_not),
+    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__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__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__works),
+
+    cmocka_unit_test(test__f_file_stream_reopen__fails),
+    cmocka_unit_test(test__f_file_stream_reopen__returns_data_not),
+    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__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__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__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__works),
 
     cmocka_unit_test(test__f_file_touch__fails),
     cmocka_unit_test(test__f_file_touch__returns_data_not),
@@ -294,10 +315,15 @@ int main(void) {
     cmocka_unit_test(test__f_file_touch_at__returns_data_not),
     cmocka_unit_test(test__f_file_touch_at__works),
 
-    // f_file_type
+    cmocka_unit_test(test__f_file_type__fails),
+    cmocka_unit_test(test__f_file_type__returns_data_not),
+    cmocka_unit_test(test__f_file_type__works),
 
-    // f_file_type_at
+    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__works),
 
+/*
     // f_file_umask_get
 
     // f_file_umask_set