LCOV - code coverage report
Current view: top level - app/test-mldev - ml_main.c (source / functions) Hit Total Coverage
Test: Code coverage Lines: 0 53 0.0 %
Date: 2025-03-01 20:23:48 Functions: 0 1 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 0 -

           Branch data     Line data    Source code
       1                 :            : /* SPDX-License-Identifier: BSD-3-Clause
       2                 :            :  * Copyright (c) 2022 Marvell.
       3                 :            :  */
       4                 :            : 
       5                 :            : #include <rte_debug.h>
       6                 :            : #include <rte_eal.h>
       7                 :            : #include <rte_mldev.h>
       8                 :            : 
       9                 :            : #include "ml_common.h"
      10                 :            : #include "ml_test.h"
      11                 :            : 
      12                 :            : struct ml_options opt;
      13                 :            : struct ml_test *test;
      14                 :            : 
      15                 :            : int
      16                 :          0 : main(int argc, char **argv)
      17                 :            : {
      18                 :            :         uint16_t mldevs;
      19                 :            :         int ret;
      20                 :            : 
      21                 :          0 :         ret = rte_eal_init(argc, argv);
      22                 :          0 :         if (ret < 0)
      23                 :          0 :                 rte_panic("invalid EAL arguments\n");
      24                 :          0 :         argc -= ret;
      25                 :          0 :         argv += ret;
      26                 :            : 
      27                 :          0 :         mldevs = rte_ml_dev_count();
      28                 :          0 :         if (!mldevs) {
      29                 :          0 :                 ml_err("no mldev devices found\n");
      30                 :          0 :                 goto error;
      31                 :            :         }
      32                 :            : 
      33                 :            :         /* set default values for options */
      34                 :          0 :         ml_options_default(&opt);
      35                 :            : 
      36                 :            :         /* parse the command line arguments */
      37                 :          0 :         ret = ml_options_parse(&opt, argc, argv);
      38                 :          0 :         if (ret) {
      39                 :          0 :                 ml_err("parsing one or more user options failed");
      40                 :          0 :                 goto error;
      41                 :            :         }
      42                 :            : 
      43                 :            :         /* get test struct from name */
      44                 :          0 :         test = ml_test_get(opt.test_name);
      45                 :          0 :         if (test == NULL) {
      46                 :          0 :                 ml_err("failed to find requested test: %s", opt.test_name);
      47                 :          0 :                 goto error;
      48                 :            :         }
      49                 :            : 
      50                 :          0 :         if (test->ops.test_result == NULL) {
      51                 :          0 :                 ml_err("%s: ops.test_result not found", opt.test_name);
      52                 :          0 :                 goto error;
      53                 :            :         }
      54                 :            : 
      55                 :            :         /* check test options */
      56                 :          0 :         if (test->ops.opt_check) {
      57                 :          0 :                 if (test->ops.opt_check(&opt)) {
      58                 :          0 :                         ml_err("invalid command line argument");
      59                 :          0 :                         goto error;
      60                 :            :                 }
      61                 :            :         }
      62                 :            : 
      63                 :            :         /* check the device capability */
      64                 :          0 :         if (test->ops.cap_check) {
      65                 :          0 :                 if (test->ops.cap_check(&opt) == false) {
      66                 :          0 :                         ml_info("unsupported test: %s", opt.test_name);
      67                 :            :                         ret = ML_TEST_UNSUPPORTED;
      68                 :          0 :                         goto no_cap;
      69                 :            :                 }
      70                 :            :         }
      71                 :            : 
      72                 :            :         /* dump options */
      73                 :          0 :         if (opt.debug) {
      74                 :          0 :                 if (test->ops.opt_dump)
      75                 :          0 :                         test->ops.opt_dump(&opt);
      76                 :            :         }
      77                 :            : 
      78                 :            :         /* test specific setup */
      79                 :          0 :         if (test->ops.test_setup) {
      80                 :          0 :                 if (test->ops.test_setup(test, &opt)) {
      81                 :          0 :                         ml_err("failed to setup test: %s", opt.test_name);
      82                 :          0 :                         goto error;
      83                 :            :                 }
      84                 :            :         }
      85                 :            : 
      86                 :            :         /* test driver */
      87                 :          0 :         if (test->ops.test_driver)
      88                 :          0 :                 test->ops.test_driver(test, &opt);
      89                 :            : 
      90                 :            :         /* get result */
      91                 :          0 :         if (test->ops.test_result)
      92                 :          0 :                 ret = test->ops.test_result(test, &opt);
      93                 :            : 
      94                 :          0 :         if (test->ops.test_destroy)
      95                 :          0 :                 test->ops.test_destroy(test, &opt);
      96                 :            : 
      97                 :          0 : no_cap:
      98                 :          0 :         if (ret == ML_TEST_SUCCESS) {
      99                 :            :                 printf("Result: " CLGRN "%s" CLNRM "\n", "Success");
     100                 :          0 :         } else if (ret == ML_TEST_FAILED) {
     101                 :            :                 printf("Result: " CLRED "%s" CLNRM "\n", "Failed");
     102                 :          0 :                 return EXIT_FAILURE;
     103                 :          0 :         } else if (ret == ML_TEST_UNSUPPORTED) {
     104                 :            :                 printf("Result: " CLYEL "%s" CLNRM "\n", "Unsupported");
     105                 :            :         }
     106                 :            : 
     107                 :          0 :         rte_eal_cleanup();
     108                 :            : 
     109                 :          0 :         return 0;
     110                 :            : 
     111                 :          0 : error:
     112                 :          0 :         rte_eal_cleanup();
     113                 :            : 
     114                 :          0 :         return EXIT_FAILURE;
     115                 :            : }

Generated by: LCOV version 1.14