LCOV - code coverage report
Current view: top level - app/test-eventdev - evt_main.c (source / functions) Hit Total Coverage
Test: Code coverage Lines: 0 110 0.0 %
Date: 2025-03-01 20:23:48 Functions: 0 2 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) 2017 Cavium, Inc
       3                 :            :  */
       4                 :            : 
       5                 :            : #include <stdio.h>
       6                 :            : #include <stdlib.h>
       7                 :            : #include <unistd.h>
       8                 :            : #include <signal.h>
       9                 :            : 
      10                 :            : #include <rte_debug.h>
      11                 :            : #include <rte_eal.h>
      12                 :            : #include <rte_eventdev.h>
      13                 :            : 
      14                 :            : #include "evt_options.h"
      15                 :            : #include "evt_test.h"
      16                 :            : 
      17                 :            : struct evt_options opt;
      18                 :            : struct evt_test *test;
      19                 :            : 
      20                 :            : static void
      21                 :          0 : signal_handler(int signum)
      22                 :            : {
      23                 :          0 :         if (signum == SIGINT || signum == SIGTERM) {
      24                 :          0 :                 if (test != NULL) {
      25                 :            :                         /* request all lcores to exit from the main loop */
      26                 :          0 :                         *(int *)test->test_priv = true;
      27                 :            :                         rte_wmb();
      28                 :            :                 }
      29                 :            :         }
      30                 :          0 : }
      31                 :            : 
      32                 :            : static inline void
      33                 :            : evt_options_dump_all(struct evt_test *test, struct evt_options *opts)
      34                 :            : {
      35                 :          0 :         evt_options_dump(opts);
      36                 :          0 :         if (test->ops.opt_dump)
      37                 :          0 :                 test->ops.opt_dump(opts);
      38                 :            : }
      39                 :            : 
      40                 :            : int
      41                 :          0 : main(int argc, char **argv)
      42                 :            : {
      43                 :            :         uint8_t evdevs;
      44                 :            :         int ret;
      45                 :            : 
      46                 :          0 :         signal(SIGINT, signal_handler);
      47                 :          0 :         signal(SIGTERM, signal_handler);
      48                 :            : 
      49                 :          0 :         ret = rte_eal_init(argc, argv);
      50                 :          0 :         if (ret < 0)
      51                 :          0 :                 rte_panic("invalid EAL arguments\n");
      52                 :          0 :         argc -= ret;
      53                 :          0 :         argv += ret;
      54                 :            : 
      55                 :          0 :         evdevs = rte_event_dev_count();
      56                 :          0 :         if (!evdevs)
      57                 :          0 :                 rte_panic("no eventdev devices found\n");
      58                 :            : 
      59                 :            :         /* Populate the default values of the options */
      60                 :          0 :         evt_options_default(&opt);
      61                 :            : 
      62                 :            :         /* Parse the command line arguments */
      63                 :          0 :         ret = evt_options_parse(&opt, argc, argv);
      64                 :          0 :         if (ret) {
      65                 :          0 :                 evt_err("parsing one or more user options failed");
      66                 :          0 :                 goto error;
      67                 :            :         }
      68                 :            : 
      69                 :            :         /* Get struct evt_test *test from name */
      70                 :          0 :         test = evt_test_get(opt.test_name);
      71                 :          0 :         if (test == NULL) {
      72                 :          0 :                 evt_err("failed to find requested test: %s", opt.test_name);
      73                 :          0 :                 goto error;
      74                 :            :         }
      75                 :            : 
      76                 :          0 :         if (test->ops.test_result == NULL) {
      77                 :          0 :                 evt_err("%s: ops.test_result not found", opt.test_name);
      78                 :          0 :                 goto error;
      79                 :            :         }
      80                 :            : 
      81                 :            :         /* Verify the command line options */
      82                 :          0 :         if (opt.dev_id >= rte_event_dev_count()) {
      83                 :          0 :                 evt_err("invalid event device %d", opt.dev_id);
      84                 :          0 :                 goto error;
      85                 :            :         }
      86                 :          0 :         if (test->ops.opt_check) {
      87                 :          0 :                 if (test->ops.opt_check(&opt)) {
      88                 :          0 :                         evt_err("invalid command line argument");
      89                 :          0 :                         evt_options_dump_all(test, &opt);
      90                 :          0 :                         goto error;
      91                 :            :                 }
      92                 :            :         }
      93                 :            : 
      94                 :            :         /* Check the eventdev capability before proceeding */
      95                 :          0 :         if (test->ops.cap_check) {
      96                 :          0 :                 if (test->ops.cap_check(&opt) == false) {
      97                 :          0 :                         evt_info("unsupported test: %s", opt.test_name);
      98                 :          0 :                         evt_options_dump_all(test, &opt);
      99                 :            :                         ret = EVT_TEST_UNSUPPORTED;
     100                 :          0 :                         goto nocap;
     101                 :            :                 }
     102                 :            :         }
     103                 :            : 
     104                 :            :         /* Dump the options */
     105                 :          0 :         if (opt.verbose_level)
     106                 :          0 :                 evt_options_dump_all(test, &opt);
     107                 :            : 
     108                 :            :         /* Test specific setup */
     109                 :          0 :         if (test->ops.test_setup) {
     110                 :          0 :                 if (test->ops.test_setup(test, &opt))  {
     111                 :          0 :                         evt_err("failed to setup test: %s", opt.test_name);
     112                 :          0 :                         goto error;
     113                 :            : 
     114                 :            :                 }
     115                 :            :         }
     116                 :            : 
     117                 :            :         /* Test specific mempool setup */
     118                 :          0 :         if (test->ops.mempool_setup) {
     119                 :          0 :                 if (test->ops.mempool_setup(test, &opt)) {
     120                 :          0 :                         evt_err("%s: mempool setup failed", opt.test_name);
     121                 :          0 :                         goto test_destroy;
     122                 :            :                 }
     123                 :            :         }
     124                 :            : 
     125                 :            :         /* Test specific ethdev setup */
     126                 :          0 :         if (test->ops.ethdev_setup) {
     127                 :          0 :                 if (test->ops.ethdev_setup(test, &opt)) {
     128                 :          0 :                         evt_err("%s: ethdev setup failed", opt.test_name);
     129                 :          0 :                         goto mempool_destroy;
     130                 :            :                 }
     131                 :            :         }
     132                 :            : 
     133                 :            :         /* Test specific cryptodev setup */
     134                 :          0 :         if (test->ops.cryptodev_setup) {
     135                 :          0 :                 if (test->ops.cryptodev_setup(test, &opt)) {
     136                 :          0 :                         evt_err("%s: cryptodev setup failed", opt.test_name);
     137                 :          0 :                         goto ethdev_destroy;
     138                 :            :                 }
     139                 :            :         }
     140                 :            : 
     141                 :            :         /* Test specific dmadev setup */
     142                 :          0 :         if (test->ops.dmadev_setup) {
     143                 :          0 :                 if (test->ops.dmadev_setup(test, &opt)) {
     144                 :          0 :                         evt_err("%s: dmadev setup failed", opt.test_name);
     145                 :          0 :                         goto dmadev_destroy;
     146                 :            :                 }
     147                 :            :         }
     148                 :            : 
     149                 :            :         /* Test specific eventdev setup */
     150                 :          0 :         if (test->ops.eventdev_setup) {
     151                 :          0 :                 if (test->ops.eventdev_setup(test, &opt)) {
     152                 :          0 :                         evt_err("%s: eventdev setup failed", opt.test_name);
     153                 :          0 :                         goto cryptodev_destroy;
     154                 :            :                 }
     155                 :            :         }
     156                 :            : 
     157                 :            :         /* Launch lcores */
     158                 :          0 :         if (test->ops.launch_lcores) {
     159                 :          0 :                 if (test->ops.launch_lcores(test, &opt)) {
     160                 :          0 :                         evt_err("%s: failed to launch lcores", opt.test_name);
     161                 :          0 :                         goto eventdev_destroy;
     162                 :            :                 }
     163                 :            :         }
     164                 :            : 
     165                 :          0 :         if (test->ops.ethdev_rx_stop)
     166                 :          0 :                 test->ops.ethdev_rx_stop(test, &opt);
     167                 :            : 
     168                 :          0 :         rte_eal_mp_wait_lcore();
     169                 :            : 
     170                 :          0 :         if (test->ops.test_result)
     171                 :          0 :                 test->ops.test_result(test, &opt);
     172                 :            : 
     173                 :          0 :         if (test->ops.ethdev_destroy)
     174                 :          0 :                 test->ops.ethdev_destroy(test, &opt);
     175                 :            : 
     176                 :          0 :         if (test->ops.eventdev_destroy)
     177                 :          0 :                 test->ops.eventdev_destroy(test, &opt);
     178                 :            : 
     179                 :          0 :         if (test->ops.cryptodev_destroy)
     180                 :          0 :                 test->ops.cryptodev_destroy(test, &opt);
     181                 :            : 
     182                 :          0 :         if (test->ops.dmadev_destroy)
     183                 :          0 :                 test->ops.dmadev_destroy(test, &opt);
     184                 :            : 
     185                 :          0 :         if (test->ops.mempool_destroy)
     186                 :          0 :                 test->ops.mempool_destroy(test, &opt);
     187                 :            : 
     188                 :          0 :         if (test->ops.test_destroy)
     189                 :          0 :                 test->ops.test_destroy(test, &opt);
     190                 :            : 
     191                 :          0 : nocap:
     192                 :            :         if (ret == EVT_TEST_SUCCESS) {
     193                 :            :                 printf("Result: "CLGRN"%s"CLNRM"\n", "Success");
     194                 :            :         } else if (ret == EVT_TEST_FAILED) {
     195                 :            :                 printf("Result: "CLRED"%s"CLNRM"\n", "Failed");
     196                 :            :                 return EXIT_FAILURE;
     197                 :            :         } else if (ret == EVT_TEST_UNSUPPORTED) {
     198                 :            :                 printf("Result: "CLYEL"%s"CLNRM"\n", "Unsupported");
     199                 :            :         }
     200                 :            : 
     201                 :            :         return 0;
     202                 :            : eventdev_destroy:
     203                 :          0 :         if (test->ops.eventdev_destroy)
     204                 :          0 :                 test->ops.eventdev_destroy(test, &opt);
     205                 :            : 
     206                 :          0 : cryptodev_destroy:
     207                 :          0 :         if (test->ops.cryptodev_destroy)
     208                 :          0 :                 test->ops.cryptodev_destroy(test, &opt);
     209                 :            : 
     210                 :          0 : dmadev_destroy:
     211                 :          0 :         if (test->ops.dmadev_destroy)
     212                 :          0 :                 test->ops.dmadev_destroy(test, &opt);
     213                 :            : 
     214                 :          0 : ethdev_destroy:
     215                 :          0 :         if (test->ops.ethdev_destroy)
     216                 :          0 :                 test->ops.ethdev_destroy(test, &opt);
     217                 :            : 
     218                 :          0 : mempool_destroy:
     219                 :          0 :         if (test->ops.mempool_destroy)
     220                 :          0 :                 test->ops.mempool_destroy(test, &opt);
     221                 :            : 
     222                 :          0 : test_destroy:
     223                 :          0 :         if (test->ops.test_destroy)
     224                 :          0 :                 test->ops.test_destroy(test, &opt);
     225                 :          0 : error:
     226                 :            :         return EXIT_FAILURE;
     227                 :            : }

Generated by: LCOV version 1.14