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