20
_open_cb(void *data EINA_UNUSED, Eio_File *handler EINA_UNUSED, Eet_File *ef)
23
ecore_main_loop_quit();
27
_done_cb(void *data EINA_UNUSED, Eio_File *handler EINA_UNUSED)
29
ecore_main_loop_quit();
33
_write_done_cb(void *data EINA_UNUSED, Eio_File *handler EINA_UNUSED, int i)
36
ecore_main_loop_quit();
40
_read_done_cb(void *data, Eio_File *handler EINA_UNUSED, void *read_data,
44
char *read_str = read_data;
47
fail_if(size != strlen(str) + 1);
48
fail_if(memcmp(str, read_str, strlen(str) + 1) != 0);
50
ecore_main_loop_quit();
54
_error_cb(void *data EINA_UNUSED, Eio_File *handler EINA_UNUSED, int error)
56
fprintf(stderr, "Error:%s\n", strerror(error));
58
ecore_main_loop_quit();
62
_eet_error_cb(void *data EINA_UNUSED, Eio_File *handler EINA_UNUSED, Eet_Error err EINA_UNUSED)
65
ecore_main_loop_quit();
68
EFL_START_TEST(eio_test_eet_cipher_decipher)
71
char *data = "This is the data to save in file";
72
const char *key = "This is a secret key";
78
ret = eina_file_mkstemp("eio_eet_example_XXXXXX", &file);
81
ef = eio_eet_open(file, EET_FILE_MODE_WRITE, _open_cb, _error_cb, NULL);
82
ecore_main_loop_begin();
85
ef = eio_eet_write_cipher(ee, "keys/tests", data, strlen(data) + 1, 0,
86
key, _write_done_cb, _error_cb, NULL);
87
ecore_main_loop_begin();
90
ef = eio_eet_close(ee, _done_cb, _eet_error_cb, NULL);
91
ecore_main_loop_begin();
94
ef = eio_eet_open(file, EET_FILE_MODE_READ, _open_cb, _error_cb, NULL);
95
ecore_main_loop_begin();
98
ef = eio_eet_read_cipher(ee, "keys/tests", key, _read_done_cb,
100
ecore_main_loop_begin();
103
ef = eio_eet_close(ee, _done_cb, _eet_error_cb, NULL);
104
ecore_main_loop_begin();
108
eina_tmpstr_del(file);
119
static Eet_Data_Descriptor *_test_struct_descriptor;
122
_test_struct_descriptor_init(void)
124
Eet_Data_Descriptor_Class eddc;
126
EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Test_Struct);
127
_test_struct_descriptor = eet_data_descriptor_stream_new(&eddc);
129
EET_DATA_DESCRIPTOR_ADD_BASIC(_test_struct_descriptor, Test_Struct,
130
"id", id, EET_T_INT);
131
EET_DATA_DESCRIPTOR_ADD_BASIC(_test_struct_descriptor, Test_Struct,
132
"name", name, EET_T_STRING);
136
_test_struct_new(void)
138
Test_Struct *tc = calloc(1, sizeof(Test_Struct));
142
tc->name = "eio_eet_test";
148
_data_read_done_cb(void *data, Eio_File *handler EINA_UNUSED, void *decoded)
150
Test_Struct *res = decoded;
151
Test_Struct *orig = data;
154
fail_if(res->id != orig->id);
155
fail_if(strcmp(res->name, orig->name) != 0);
156
ecore_main_loop_quit();
159
EFL_START_TEST(eio_test_eet_data_cipher_decipher)
162
const char *key = "This is a secret key";
169
_test_struct_descriptor_init();
170
tc = _test_struct_new();
172
ret = eina_file_mkstemp("eio_eet_example_XXXXXX", &file);
175
ef = eio_eet_open(file, EET_FILE_MODE_WRITE, _open_cb, _error_cb, NULL);
176
ecore_main_loop_begin();
179
ef = eio_eet_data_write_cipher(ee, _test_struct_descriptor, "test",
180
key, tc, 0, _write_done_cb, _error_cb, NULL);
181
ecore_main_loop_begin();
184
ef = eio_eet_close(ee, _done_cb, _eet_error_cb, NULL);
185
ecore_main_loop_begin();
188
ef = eio_eet_open(file, EET_FILE_MODE_READ, _open_cb, _error_cb, NULL);
189
ecore_main_loop_begin();
192
ef = eio_eet_data_read_cipher(ee, _test_struct_descriptor, "test",
193
key, _data_read_done_cb, _error_cb, tc);
194
ecore_main_loop_begin();
197
ef = eio_eet_close(ee, _done_cb, _eet_error_cb, NULL);
198
ecore_main_loop_begin();
202
eina_tmpstr_del(file);
208
eio_test_eet(TCase *tc)
210
tcase_add_test(tc, eio_test_eet_cipher_decipher);
211
tcase_add_test(tc, eio_test_eet_data_cipher_decipher);