• 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 #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 #include <unistd.h>
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 
177     printf("\n Verifying start/stop video preview...\n");
178     for (i = 0; i < cam_app->num_cameras; i++) {
179         memset(&test_obj, 0, sizeof(mm_camera_test_obj_t));
180         rc = mm_app_open(cam_app, i, &test_obj);
181         if (rc != MM_CAMERA_OK) {
182             LOGE("mm_app_open() cam_idx=%d, err=%d\n",
183                         i, rc);
184             break;
185         }
186 
187         for (j = 0; j < MM_QCAMERA_APP_UTEST_INNER_LOOP; j++) {
188             rc = mm_app_start_record_preview(&test_obj);
189             if (rc != MM_CAMERA_OK) {
190                 LOGE("mm_app_start_record_preview() cam_idx=%d, err=%d\n",
191                             i, rc);
192                 break;
193             }
194             sleep(1);
195             rc = mm_app_stop_record_preview(&test_obj);
196             if (rc != MM_CAMERA_OK) {
197                 LOGE("mm_app_stop_record_preview() cam_idx=%d, err=%d\n",
198                             i, rc);
199                 break;
200             }
201         }
202 
203         rc = mm_app_close(&test_obj);
204         if (rc != MM_CAMERA_OK) {
205             LOGE("mm_app_close() cam_idx=%d, err=%d\n",
206                         i, rc);
207             break;
208         }
209     }
210     if (rc == MM_CAMERA_OK) {
211         printf("\nPassed\n");
212     } else {
213         printf("\nFailed\n");
214     }
215     LOGD("END, rc = %d\n",  rc);
216     return rc;
217 }
218 
mm_app_tc_start_stop_video_record(mm_camera_app_t * cam_app)219 int mm_app_tc_start_stop_video_record(mm_camera_app_t *cam_app)
220 {
221     int rc = MM_CAMERA_OK;
222     int i, j;
223     mm_camera_test_obj_t test_obj;
224 
225     printf("\n Verifying start/stop recording...\n");
226     for (i = 0; i < cam_app->num_cameras; i++) {
227         memset(&test_obj, 0, sizeof(mm_camera_test_obj_t));
228         rc = mm_app_open(cam_app, i, &test_obj);
229         if (rc != MM_CAMERA_OK) {
230             LOGE("mm_app_open() cam_idx=%d, err=%d\n",
231                         i, rc);
232             break;
233         }
234 
235         rc = mm_app_start_record_preview(&test_obj);
236         if (rc != MM_CAMERA_OK) {
237             LOGE("mm_app_start_record_preview() cam_idx=%d, err=%d\n",
238                         i, rc);
239             mm_app_close(&test_obj);
240             break;
241         }
242 
243         sleep(1);
244 
245         for (j = 0; j < MM_QCAMERA_APP_UTEST_INNER_LOOP; j++) {
246             rc = mm_app_start_record(&test_obj);
247             if (rc != MM_CAMERA_OK) {
248                 LOGE("mm_app_start_record() cam_idx=%d, err=%d\n",
249                             i, rc);
250                 break;
251             }
252 
253             sleep(1);
254 
255             rc = mm_app_stop_record(&test_obj);
256             if (rc != MM_CAMERA_OK) {
257                 LOGE("mm_app_stop_record() cam_idx=%d, err=%d\n",
258                             i, rc);
259                 break;
260             }
261         }
262         if (rc != MM_CAMERA_OK) {
263             LOGE("start/stop record cam_idx=%d, err=%d\n",
264                         i, rc);
265             mm_app_stop_record_preview(&test_obj);
266             mm_app_close(&test_obj);
267             break;
268         }
269 
270         rc = mm_app_stop_record_preview(&test_obj);
271         if (rc != MM_CAMERA_OK) {
272             LOGE("mm_app_stop_record_preview() cam_idx=%d, err=%d\n",
273                         i, rc);
274             mm_app_close(&test_obj);
275             break;
276         }
277 
278         rc = mm_app_close(&test_obj);
279         if (rc != MM_CAMERA_OK) {
280             LOGE("mm_app_close() cam_idx=%d, err=%d\n",
281                         i, rc);
282             break;
283         }
284     }
285     if (rc == MM_CAMERA_OK) {
286         printf("\nPassed\n");
287     } else {
288         printf("\nFailed\n");
289     }
290     LOGD("END, rc = %d\n",  rc);
291     return rc;
292 }
293 
mm_app_tc_start_stop_live_snapshot(mm_camera_app_t * cam_app)294 int mm_app_tc_start_stop_live_snapshot(mm_camera_app_t *cam_app)
295 {
296     int rc = MM_CAMERA_OK;
297     int i, j;
298     mm_camera_test_obj_t test_obj;
299 
300     printf("\n Verifying start/stop live snapshot...\n");
301     for (i = 0; i < cam_app->num_cameras; i++) {
302         memset(&test_obj, 0, sizeof(mm_camera_test_obj_t));
303         rc = mm_app_open(cam_app, i, &test_obj);
304         if (rc != MM_CAMERA_OK) {
305             LOGE("mm_app_open() cam_idx=%d, err=%d\n",
306                         i, rc);
307             break;
308         }
309 
310         rc = mm_app_start_record_preview(&test_obj);
311         if (rc != MM_CAMERA_OK) {
312             LOGE("mm_app_start_record_preview() cam_idx=%d, err=%d\n",
313                         i, rc);
314             mm_app_close(&test_obj);
315             break;
316         }
317 
318         sleep(1);
319 
320         rc = mm_app_start_record(&test_obj);
321         if (rc != MM_CAMERA_OK) {
322             LOGE("mm_app_start_record() cam_idx=%d, err=%d\n",
323                         i, rc);
324             mm_app_stop_record_preview(&test_obj);
325             mm_app_close(&test_obj);
326             break;
327         }
328 
329         sleep(1);
330 
331         for (j = 0; j < MM_QCAMERA_APP_UTEST_INNER_LOOP; j++) {
332             rc = mm_app_start_live_snapshot(&test_obj);
333             if (rc != MM_CAMERA_OK) {
334                 LOGE("mm_app_start_live_snapshot() cam_idx=%d, err=%d\n",
335                             i, rc);
336                 break;
337             }
338 
339             /* wait for jpeg is done */
340             mm_camera_app_wait();
341 
342             rc = mm_app_stop_live_snapshot(&test_obj);
343             if (rc != MM_CAMERA_OK) {
344                 LOGE("mm_app_stop_live_snapshot() cam_idx=%d, err=%d\n",
345                             i, rc);
346                 break;
347             }
348         }
349         if (rc != MM_CAMERA_OK) {
350             LOGE("start/stop live snapshot cam_idx=%d, err=%d\n",
351                         i, rc);
352             mm_app_stop_record(&test_obj);
353             mm_app_stop_record_preview(&test_obj);
354             mm_app_close(&test_obj);
355             break;
356         }
357 
358         rc = mm_app_stop_record(&test_obj);
359         if (rc != MM_CAMERA_OK) {
360             LOGE("mm_app_stop_record() cam_idx=%d, err=%d\n",
361                         i, rc);
362             mm_app_stop_record_preview(&test_obj);
363             mm_app_close(&test_obj);
364             break;
365         }
366 
367         sleep(1);
368 
369         rc = mm_app_stop_record_preview(&test_obj);
370         if (rc != MM_CAMERA_OK) {
371             LOGE("mm_app_stop_record_preview() cam_idx=%d, err=%d\n",
372                         i, rc);
373             mm_app_close(&test_obj);
374             break;
375         }
376 
377         rc = mm_app_close(&test_obj);
378         if (rc != MM_CAMERA_OK) {
379             LOGE("mm_app_close() cam_idx=%d, err=%d\n",
380                         i, rc);
381             break;
382         }
383     }
384     if (rc == MM_CAMERA_OK) {
385         printf("\nPassed\n");
386     } else {
387         printf("\nFailed\n");
388     }
389     LOGD("END, rc = %d\n",  rc);
390     return rc;
391 }
392 
mm_app_tc_capture_raw(mm_camera_app_t * cam_app)393 int mm_app_tc_capture_raw(mm_camera_app_t *cam_app)
394 {
395     int rc = MM_CAMERA_OK;
396     int i, j;
397     mm_camera_test_obj_t test_obj;
398     uint8_t num_snapshot = 1;
399     uint8_t num_rcvd_snapshot = 0;
400 
401     printf("\n Verifying raw capture...\n");
402     for (i = 0; i < cam_app->num_cameras; i++) {
403         memset(&test_obj, 0, sizeof(mm_camera_test_obj_t));
404         rc = mm_app_open(cam_app, i, &test_obj);
405         if (rc != MM_CAMERA_OK) {
406             LOGE("mm_app_open() cam_idx=%d, err=%d\n",
407                         i, rc);
408             break;
409         }
410 
411         for (j = 0; j < MM_QCAMERA_APP_UTEST_INNER_LOOP; j++) {
412             rc = mm_app_start_capture_raw(&test_obj, num_snapshot);
413             if (rc != MM_CAMERA_OK) {
414                 LOGE(" mm_app_start_capture() cam_idx=%d, err=%d\n",
415                             i, rc);
416                 break;
417             }
418             while (num_rcvd_snapshot < num_snapshot) {
419                 mm_camera_app_wait();
420                 num_rcvd_snapshot++;
421             }
422             rc = mm_app_stop_capture_raw(&test_obj);
423             if (rc != MM_CAMERA_OK) {
424                 LOGE(" mm_app_stop_capture() cam_idx=%d, err=%d\n",
425                             i, rc);
426                 break;
427             }
428         }
429 
430         rc |= mm_app_close(&test_obj);
431         if (rc != MM_CAMERA_OK) {
432             LOGE("mm_app_close() cam_idx=%d, err=%d\n",
433                         i, rc);
434             break;
435         }
436     }
437     if (rc == MM_CAMERA_OK) {
438         printf("\nPassed\n");
439     } else {
440         printf("\nFailed\n");
441     }
442     LOGD("END, rc = %d\n",  rc);
443     return rc;
444 }
445 
mm_app_tc_capture_regular(mm_camera_app_t * cam_app)446 int mm_app_tc_capture_regular(mm_camera_app_t *cam_app)
447 {
448     int rc = MM_CAMERA_OK;
449     int i, j;
450     mm_camera_test_obj_t test_obj;
451     uint8_t num_snapshot = 1;
452     uint8_t num_rcvd_snapshot = 0;
453 
454     printf("\n Verifying capture...\n");
455     for (i = 0; i < cam_app->num_cameras; i++) {
456         memset(&test_obj, 0, sizeof(mm_camera_test_obj_t));
457         rc = mm_app_open(cam_app, i, &test_obj);
458         if (rc != MM_CAMERA_OK) {
459             LOGE("mm_app_open() cam_idx=%d, err=%d\n",
460                         i, rc);
461             break;
462         }
463 
464         for (j = 0; j < MM_QCAMERA_APP_UTEST_INNER_LOOP; j++) {
465             rc = mm_app_start_capture(&test_obj, num_snapshot);
466             if (rc != MM_CAMERA_OK) {
467                 LOGE(" mm_app_start_capture() cam_idx=%d, err=%d\n",
468                             i, rc);
469                 break;
470             }
471             while (num_rcvd_snapshot < num_snapshot) {
472                 mm_camera_app_wait();
473                 num_rcvd_snapshot++;
474             }
475             rc = mm_app_stop_capture(&test_obj);
476             if (rc != MM_CAMERA_OK) {
477                 LOGE(" mm_app_stop_capture() cam_idx=%d, err=%d\n",
478                             i, rc);
479                 break;
480             }
481         }
482 
483         rc = mm_app_close(&test_obj);
484         if (rc != MM_CAMERA_OK) {
485             LOGE("mm_app_close() cam_idx=%d, err=%d\n",
486                         i, rc);
487             break;
488         }
489     }
490     if (rc == MM_CAMERA_OK) {
491         printf("\nPassed\n");
492     } else {
493         printf("\nFailed\n");
494     }
495     LOGD("END, rc = %d\n",  rc);
496     return rc;
497 }
498 
mm_app_tc_capture_burst(mm_camera_app_t * cam_app)499 int mm_app_tc_capture_burst(mm_camera_app_t *cam_app)
500 {
501     int rc = MM_CAMERA_OK;
502     int i, j;
503     mm_camera_test_obj_t test_obj;
504     uint8_t num_snapshot = 3;
505     uint8_t num_rcvd_snapshot = 0;
506 
507     printf("\n Verifying capture...\n");
508     for (i = 0; i < cam_app->num_cameras; i++) {
509         memset(&test_obj, 0, sizeof(mm_camera_test_obj_t));
510         rc = mm_app_open(cam_app, i, &test_obj);
511         if (rc != MM_CAMERA_OK) {
512             LOGE("mm_app_open() cam_idx=%d, err=%d\n",
513                         i, rc);
514             break;
515         }
516 
517         for (j = 0; j < MM_QCAMERA_APP_UTEST_INNER_LOOP; j++) {
518             rc = mm_app_start_capture(&test_obj, num_snapshot);
519             if (rc != MM_CAMERA_OK) {
520                 LOGE(" mm_app_start_capture() cam_idx=%d, err=%d\n",
521                             i, rc);
522                 break;
523             }
524             while (num_rcvd_snapshot < num_snapshot) {
525                 mm_camera_app_wait();
526                 num_rcvd_snapshot++;
527             }
528             rc = mm_app_stop_capture(&test_obj);
529             if (rc != MM_CAMERA_OK) {
530                 LOGE(" mm_app_stop_capture() cam_idx=%d, err=%d\n",
531                             i, rc);
532                 break;
533             }
534         }
535 
536         rc = mm_app_close(&test_obj);
537         if (rc != MM_CAMERA_OK) {
538             LOGE("mm_app_close() cam_idx=%d, err=%d\n",
539                         i, rc);
540             break;
541         }
542     }
543     if (rc == MM_CAMERA_OK) {
544         printf("\nPassed\n");
545     } else {
546         printf("\nFailed\n");
547     }
548     LOGD("END, rc = %d\n",  rc);
549     return rc;
550 }
551 
mm_app_tc_rdi_burst(mm_camera_app_t * cam_app)552 int mm_app_tc_rdi_burst(mm_camera_app_t *cam_app)
553 {
554     int rc = MM_CAMERA_OK, rc2 = MM_CAMERA_OK;
555     int i, j;
556     mm_camera_test_obj_t test_obj;
557 
558     printf("\n Verifying rdi burst (3) capture...\n");
559     for (i = 0; i < cam_app->num_cameras; i++) {
560         memset(&test_obj, 0, sizeof(mm_camera_test_obj_t));
561         rc = mm_app_open(cam_app, i, &test_obj);
562         if (rc != MM_CAMERA_OK) {
563             LOGE("mm_app_open() cam_idx=%d, err=%d\n",
564                         i, rc);
565             break;
566         }
567 
568         for (j = 0; j < MM_QCAMERA_APP_UTEST_INNER_LOOP; j++) {
569             rc = mm_app_start_rdi(&test_obj, 3);
570             if (rc != MM_CAMERA_OK) {
571                 LOGE(" mm_app_start_preview() cam_idx=%d, err=%d\n",
572                             i, rc);
573                 break;
574             }
575             sleep(1);
576             rc = mm_app_stop_rdi(&test_obj);
577             if (rc != MM_CAMERA_OK) {
578                 LOGE(" mm_app_stop_preview() cam_idx=%d, err=%d\n",
579                             i, rc);
580                 break;
581             }
582         }
583 
584         rc2 = mm_app_close(&test_obj);
585         if (rc2 != MM_CAMERA_OK) {
586             LOGE("mm_app_close() cam_idx=%d, err=%d\n",
587                         i, rc2);
588             if (rc == MM_CAMERA_OK) {
589                 rc = rc2;
590             }
591             break;
592         }
593     }
594     if (rc == MM_CAMERA_OK) {
595         printf("\nPassed\n");
596     } else {
597         printf("\nFailed\n");
598     }
599     LOGD("END, rc = %d\n",  rc);
600     return rc;
601 }
602 
mm_app_tc_rdi_cont(mm_camera_app_t * cam_app)603 int mm_app_tc_rdi_cont(mm_camera_app_t *cam_app)
604 {
605     int rc = MM_CAMERA_OK, rc2 = MM_CAMERA_OK;
606     int i, j;
607     mm_camera_test_obj_t test_obj;
608 
609     printf("\n Verifying rdi continuous capture...\n");
610     for (i = 0; i < cam_app->num_cameras; i++) {
611         memset(&test_obj, 0, sizeof(mm_camera_test_obj_t));
612         rc = mm_app_open(cam_app, i, &test_obj);
613         if (rc != MM_CAMERA_OK) {
614             LOGE("mm_app_open() cam_idx=%d, err=%d\n",
615                         i, rc);
616             break;
617         }
618 
619         for (j = 0; j < MM_QCAMERA_APP_UTEST_INNER_LOOP; j++) {
620             rc = mm_app_start_rdi(&test_obj, 0);
621             if (rc != MM_CAMERA_OK) {
622                 LOGE(" mm_app_start_preview() cam_idx=%d, err=%d\n",
623                             i, rc);
624                 break;
625             }
626             sleep(1);
627             rc = mm_app_stop_rdi(&test_obj);
628             if (rc != MM_CAMERA_OK) {
629                 LOGE(" mm_app_stop_preview() cam_idx=%d, err=%d\n",
630                             i, rc);
631                 break;
632             }
633         }
634 
635         rc2 = mm_app_close(&test_obj);
636         if (rc2 != MM_CAMERA_OK) {
637             LOGE("mm_app_close() cam_idx=%d, err=%d\n",
638                         i, rc2);
639             if (rc == MM_CAMERA_OK) {
640                 rc = rc2;
641             }
642             break;
643         }
644     }
645     if (rc == MM_CAMERA_OK) {
646         printf("\nPassed\n");
647     } else {
648         printf("\nFailed\n");
649     }
650     LOGD("END, rc = %d\n",  rc);
651     return rc;
652 }
653 
mm_app_gen_test_cases()654 int mm_app_gen_test_cases()
655 {
656     int tc = 0;
657     memset(mm_app_tc, 0, sizeof(mm_app_tc));
658     if (tc < MM_QCAM_APP_TEST_NUM) mm_app_tc[tc++].f = mm_app_tc_open_close;
659     if (tc < MM_QCAM_APP_TEST_NUM) mm_app_tc[tc++].f = mm_app_tc_start_stop_preview;
660     //if (tc < MM_QCAM_APP_TEST_NUM) mm_app_tc[tc++].f = mm_app_tc_start_stop_zsl;
661     //if (tc < MM_QCAM_APP_TEST_NUM) mm_app_tc[tc++].f = mm_app_tc_start_stop_video_preview;
662     //if (tc < MM_QCAM_APP_TEST_NUM) mm_app_tc[tc++].f = mm_app_tc_start_stop_video_record;
663     //if (tc < MM_QCAM_APP_TEST_NUM) mm_app_tc[tc++].f = mm_app_tc_start_stop_live_snapshot;
664     //if (tc < MM_QCAM_APP_TEST_NUM) mm_app_tc[tc++].f = mm_app_tc_capture_regular;
665     //if (tc < MM_QCAM_APP_TEST_NUM) mm_app_tc[tc++].f = mm_app_tc_capture_burst;
666     //if (tc < MM_QCAM_APP_TEST_NUM) mm_app_tc[tc++].f = mm_app_tc_rdi_cont;
667     //if (tc < MM_QCAM_APP_TEST_NUM) mm_app_tc[tc++].f = mm_app_tc_rdi_burst;
668 
669     return tc;
670 }
671 
mm_app_unit_test_entry(mm_camera_app_t * cam_app)672 int mm_app_unit_test_entry(mm_camera_app_t *cam_app)
673 {
674     int rc = MM_CAMERA_OK;
675     int i, j, tc = 0;
676 
677     tc = mm_app_gen_test_cases();
678     LOGD("Running %d test cases\n",tc);
679     for (i = 0; i < tc; i++) {
680         for (j = 0; j < MM_QCAMERA_APP_UTEST_OUTER_LOOP; j++) {
681             mm_app_tc[i].r = mm_app_tc[i].f(cam_app);
682             if (mm_app_tc[i].r != MM_CAMERA_OK) {
683                 printf(" test case %d (iteration %d) error = %d, abort unit testing engine!!!!\n",
684                         i, j, mm_app_tc[i].r);
685                 rc = mm_app_tc[i].r;
686                 goto end;
687             }
688         }
689     }
690 end:
691     printf("nTOTAL_TSET_CASE = %d, NUM_TEST_RAN = %d, rc=%d\n", tc, i, rc);
692     return rc;
693 }
694 
695 
696 
697 
698