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