summaryrefslogtreecommitdiff
path: root/src/tests/eio
diff options
context:
space:
mode:
authorStefan Schmidt <stefan@osg.samsung.com>2016-06-15 18:23:24 +0200
committerStefan Schmidt <stefan@osg.samsung.com>2016-06-16 14:15:25 +0200
commit6d54b94db5c9a629e939754c750af80c7d66697b (patch)
tree1d8c40af58323620da640c53042c90688ec74822 /src/tests/eio
parentff95c52ae714233cce9b5e2696c822a452113a49 (diff)
tests: eio: use eina file infrastructure for temporary file creation
The tmp dir is not always /tmp.
Diffstat (limited to 'src/tests/eio')
-rw-r--r--src/tests/eio/eio_test_map.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/tests/eio/eio_test_map.c b/src/tests/eio/eio_test_map.c
index b2ce2191ec..7dbd50d5f4 100644
--- a/src/tests/eio/eio_test_map.c
+++ b/src/tests/eio/eio_test_map.c
@@ -56,20 +56,21 @@ _error_cb(void *data EINA_UNUSED, Eio_File *handler EINA_UNUSED, int error)
56START_TEST(eio_test_map_simple) 56START_TEST(eio_test_map_simple)
57{ 57{
58 int fd; 58 int fd;
59 char *file = strdup("/tmp/eio_map_example.txt"); 59 const char *file = "eio_map_exampleXXXXXX.txt";
60 const char *data = "This is the data to save in file"; 60 const char *data = "This is the data to save in file";
61 Eio_File *ef; 61 Eio_File *ef;
62 Eina_Tmpstr *file_path;
62 63
63 ecore_init(); 64 ecore_init();
64 eina_init(); 65 eina_init();
65 eio_init(); 66 eio_init();
66 67
67 fd = open(file, O_WRONLY | O_CREAT | O_TRUNC, S_IRWXU | S_IRWXG); 68 fd = eina_file_mkstemp(file, &file_path);
68 fail_if(fd == 0); 69 fail_if(fd < 0);
69 fail_if(write(fd, data, strlen(data)) != (ssize_t)strlen(data)); 70 fail_if(write(fd, data, strlen(data)) != (ssize_t)strlen(data));
70 close(fd); 71 close(fd);
71 72
72 ef = eio_file_open(file, EINA_FALSE, _open_cb, _error_cb, NULL); 73 ef = eio_file_open(file_path, EINA_FALSE, _open_cb, _error_cb, NULL);
73 ecore_main_loop_begin(); 74 ecore_main_loop_begin();
74 fail_if(!ef); 75 fail_if(!ef);
75 76
@@ -87,6 +88,7 @@ START_TEST(eio_test_map_simple)
87 ecore_main_loop_begin(); 88 ecore_main_loop_begin();
88 fail_if(!ef); 89 fail_if(!ef);
89 90
91 eina_tmpstr_del(file_path);
90 eio_shutdown(); 92 eio_shutdown();
91 eina_shutdown(); 93 eina_shutdown();
92 ecore_shutdown(); 94 ecore_shutdown();