summaryrefslogtreecommitdiff
path: root/src/tests
diff options
context:
space:
mode:
authorVincent Torri <vincent dot torri at gmail dot com>2015-12-03 11:42:08 +0100
committerCedric BAIL <cedric@osg.samsung.com>2015-12-05 21:06:04 +0100
commit0497b9685c782c24fba84a1d5391edaa8d5ce10a (patch)
tree7a9547ea7ab407cfa555598646302bbc0b21b8c4 /src/tests
parent4f242fb48a5cf18b6e5ea6598681486abf791771 (diff)
efl: add binary mode to open() calls
This allows better compatibility with Windows Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
Diffstat (limited to 'src/tests')
-rw-r--r--src/tests/ecore/ecore_test_ecore_file.c14
-rw-r--r--src/tests/eet/eet_suite.c6
-rw-r--r--src/tests/eina/eina_test_file.c14
-rw-r--r--src/tests/eio/eio_test_file.c8
4 files changed, 29 insertions, 13 deletions
diff --git a/src/tests/ecore/ecore_test_ecore_file.c b/src/tests/ecore/ecore_test_ecore_file.c
index 1e2d801039..28ffb83e5a 100644
--- a/src/tests/ecore/ecore_test_ecore_file.c
+++ b/src/tests/ecore/ecore_test_ecore_file.c
@@ -15,6 +15,10 @@
15 15
16#include "ecore_suite.h" 16#include "ecore_suite.h"
17 17
18#ifndef O_BINARY
19# define O_BINARY 0
20#endif
21
18#define MAXSIZE 256 22#define MAXSIZE 256
19 23
20void 24void
@@ -242,7 +246,7 @@ START_TEST(ecore_test_ecore_file_operations)
242 src_file = get_tmp_file(); 246 src_file = get_tmp_file();
243 fail_if(!src_file); 247 fail_if(!src_file);
244 fail_if(ecore_file_remove(src_file) != EINA_TRUE); 248 fail_if(ecore_file_remove(src_file) != EINA_TRUE);
245 fd = open(src_file, O_RDWR|O_CREAT, 0700); 249 fd = open(src_file, O_RDWR | O_BINARY | O_CREAT, 0700);
246 fail_if(fd < 0); 250 fail_if(fd < 0);
247 fail_if(close(fd) != 0); 251 fail_if(close(fd) != 0);
248 fail_if(ecore_file_can_exec(src_file) != EINA_TRUE); 252 fail_if(ecore_file_can_exec(src_file) != EINA_TRUE);
@@ -295,7 +299,7 @@ START_TEST(ecore_test_ecore_file_operations)
295 src_file = get_tmp_file(); 299 src_file = get_tmp_file();
296 fail_if(!src_file); 300 fail_if(!src_file);
297 fail_if(ecore_file_remove(src_file) != EINA_TRUE); 301 fail_if(ecore_file_remove(src_file) != EINA_TRUE);
298 fd = open(src_file, O_RDWR|O_CREAT, 0400); 302 fd = open(src_file, O_RDWR | O_BINARY | O_CREAT, 0400);
299 fail_if(fd < 0); 303 fail_if(fd < 0);
300 fail_if(close(fd) != 0); 304 fail_if(close(fd) != 0);
301 fail_if(ecore_file_can_read(src_file) != EINA_TRUE); 305 fail_if(ecore_file_can_read(src_file) != EINA_TRUE);
@@ -306,7 +310,7 @@ START_TEST(ecore_test_ecore_file_operations)
306 src_file = get_tmp_file(); 310 src_file = get_tmp_file();
307 fail_if(!src_file); 311 fail_if(!src_file);
308 fail_if(ecore_file_remove(src_file) != EINA_TRUE); 312 fail_if(ecore_file_remove(src_file) != EINA_TRUE);
309 fd = open(src_file, O_RDWR|O_CREAT, 0200); 313 fd = open(src_file, O_RDWR | O_BINARY | O_CREAT, 0200);
310 fail_if(fd < 0); 314 fail_if(fd < 0);
311 fail_if(close(fd) != 0); 315 fail_if(close(fd) != 0);
312 fail_if(ecore_file_can_read(src_file) != EINA_FALSE); 316 fail_if(ecore_file_can_read(src_file) != EINA_FALSE);
@@ -316,7 +320,7 @@ START_TEST(ecore_test_ecore_file_operations)
316 src_file = get_tmp_file(); 320 src_file = get_tmp_file();
317 fail_if(!src_file); 321 fail_if(!src_file);
318 fail_if(ecore_file_remove(src_file) != EINA_TRUE); 322 fail_if(ecore_file_remove(src_file) != EINA_TRUE);
319 fd = open(src_file, O_RDWR|O_CREAT, 0100); 323 fd = open(src_file, O_RDWR | O_BINARY | O_CREAT, 0100);
320 fail_if(fd < 0); 324 fail_if(fd < 0);
321 fail_if(close(fd) != 0); 325 fail_if(close(fd) != 0);
322 fail_if(ecore_file_can_read(src_file) != EINA_FALSE); 326 fail_if(ecore_file_can_read(src_file) != EINA_FALSE);
@@ -355,7 +359,7 @@ START_TEST(ecore_test_ecore_file_path)
355 src_file = get_tmp_file(); 359 src_file = get_tmp_file();
356 fail_if(!src_file); 360 fail_if(!src_file);
357 fail_if(ecore_file_remove(src_file) != EINA_TRUE); 361 fail_if(ecore_file_remove(src_file) != EINA_TRUE);
358 fd = open(src_file, O_RDWR|O_CREAT, 0700); 362 fd = open(src_file, O_RDWR | O_BINARY | O_CREAT, 0700);
359 fail_if(fd < 0); 363 fail_if(fd < 0);
360 fail_if(close(fd) != 0); 364 fail_if(close(fd) != 0);
361 fail_if(ecore_file_can_exec(src_file) != EINA_TRUE); 365 fail_if(ecore_file_can_exec(src_file) != EINA_TRUE);
diff --git a/src/tests/eet/eet_suite.c b/src/tests/eet/eet_suite.c
index 673294bbb9..e7737a7f1c 100644
--- a/src/tests/eet/eet_suite.c
+++ b/src/tests/eet/eet_suite.c
@@ -17,6 +17,10 @@
17 17
18#include "eet_suite.h" 18#include "eet_suite.h"
19 19
20#ifndef O_BINARY
21# define O_BINARY 0
22#endif
23
20static char _key_pem[PATH_MAX] = ""; 24static char _key_pem[PATH_MAX] = "";
21static char _cert_pem[PATH_MAX] = ""; 25static char _cert_pem[PATH_MAX] = "";
22static char _key_enc[PATH_MAX] = ""; 26static char _key_enc[PATH_MAX] = "";
@@ -1775,7 +1779,7 @@ START_TEST(eet_identity_simple)
1775 eet_clearcache(); 1779 eet_clearcache();
1776 1780
1777 /* Corrupting the file. */ 1781 /* Corrupting the file. */
1778 fd = open(file, O_WRONLY); 1782 fd = open(file, O_WRONLY | O_BINARY);
1779 fail_if(fd < 0); 1783 fail_if(fd < 0);
1780 1784
1781 fail_if(lseek(fd, 200, SEEK_SET) != 200); 1785 fail_if(lseek(fd, 200, SEEK_SET) != 200);
diff --git a/src/tests/eina/eina_test_file.c b/src/tests/eina/eina_test_file.c
index 617ce88287..c307b92809 100644
--- a/src/tests/eina/eina_test_file.c
+++ b/src/tests/eina/eina_test_file.c
@@ -38,6 +38,10 @@
38# define PATH_SEP_C '/' 38# define PATH_SEP_C '/'
39#endif 39#endif
40 40
41#ifndef O_BINARY
42# define O_BINARY 0
43#endif
44
41static int default_dir_rights = 0777; 45static int default_dir_rights = 0777;
42const int file_min_offset = 1; 46const int file_min_offset = 1;
43 47
@@ -353,12 +357,12 @@ START_TEST(eina_file_map_new_test)
353 strcpy(test_file2_path, (char *)test_dirname); 357 strcpy(test_file2_path, (char *)test_dirname);
354 strcat(test_file2_path, test_file2_name_part); 358 strcat(test_file2_path, test_file2_name_part);
355 359
356 fd = open(test_file_path, O_WRONLY | O_CREAT | O_TRUNC, S_IWUSR | S_IRUSR); 360 fd = open(test_file_path, O_WRONLY | O_BINARY | O_CREAT | O_TRUNC, S_IWUSR | S_IRUSR);
357 fail_if(fd == 0); 361 fail_if(fd == 0);
358 fail_if(write(fd, eina_map_test_string, strlen(eina_map_test_string)) != (ssize_t) strlen(eina_map_test_string)); 362 fail_if(write(fd, eina_map_test_string, strlen(eina_map_test_string)) != (ssize_t) strlen(eina_map_test_string));
359 close(fd); 363 close(fd);
360 364
361 fd = open(test_file2_path, O_WRONLY | O_CREAT | O_TRUNC, S_IWUSR | S_IRUSR); 365 fd = open(test_file2_path, O_WRONLY | O_BINARY | O_CREAT | O_TRUNC, S_IWUSR | S_IRUSR);
362 fail_if(fd == 0); 366 fail_if(fd == 0);
363 fail_if(write(fd, big_buffer, big_buffer_size - file_min_offset) != big_buffer_size - file_min_offset); 367 fail_if(write(fd, big_buffer, big_buffer_size - file_min_offset) != big_buffer_size - file_min_offset);
364 close(fd); 368 close(fd);
@@ -566,7 +570,7 @@ START_TEST(eina_test_file_xattr)
566 eina_init(); 570 eina_init();
567 test_file_path = get_full_path(XATTR_TEST_DIR, filename); 571 test_file_path = get_full_path(XATTR_TEST_DIR, filename);
568 572
569 fd = open(test_file_path, O_RDONLY | O_CREAT | O_TRUNC, S_IRWXU | S_IRWXG | S_IRWXO); 573 fd = open(test_file_path, O_RDONLY | O_BINARY | O_CREAT | O_TRUNC, S_IRWXU | S_IRWXG | S_IRWXO);
570 fail_if(fd == 0); 574 fail_if(fd == 0);
571 close(fd); 575 close(fd);
572 576
@@ -699,12 +703,12 @@ START_TEST(eina_test_file_statat)
699 test_file1_path = get_full_path(test_dirname, "example1.txt"); 703 test_file1_path = get_full_path(test_dirname, "example1.txt");
700 test_file2_path = get_full_path(test_dirname, "example2.txt"); 704 test_file2_path = get_full_path(test_dirname, "example2.txt");
701 705
702 fd = open(test_file1_path, O_WRONLY | O_CREAT | O_TRUNC, S_IWUSR | S_IRUSR); 706 fd = open(test_file1_path, O_WRONLY | O_BINARY | O_CREAT | O_TRUNC, S_IWUSR | S_IRUSR);
703 fail_if(fd == 0); 707 fail_if(fd == 0);
704 fail_if(write(fd, template, template_size) != template_size); 708 fail_if(write(fd, template, template_size) != template_size);
705 close(fd); 709 close(fd);
706 710
707 fd = open(test_file2_path, O_WRONLY | O_CREAT | O_TRUNC, S_IWUSR | S_IRUSR); 711 fd = open(test_file2_path, O_WRONLY | O_BINARY | O_CREAT | O_TRUNC, S_IWUSR | S_IRUSR);
708 fail_if(fd == 0); 712 fail_if(fd == 0);
709 fail_if(write(fd, template, template_size) != template_size); 713 fail_if(write(fd, template, template_size) != template_size);
710 close(fd); 714 close(fd);
diff --git a/src/tests/eio/eio_test_file.c b/src/tests/eio/eio_test_file.c
index f0e231cd99..c17246ec26 100644
--- a/src/tests/eio/eio_test_file.c
+++ b/src/tests/eio/eio_test_file.c
@@ -14,6 +14,10 @@
14 14
15#include "eio_suite.h" 15#include "eio_suite.h"
16 16
17#ifndef O_BINARY
18# define O_BINARY 0
19#endif
20
17static unsigned int default_rights = 0755; 21static unsigned int default_rights = 0755;
18static int test_count = 0; 22static int test_count = 0;
19static const char *good_dirs[] = 23static const char *good_dirs[] =
@@ -154,7 +158,7 @@ create_test_dirs(Eina_Tmpstr *test_dirname)
154 for (i = 0; i != count; ++i) 158 for (i = 0; i != count; ++i)
155 { 159 {
156 Eina_Tmpstr *filename = get_full_path(test_dirname, files[i]); 160 Eina_Tmpstr *filename = get_full_path(test_dirname, files[i]);
157 fd = open(filename, O_RDWR|O_CREAT, default_rights); 161 fd = open(filename, O_RDWR | O_BINARY | O_CREAT, default_rights);
158 fail_if(fd < 0); 162 fail_if(fd < 0);
159 fail_if(close(fd) != 0); 163 fail_if(close(fd) != 0);
160 eina_tmpstr_del(filename); 164 eina_tmpstr_del(filename);
@@ -163,7 +167,7 @@ create_test_dirs(Eina_Tmpstr *test_dirname)
163 for (i = 0; i != count; ++i) 167 for (i = 0; i != count; ++i)
164 { 168 {
165 Eina_Tmpstr *filename = get_full_path(nested_dirname, files[i]); 169 Eina_Tmpstr *filename = get_full_path(nested_dirname, files[i]);
166 fd = open(filename, O_RDWR|O_CREAT, default_rights); 170 fd = open(filename, O_RDWR | O_BINARY | O_CREAT, default_rights);
167 fail_if(fd < 0); 171 fail_if(fd < 0);
168 fail_if(close(fd) != 0); 172 fail_if(close(fd) != 0);
169 eina_tmpstr_del(filename); 173 eina_tmpstr_del(filename);