LCOV - code coverage report
Current view: top level - app/test - test_rawdev.c (source / functions) Hit Total Coverage
Test: Code coverage Lines: 12 16 75.0 %
Date: 2024-12-01 18:57:19 Functions: 3 3 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 3 8 37.5 %

           Branch data     Line data    Source code
       1                 :            : /* SPDX-License-Identifier: BSD-3-Clause
       2                 :            :  * Copyright 2017 NXP
       3                 :            :  */
       4                 :            : 
       5                 :            : #include "test.h"
       6                 :            : 
       7                 :            : #include <rte_common.h>
       8                 :            : #include <rte_mbuf.h>
       9                 :            : #include <rte_malloc.h>
      10                 :            : #include <rte_memcpy.h>
      11                 :            : #include <rte_dev.h>
      12                 :            : 
      13                 :            : #ifdef RTE_EXEC_ENV_WINDOWS
      14                 :            : static int
      15                 :            : test_rawdev_selftests(void)
      16                 :            : {
      17                 :            :         printf("rawdev not supported on Windows, skipping test\n");
      18                 :            :         return TEST_SKIPPED;
      19                 :            : }
      20                 :            : #else
      21                 :            : 
      22                 :            : #include <rte_rawdev.h>
      23                 :            : #include <rte_bus_vdev.h>
      24                 :            : 
      25                 :            : static int
      26                 :          1 : test_rawdev_selftest_impl(const char *pmd, const char *opts)
      27                 :            : {
      28                 :            :         int ret;
      29                 :            : 
      30                 :            :         printf("\n### Test rawdev infrastructure using skeleton driver\n");
      31                 :          1 :         rte_vdev_init(pmd, opts);
      32                 :          1 :         ret = rte_rawdev_selftest(rte_rawdev_get_dev_id(pmd));
      33                 :          1 :         rte_vdev_uninit(pmd);
      34                 :          1 :         return ret;
      35                 :            : }
      36                 :            : 
      37                 :            : static int
      38                 :            : test_rawdev_selftest_skeleton(void)
      39                 :            : {
      40                 :          1 :         return test_rawdev_selftest_impl("rawdev_skeleton", "");
      41                 :            : }
      42                 :            : 
      43                 :            : static int
      44                 :          1 : test_rawdev_selftests(void)
      45                 :            : {
      46                 :          1 :         const int count = rte_rawdev_count();
      47                 :            :         int ret = 0;
      48                 :            :         int i;
      49                 :            : 
      50                 :            :         /* basic sanity on rawdev infrastructure */
      51         [ +  - ]:          1 :         if (test_rawdev_selftest_skeleton() < 0)
      52                 :            :                 return -1;
      53                 :            : 
      54                 :            :         /* now run self-test on all rawdevs */
      55         [ -  + ]:          1 :         if (count > 0)
      56                 :            :                 printf("\n### Run selftest on each available rawdev\n");
      57         [ -  + ]:          1 :         for (i = 0; i < count; i++) {
      58                 :          0 :                 int result = rte_rawdev_selftest(i);
      59         [ #  # ]:          0 :                 printf("Rawdev %u (%s) selftest: %s\n", i,
      60                 :          0 :                                 rte_rawdevs[i].name,
      61                 :            :                                 result == 0 ? "Passed" : "Failed");
      62                 :          0 :                 ret |=  result;
      63                 :            :         }
      64                 :            : 
      65                 :            :         return ret;
      66                 :            : }
      67                 :            : 
      68                 :            : #endif /* !RTE_EXEC_ENV_WINDOWS */
      69                 :            : 
      70                 :        251 : REGISTER_FAST_TEST(rawdev_autotest, true, true, test_rawdev_selftests);

Generated by: LCOV version 1.14