blob: ef607b5ead4c7c90eba6e6069bfdce940cfe3652 [file] [log] [blame]
Pascal Brandc639ac82015-07-02 08:53:34 +02001/*
2 * Copyright (c) 2014, STMicroelectronics International N.V.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License Version 2 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 */
13
14#include <string.h>
15#include <stdio.h>
16
17#include <adbg.h>
18#include <xtest_test.h>
19#include <xtest_helpers.h>
20
21#include <tee_client_api.h>
22#include <ta_storage.h>
23#include <tee_api_defines.h>
24#include <tee_api_types.h>
25
26static uint8_t file_00[] = {
27 0x00, 0x6E, 0x04, 0x57, 0x08, 0xFB, 0x71, 0x96,
28 0xF0, 0x2E, 0x55, 0x3D, 0x02, 0xC3, 0xA6, 0x92,
29 0xE9, 0xC3, 0xEF, 0x8A, 0xB2, 0x34, 0x53, 0xE6,
30 0xF0, 0x74, 0x9C, 0xD6, 0x36, 0xE7, 0xA8, 0x8E
31};
32
33static uint8_t file_01[] = {
34 0x01, 0x00
35};
36
37static uint8_t file_02[] = {
38 0x02, 0x11, 0x02
39};
40
41static uint8_t file_03[] = {
42 0x03, 0x13, 0x03
43};
44
45static uint8_t data_00[] = {
46 0x00, 0x6E, 0x04, 0x57, 0x08, 0xFB, 0x71, 0x96,
47 0x00, 0x2E, 0x55, 0x3D, 0x02, 0xC3, 0xA6, 0x92,
48 0x00, 0xC3, 0xEF, 0x8A, 0xB2, 0x34, 0x53, 0xE6,
49 0x00, 0x74, 0x9C, 0xD6, 0x36, 0xE7, 0xA8, 0x00
50};
51
52static uint8_t data_01[] = {
53 0x01, 0x6E, 0x04, 0x57, 0x08, 0xFB, 0x71, 0x96,
54 0x01, 0x2E, 0x55, 0x3D, 0x02, 0xC3, 0xA6, 0x92,
55 0x01, 0xC3, 0xEF, 0x8A, 0xB2, 0x34, 0x53, 0xE6,
56 0x01, 0x74, 0x9C, 0xD6, 0x36, 0xE7, 0xA8, 0x01
57};
58
59static TEEC_Result fs_open(TEEC_Session *sess, void *id, uint32_t id_size,
60 uint32_t flags, uint32_t *obj)
61{
62 TEEC_Operation op;
63 TEEC_Result res;
64 uint32_t org;
65
66 op.params[0].tmpref.buffer = id;
67 op.params[0].tmpref.size = id_size;
68 op.params[1].value.a = flags;
69 op.params[1].value.b = 0;
70
71 op.paramTypes = TEEC_PARAM_TYPES(TEEC_MEMREF_TEMP_INPUT,
72 TEEC_VALUE_INOUT, TEEC_NONE,
73 TEEC_NONE);
74
75 res = TEEC_InvokeCommand(sess, TA_STORAGE_CMD_OPEN, &op, &org);
76
77 if (res == TEEC_SUCCESS)
78 *obj = op.params[1].value.b;
79
80 return res;
81}
82
83static TEEC_Result fs_create(TEEC_Session *sess, void *id, uint32_t id_size,
84 uint32_t flags, uint32_t attr, void *data,
85 uint32_t data_size, uint32_t *obj)
86{
87 TEEC_Operation op;
88 TEEC_Result res;
89 uint32_t org;
90
91 op.params[0].tmpref.buffer = id;
92 op.params[0].tmpref.size = id_size;
93 op.params[1].value.a = flags;
94 op.params[1].value.b = 0;
95 op.params[2].value.a = attr;
96 op.params[2].value.b = 0;
97 op.params[3].tmpref.buffer = data;
98 op.params[3].tmpref.size = data_size;
99
100 op.paramTypes = TEEC_PARAM_TYPES(TEEC_MEMREF_TEMP_INPUT,
101 TEEC_VALUE_INOUT, TEEC_VALUE_INPUT,
102 TEEC_MEMREF_TEMP_INPUT);
103
104 res = TEEC_InvokeCommand(sess, TA_STORAGE_CMD_CREATE, &op, &org);
105
106 if (res == TEEC_SUCCESS)
107 *obj = op.params[1].value.b;
108
109 return res;
110}
111
112static TEEC_Result fs_close(TEEC_Session *sess, uint32_t obj)
113{
114 TEEC_Operation op;
115 uint32_t org;
116
117 op.params[0].value.a = obj;
118
119 op.paramTypes = TEEC_PARAM_TYPES(TEEC_VALUE_INPUT, TEEC_NONE,
120 TEEC_NONE, TEEC_NONE);
121
122 return TEEC_InvokeCommand(sess, TA_STORAGE_CMD_CLOSE, &op, &org);
123}
124
125static TEEC_Result fs_read(TEEC_Session *sess, uint32_t obj, void *data,
126 uint32_t data_size, uint32_t *count)
127{
128 TEEC_Result res;
129 TEEC_Operation op;
130 uint32_t org;
131
132 op.params[0].tmpref.buffer = data;
133 op.params[0].tmpref.size = data_size;
134 op.params[1].value.a = obj;
135 op.params[1].value.b = 0;
136
137 op.paramTypes = TEEC_PARAM_TYPES(TEEC_MEMREF_TEMP_OUTPUT,
138 TEEC_VALUE_INOUT, TEEC_NONE,
139 TEEC_NONE);
140
141 res = TEEC_InvokeCommand(sess, TA_STORAGE_CMD_READ, &op, &org);
142
143 if (res == TEEC_SUCCESS)
144 *count = op.params[1].value.b;
145
146 return res;
147}
148
149static TEEC_Result fs_write(TEEC_Session *sess, uint32_t obj, void *data,
150 uint32_t data_size)
151{
152 TEEC_Operation op;
153 uint32_t org;
154
155 op.params[0].tmpref.buffer = data;
156 op.params[0].tmpref.size = data_size;
157 op.params[1].value.a = obj;
158 op.params[1].value.b = 0;
159
160 op.paramTypes = TEEC_PARAM_TYPES(TEEC_MEMREF_TEMP_INPUT,
161 TEEC_VALUE_INPUT, TEEC_NONE,
162 TEEC_NONE);
163
164 return TEEC_InvokeCommand(sess, TA_STORAGE_CMD_WRITE, &op, &org);
165}
166
167static TEEC_Result fs_seek(TEEC_Session *sess, uint32_t obj, int32_t offset,
168 int32_t whence)
169{
170 TEEC_Operation op;
171 uint32_t org;
172
173 op.params[0].value.a = obj;
174 op.params[0].value.b = offset;
175 op.params[1].value.a = whence;
176
177 op.paramTypes = TEEC_PARAM_TYPES(TEEC_VALUE_INPUT, TEEC_VALUE_INOUT,
178 TEEC_NONE, TEEC_NONE);
179
180 return TEEC_InvokeCommand(sess, TA_STORAGE_CMD_SEEK, &op, &org);
181}
182
183static TEEC_Result fs_unlink(TEEC_Session *sess, uint32_t obj)
184{
185 TEEC_Operation op;
186 uint32_t org;
187
188 op.params[0].value.a = obj;
189
190 op.paramTypes = TEEC_PARAM_TYPES(TEEC_VALUE_INPUT, TEEC_NONE,
191 TEEC_NONE, TEEC_NONE);
192
193 return TEEC_InvokeCommand(sess, TA_STORAGE_CMD_UNLINK, &op, &org);
194}
195
196static TEEC_Result fs_trunc(TEEC_Session *sess, uint32_t obj, uint32_t len)
197{
198 TEEC_Operation op;
199 uint32_t org;
200
201 op.params[0].value.a = obj;
202 op.params[0].value.b = len;
203
204 op.paramTypes = TEEC_PARAM_TYPES(TEEC_VALUE_INPUT, TEEC_NONE,
205 TEEC_NONE, TEEC_NONE);
206
207 return TEEC_InvokeCommand(sess, TA_STORAGE_CMD_TRUNC, &op, &org);
208}
209
210static TEEC_Result fs_rename(TEEC_Session *sess, uint32_t obj, void *id,
211 uint32_t id_size)
212{
213 TEEC_Operation op;
214 uint32_t org;
215
216 op.params[0].value.a = obj;
217 op.params[1].tmpref.buffer = id;
218 op.params[1].tmpref.size = id_size;
219
220 op.paramTypes = TEEC_PARAM_TYPES(TEEC_VALUE_INPUT,
221 TEEC_MEMREF_TEMP_INPUT, TEEC_NONE,
222 TEEC_NONE);
223
224 return TEEC_InvokeCommand(sess, TA_STORAGE_CMD_RENAME, &op, &org);
225}
226
227static TEEC_Result fs_alloc_enum(TEEC_Session *sess, uint32_t *e)
228{
229 TEEC_Result res;
230 TEEC_Operation op;
231 uint32_t org;
232
233 op.paramTypes = TEEC_PARAM_TYPES(TEEC_VALUE_OUTPUT, TEEC_NONE,
234 TEEC_NONE, TEEC_NONE);
235
236 res = TEEC_InvokeCommand(sess, TA_STORAGE_CMD_ALLOC_ENUM, &op, &org);
237
238 if (res == TEEC_SUCCESS)
239 *e = op.params[0].value.a;
240
241 return res;
242}
243
244static TEEC_Result fs_free_enum(TEEC_Session *sess, uint32_t e)
245{
246 TEEC_Operation op;
247 uint32_t org;
248
249 op.paramTypes = TEEC_PARAM_TYPES(TEEC_VALUE_INPUT, TEEC_NONE, TEEC_NONE,
250 TEEC_NONE);
251
252 op.params[0].value.a = e;
253
254 return TEEC_InvokeCommand(sess, TA_STORAGE_CMD_FREE_ENUM, &op, &org);
255}
256
257static TEEC_Result fs_start_enum(TEEC_Session *sess, uint32_t e)
258{
259 TEEC_Operation op;
260 uint32_t org;
261
262 op.paramTypes = TEEC_PARAM_TYPES(TEEC_VALUE_INPUT, TEEC_NONE,
263 TEEC_NONE, TEEC_NONE);
264
265 op.params[0].value.a = e;
266
267 return TEEC_InvokeCommand(sess, TA_STORAGE_CMD_START_ENUM, &op, &org);
268}
269
270static TEEC_Result fs_next_enum(TEEC_Session *sess, uint32_t e, void *obj_info,
271 size_t info_size, void *id, uint32_t id_size)
272{
273 TEEC_Operation op;
274 uint32_t org;
275
276 op.paramTypes = TEEC_PARAM_TYPES(TEEC_VALUE_INPUT,
277 TEEC_MEMREF_TEMP_OUTPUT,
278 TEEC_MEMREF_TEMP_OUTPUT, TEEC_NONE);
279
280 op.params[0].value.a = e;
281 op.params[1].tmpref.buffer = obj_info;
282 op.params[1].tmpref.size = info_size;
283 op.params[2].tmpref.buffer = id;
284 op.params[2].tmpref.size = id_size;
285
286 return TEEC_InvokeCommand(sess, TA_STORAGE_CMD_NEXT_ENUM, &op, &org);
287}
288
289/* create */
290static void xtest_tee_test_6001(ADBG_Case_t *c)
291{
292 TEEC_Session sess;
293 uint32_t obj;
294 uint32_t orig;
295
296 if (!ADBG_EXPECT_TEEC_SUCCESS(c,
297 xtest_teec_open_session(&sess, &storage_ta_uuid, NULL, &orig)))
298 return;
299
300 if (!ADBG_EXPECT_TEEC_SUCCESS(c,
301 fs_create(&sess, file_00, sizeof(file_00),
302 TEE_DATA_FLAG_ACCESS_WRITE |
303 TEE_DATA_FLAG_ACCESS_WRITE_META, 0, data_00,
304 sizeof(data_00), &obj)))
305 goto exit;
306
307 /* clean */
308 if (!ADBG_EXPECT_TEEC_SUCCESS(c, fs_unlink(&sess, obj)))
309 goto exit;
310
311exit:
312 TEEC_CloseSession(&sess);
313}
314
315/* open */
316static void xtest_tee_test_6002(ADBG_Case_t *c)
317{
318 TEEC_Session sess;
319 uint32_t obj;
320 uint32_t orig;
321
322 if (!ADBG_EXPECT_TEEC_SUCCESS(c,
323 xtest_teec_open_session(&sess, &storage_ta_uuid, NULL, &orig)))
324 return;
325
326 if (!ADBG_EXPECT_TEEC_SUCCESS(c,
327 fs_create(&sess, file_01, sizeof(file_01),
328 TEE_DATA_FLAG_ACCESS_WRITE, 0, data_00,
329 sizeof(data_00), &obj)))
330 goto exit;
331
332 if (!ADBG_EXPECT_TEEC_SUCCESS(c, fs_close(&sess, obj)))
333 goto exit;
334
335 if (!ADBG_EXPECT_TEEC_SUCCESS(c,
336 fs_open(&sess, file_01, sizeof(file_01),
337 TEE_DATA_FLAG_ACCESS_WRITE_META, &obj)))
338 goto exit;
339
340 if (!ADBG_EXPECT_TEEC_SUCCESS(c, fs_close(&sess, obj)))
341 goto exit;
342
343 if (!ADBG_EXPECT_TEEC_SUCCESS(c,
344 fs_open(&sess, file_01, sizeof(file_01),
345 TEE_DATA_FLAG_ACCESS_WRITE_META, &obj)))
346 goto exit;
347
348 /* clean */
349 if (!ADBG_EXPECT_TEEC_SUCCESS(c, fs_unlink(&sess, obj)))
350 goto exit;
351
352exit:
353 TEEC_CloseSession(&sess);
354}
355
356/* read */
357static void xtest_tee_test_6003(ADBG_Case_t *c)
358{
359 TEEC_Session sess;
360 uint32_t obj;
361 uint8_t out[10] = { 0 };
362 uint32_t count;
363 uint32_t orig;
364
365 if (!ADBG_EXPECT_TEEC_SUCCESS(c,
366 xtest_teec_open_session(&sess, &storage_ta_uuid, NULL, &orig)))
367 return;
368
369 if (!ADBG_EXPECT_TEEC_SUCCESS(c,
370 fs_create(&sess, file_02, sizeof(file_02),
371 TEE_DATA_FLAG_ACCESS_WRITE, 0, data_01,
372 sizeof(data_01), &obj)))
373 goto exit;
374
375 if (!ADBG_EXPECT_TEEC_SUCCESS(c, fs_close(&sess, obj)))
376 goto exit;
377
378 if (!ADBG_EXPECT_TEEC_SUCCESS(c,
379 fs_open(&sess, file_02, sizeof(file_02),
380 TEE_DATA_FLAG_ACCESS_READ |
381 TEE_DATA_FLAG_ACCESS_WRITE_META, &obj)))
382 goto exit;
383
384 if (!ADBG_EXPECT_TEEC_SUCCESS(c, fs_read(&sess, obj, out, 10, &count)))
385 goto exit;
386
387 (void)ADBG_EXPECT_BUFFER(c, data_01, 10, out, count);
388
389 /* clean */
390 if (!ADBG_EXPECT_TEEC_SUCCESS(c, fs_unlink(&sess, obj)))
391 goto exit;
392
393exit:
394 TEEC_CloseSession(&sess);
395}
396
397/* write */
398static void xtest_tee_test_6004(ADBG_Case_t *c)
399{
400 TEEC_Session sess;
401 uint32_t obj;
402 uint8_t out[10] = { 0 };
403 uint32_t count;
404 uint32_t orig;
405
406 if (!ADBG_EXPECT_TEEC_SUCCESS(c,
407 xtest_teec_open_session(&sess, &storage_ta_uuid, NULL, &orig)))
408 return;
409
410 /* create */
411 if (!ADBG_EXPECT_TEEC_SUCCESS(c,
412 fs_create(&sess, file_02, sizeof(file_02),
413 TEE_DATA_FLAG_ACCESS_WRITE, 0, data_01,
414 sizeof(data_01), &obj)))
415 goto exit;
416
417 if (!ADBG_EXPECT_TEEC_SUCCESS(c, fs_close(&sess, obj)))
418 goto exit;
419
420 /* write new data */
421 if (!ADBG_EXPECT_TEEC_SUCCESS(c,
422 fs_open(&sess, file_02, sizeof(file_02),
423 TEE_DATA_FLAG_ACCESS_WRITE, &obj)))
424 goto exit;
425
426 if (!ADBG_EXPECT_TEEC_SUCCESS(c,
427 fs_write(&sess, obj, data_00, sizeof(data_00))))
428 goto exit;
429
430 if (!ADBG_EXPECT_TEEC_SUCCESS(c, fs_close(&sess, obj)))
431 goto exit;
432
433 /* verify */
434 if (!ADBG_EXPECT_TEEC_SUCCESS(c,
435 fs_open(&sess, file_02, sizeof(file_02),
436 TEE_DATA_FLAG_ACCESS_READ |
437 TEE_DATA_FLAG_ACCESS_WRITE_META, &obj)))
438 goto exit;
439
440 if (!ADBG_EXPECT_TEEC_SUCCESS(c, fs_read(&sess, obj, out, 10, &count)))
441 goto exit;
442
443 (void)ADBG_EXPECT_BUFFER(c, data_00, 10, out, count);
444
445 /* clean */
446 if (!ADBG_EXPECT_TEEC_SUCCESS(c, fs_unlink(&sess, obj)))
447 goto exit;
448
449exit:
450 TEEC_CloseSession(&sess);
451}
452
453/* seek */
454static void xtest_tee_test_6005(ADBG_Case_t *c)
455{
456 TEEC_Session sess;
457 uint32_t obj;
458 uint8_t out[10] = { 0 };
459 uint32_t count;
460 uint32_t orig;
461
462 if (!ADBG_EXPECT_TEEC_SUCCESS(c,
463 xtest_teec_open_session(&sess, &storage_ta_uuid, NULL, &orig)))
464 return;
465
466 /* create */
467 if (!ADBG_EXPECT_TEEC_SUCCESS(c,
468 fs_create(&sess, file_01, sizeof(file_01),
469 TEE_DATA_FLAG_ACCESS_WRITE |
470 TEE_DATA_FLAG_ACCESS_READ |
471 TEE_DATA_FLAG_ACCESS_WRITE_META, 0, data_00,
472 sizeof(data_00), &obj)))
473 goto exit;
474
475 /* seek */
476 if (!ADBG_EXPECT_TEEC_SUCCESS(c,
477 fs_seek(&sess, obj, 10, TEE_DATA_SEEK_SET)))
478 goto exit;
479
480 /* verify */
481 if (!ADBG_EXPECT_TEEC_SUCCESS(c, fs_read(&sess, obj, out, 10, &count)))
482 goto exit;
483
484 (void)ADBG_EXPECT_BUFFER(c, &data_00[10], 10, out, count);
485
486 /* clean */
487 if (!ADBG_EXPECT_TEEC_SUCCESS(c, fs_unlink(&sess, obj)))
488 goto exit;
489
490exit:
491 TEEC_CloseSession(&sess);
492}
493
494/* unlink */
495static void xtest_tee_test_6006(ADBG_Case_t *c)
496{
497 TEEC_Session sess;
498 uint32_t obj;
499 uint32_t orig;
500
501 if (!ADBG_EXPECT_TEEC_SUCCESS(c,
502 xtest_teec_open_session(&sess, &storage_ta_uuid, NULL, &orig)))
503 return;
504
505 /* create */
506 if (!ADBG_EXPECT_TEEC_SUCCESS(c,
507 fs_create(&sess, file_01, sizeof(file_01),
508 TEE_DATA_FLAG_ACCESS_WRITE_META, 0, data_00,
509 sizeof(data_00), &obj)))
510 goto exit;
511
512 /* del & close */
513 if (!ADBG_EXPECT_TEEC_SUCCESS(c, fs_unlink(&sess, obj)))
514 goto exit;
515
516 /* check result */
517 if (!ADBG_EXPECT_TEEC_RESULT(c, TEEC_ERROR_ITEM_NOT_FOUND,
518 fs_open(&sess, file_01, sizeof(file_01),
519 TEE_DATA_FLAG_ACCESS_READ, &obj)))
520 goto exit;
521
522exit:
523 TEEC_CloseSession(&sess);
524}
525
526/* trunc */
527static void xtest_tee_test_6007(ADBG_Case_t *c)
528{
529 TEEC_Session sess;
530 uint32_t obj;
531 uint8_t out[10] = { 0 };
532 uint32_t count;
533 uint32_t orig;
534
535 if (!ADBG_EXPECT_TEEC_SUCCESS(c,
536 xtest_teec_open_session(&sess, &storage_ta_uuid, NULL, &orig)))
537 return;
538
539 /* create */
540 if (!ADBG_EXPECT_TEEC_SUCCESS(c,
541 fs_create(&sess, file_01, sizeof(file_01),
542 TEE_DATA_FLAG_ACCESS_WRITE |
543 TEE_DATA_FLAG_ACCESS_READ |
544 TEE_DATA_FLAG_ACCESS_WRITE_META, 0, data_00,
545 sizeof(data_00), &obj)))
546 goto exit;
547
548 /* trunc */
549 if (!ADBG_EXPECT_TEEC_SUCCESS(c, fs_trunc(&sess, obj, 10)))
550 goto exit;
551
552 /* seek */
553 if (!ADBG_EXPECT_TEEC_SUCCESS(
554 c, fs_seek(&sess, obj, 5, TEE_DATA_SEEK_SET)))
555 goto exit;
556
557 /* verify */
558 if (!ADBG_EXPECT_TEEC_SUCCESS(c, fs_read(&sess, obj, out, 10, &count)))
559 goto exit;
560
561 /* check buffer */
562 (void)ADBG_EXPECT_BUFFER(c, &data_00[5], 5, out, count);
563
564 /* clean */
565 if (!ADBG_EXPECT_TEEC_SUCCESS(c, fs_unlink(&sess, obj)))
566 goto exit;
567
568exit:
569 TEEC_CloseSession(&sess);
570}
571
572static void xtest_tee_test_6008(ADBG_Case_t *c)
573{
574 TEEC_Session sess;
575 uint32_t obj;
576 uint8_t out[10] = { 0 };
577 uint32_t count;
578 uint32_t orig;
579
580 if (!ADBG_EXPECT_TEEC_SUCCESS(c,
581 xtest_teec_open_session(&sess, &storage_ta_uuid, NULL, &orig)))
582 return;
583
584 /* create */
585 if (!ADBG_EXPECT_TEEC_SUCCESS(c,
586 fs_create(&sess, file_02, sizeof(file_02),
587 TEE_DATA_FLAG_ACCESS_WRITE, 0, data_01,
588 sizeof(data_01), &obj)))
589 goto exit;
590
591 if (!ADBG_EXPECT_TEEC_SUCCESS(c, fs_close(&sess, obj)))
592 goto exit;
593
594 if (!ADBG_EXPECT_TEEC_SUCCESS(c,
595 fs_open(&sess, file_02, sizeof(file_02),
596 TEE_DATA_FLAG_ACCESS_WRITE |
597 TEE_DATA_FLAG_ACCESS_WRITE_META, &obj)))
598 goto exit;
599
600 /* write new data */
601 if (!ADBG_EXPECT_TEEC_SUCCESS(c,
602 fs_write(&sess, obj, data_00, sizeof(data_00))))
603 goto exit;
604
605 if (!ADBG_EXPECT_TEEC_SUCCESS(c,
606 fs_rename(&sess, obj, file_03, sizeof(file_03))))
607 goto exit;
608
609 /* close */
610 if (!ADBG_EXPECT_TEEC_SUCCESS(c, fs_close(&sess, obj)))
611 goto exit;
612
613 /* verify */
614 if (!ADBG_EXPECT_TEEC_SUCCESS(c,
615 fs_open(&sess, file_03, sizeof(file_03),
616 TEE_DATA_FLAG_ACCESS_READ |
617 TEE_DATA_FLAG_ACCESS_WRITE_META, &obj)))
618 goto exit;
619
620 if (!ADBG_EXPECT_TEEC_SUCCESS(c, fs_read(&sess, obj, out, 10, &count)))
621 goto exit;
622
623 /* check buffer */
624 (void)ADBG_EXPECT_BUFFER(c, data_00, 10, out, count);
625
626 /* clean */
627 if (!ADBG_EXPECT_TEEC_SUCCESS(c, fs_unlink(&sess, obj)))
628 goto exit;
629
630exit:
631 TEEC_CloseSession(&sess);
632}
633
634static void xtest_tee_test_6009(ADBG_Case_t *c)
635{
636 TEEC_Session sess;
637 uint32_t obj0;
638 uint32_t obj1;
639 uint32_t obj2;
640 uint32_t e = 0;
641 uint8_t info[200];
642 uint8_t id[200];
643 uint32_t orig;
644
645 if (!ADBG_EXPECT_TEEC_SUCCESS(c,
646 xtest_teec_open_session(&sess, &storage_ta_uuid, NULL, &orig)))
647 return;
648
649 /* create file 00 */
650 if (!ADBG_EXPECT_TEEC_SUCCESS(c,
651 fs_create(&sess, file_00, sizeof(file_00),
652 TEE_DATA_FLAG_ACCESS_WRITE, 0, data_01,
653 sizeof(data_01), &obj0)))
654 goto exit;
655
656 /* create file 01 */
657 if (!ADBG_EXPECT_TEEC_SUCCESS(c,
658 fs_create(&sess, file_01, sizeof(file_01),
659 TEE_DATA_FLAG_ACCESS_WRITE, 0, data_01,
660 sizeof(data_01), &obj1)))
661 goto exit;
662
663 /* create file 02 */
664 if (!ADBG_EXPECT_TEEC_SUCCESS(c,
665 fs_create(&sess, file_02, sizeof(file_02),
666 TEE_DATA_FLAG_ACCESS_WRITE, 0, data_01,
667 sizeof(data_01), &obj2)))
668 goto exit;
669
670 if (!ADBG_EXPECT_TEEC_SUCCESS(c, fs_close(&sess, obj0)))
671 goto exit;
672
673 if (!ADBG_EXPECT_TEEC_SUCCESS(c, fs_close(&sess, obj1)))
674 goto exit;
675
676 if (!ADBG_EXPECT_TEEC_SUCCESS(c, fs_close(&sess, obj2)))
677 goto exit;
678
679 /* iterate */
680 if (!ADBG_EXPECT_TEEC_SUCCESS(c, fs_alloc_enum(&sess, &e)))
681 goto exit;
682
683 if (!ADBG_EXPECT_TEEC_SUCCESS(c, fs_start_enum(&sess, e)))
684 goto exit;
685
686 /* get 00 */
687 if (!ADBG_EXPECT_TEEC_SUCCESS(c,
688 fs_next_enum(&sess, e, info, sizeof(info), id, sizeof(id))))
689 goto exit;
690
691 /* get 01 */
692 if (!ADBG_EXPECT_TEEC_SUCCESS(c,
693 fs_next_enum(&sess, e, info, sizeof(info), id, sizeof(id))))
694 goto exit;
695
696 /* get 02 */
697 if (!ADBG_EXPECT_TEEC_SUCCESS(c,
698 fs_next_enum(&sess, e, info, sizeof(info), id, sizeof(id))))
699 goto exit;
700
701 /* we should not have more files */
702 if (!ADBG_EXPECT_TEEC_RESULT(c, TEEC_ERROR_ITEM_NOT_FOUND,
703 fs_next_enum(&sess, e, info, sizeof(info), id, sizeof(id))))
704 goto exit;
705
706 if (!ADBG_EXPECT_TEEC_SUCCESS(c, fs_free_enum(&sess, e)))
707 goto exit;
708
709 /* clean */
710 if (!ADBG_EXPECT_TEEC_SUCCESS(c,
711 fs_open(&sess, file_00, sizeof(file_00),
712 TEE_DATA_FLAG_ACCESS_WRITE_META, &obj0)))
713 goto exit;
714
715 if (!ADBG_EXPECT_TEEC_SUCCESS(c, fs_unlink(&sess, obj0)))
716 goto exit;
717
718 if (!ADBG_EXPECT_TEEC_SUCCESS(c,
719 fs_open(&sess, file_01, sizeof(file_01),
720 TEE_DATA_FLAG_ACCESS_WRITE_META, &obj1)))
721 goto exit;
722
723 if (!ADBG_EXPECT_TEEC_SUCCESS(c, fs_unlink(&sess, obj1)))
724 goto exit;
725
726 if (!ADBG_EXPECT_TEEC_SUCCESS(c,
727 fs_open(&sess, file_02, sizeof(file_02),
728 TEE_DATA_FLAG_ACCESS_WRITE_META, &obj2)))
729 goto exit;
730
731 if (!ADBG_EXPECT_TEEC_SUCCESS(c, fs_unlink(&sess, obj2)))
732 goto exit;
733
734exit:
735 TEEC_CloseSession(&sess);
736}
737
738ADBG_CASE_DEFINE(
739 XTEST_TEE_6001, xtest_tee_test_6001,
740 /* Title */
741 "Test TEE_CreatePersistentObject",
742 /* Short description */
743 "Short description ...",
744 /* Requirement IDs */
745 "TEE-??",
746 /* How to implement */
747 "Description of how to implement ..."
748 );
749
750ADBG_CASE_DEFINE(
751 XTEST_TEE_6002, xtest_tee_test_6002,
752 /* Title */
753 "Test TEE_OpenPersistentObject",
754 /* Short description */
755 "Short description ...",
756 /* Requirement IDs */
757 "TEE-??",
758 /* How to implement */
759 "Description of how to implement ..."
760 );
761
762ADBG_CASE_DEFINE(
763 XTEST_TEE_6003, xtest_tee_test_6003,
764 /* Title */
765 "Test TEE_ReadObjectData",
766 /* Short description */
767 "Short description ...",
768 /* Requirement IDs */
769 "TEE-??",
770 /* How to implement */
771 "Description of how to implement ..."
772 );
773
774ADBG_CASE_DEFINE(
775 XTEST_TEE_6004, xtest_tee_test_6004,
776 /* Title */
777 "Test TEE_WriteObjectData",
778 /* Short description */
779 "Short description ...",
780 /* Requirement IDs */
781 "TEE-??",
782 /* How to implement */
783 "Description of how to implement ..."
784 );
785
786ADBG_CASE_DEFINE(
787 XTEST_TEE_6005, xtest_tee_test_6005,
788 /* Title */
789 "Test TEE_SeekObjectData",
790 /* Short description */
791 "Short description ...",
792 /* Requirement IDs */
793 "TEE-??",
794 /* How to implement */
795 "Description of how to implement ..."
796 );
797
798ADBG_CASE_DEFINE(
799 XTEST_TEE_6006, xtest_tee_test_6006,
800 /* Title */
801 "Test TEE_CloseAndDeletePersistentObject",
802 /* Short description */
803 "Short description ...",
804 /* Requirement IDs */
805 "TEE-??",
806 /* How to implement */
807 "Description of how to implement ..."
808 );
809
810ADBG_CASE_DEFINE(
811 XTEST_TEE_6007, xtest_tee_test_6007,
812 /* Title */
813 "Test TEE_TruncateObjectData",
814 /* Short description */
815 "Short description ...",
816 /* Requirement IDs */
817 "TEE-??",
818 /* How to implement */
819 "Description of how to implement ..."
820 );
821
822ADBG_CASE_DEFINE(
823 XTEST_TEE_6008, xtest_tee_test_6008,
824 /* Title */
825 "Test TEE_RenamePersistentObject",
826 /* Short description */
827 "Short description ...",
828 /* Requirement IDs */
829 "TEE-??",
830 /* How to implement */
831 "Description of how to implement ..."
832 );
833
834ADBG_CASE_DEFINE(
835 XTEST_TEE_6009, xtest_tee_test_6009,
836 /* Title */
837 "Test TEE Internal API Persistent Object Enumeration Functions",
838 /* Short description */
839 "Short description ...",
840 /* Requirement IDs */
841 "TEE-??",
842 /* How to implement */
843 "Description of how to implement ..."
844 );