1 /* Copyright (c) 2013, 2016, The Linux Foundation. All rights reserved.
2 *
3 * Redistribution and use in source and binary forms, with or without
4 * modification, are permitted provided that the following conditions are
5 * met:
6 * * Redistributions of source code must retain the above copyright
7 * notice, this list of conditions and the following disclaimer.
8 * * Redistributions in binary form must reproduce the above
9 * copyright notice, this list of conditions and the following
10 * disclaimer in the documentation and/or other materials provided
11 * with the distribution.
12 * * Neither the name of The Linux Foundation nor the names of its
13 * contributors may be used to endorse or promote products derived
14 * from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
17 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
20 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
23 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
24 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
25 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
26 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 *
28 */
29
30 // Camera dependencies
31 #include "mm_qcamera_app.h"
32 #include "mm_qcamera_dbg.h"
33
34 #define MM_QCAMERA_APP_UTEST_MAX_MAIN_LOOP 1
35 #define MM_QCAMERA_APP_UTEST_OUTER_LOOP 1
36 #define MM_QCAMERA_APP_UTEST_INNER_LOOP 1
37 #define MM_QCAM_APP_TEST_NUM 128
38
39 static mm_app_tc_t mm_app_tc[MM_QCAM_APP_TEST_NUM];
40
mm_app_tc_open_close(mm_camera_app_t * cam_app)41 int mm_app_tc_open_close(mm_camera_app_t *cam_app)
42 {
43 int rc = MM_CAMERA_OK;
44 int i;
45 mm_camera_test_obj_t test_obj;
46
47 printf("\n Verifying open/close cameras...\n");
48 for (i = 0; i < cam_app->num_cameras; i++) {
49 memset(&test_obj, 0, sizeof(mm_camera_test_obj_t));
50 rc = mm_app_open(cam_app, i, &test_obj);
51 if (rc != MM_CAMERA_OK) {
52 LOGE("mm_app_open() cam_idx=%d, err=%d\n",
53 i, rc);
54 break;
55 }
56 sleep(1);
57 rc = mm_app_close(&test_obj);
58 if (rc != MM_CAMERA_OK) {
59 LOGE("mm_app_close() cam_idx=%d, err=%d\n",
60 i, rc);
61 break;
62 }
63 }
64 if (rc == MM_CAMERA_OK) {
65 printf("\nPassed\n");
66 } else {
67 printf("\nFailed\n");
68 }
69 LOGD("END, rc = %d\n", rc);
70 return rc;
71 }
72
mm_app_tc_start_stop_preview(mm_camera_app_t * cam_app)73 int mm_app_tc_start_stop_preview(mm_camera_app_t *cam_app)
74 {
75 int rc = MM_CAMERA_OK;
76 int i, j;
77 mm_camera_test_obj_t test_obj;
78
79 printf("\n Verifying start/stop preview...\n");
80 for (i = 0; i < cam_app->num_cameras; i++) {
81 memset(&test_obj, 0, sizeof(mm_camera_test_obj_t));
82 rc = mm_app_open(cam_app, i, &test_obj);
83 if (rc != MM_CAMERA_OK) {
84 LOGE("mm_app_open() cam_idx=%d, err=%d\n",
85 i, rc);
86 break;
87 }
88
89 for (j = 0; j < MM_QCAMERA_APP_UTEST_INNER_LOOP; j++) {
90 rc = mm_app_start_preview(&test_obj);
91 if (rc != MM_CAMERA_OK) {
92 LOGE(" mm_app_start_preview() cam_idx=%d, err=%d\n",
93 i, rc);
94 break;
95 }
96 sleep(1);
97 rc = mm_app_stop_preview(&test_obj);
98 if (rc != MM_CAMERA_OK) {
99 LOGE(" mm_app_stop_preview() cam_idx=%d, err=%d\n",
100 i, rc);
101 break;
102 }
103 }
104
105 rc |= mm_app_close(&test_obj);
106 if (rc != MM_CAMERA_OK) {
107 LOGE("mm_app_close() cam_idx=%d, err=%d\n",
108 i, rc);
109 break;
110 }
111 }
112 if (rc == MM_CAMERA_OK) {
113 printf("\nPassed\n");
114 } else {
115 printf("\nFailed\n");
116 }
117 LOGD("END, rc = %d\n", rc);
118 return rc;
119 }
120
mm_app_tc_start_stop_zsl(mm_camera_app_t * cam_app)121 int mm_app_tc_start_stop_zsl(mm_camera_app_t *cam_app)
122 {
123 int rc = MM_CAMERA_OK;
124 int i, j;
125 mm_camera_test_obj_t test_obj;
126
127 printf("\n Verifying start/stop preview...\n");
128 for (i = 0; i < cam_app->num_cameras; i++) {
129 memset(&test_obj, 0, sizeof(mm_camera_test_obj_t));
130 rc = mm_app_open(cam_app, i, &test_obj);
131 if (rc != MM_CAMERA_OK) {
132 LOGE("mm_app_open() cam_idx=%d, err=%d\n",
133 i, rc);
134 break;
135 }
136
137 for (j = 0; j < 1; j++) {
138 rc = mm_app_start_preview_zsl(&test_obj);
139 if (rc != MM_CAMERA_OK) {
140 LOGE(" mm_app_start_preview_zsl() cam_idx=%d, err=%d\n",
141 i, rc);
142 break;
143 }
144 sleep(1);
145 rc = mm_app_stop_preview_zsl(&test_obj);
146 if (rc != MM_CAMERA_OK) {
147 LOGE(" mm_app_stop_preview_zsl() cam_idx=%d, err=%d\n",
148 i, rc);
149 break;
150 }
151 }
152
153 rc = mm_app_close(&test_obj);
154 if (rc != MM_CAMERA_OK) {
155 LOGE("mm_app_close() cam_idx=%d, err=%d\n",
156 i, rc);
157 break;
158 }
159 }
160 if (rc == MM_CAMERA_OK) {
161 printf("\nPassed\n");
162 } else {
163 printf("\nFailed\n");
164 }
165 LOGD("END, rc = %d\n", rc);
166 return rc;
167 }
168
mm_app_tc_start_stop_video_preview(mm_camera_app_t * cam_app)169 int mm_app_tc_start_stop_video_preview(mm_camera_app_t *cam_app)
170 {
171 int rc = MM_CAMERA_OK;
172 int i, j;
173 mm_camera_test_obj_t test_obj;
174
175 printf("\n Verifying start/stop video preview...\n");
176 for (i = 0; i < cam_app->num_cameras; i++) {
177 memset(&test_obj, 0, sizeof(mm_camera_test_obj_t));
178 rc = mm_app_open(cam_app, i, &test_obj);
179 if (rc != MM_CAMERA_OK) {
180 LOGE("mm_app_open() cam_idx=%d, err=%d\n",
181 i, rc);
182 break;
183 }
184
185 for (j = 0; j < MM_QCAMERA_APP_UTEST_INNER_LOOP; j++) {
186 rc = mm_app_start_record_preview(&test_obj);
187 if (rc != MM_CAMERA_OK) {
188 LOGE("mm_app_start_record_preview() cam_idx=%d, err=%d\n",
189 i, rc);
190 break;
191 }
192 sleep(1);
193 rc = mm_app_stop_record_preview(&test_obj);
194 if (rc != MM_CAMERA_OK) {
195 LOGE("mm_app_stop_record_preview() cam_idx=%d, err=%d\n",
196 i, rc);
197 break;
198 }
199 }
200
201 rc = mm_app_close(&test_obj);
202 if (rc != MM_CAMERA_OK) {
203 LOGE("mm_app_close() cam_idx=%d, err=%d\n",
204 i, rc);
205 break;
206 }
207 }
208 if (rc == MM_CAMERA_OK) {
209 printf("\nPassed\n");
210 } else {
211 printf("\nFailed\n");
212 }
213 LOGD("END, rc = %d\n", rc);
214 return rc;
215 }
216
mm_app_tc_start_stop_video_record(mm_camera_app_t * cam_app)217 int mm_app_tc_start_stop_video_record(mm_camera_app_t *cam_app)
218 {
219 int rc = MM_CAMERA_OK;
220 int i, j;
221 mm_camera_test_obj_t test_obj;
222
223 printf("\n Verifying start/stop recording...\n");
224 for (i = 0; i < cam_app->num_cameras; i++) {
225 memset(&test_obj, 0, sizeof(mm_camera_test_obj_t));
226 rc = mm_app_open(cam_app, i, &test_obj);
227 if (rc != MM_CAMERA_OK) {
228 LOGE("mm_app_open() cam_idx=%d, err=%d\n",
229 i, rc);
230 break;
231 }
232
233 rc = mm_app_start_record_preview(&test_obj);
234 if (rc != MM_CAMERA_OK) {
235 LOGE("mm_app_start_record_preview() cam_idx=%d, err=%d\n",
236 i, rc);
237 mm_app_close(&test_obj);
238 break;
239 }
240
241 sleep(1);
242
243 for (j = 0; j < MM_QCAMERA_APP_UTEST_INNER_LOOP; j++) {
244 rc = mm_app_start_record(&test_obj);
245 if (rc != MM_CAMERA_OK) {
246 LOGE("mm_app_start_record() cam_idx=%d, err=%d\n",
247 i, rc);
248 break;
249 }
250
251 sleep(1);
252
253 rc = mm_app_stop_record(&test_obj);
254 if (rc != MM_CAMERA_OK) {
255 LOGE("mm_app_stop_record() cam_idx=%d, err=%d\n",
256 i, rc);
257 break;
258 }
259 }
260 if (rc != MM_CAMERA_OK) {
261 LOGE("start/stop record cam_idx=%d, err=%d\n",
262 i, rc);
263 mm_app_stop_record_preview(&test_obj);
264 mm_app_close(&test_obj);
265 break;
266 }
267
268 rc = mm_app_stop_record_preview(&test_obj);
269 if (rc != MM_CAMERA_OK) {
270 LOGE("mm_app_stop_record_preview() cam_idx=%d, err=%d\n",
271 i, rc);
272 mm_app_close(&test_obj);
273 break;
274 }
275
276 rc = mm_app_close(&test_obj);
277 if (rc != MM_CAMERA_OK) {
278 LOGE("mm_app_close() cam_idx=%d, err=%d\n",
279 i, rc);
280 break;
281 }
282 }
283 if (rc == MM_CAMERA_OK) {
284 printf("\nPassed\n");
285 } else {
286 printf("\nFailed\n");
287 }
288 LOGD("END, rc = %d\n", rc);
289 return rc;
290 }
291
mm_app_tc_start_stop_live_snapshot(mm_camera_app_t * cam_app)292 int mm_app_tc_start_stop_live_snapshot(mm_camera_app_t *cam_app)
293 {
294 int rc = MM_CAMERA_OK;
295 int i, j;
296 mm_camera_test_obj_t test_obj;
297
298 printf("\n Verifying start/stop live snapshot...\n");
299 for (i = 0; i < cam_app->num_cameras; i++) {
300 memset(&test_obj, 0, sizeof(mm_camera_test_obj_t));
301 rc = mm_app_open(cam_app, i, &test_obj);
302 if (rc != MM_CAMERA_OK) {
303 LOGE("mm_app_open() cam_idx=%d, err=%d\n",
304 i, rc);
305 break;
306 }
307
308 rc = mm_app_start_record_preview(&test_obj);
309 if (rc != MM_CAMERA_OK) {
310 LOGE("mm_app_start_record_preview() cam_idx=%d, err=%d\n",
311 i, rc);
312 mm_app_close(&test_obj);
313 break;
314 }
315
316 sleep(1);
317
318 rc = mm_app_start_record(&test_obj);
319 if (rc != MM_CAMERA_OK) {
320 LOGE("mm_app_start_record() cam_idx=%d, err=%d\n",
321 i, rc);
322 mm_app_stop_record_preview(&test_obj);
323 mm_app_close(&test_obj);
324 break;
325 }
326
327 sleep(1);
328
329 for (j = 0; j < MM_QCAMERA_APP_UTEST_INNER_LOOP; j++) {
330 rc = mm_app_start_live_snapshot(&test_obj);
331 if (rc != MM_CAMERA_OK) {
332 LOGE("mm_app_start_live_snapshot() cam_idx=%d, err=%d\n",
333 i, rc);
334 break;
335 }
336
337 /* wait for jpeg is done */
338 mm_camera_app_wait();
339
340 rc = mm_app_stop_live_snapshot(&test_obj);
341 if (rc != MM_CAMERA_OK) {
342 LOGE("mm_app_stop_live_snapshot() cam_idx=%d, err=%d\n",
343 i, rc);
344 break;
345 }
346 }
347 if (rc != MM_CAMERA_OK) {
348 LOGE("start/stop live snapshot cam_idx=%d, err=%d\n",
349 i, rc);
350 mm_app_stop_record(&test_obj);
351 mm_app_stop_record_preview(&test_obj);
352 mm_app_close(&test_obj);
353 break;
354 }
355
356 rc = mm_app_stop_record(&test_obj);
357 if (rc != MM_CAMERA_OK) {
358 LOGE("mm_app_stop_record() cam_idx=%d, err=%d\n",
359 i, rc);
360 mm_app_stop_record_preview(&test_obj);
361 mm_app_close(&test_obj);
362 break;
363 }
364
365 sleep(1);
366
367 rc = mm_app_stop_record_preview(&test_obj);
368 if (rc != MM_CAMERA_OK) {
369 LOGE("mm_app_stop_record_preview() cam_idx=%d, err=%d\n",
370 i, rc);
371 mm_app_close(&test_obj);
372 break;
373 }
374
375 rc = mm_app_close(&test_obj);
376 if (rc != MM_CAMERA_OK) {
377 LOGE("mm_app_close() cam_idx=%d, err=%d\n",
378 i, rc);
379 break;
380 }
381 }
382 if (rc == MM_CAMERA_OK) {
383 printf("\nPassed\n");
384 } else {
385 printf("\nFailed\n");
386 }
387 LOGD("END, rc = %d\n", rc);
388 return rc;
389 }
390
mm_app_tc_capture_raw(mm_camera_app_t * cam_app)391 int mm_app_tc_capture_raw(mm_camera_app_t *cam_app)
392 {
393 int rc = MM_CAMERA_OK;
394 int i, j;
395 mm_camera_test_obj_t test_obj;
396 uint8_t num_snapshot = 1;
397 uint8_t num_rcvd_snapshot = 0;
398
399 printf("\n Verifying raw capture...\n");
400 for (i = 0; i < cam_app->num_cameras; i++) {
401 memset(&test_obj, 0, sizeof(mm_camera_test_obj_t));
402 rc = mm_app_open(cam_app, i, &test_obj);
403 if (rc != MM_CAMERA_OK) {
404 LOGE("mm_app_open() cam_idx=%d, err=%d\n",
405 i, rc);
406 break;
407 }
408
409 for (j = 0; j < MM_QCAMERA_APP_UTEST_INNER_LOOP; j++) {
410 rc = mm_app_start_capture_raw(&test_obj, num_snapshot);
411 if (rc != MM_CAMERA_OK) {
412 LOGE(" mm_app_start_capture() cam_idx=%d, err=%d\n",
413 i, rc);
414 break;
415 }
416 while (num_rcvd_snapshot < num_snapshot) {
417 mm_camera_app_wait();
418 num_rcvd_snapshot++;
419 }
420 rc = mm_app_stop_capture_raw(&test_obj);
421 if (rc != MM_CAMERA_OK) {
422 LOGE(" mm_app_stop_capture() cam_idx=%d, err=%d\n",
423 i, rc);
424 break;
425 }
426 }
427
428 rc |= mm_app_close(&test_obj);
429 if (rc != MM_CAMERA_OK) {
430 LOGE("mm_app_close() cam_idx=%d, err=%d\n",
431 i, rc);
432 break;
433 }
434 }
435 if (rc == MM_CAMERA_OK) {
436 printf("\nPassed\n");
437 } else {
438 printf("\nFailed\n");
439 }
440 LOGD("END, rc = %d\n", rc);
441 return rc;
442 }
443
mm_app_tc_capture_regular(mm_camera_app_t * cam_app)444 int mm_app_tc_capture_regular(mm_camera_app_t *cam_app)
445 {
446 int rc = MM_CAMERA_OK;
447 int i, j;
448 mm_camera_test_obj_t test_obj;
449 uint8_t num_snapshot = 1;
450 uint8_t num_rcvd_snapshot = 0;
451
452 printf("\n Verifying capture...\n");
453 for (i = 0; i < cam_app->num_cameras; i++) {
454 memset(&test_obj, 0, sizeof(mm_camera_test_obj_t));
455 rc = mm_app_open(cam_app, i, &test_obj);
456 if (rc != MM_CAMERA_OK) {
457 LOGE("mm_app_open() cam_idx=%d, err=%d\n",
458 i, rc);
459 break;
460 }
461
462 for (j = 0; j < MM_QCAMERA_APP_UTEST_INNER_LOOP; j++) {
463 rc = mm_app_start_capture(&test_obj, num_snapshot);
464 if (rc != MM_CAMERA_OK) {
465 LOGE(" mm_app_start_capture() cam_idx=%d, err=%d\n",
466 i, rc);
467 break;
468 }
469 while (num_rcvd_snapshot < num_snapshot) {
470 mm_camera_app_wait();
471 num_rcvd_snapshot++;
472 }
473 rc = mm_app_stop_capture(&test_obj);
474 if (rc != MM_CAMERA_OK) {
475 LOGE(" mm_app_stop_capture() cam_idx=%d, err=%d\n",
476 i, rc);
477 break;
478 }
479 }
480
481 rc = mm_app_close(&test_obj);
482 if (rc != MM_CAMERA_OK) {
483 LOGE("mm_app_close() cam_idx=%d, err=%d\n",
484 i, rc);
485 break;
486 }
487 }
488 if (rc == MM_CAMERA_OK) {
489 printf("\nPassed\n");
490 } else {
491 printf("\nFailed\n");
492 }
493 LOGD("END, rc = %d\n", rc);
494 return rc;
495 }
496
mm_app_tc_capture_burst(mm_camera_app_t * cam_app)497 int mm_app_tc_capture_burst(mm_camera_app_t *cam_app)
498 {
499 int rc = MM_CAMERA_OK;
500 int i, j;
501 mm_camera_test_obj_t test_obj;
502 uint8_t num_snapshot = 3;
503 uint8_t num_rcvd_snapshot = 0;
504
505 printf("\n Verifying capture...\n");
506 for (i = 0; i < cam_app->num_cameras; i++) {
507 memset(&test_obj, 0, sizeof(mm_camera_test_obj_t));
508 rc = mm_app_open(cam_app, i, &test_obj);
509 if (rc != MM_CAMERA_OK) {
510 LOGE("mm_app_open() cam_idx=%d, err=%d\n",
511 i, rc);
512 break;
513 }
514
515 for (j = 0; j < MM_QCAMERA_APP_UTEST_INNER_LOOP; j++) {
516 rc = mm_app_start_capture(&test_obj, num_snapshot);
517 if (rc != MM_CAMERA_OK) {
518 LOGE(" mm_app_start_capture() cam_idx=%d, err=%d\n",
519 i, rc);
520 break;
521 }
522 while (num_rcvd_snapshot < num_snapshot) {
523 mm_camera_app_wait();
524 num_rcvd_snapshot++;
525 }
526 rc = mm_app_stop_capture(&test_obj);
527 if (rc != MM_CAMERA_OK) {
528 LOGE(" mm_app_stop_capture() cam_idx=%d, err=%d\n",
529 i, rc);
530 break;
531 }
532 }
533
534 rc = mm_app_close(&test_obj);
535 if (rc != MM_CAMERA_OK) {
536 LOGE("mm_app_close() cam_idx=%d, err=%d\n",
537 i, rc);
538 break;
539 }
540 }
541 if (rc == MM_CAMERA_OK) {
542 printf("\nPassed\n");
543 } else {
544 printf("\nFailed\n");
545 }
546 LOGD("END, rc = %d\n", rc);
547 return rc;
548 }
549
mm_app_tc_rdi_burst(mm_camera_app_t * cam_app)550 int mm_app_tc_rdi_burst(mm_camera_app_t *cam_app)
551 {
552 int rc = MM_CAMERA_OK, rc2 = MM_CAMERA_OK;
553 int i, j;
554 mm_camera_test_obj_t test_obj;
555
556 printf("\n Verifying rdi burst (3) capture...\n");
557 for (i = 0; i < cam_app->num_cameras; i++) {
558 memset(&test_obj, 0, sizeof(mm_camera_test_obj_t));
559 rc = mm_app_open(cam_app, i, &test_obj);
560 if (rc != MM_CAMERA_OK) {
561 LOGE("mm_app_open() cam_idx=%d, err=%d\n",
562 i, rc);
563 break;
564 }
565
566 for (j = 0; j < MM_QCAMERA_APP_UTEST_INNER_LOOP; j++) {
567 rc = mm_app_start_rdi(&test_obj, 3);
568 if (rc != MM_CAMERA_OK) {
569 LOGE(" mm_app_start_preview() cam_idx=%d, err=%d\n",
570 i, rc);
571 break;
572 }
573 sleep(1);
574 rc = mm_app_stop_rdi(&test_obj);
575 if (rc != MM_CAMERA_OK) {
576 LOGE(" mm_app_stop_preview() cam_idx=%d, err=%d\n",
577 i, rc);
578 break;
579 }
580 }
581
582 rc2 = mm_app_close(&test_obj);
583 if (rc2 != MM_CAMERA_OK) {
584 LOGE("mm_app_close() cam_idx=%d, err=%d\n",
585 i, rc2);
586 if (rc == MM_CAMERA_OK) {
587 rc = rc2;
588 }
589 break;
590 }
591 }
592 if (rc == MM_CAMERA_OK) {
593 printf("\nPassed\n");
594 } else {
595 printf("\nFailed\n");
596 }
597 LOGD("END, rc = %d\n", rc);
598 return rc;
599 }
600
mm_app_tc_rdi_cont(mm_camera_app_t * cam_app)601 int mm_app_tc_rdi_cont(mm_camera_app_t *cam_app)
602 {
603 int rc = MM_CAMERA_OK, rc2 = MM_CAMERA_OK;
604 int i, j;
605 mm_camera_test_obj_t test_obj;
606
607 printf("\n Verifying rdi continuous capture...\n");
608 for (i = 0; i < cam_app->num_cameras; i++) {
609 memset(&test_obj, 0, sizeof(mm_camera_test_obj_t));
610 rc = mm_app_open(cam_app, i, &test_obj);
611 if (rc != MM_CAMERA_OK) {
612 LOGE("mm_app_open() cam_idx=%d, err=%d\n",
613 i, rc);
614 break;
615 }
616
617 for (j = 0; j < MM_QCAMERA_APP_UTEST_INNER_LOOP; j++) {
618 rc = mm_app_start_rdi(&test_obj, 0);
619 if (rc != MM_CAMERA_OK) {
620 LOGE(" mm_app_start_preview() cam_idx=%d, err=%d\n",
621 i, rc);
622 break;
623 }
624 sleep(1);
625 rc = mm_app_stop_rdi(&test_obj);
626 if (rc != MM_CAMERA_OK) {
627 LOGE(" mm_app_stop_preview() cam_idx=%d, err=%d\n",
628 i, rc);
629 break;
630 }
631 }
632
633 rc2 = mm_app_close(&test_obj);
634 if (rc2 != MM_CAMERA_OK) {
635 LOGE("mm_app_close() cam_idx=%d, err=%d\n",
636 i, rc2);
637 if (rc == MM_CAMERA_OK) {
638 rc = rc2;
639 }
640 break;
641 }
642 }
643 if (rc == MM_CAMERA_OK) {
644 printf("\nPassed\n");
645 } else {
646 printf("\nFailed\n");
647 }
648 LOGD("END, rc = %d\n", rc);
649 return rc;
650 }
651
mm_app_gen_test_cases()652 int mm_app_gen_test_cases()
653 {
654 int tc = 0;
655 memset(mm_app_tc, 0, sizeof(mm_app_tc));
656 if (tc < MM_QCAM_APP_TEST_NUM) mm_app_tc[tc++].f = mm_app_tc_open_close;
657 if (tc < MM_QCAM_APP_TEST_NUM) mm_app_tc[tc++].f = mm_app_tc_start_stop_preview;
658 //if (tc < MM_QCAM_APP_TEST_NUM) mm_app_tc[tc++].f = mm_app_tc_start_stop_zsl;
659 //if (tc < MM_QCAM_APP_TEST_NUM) mm_app_tc[tc++].f = mm_app_tc_start_stop_video_preview;
660 //if (tc < MM_QCAM_APP_TEST_NUM) mm_app_tc[tc++].f = mm_app_tc_start_stop_video_record;
661 //if (tc < MM_QCAM_APP_TEST_NUM) mm_app_tc[tc++].f = mm_app_tc_start_stop_live_snapshot;
662 //if (tc < MM_QCAM_APP_TEST_NUM) mm_app_tc[tc++].f = mm_app_tc_capture_regular;
663 //if (tc < MM_QCAM_APP_TEST_NUM) mm_app_tc[tc++].f = mm_app_tc_capture_burst;
664 //if (tc < MM_QCAM_APP_TEST_NUM) mm_app_tc[tc++].f = mm_app_tc_rdi_cont;
665 //if (tc < MM_QCAM_APP_TEST_NUM) mm_app_tc[tc++].f = mm_app_tc_rdi_burst;
666
667 return tc;
668 }
669
mm_app_unit_test_entry(mm_camera_app_t * cam_app)670 int mm_app_unit_test_entry(mm_camera_app_t *cam_app)
671 {
672 int rc = MM_CAMERA_OK;
673 int i, j, tc = 0;
674
675 tc = mm_app_gen_test_cases();
676 LOGD("Running %d test cases\n",tc);
677 for (i = 0; i < tc; i++) {
678 for (j = 0; j < MM_QCAMERA_APP_UTEST_OUTER_LOOP; j++) {
679 mm_app_tc[i].r = mm_app_tc[i].f(cam_app);
680 if (mm_app_tc[i].r != MM_CAMERA_OK) {
681 printf(" test case %d (iteration %d) error = %d, abort unit testing engine!!!!\n",
682 i, j, mm_app_tc[i].r);
683 rc = mm_app_tc[i].r;
684 goto end;
685 }
686 }
687 }
688 end:
689 printf("nTOTAL_TSET_CASE = %d, NUM_TEST_RAN = %d, rc=%d\n", tc, i, rc);
690 return rc;
691 }
692
693
694
695
696